[unsolved] (Player).setname() not working?

Discussion in 'Plugin Development' started by tuskiomi, Nov 7, 2015.

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

    tuskiomi

    Hello, all
    I have a plugin that has the following in the event handler:

    Code:
        @EventHandler
        public void PlayerJoin(PlayerJoinEvent plyEvt){
            plyEvt.setJoinMessage("");   
                if(plyEvt.getPlayer().getUniqueId() == UUID.fromString("mememe-meee-myUUID-ThisIsMyUUIDForMe")){
                    plyEvt.getPlayer().setCustomName("Foo");
                    plyEvt.getPlayer().setDisplayName("Foo Bar");
                    plyEvt.getPlayer().setPlayerListName("TooFoo Bar");
                    plyEvt.getPlayer().setCustomNameVisible(true);
            }
           
        }
    but despite all of this, my user name is still the same in the tab list and above my head, and in the chat. Am I doing something wrong?
     
  2. Offline

    teej107

    Yes.
    1. You are comparing Objects with ==.
    2. You are trying to set a Player's custom name when it states in the JavaDocs that it'll have no effect.
    3. Player doesn't even have the method setDisplayName.
     
  3. Offline

    tuskiomi

    what's wrong in the first one? a UUID is just a byte array.
    the second one was my fault
    the third one is wrong: https://hub.spigotmc.org/javadocs/b.../Player.html#setDisplayName(java.lang.String)
     
  4. Offline

    teej107

    tuskiomi likes this.
  5. Offline

    MasterDoctor

    This will set the name in that tablist.
    In this example, It will set the player name to dark red.
    Code:
    player.setPlayerListName(ChatColor.DARK_RED + player.getName());
    So you use
    Code:
    player.setPlayerListName("{NAME}");
     
  6. Offline

    tuskiomi

    @MasterDoctor why can't I rename myself to "TooFoo Bar"? Does it not work with my own user because i'm the one tabbing?
     
  7. Offline

    MasterDoctor

    The code you used should work fine for that.
    @tuskiomi
     
  8. Offline

    teej107

    Are you sure your if statement is true? Did you register the event?
     
    MasterDoctor likes this.
  9. Offline

    MasterDoctor

    Didn't think of that :)
     
  10. Offline

    tuskiomi

    I have another If statement that uses the same UUID to send a custom greeting, and i do get the greeting. so i'm sure it works.
     
  11. Offline

    tuskiomi

    debug test succeeded. it's running the code.
     
Thread Status:
Not open for further replies.

Share This Page