Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. package net.minecraft.server.v1_7_R4;
  2.  
  3. import java.io.IOException;
  4. import net.minecraft.util.com.mojang.authlib.GameProfile;
  5. import net.minecraft.util.com.mojang.authlib.properties.Property;
  6. import net.minecraft.util.com.mojang.authlib.properties.PropertyMap;
  7.  
  8. public class PacketPlayOutPlayerInfo
  9. extends Packet
  10. {
  11. private static final int ADD_PLAYER = 0;
  12. private static final int UPDATE_GAMEMODE = 1;
  13. private static final int UPDATE_LATENCY = 2;
  14. private static final int UPDATE_DISPLAY_NAME = 3;
  15. private static final int REMOVE_PLAYER = 4;
  16. private int action;
  17. private GameProfile player;
  18. private int gamemode;
  19. private int ping;
  20. private String username;
  21.  
  22. public static PacketPlayOutPlayerInfo addPlayer(EntityPlayer player)
  23. {
  24. PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
  25. packet.action = 0;
  26. packet.username = player.listName;
  27. packet.player = player.getProfile();
  28. packet.ping = player.ping;
  29. packet.gamemode = player.playerInteractManager.getGameMode().getId();
  30. return packet;
  31. }
  32.  
  33. public static PacketPlayOutPlayerInfo updatePing(EntityPlayer player)
  34. {
  35. PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
  36. packet.action = 2;
  37. packet.username = player.listName;
  38. packet.player = player.getProfile();
  39. packet.ping = player.ping;
  40. return packet;
  41. }
  42.  
  43. public static PacketPlayOutPlayerInfo updateGamemode(EntityPlayer player)
  44. {
  45. PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
  46. packet.action = 1;
  47. packet.username = player.listName;
  48. packet.player = player.getProfile();
  49. packet.gamemode = player.playerInteractManager.getGameMode().getId();
  50. return packet;
  51. }
  52.  
  53. public static PacketPlayOutPlayerInfo updateDisplayName(EntityPlayer player)
  54. {
  55. PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
  56. packet.action = 3;
  57. packet.username = player.listName;
  58. packet.player = player.getProfile();
  59. return packet;
  60. }
  61.  
  62. public static PacketPlayOutPlayerInfo removePlayer(EntityPlayer player)
  63. {
  64. PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
  65. packet.action = 4;
  66. packet.username = player.listName;
  67. packet.player = player.getProfile();
  68. return packet;
  69. }
  70.  
  71. public void a(PacketDataSerializer packetdataserializer)
  72. throws IOException
  73. {}
  74.  
  75. public void b(PacketDataSerializer packetdataserializer)
  76. throws IOException
  77. {
  78. String username = this.username;
  79. if ((packetdataserializer.version >= 47) && (this.action == 0) && (username != null) && (username.equals(this.player.getName()))) {
  80. username = null;
  81. }
  82. if (packetdataserializer.version >= 20)
  83. {
  84. packetdataserializer.b(this.action);
  85. packetdataserializer.b(1);
  86. packetdataserializer.writeUUID(this.player.getId());
  87. switch (this.action)
  88. {
  89. case 0:
  90. packetdataserializer.a(this.player.getName());
  91. PropertyMap properties = this.player.getProperties();
  92. packetdataserializer.b(properties.size());
  93. for (Property property : properties.values())
  94. {
  95. packetdataserializer.a(property.getName());
  96. packetdataserializer.a(property.getValue());
  97. packetdataserializer.writeBoolean(property.hasSignature());
  98. if (property.hasSignature()) {
  99. packetdataserializer.a(property.getSignature());
  100. }
  101. }
  102. packetdataserializer.b(this.gamemode);
  103. packetdataserializer.b(this.ping);
  104. packetdataserializer.writeBoolean(username != null);
  105. if (username != null) {
  106. packetdataserializer.a(ChatSerializer.a(org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage.fromString(username)[0]));
  107. }
  108. break;
  109. case 1:
  110. packetdataserializer.b(this.gamemode);
  111. break;
  112. case 2:
  113. packetdataserializer.b(this.ping);
  114. break;
  115. case 3:
  116. packetdataserializer.writeBoolean(username != null);
  117. if (username != null) {
  118. packetdataserializer.a(ChatSerializer.a(org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage.fromString(username)[0]));
  119. }
  120. break;
  121. }
  122. }
  123. else
  124. {
  125. packetdataserializer.a(username);
  126. packetdataserializer.writeBoolean(this.action != 4);
  127. packetdataserializer.writeShort(this.ping);
  128. }
  129. }
  130.  
  131. public void a(PacketPlayOutListener packetplayoutlistener)
  132. {
  133. packetplayoutlistener.a(this);
  134. }
  135.  
  136. public void handle(PacketListener packetlistener)
  137. {
  138. a((PacketPlayOutListener)packetlistener);
  139. }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement