Enum Permissions

Discussion in 'Plugin Development' started by Admison, Jan 31, 2016.

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


    Hi there,

    Essentially what I'm trying to do is implement ranks into my core plugin so that I do not have to use PermissionsEX or whatever. That said, I was only recommended to use this and therefore are unsure on how to do so. I have already identified the prefix name and the color I want to identify it as, but I am unsure what to do from here. Any help would be appreciated.

    Here is my Rank class:
    package domlex.core.common;
    import org.bukkit.ChatColor;
    public enum Rank {
        OWNER("Owner", ChatColor.DARK_RED),
        ADMIN("Admin", ChatColor.RED),
        DEFAULT(null, ChatColor.YELLOW);
        public String name;
        private ChatColor color;
        private Rank(String name, ChatColor color) {
            this.name = name;
            this.color = color;
        public String getName() {
            return name;
        public ChatColor getColor() {
            return color;
    Thank you.
  2. Offline


    IMHO, you should use classes to store ranks, not enums.

    What you would need to do now is somehow tag each player to their rank. This can be achieved through Hashmaps, where you store the Player as the key and their rank as the value. After that, you create a AsyncPlayerhatEvent that will get the player's enum from the hashmap and display the prefix before the name.
  3. Offline


    Lol that'd be an awesome event!

    @Admison Zombie_Striker said a good suggestion. Just be aware that HashMap isn't thread safe so stick with a thread safe Map implementation or use the PlayerChatEvent and as always, don't forget to handle the Player in the Map when they leave.
    Zombie_Striker likes this.
  4. Offline


    Don't quite understand what exactly you want to find out. But if you are needing to do permissions so other plugins can function with these ranks, it'll get a bit more complicated!

    I used this tutorial a while back when I was trying to do a similar thing:
Thread Status:
Not open for further replies.

Share This Page