Solved Enum Permission Plugin

Discussion in 'Spigot Plugin Development' started by RustyDesigns, Jun 3, 2016.

  1. HEY SPIGOT!
    I've made permission plugins before, and I was wondering if anybody knew how to implement Enums. I want to use an method to see if the player is a certain rank, rather than handling permissions. Anybody know how?
     
  2. If I understand what you want:
    Make a rank enum
    Create a player wrapper with getters and setters for ranks using that enum
    ???
    Profit

    <sarcasm>P.S. that giant bold italicized text really helped me find this thread, please keep doing it</sarcasm>
     
  3. @Redrield
    Lol, thanks for the note on my header.

    My think is, how do I create the setter?
     
  4. The way you create any other setter?
     
  5. @Redrield
    How do I set it for an specific player?
    Code (Text):

    public static void setRank(Player player, Rank rank) {
    currentRank = rank;
    }
     
     
  6. Like I said, use a wrapper object.
     
  7. Code (Text):


    public class PlayerWrapper {

    private Player player;
    private RankEnum rank;

    public PlayerWrapper(Player player) {
    this.player = player;
    }
    //Getters and setters
    }
     
  8. @Redrield
    Now, I'm confused on how to make the setter method. Spoonfeed me. xD ;)
     
  9. Will a fork do?
     
  10. No, how am I supposed to eat soup with a fork? If it doesn't bother you too much, it would be a real help if you perhaps could reveal the setter method. xD
     
  11. Read the sig.
     
  12. public void setRank(RankEnum rank) {
    this.rank = rank;
    }
     
    • Optimistic Optimistic x 1
  13. A setter is simply a method to set the value of a variable, like this:

    private String name;
    public void setName(String name){
    this.name = name;
    }
     
  14. when you call the constructor ur setting the player? now you simply get the player if you want to use him
     
    • Optimistic Optimistic x 1
  15. Considering the player it would be applied to is specified in the constructor of the wrapper, I don't see the problem
     
  16. @Redrield
    My knowledge is limited. I don't know how to do that.
     
  17. If you don't know how constructors work, 'fraid you're gonna have to learn java before I help you.
     
    • Agree Agree x 1
  18. heres a hint: return the player you originally got from the constructor... (sort of like how you do with ranks)



    hope this isnt too much spoon feed
     
    • Optimistic Optimistic x 1