Why doesn't this method work?

Discussion in 'Plugin Development' started by PoseidonnodiesoP, Apr 15, 2014.

Thread Status:
Not open for further replies.
  1. Code:java
    1. public void onEnable() {
    2. PluginDescriptionFile pdfFile = this.getDescription();
    3. this.log.info(pdfFile.getName() + " v" + pdfFile.getVersion() + " is enabled");
    4. PluginManager pm = this.getServer().getPluginManager();
    5. this.setupPermissions();
    6. Player[] onlinePlayers = getServer().getOnlinePlayers();
    7. for(int counter = 0; counter <= onlinePlayers.length - 1; counter++) {
    8. setColor(onlinePlayers[counter]);
    9. }
    10. pm.registerEvents(new JoinListener(this), this);
    11. }
    12.  
    13. public void setColor(Player player) {
    14. ArrayList<String> groups = new ArrayList<String>();
    15. String[] groupsArray = permission.getPlayerGroups(player);
    16. for(int counter = 0; counter <= permission.getPlayerGroups(player).length - 1; counter++) {
    17. groups.add(groupsArray[counter]);
    18. }
    19. if(groups.contains("Owner")) {
    20. player.setPlayerListName(ChatColor.AQUA.ITALIC + player.getName());
    21. } else if(groups.contains("Admin")) {
    22. player.setPlayerListName(ChatColor.RED.ITALIC + player.getName());
    23. } else if(groups.contains("Moderator")) {
    24. player.setPlayerListName(ChatColor.BLUE.ITALIC + player.getName());
    25. } else if(groups.contains("Member")) {
    26. player.setPlayerListName(ChatColor.GREEN + player.getName());
    27. } else {
    28. player.setPlayerListName(ChatColor.DARK_GRAY + player.getName());
    29. }
    30. }
    31.  


    I know that all the methods are being run through. I debugged with sendMessage() methods.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    idontcare1025

    Be more specific. Tell us what you want the method to do, what it is doing, and if it gives you any errors.
     
  3. I want it to change my player name to one of those colors. It doesn't give errors. I used the player parameter to test whether the setColor method was running and being referred to me (the player). It sent me a message when I put the test sendMessage in the code. So I know that the code is getting the players, but not actually changing color like it's supposed to.
     
  4. Offline

    idontcare1025

    You don't use setPlayerListName() for what you're trying to do, you use setDisplayName().
     
  5. Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page