
Vault - Chat#getPlayerInfoInteger - Returns always the default value
Closed this issue ยท 10 comments
the method Chat#getPlayerInfoInteger
from Vault does always return the default value with LuckPerms.
So I need to use the API instead of using Vault to make the plugin useable for multiple permission plugins?
Yes, as I just said, you cannot use Vault for offline player lookups.
The Vault Permission API is not written in a way which allows for i/o in the background. When it was written, it was the norm that permission plugins would store all of their data in memory.
For offline players, I have to perform i/o in order to retrieve data. The majority of plugins which use Vault do so on the main thread (since the majority of permission plugins are not thread safe). Put those two things together and you have a problem.
I cannot block the main thread with i/o calls, or your server will pause for a few seconds every time a plugin performs a Vault operation.
Actually I'm wrong, sorry. I'm using it while the player is online.
Few seconds after the player logged in.
That's how I want to use it atm:
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
final Player player = event.getPlayer();
Bukkit.getScheduler().scheduleSyncDelayedTask(MyPlugin.instance, new Runnable() {
@Override
public void run() {
int tokens = MyPlugin.getChat().getPlayerInfoInteger(player, PermissionOptions.DAILY_TOKENS, 0);
MyPlugin.instance.getLogger().info("Tokens: " + tokens);
}
}, 60);
}