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 Removed in 1.9
*/ */
@Deprecated @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 Removed in 1.9
*/ */
@Deprecated @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 Removed in 1.9
*/ */
@Deprecated @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 // ----- Renamed packets
@ -235,9 +235,8 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
* @deprecated Replaced by {@link TILE_ENTITY_DATA} * @deprecated Replaced by {@link TILE_ENTITY_DATA}
*/ */
@Deprecated @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(); private final static Server INSTANCE = new Server();
// Prevent accidental construction // Prevent accidental construction
@ -249,6 +248,11 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
public static Server getInstance() { public static Server getInstance() {
return INSTANCE; 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. * 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 Protocol protocol;
private final Sender sender; private final Sender sender;
@ -1075,6 +1079,14 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
return forceAsync; return forceAsync;
} }
private PacketType deprecatedIn(MinecraftVersion version) {
try {
return MinecraftVersion.getCurrentVersion().isAtLeast(version) ? deprecated() : this;
} catch (Throwable ex) {
return deprecated();
}
}
private PacketType deprecated() { private PacketType deprecated() {
PacketType ret = clone(); PacketType ret = clone();
ret.deprecated = true; ret.deprecated = true;

Datei anzeigen

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