SetPlayerDisplayName not working for me

Discussion in 'Plugin Development' started by dillyg10, Feb 21, 2012.

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

    dillyg10

    Hey, so I'm just playing around with a few things ATM, and I tried to change the palyer name when they login. Doesn't work D:. Here is the code, no errors, just plain doens't work...
    Code:
    package com.gmail.dillyg10.ColorNames;
     
    public class LoginEvent implements Listener {
        private static ColorNames plugin;
        public static void LoginEvent(ColorNames instance){
            plugin = instance;
        }
        @EventHandler
        public static void onPlayerLogin(PlayerLoginEvent event) {
            Player player = event.getPlayer();
            player.setDisplayName("Hello");
           
        }
       
    }
    
    I put the eventListener in my onEnable() in the main class, I did a log.info test to see if it was being called, and it was :D.
     
  2. Offline

    nisovin

    What are you expecting to happen?
     
  3. Offline

    dillyg10

    nisovin It should change the player name when they login..
     
  4. Offline

    nisovin

    That didn't really answer my question. Specifically, what are you expecting? I think you might be expecting that method to do something that it doesn't do.
     
  5. Offline

    Seadragon91

    It change only the name in chat, not the name over the head.
     
  6. Offline

    dillyg10

    I know that, but it isn't changing the name in chat. I'm expecting the method to change the inchat name :D
     
  7. dillyg10
    Be more clear, does it or does it not affect the name when you send a message in chat or do you want to also affect the "<Player> joined the game" message ? I belive the event has possiblity to set that message manually.
     
  8. Offline

    dillyg10

    Ok, let me be tottaly clear...

    I want when the player to chat it to say...
    <MyNameInPlugin> playermessage

    I don't care about the name when it says "blahblahblah has joined the game"
     
  9. Did you register the class as a event class ?
    Code:
    getServer().getPluginManager().registerEvents(class, plugin);
    Also, PlayerLoginEvent triggers when player logs in with minecraft.net, on offline players the event never triggers, If you don't want to depend on that, use PlayerJoinEvent.
     
  10. Offline

    bassfader

    For this to work you need some chat Plugin like iChat, the Chat Manager of PEX, etc... If there is no plugin utilizing the DisplayName then you won't see any difference ingame.

    Also don't forget, many of the Chat plugins allow you to define a "chat pattern", and they often differentiate between the players name, and the players display name! In PEX´s Chat Manager for example you can enter %name in the "chat pattern", or you can also use %displayname
     
  11. That's not true, I ran a test plugin with no other plugins and it changed my chat name just fine.
    I think you're refering to chat name prefix, there are plugins that support that and that's not part of bukkit API, setDisplayName() always has been part of bukkit API.
     
  12. Offline

    bassfader

    Oh, I think I confused something there :oops: Thanks for correcting me ^^

    Though the second part of my posting is still relevant. It may be possible he has some sort of Chat plugin where the settings are set to use the player name instead of the players display name (I think PEX´s Chat Manager for example is - or at least was - set like that by default).
     
  13. Yes, another plugin could overwrite his plugin's display name or even the other way around, depends on triggering time or priority.
     
Thread Status:
Not open for further replies.

Share This Page