Changing Names

Discussion in 'Plugin Development' started by geekygenius, Mar 15, 2012.

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

    winter4w

    Hmm I wonder if some one can make the craftbukkit file or request notch to make it possible with plugin's
     
  2. Offline

    DrAgonmoray

    this is a bit late, but that's always been possible. any entity can ride any other entity.
    you could make a soviet russia plugin where "MINECART RIDE YOU"
     
    geekygenius likes this.
  3. Offline

    geekygenius

    I posted code earlier in the thread. I can guarantee one will be out there soon after the Mod API comes out if it has floating name support. If there isn't one, feel free to PM me, and I'll make you a simple one. :)

    EvilSeph has confirmed it though, and he is working on the Mod API directly, so just wait for that!
     
  4. Offline

    TheTrixsta

    Code:
    package Utilities;
     
    import java.lang.reflect.Field;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.craftbukkit.entity.CraftPlayer;
    import org.bukkit.entity.Player;
     
    import net.minecraft.server.EntityPlayer;
     
    public class NameUtils {
     
        private static Field name = null;
     
        public NameUtils() {
            setup();
        }
     
        private void setup() {
            try {
                // Grab the field
                for (Field field : EntityPlayer.class.getFields()) {
                    if (field.getName().equalsIgnoreCase("name")) {
                        name = field;
                    }
                }
                name.setAccessible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
     
        public void updateName(ChatColor color, Player player) {
            String n = color + (player.getName());
     
            /*if (team != null) {
                n = team.getChatColor() + n + ChatColor.WHITE;
            } else {
                // n = ChatColor.BLACK+n;
            }*/
     
            // Update the name
            setName(player, n);
            Player[] players = Bukkit.getOnlinePlayers();
            for (Player p : players) {
                if (p != player) {
                    // Refresh the packet!
                    p.hidePlayer(player);
                    p.showPlayer(player);
                }
            }
            // setName(player, ChatColor.stripColor(n));
        }
     
        private void setName(Player player, String name) {
            CraftPlayer cp = (CraftPlayer) player;
            EntityPlayer ep = cp.getHandle();
            ep.name = name;
            // does this actually help?
            player.setDisplayName(name);
            player.setPlayerListName(name);
        }
     
    }
    
    Here you go, this works but if you color the name above your head it will mess with permissions, so i had to strip color out of permissions to color names :D but this doesnt update every 40 seconds or something like that
     
  5. Offline

    winter4w

    Ok I am a noob with java how can I extract the bukkit jar file and where do I paste the code
     
  6. Offline

    Sorroko

  7. Offline

    winter4w

    Ok so I can add color to my name with my skin ???

    Ya that is what I want some one to do lol

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
  8. Offline

    izak12345678910

    Can you make it with permissions or can you make a custom permissions?
     
  9. Offline

    TheTrixsta

    you dont need to edit your craftbukkit.jar, this can be used in a plugin
     
  10. Offline

    winter4w

    Then can somone make it ?
     
  11. Offline

    caldabeast

    I just tested this myself. I recompiled it with maven, but when I went to run it, it still showed my name as being the normal white color.
    Code:
    public String getLocalizedName() {
        if (this.name.equals("CalDaBeast"))
            return (ChatColor.LIGHT_PURPLE + "CalDaBeast" + ChatColor.WHITE);
        else return this.name;
    }
    Am I doing it right?
     
  12. Offline

    ddeckys

    I might have to snag some of that code from you ;)
     
  13. look at the resources section of the plugin devoment
     
  14. Offline

    RawCode

    blackmagic is extremely harmfull, you shoud replace player handler and alter entityspawn packets, not entity data itself.
     
  15. Offline

    ddeckys

  16. Offline

    izak12345678910

    On the thread he posted a download link to it in a request thread he didn't make a separate thread
     
  17. Yea, cause it's just a prove that it's possible. Hence why I share it (with the sources) at the development forum.
     
  18. Offline

    winter4w

  19. Offline

    Jakeob22

    No. This meathod changes their name and it can't retrieve the skin from the minecraft skin database. :/
     
  20. It surely does. But since there's no player with a color code in the name, it'll get the default skin.
     
  21. Offline

    Jakeob22

    Exactly ^ :)
     
  22. Offline

    winter4w

    I did here it is possible
     
  23. Offline

    Jakeob22

    You will only be able to get a skin if the name that you pick is an existing name.
     
  24. Offline

    wirher

    Oh god. It isn't. Client checks minecraft skin database for example for "&3wirher" and it will never find it. You can't do this without client mod.
     
  25. Offline

    izak12345678910

    Will this break permission plugins and like any command that involves the players name? In another thread someone said it would
     
  26. As explained in the other thread where you asked the same: No.
     
  27. Offline

    ddeckys

    Colored name do break permissions. Bpermissions at least, from my experiance.

    Would you be angry if I decompiled your code and used some of it in my own plugin?
     
  28. Offline

    izak12345678910

    This one didn't break my permissions. It just break skins which i wanna know if someone can fix
     
  29. This one won't as it will change the name in the packages sended to the clients only. The name stored inside of the server does not change, as such bPermissions won't break.
    No, you don't even need to decompile it: The sources are included in the jar file. ;)
    No.
     
Thread Status:
Not open for further replies.

Share This Page