Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Change Player Name Source code
package net.rymate.ChangeName;
import java.util.logging.Logger;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityTracker;
import net.minecraft.server.WorldServer;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.PluginManager;
public class ChangeName extends JavaPlugin {
Logger log = Logger.getLogger("Minecraft");
public void onDisable() { + "disabled!");
public void onEnable() { + "enabled!");
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (!(sender instanceof CraftPlayer)) {
sender.sendMessage("You are not a craftplayer!");
return true;
if (sender.hasPermission("changename.change")) {
CraftPlayer player = (CraftPlayer) sender;
if (args.length > 0) {"Player "+player.getName()+" changing name to "+args[0]);
sender.sendMessage("\u00a7eYou are now disguised as " + args[0] + "!");
PluginManager pm = getServer().getPluginManager();
pm.callEvent(new PlayerQuitEvent(player, "changing name"));
setPlayerName(player.getHandle(), args[0]);
pm.callEvent(new PlayerJoinEvent(player, "changing name"));
} else {
sender.sendMessage("\u00a7eWrong usage! /changename <name>");
return true;
} else {
sender.sendMessage("\u00a7eYou do not have necessary permission to change your name.");
return true;
* Set an EntityPlayer's name and update it to other clients
* @param player entityplayer to change name of
* @param newname name to set to
* @author lahwran
public void setPlayerName(EntityPlayer player, String newname) {
WorldServer world = (WorldServer);
EntityTracker tracker = world.tracker;
tracker.untrackEntity(player); = newname;
Copy link

jkmanye commented Aug 31, 2020

but had you been tested it?

Copy link

but had you been tested it?

I'm sure you figured it out by now but this was made 2 months before Minecraft 1.0 came out, so it's safe to say it does not work now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment