Player Name Bug?

Discussion in 'Plugin Development' started by ChucknorisSR, Jun 27, 2015.

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


    So my friend is new to coding so he asked me to help him out. He created a simple join message plugin but for some reason when the player joins it says: "Hi randy CraftPlayer{name=Ninjka}! I have never seen this before. Here is the code:
    package main;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    public class main extends JavaPlugin implements Listener {
        public void onEnable() {
            System.out.println("Welcome enabled!"); 
            getServer().getPluginManager().registerEvents(this, this);
        public void onDisable() {
            System.out.println("Welcome disabled!");
        public void onPlayerJoin(PlayerJoinEvent e) {
            Player p = (Player)e.getPlayer();
            p.sendMessage(ChatColor.DARK_RED + "Hi randy " + ChatColor.BLUE + e.getPlayer() + ChatColor.DARK_RED + "!");
  2. Offline


    Line 28
    It is writing the output of the getplayer player object to string on the screen, when you prob want it to be the getname from that gotten player...
  3. Offline


  4. Offline


  5. Offline


    As pretty much said above, getPlayer() returns a Player which contains the player's UUID, Location, etc, including the player's name. Player is NOT a string of the player's name. In order to get the name, use e.getPlayer().getName()
    Sulphate likes this.
  6. Offline


    I'm almost positive you're lying. YOU are new to coding.
  7. Offline


    @Rahat -- User asked questions get the mail, no tag required...
Thread Status:
Not open for further replies.

Share This Page