Getting a player's PEX prefix.

Discussion in 'Plugin Development' started by Xx_LeetGamer_xX, Sep 5, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Xx_LeetGamer_xX

    I need to get a player's group's prefix when hooking into PermissionsEx.

    My current code:

    Code:
    public class AsyncPlayerChat implements Listener{
        @EventHandler
        public void onEvent(AsyncPlayerChatEvent e){
            String prefix = PermissionsEx.getUser(e.getPlayer()).getPrefix();
            e.getPlayer().sendMessage("Your prefix: \"" + prefix + "\"");
        }
    }
    The prefix for this is always blank. There are no exceptions for me to work with on figuring this out.

    How can I do this?
     
  2. Offline

    Xx_LeetGamer_xX

    That returns the text "null" :confused:

    EDIT:

    Doing this returns "owner", but the prefix isn't being returned. I'm 100% sure that a prefix is set.

    Code:
    String prefix = PermissionsEx.getUser(e.getPlayer()).getGroups()[0].getName();
    For now I will just use the group name to create a custom prefix.
     
  3. Offline

    Stealth2800

    Is a prefix indeed set for the group in the permissions.yml file?
    Code:
    Member:
      default: false
      prefix: '[Mem]'
      permissions:
        //permissions
    and is the member actually in the group?
     
  4. Offline

    iBCoLLiN

    Code:java
    1. String prefix = PermissionsEx.getUser(e.getPlayer()).getGroups()[0].getPrefix();

    Try that.
     
  5. Offline

    Stealth2800

    Nice bump. :)
     
Thread Status:
Not open for further replies.

Share This Page