LuckPerms

LuckPerms

41.4k Downloads

Vault - Chat#getPlayerInfoInteger - Returns always the default value

Sir-Will opened this issue ยท 10 comments

commented

the method Chat#getPlayerInfoInteger from Vault does always return the default value with LuckPerms.

commented

Can you show me the code you're using?

commented

Is player online?

commented

MyPlugin.getChat().getPlayerInfoInteger(player, "myplugin.daily", 0);

commented

offline

commented

You cannot use Vault for offline player lookups. Use the native API.

commented

So I need to use the API instead of using Vault to make the plugin useable for multiple permission plugins?

commented

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.

commented

Actually I'm wrong, sorry. I'm using it while the player is online.
Few seconds after the player logged in.

commented

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);
    }
commented

Thanks, that fixed it.