1.8 tablist fix - spigot needs to be updated!
This commit is contained in:
parent
f8885e4c5c
commit
2f64b5f401
@ -0,0 +1,157 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package net.minecraft.server.v1_7_R4;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.util.com.mojang.authlib.properties.Property;
|
||||
import net.minecraft.util.com.mojang.authlib.properties.PropertyMap;
|
||||
|
||||
public class PacketPlayOutPlayerInfo extends Packet {
|
||||
public static final int ADD_PLAYER = 0;
|
||||
public static final int UPDATE_GAMEMODE = 1;
|
||||
public static final int UPDATE_LATENCY = 2;
|
||||
public static final int UPDATE_DISPLAY_NAME = 3;
|
||||
public static final int REMOVE_PLAYER = 4;
|
||||
public int action;
|
||||
public GameProfile player;
|
||||
public int gamemode;
|
||||
public int ping;
|
||||
public String username;
|
||||
public String _tabName;
|
||||
|
||||
public PacketPlayOutPlayerInfo() {
|
||||
}
|
||||
|
||||
public static PacketPlayOutPlayerInfo addPlayer(EntityPlayer player) {
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
|
||||
packet.action = 0;
|
||||
packet.username = player.listName;
|
||||
packet.player = player.getProfile();
|
||||
packet.ping = player.ping;
|
||||
packet.gamemode = player.playerInteractManager.getGameMode().getId();
|
||||
packet._tabName = getFormattedName(player);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static PacketPlayOutPlayerInfo updatePing(EntityPlayer player) {
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
|
||||
packet.action = 2;
|
||||
packet.username = player.listName;
|
||||
packet.player = player.getProfile();
|
||||
packet.ping = player.ping;
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static PacketPlayOutPlayerInfo updateGamemode(EntityPlayer player) {
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
|
||||
packet.action = 1;
|
||||
packet.username = player.listName;
|
||||
packet.player = player.getProfile();
|
||||
packet.gamemode = player.playerInteractManager.getGameMode().getId();
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static PacketPlayOutPlayerInfo updateDisplayName(EntityPlayer player) {
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
|
||||
packet.action = 3;
|
||||
packet.username = player.listName;
|
||||
packet.player = player.getProfile();
|
||||
packet._tabName = getFormattedName(player);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static PacketPlayOutPlayerInfo removePlayer(EntityPlayer player) {
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo();
|
||||
packet.action = 4;
|
||||
packet.username = player.listName;
|
||||
packet.player = player.getProfile();
|
||||
return packet;
|
||||
}
|
||||
|
||||
public void a(PacketDataSerializer packetdataserializer) throws IOException {
|
||||
}
|
||||
|
||||
public void b(PacketDataSerializer packetdataserializer) throws IOException {
|
||||
if(packetdataserializer.version >= 20) {
|
||||
packetdataserializer.b(this.action);
|
||||
packetdataserializer.b(1);
|
||||
packetdataserializer.writeUUID(this.player.getId());
|
||||
switch(this.action) {
|
||||
case 0:
|
||||
packetdataserializer.a(this.player.getName());
|
||||
PropertyMap properties = this.player.getProperties();
|
||||
packetdataserializer.b(properties.size());
|
||||
Iterator var3 = properties.values().iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
Property property = (Property)var3.next();
|
||||
packetdataserializer.a(property.getName());
|
||||
packetdataserializer.a(property.getValue());
|
||||
packetdataserializer.writeBoolean(property.hasSignature());
|
||||
if(property.hasSignature()) {
|
||||
packetdataserializer.a(property.getSignature());
|
||||
}
|
||||
}
|
||||
|
||||
packetdataserializer.b(this.gamemode);
|
||||
packetdataserializer.b(this.ping);
|
||||
packetdataserializer.writeBoolean(this.username != null);
|
||||
if(this.username != null) {
|
||||
// packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this.username)[0]));
|
||||
packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this._tabName)[0]));
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
packetdataserializer.b(this.gamemode);
|
||||
break;
|
||||
case 2:
|
||||
packetdataserializer.b(this.ping);
|
||||
break;
|
||||
case 3:
|
||||
packetdataserializer.writeBoolean(this.username != null);
|
||||
if(this.username != null) {
|
||||
// packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this.username)[0]));
|
||||
packetdataserializer.a(ChatSerializer.a(CraftChatMessage.fromString(this._tabName)[0]));
|
||||
}
|
||||
case 4:
|
||||
}
|
||||
} else {
|
||||
packetdataserializer.a(this.username);
|
||||
packetdataserializer.writeBoolean(this.action != 4);
|
||||
packetdataserializer.writeShort(this.ping);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void a(PacketPlayOutListener packetplayoutlistener) {
|
||||
packetplayoutlistener.a(this);
|
||||
}
|
||||
|
||||
public void handle(PacketListener packetlistener) {
|
||||
this.a((PacketPlayOutListener)((PacketPlayOutListener)packetlistener));
|
||||
}
|
||||
|
||||
private static String getFormattedName(EntityPlayer player)
|
||||
{
|
||||
String name = player.getName();
|
||||
|
||||
CraftScoreboard scoreboard = player.getBukkitEntity().getScoreboard();
|
||||
if (scoreboard != null)
|
||||
{
|
||||
Team team = scoreboard.getPlayerTeam(player.getBukkitEntity());
|
||||
if (team != null)
|
||||
name = team.getPrefix() + name + team.getSuffix();
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user