Archiviert
13
0

Make sure we use the update sign packet when it exists

Should fix #263
Dieser Commit ist enthalten in:
Dan Mulloy 2016-09-11 16:52:45 -04:00
Ursprung caaa57c915
Commit 1de6bbc9dc
2 geänderte Dateien mit 19 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -189,19 +189,19 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
* @deprecated Removed in 1.9
*/
@Deprecated
public static final PacketType MAP_CHUNK_BULK = new PacketType(PROTOCOL, SENDER, -1, -1, "MapChunkBulk").deprecated();
public static final PacketType MAP_CHUNK_BULK = new PacketType(PROTOCOL, SENDER, -1, -1, "MapChunkBulk").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
/**
* @deprecated Removed in 1.9
*/
@Deprecated
public static final PacketType SET_COMPRESSION = new PacketType(PROTOCOL, SENDER, -1, -1, "SetCompression").deprecated();
public static final PacketType SET_COMPRESSION = new PacketType(PROTOCOL, SENDER, -1, -1, "SetCompression").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
/**
* @deprecated Removed in 1.9
*/
@Deprecated
public static final PacketType UPDATE_ENTITY_NBT = new PacketType(PROTOCOL, SENDER, -1, -1, "UpdateEntityNBT").deprecated();
public static final PacketType UPDATE_ENTITY_NBT = new PacketType(PROTOCOL, SENDER, -1, -1, "UpdateEntityNBT").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
// ----- Renamed packets
@ -235,9 +235,8 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
* @deprecated Replaced by {@link TILE_ENTITY_DATA}
*/
@Deprecated
public static final PacketType UPDATE_SIGN = TILE_ENTITY_DATA.deprecated();
public static final PacketType UPDATE_SIGN = getUpdateSign();
// The instance must
private final static Server INSTANCE = new Server();
// Prevent accidental construction
@ -249,6 +248,11 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
public static Server getInstance() {
return INSTANCE;
}
private static PacketType getUpdateSign() {
PacketType type = new PacketType(PROTOCOL, SENDER, -1, -1, "UpdateSign");
return type.getPacketClass() != null ? type : UPDATE_ENTITY_NBT.deprecated();
}
}
/**
@ -582,7 +586,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
/**
* Protocol version of all the current IDs.
*/
private static final MinecraftVersion PROTOCOL_VERSION = MinecraftVersion.BOUNTIFUL_UPDATE;
private static final MinecraftVersion PROTOCOL_VERSION = MinecraftVersion.FROSTBURN_UPDATE;
private final Protocol protocol;
private final Sender sender;
@ -1075,6 +1079,14 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
return forceAsync;
}
private PacketType deprecatedIn(MinecraftVersion version) {
try {
return MinecraftVersion.getCurrentVersion().isAtLeast(version) ? deprecated() : this;
} catch (Throwable ex) {
return deprecated();
}
}
private PacketType deprecated() {
PacketType ret = clone();
ret.deprecated = true;

Datei anzeigen

@ -1338,8 +1338,7 @@ public class PacketContainer implements Serializable {
private static class ComponentArrayConverter implements EquivalentConverter<WrappedChatComponent[]> {
private static final EquivalentConverter<WrappedChatComponent[]> DELEGATE;
static {
Class<?> packetClass = PacketType.Play.Server.UPDATE_SIGN.getPacketClass();
if (packetClass.getName().contains("Sign")) {
if (!PacketType.Play.Server.UPDATE_SIGN.isDeprecated()) {
DELEGATE = new LegacyComponentConverter();
} else {
DELEGATE = new NBTComponentConverter();