Hook into permissions plugins

Discussion in 'Plugin Development' started by iAd4m, Jan 8, 2015.

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

    iAd4m

    Im trying to hook into permissions plugins so I can get the prefix of a user, Im new to bukkit modding so if theres anything wrong with this post please let me know. :)
     
  2. Offline

    CubieX

    There is nothing wrong.
    But you should give more details. What do you have so far?

    The easiest and most universal way to get the player prefix is to use the "Vault" plugin.
    This way you can support every common permissions plugin without having to now the specific API or which plugin the server is using.
    You only need to use the Vault API.
    The plugin page of Vault has examples on how to hook into permissions plugins.
    But you have to have a basic plugin up and running to use those examples.
    Do you have this already?
     
  3. the prefix of an user is set by an plugin for instance Essentials so if you want to get the DisplayName or the CustomName of an user you could also just use
    Code:
    player.getDisplayName();
    //or
    player.getCustomName();
    
    this would be the name with the prefix included i think
     
  4. Offline

    iAd4m

    I'm making a chat plugin and it is nearly complete but I just wanted to be able to hook into any permission plugin and grab a user's prefix. I think vault will accomplish this. Thanks for the help!
     
  5. you won't get the prefix out of a permission

    but you could just check if the player has a permissions
    Code:
    if(event.getPlayer.hasPermission("color.red"){
       event.setMessage(ChatColor.RED + event.getMessage());
    }
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  6. Offline

    Ambamore2000

    Depending on the permissions plugin, not sure if this is only for permissionsex, but I know that permissionsex has a prefix thing to it.

    Some permission plugins can actually help you giving the prefix of a player.
    I tried searching, but, I found a solution for pex; If you still need help, you can post what permissions plugin you are using so others/me can help you from there.
    Show Spoiler
    I'm guessing your using PlayerChatEvent or AsyncPlayerChatEvent. Now, from there, you want to use
    PermissionUser user = PermissionsEx.getUser(player);
    Set player to event.getPlayer();
    You can then use the getPrefix() method from PermissionUser, for example
    String prefix = user.getPrefix(world);
    and you'd have to set world to the players world, obviously.


    Btw, Vault won't accomplish it I don't think, as I looked inside the api; no getPrefix() method.
     
    Last edited by a moderator: Jan 8, 2015
  7. Offline

    Skionz

    @Ambamore2000 Ill have to disagree. Vault contains a Chat#getPlayerPrefix(Player) method.
     
  8. Offline

    1Rogue

    Vault is literally made for this exact purpose.
     
    Skionz likes this.
  9. Offline

    Ambamore2000

    Oh, I just looked inside the Permissions class. Didn't think it'd be in any other.
     
  10. Offline

    CubieX

    My post was not 100% specific.
    You need to use the Chat component of vault to accomplish this.
    But the Vault plugin page has a code example for this too.
    Here are the JavaDocs of Vaults chat component.
     
Thread Status:
Not open for further replies.

Share This Page