Packet Error

Discussion in 'Plugin Development' started by rohan576, Apr 13, 2014.

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

    rohan576

    Hello! I have a little function that uses packets to change the nametag of a player. Even though I'm positive that I'm using Bukkit 1.7.8, whenever I send this packet, the server returns an internal error saying that the server is pretending to be 1.7.8. Now, what I'm assuming is that I'm sending the packet with the kind of data that was sent in earlier versions, causing Minecraft to think that the server is faking its version. Furthermore, I can assure you that the UUIDUtil.nameToUUID() (in the below code) works properly. Here's my function:
    Code:java
    1. public static void changeNameTag(Player player, String prefix) {
    2. EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
    3. PacketPlayOutNamedEntitySpawn playerpacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
    4. try {
    5. Field f = playerpacket.getClass().getDeclaredField("b");
    6. f.setAccessible(true);
    7. f.set(playerpacket, new GameProfile(UUIDUtil.nameToUUID(player.getName()), prefix + "§f " + player.getName()));
    8. f.setAccessible(!f.isAccessible());
    9. calculatePlayerCount();
    10. for (Player plr : playerList) {
    11. if (!plr.getName().equalsIgnoreCase(player.getName())) {
    12. CraftPlayer p = (CraftPlayer) plr;
    13. p.getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(entityPlayer.getId()));
    14. p.getHandle().playerConnection.sendPacket(playerpacket);
    15. }
    16. }
    17. }
    18. catch(Exception e) {
    19. e.printStackTrace();
    20. }
    21. }


    Any help is appreciated. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page