Player name seems to be changing after re-log?

Discussion in 'Plugin Development' started by xNaXDy, Jul 21, 2013.

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

    xNaXDy

    I have been fighting with this issue for a loooong time, but I do not seem to find a valuable solution...

    This is what's been bothering me:

    I have developed a plugin, with multiple classes and in one class there is a static List<String> which contains player names. Whenever I add players and/or loop through the list everything is fine but once a player relogs (nothing gets removed from the list) it does not appear to work for that player anymore.

    Example:

    The List<String> which contains player names is looped through every second to update the player name tag color. Everything that's in the list is blue, everything else is red. Charles, Barney and Billy have been added to the list while they were in game, they have blue names now. Unfortunately Charles' Minecraft client has crashed and once he logged back in he suddenly has a red name. Upon checking the list it says the following: Charles, Barney, Billy. Still, he has a red name. Once he gets added to the list again, he has a blue name. The list now says: Charles, Barney, Billy, Charles. Charles decides to relog again (testing purposes) and once again has a red name while the list still says: Charles, Barney, Billy, Charles. Once added to the list again while being ingame he now has a blue name (once again) and the list now says: Charles, Barney, Billy, Charles, Charles.

    Now what the heck is wrong there? I'm using the player.getName() method to get the players names and the bizarre thing is that if I check for his name during the login process (onPlayerLogin) e.g. when reading from a banned List<String> it seems to work.

    Explain please? *desperate*
     
  2. Offline

    StrangeOne101

    When the player logs out/disconnects, have their name removed from the list if it's in there. Then just added back in once they join again.

    Edit: In doing so, keep a list of players who have a blue name in your config file. That way the plugin knows who should and shouldn't have a blue name.
     
Thread Status:
Not open for further replies.

Share This Page