Skip to content

Commit d173be0

Browse files
committed
Actually use UpdateSign when it exists
1 parent 051989a commit d173be0

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

modules/API/src/main/java/com/comphenix/protocol/PacketType.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,19 @@ public static class Server extends ObjectEnum<PacketType> {
189189
* @deprecated Removed in 1.9
190190
*/
191191
@Deprecated
192-
public static final PacketType MAP_CHUNK_BULK = new PacketType(PROTOCOL, SENDER, -1, -1, "MapChunkBulk").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
192+
public static final PacketType MAP_CHUNK_BULK = new PacketType(PROTOCOL, SENDER, 255, 255, "MapChunkBulk").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
193193

194194
/**
195195
* @deprecated Removed in 1.9
196196
*/
197197
@Deprecated
198-
public static final PacketType SET_COMPRESSION = new PacketType(PROTOCOL, SENDER, -1, -1, "SetCompression").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
198+
public static final PacketType SET_COMPRESSION = new PacketType(PROTOCOL, SENDER, 254, 254, "SetCompression").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
199199

200200
/**
201201
* @deprecated Removed in 1.9
202202
*/
203203
@Deprecated
204-
public static final PacketType UPDATE_ENTITY_NBT = new PacketType(PROTOCOL, SENDER, -1, -1, "UpdateEntityNBT").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
204+
public static final PacketType UPDATE_ENTITY_NBT = new PacketType(PROTOCOL, SENDER, 253, 253, "UpdateEntityNBT").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
205205

206206
// ----- Renamed packets
207207

@@ -235,7 +235,8 @@ public static class Server extends ObjectEnum<PacketType> {
235235
* @deprecated Replaced by {@link TILE_ENTITY_DATA}
236236
*/
237237
@Deprecated
238-
public static final PacketType UPDATE_SIGN = getUpdateSign();
238+
public static final PacketType UPDATE_SIGN = MinecraftReflection.signUpdateExists() ? new PacketType(PROTOCOL, SENDER, 252, 252, "UpdateSign") :
239+
TILE_ENTITY_DATA.deprecated();
239240

240241
private final static Server INSTANCE = new Server();
241242

@@ -248,11 +249,6 @@ public static Sender getSender() {
248249
public static Server getInstance() {
249250
return INSTANCE;
250251
}
251-
252-
private static PacketType getUpdateSign() {
253-
PacketType type = new PacketType(PROTOCOL, SENDER, -1, -1, "UpdateSign");
254-
return type.getPacketClass() != null ? type : UPDATE_ENTITY_NBT.deprecated();
255-
}
256252
}
257253

258254
/**

modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftReflection.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,14 @@ public static Class<?> getMultiBlockChangeInfoArrayClass() {
18271827
return getArrayClass(getMultiBlockChangeInfoClass());
18281828
}
18291829

1830+
public static boolean signUpdateExists() {
1831+
try {
1832+
return getMinecraftClass("PacketPlayOutUpdateSign") != null;
1833+
} catch (RuntimeException ex) {
1834+
return false;
1835+
}
1836+
}
1837+
18301838
/**
18311839
* Retrieve a CraftItemStack from a given ItemStack.
18321840
* @param bukkitItemStack - the Bukkit ItemStack to convert.

0 commit comments

Comments
 (0)