.

Discussion in 'Plugin Development' started by elementalgodz11, Dec 6, 2013.

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

    elementalgodz11

  2. Offline

    Travisvv

    You can create a method for this, and call it when you need it in your events. For your specific example something like this would work.
    Code:java
    1. @EventHandler
    2. public void onRankJoin(PlayerJoinEvent e) {
    3. setRank(e.getPlayer);
    4. }
    5.  
    6. public void setRank(Player p){
    7. if (p.hasPermission("default")) {
    8. p.setDisplayName(ChatColor.WHITE+ p.getName());
    9. } else if (p.hasPermission("moderator")) {
    10. p.setDisplayName(ChatColor.DARK_PURPLE + p.getName());
    11. }
    12. }
     
  3. Offline

    turqmelon

    Try something like:

    Code:java
    1.  
    2. public static void updateDisplayName(Player player){
    3. // Your display name code here
    4. }
    5.  


    Then call...
    Code:java
    1.  
    2. ClassName.updateDisplayName(player);
    3.  

    ...whenever you'd like to update the name.
     
    elementalgodz11 likes this.
  4. Offline

    xXMaTTHDXx

    You could always make a enum, kinda like
    Code:
    public enum Ranks{ MODERATOR, DEFAULT }; this is only a example
    do not copy!
     
Thread Status:
Not open for further replies.

Share This Page