Actually use UpdateSign when it exists

This commit is contained in:
Dan Mulloy 2016-09-18 14:42:40 -04:00
parent 051989a396
commit d173be0db5
2 changed files with 13 additions and 9 deletions

View File

@ -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").deprecatedIn(MinecraftVersion.COMBAT_UPDATE); public static final PacketType MAP_CHUNK_BULK = new PacketType(PROTOCOL, SENDER, 255, 255, "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").deprecatedIn(MinecraftVersion.COMBAT_UPDATE); public static final PacketType SET_COMPRESSION = new PacketType(PROTOCOL, SENDER, 254, 254, "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").deprecatedIn(MinecraftVersion.COMBAT_UPDATE); public static final PacketType UPDATE_ENTITY_NBT = new PacketType(PROTOCOL, SENDER, 253, 253, "UpdateEntityNBT").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
// ----- Renamed packets // ----- Renamed packets
@ -235,7 +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 = getUpdateSign(); public static final PacketType UPDATE_SIGN = MinecraftReflection.signUpdateExists() ? new PacketType(PROTOCOL, SENDER, 252, 252, "UpdateSign") :
TILE_ENTITY_DATA.deprecated();
private final static Server INSTANCE = new Server(); private final static Server INSTANCE = new Server();
@ -248,11 +249,6 @@ 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();
}
} }
/** /**

View File

@ -1827,6 +1827,14 @@ public class MinecraftReflection {
return getArrayClass(getMultiBlockChangeInfoClass()); return getArrayClass(getMultiBlockChangeInfoClass());
} }
public static boolean signUpdateExists() {
try {
return getMinecraftClass("PacketPlayOutUpdateSign") != null;
} catch (RuntimeException ex) {
return false;
}
}
/** /**
* Retrieve a CraftItemStack from a given ItemStack. * Retrieve a CraftItemStack from a given ItemStack.
* @param bukkitItemStack - the Bukkit ItemStack to convert. * @param bukkitItemStack - the Bukkit ItemStack to convert.