Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void nick(Player p, String nickname) {
- EntityHuman eh = ((CraftPlayer)p).getHandle();
- PacketPlayOutEntityDestroy p29 = new PacketPlayOutEntityDestroy(eh.getId());
- PacketPlayOutNamedEntitySpawn p20 = new PacketPlayOutNamedEntitySpawn(eh);
- try {
- Field profileField = p20.getClass().getDeclaredField("b");
- profileField.setAccessible(true);
- profileField.set(p20, new GameProfile(p.getUniqueId(), nickname));
- } catch (Exception e) {e.printStackTrace();}
- for(Player other : Bukkit.getOnlinePlayers()) {
- if(!other.getName().equals(p.getName())) {
- ((CraftPlayer)other).getHandle().playerConnection.sendPacket(p29);
- ((CraftPlayer)other).getHandle().playerConnection.sendPacket(p20);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement