Vault

Vault

7M Downloads

getPlayerPrefix returns GroupPrefix

Fulgar opened this issue ยท 3 comments

commented

Hello, I seem to be having a strange issue with Vault. On my PListener class I have it so that it formats my chat so that it shows "kingdomPrefix" which is getPlayerPrefix and "groupPrefix" which is getGroupPrefix. For some reason it returns the groupPrefix for both, so when I say something in chat it would look something like this:

<groupPrefix - groupPrefix playerName> message

When it is supposed to look like this:

<kingdomPrefix - groupPrefix playerName> message

package me.jdawgerj515.KingdomWarfare;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.ChatColor;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@SuppressWarnings("deprecation")
public class PListener implements Listener{
public KingdomWarfare plugin;
public PListener(KingdomWarfare instance)
{
    plugin = instance;
}



@EventHandler 
public void chat(PlayerChatEvent e)
{
Player player = e.getPlayer();
String group = KingdomWarfare.perms.getPrimaryGroup(player);
String groupPrefix = KingdomWarfare.chat.getGroupPrefix(player.getWorld(), group);
String kingdomPrefix = KingdomWarfare.chat.getPlayerPrefix(player);
e.setFormat("<" + ChatColor.translateAlternateColorCodes('&', kingdomPrefix + " - " + groupPrefix) + "%s> %s");

}


@EventHandler
public void join(PlayerJoinEvent e)
{
    Player player = e.getPlayer();
    String kingdom = KingdomWarfare.players.getString(player + ".Kingdom");
    if (KingdomWarfare.players.contains(player + ".Kingdom") == false)
    {
        KingdomWarfare.chat.setPlayerPrefix(player, null);
    }
    else if (KingdomWarfare.players.getString(player + ".Kingdom") != null)
    {
        KingdomWarfare.chat.setPlayerPrefix(player, kingdom);
    }

}






}//Final bracket
commented

This is up to the permission/prefix system to return the value for the player. Most permission systems return the group prefix for the player if no player-specific prefix exists.

commented

@Sleaker I am using GroupManager which has player prefixes

commented

@jdawgerj515 - and the Vault API call directly asks GM for the player's prefix:

@Override
public String getPlayerPrefix(String worldName, String playerName) {
    AnjoPermissionsHandler handler;
    if (worldName == null) {
        handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
    } else {
        handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
    }
    if (handler == null) {
        return "";
    }
    return handler.getUserPrefix(playerName);
}

I see nothing wrong here.