Skip to content

Commit 1de6bbc

Browse files
committed
Make sure we use the update sign packet when it exists
Should fix #263
1 parent caaa57c commit 1de6bbc

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

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

Lines changed: 18 additions & 6 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").deprecated();
192+
public static final PacketType MAP_CHUNK_BULK = new PacketType(PROTOCOL, SENDER, -1, -1, "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").deprecated();
198+
public static final PacketType SET_COMPRESSION = new PacketType(PROTOCOL, SENDER, -1, -1, "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").deprecated();
204+
public static final PacketType UPDATE_ENTITY_NBT = new PacketType(PROTOCOL, SENDER, -1, -1, "UpdateEntityNBT").deprecatedIn(MinecraftVersion.COMBAT_UPDATE);
205205

206206
// ----- Renamed packets
207207

@@ -235,9 +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 = TILE_ENTITY_DATA.deprecated();
238+
public static final PacketType UPDATE_SIGN = getUpdateSign();
239239

240-
// The instance must
241240
private final static Server INSTANCE = new Server();
242241

243242
// Prevent accidental construction
@@ -249,6 +248,11 @@ public static Sender getSender() {
249248
public static Server getInstance() {
250249
return INSTANCE;
251250
}
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+
}
252256
}
253257

254258
/**
@@ -582,7 +586,7 @@ public String getPacketName() {
582586
/**
583587
* Protocol version of all the current IDs.
584588
*/
585-
private static final MinecraftVersion PROTOCOL_VERSION = MinecraftVersion.BOUNTIFUL_UPDATE;
589+
private static final MinecraftVersion PROTOCOL_VERSION = MinecraftVersion.FROSTBURN_UPDATE;
586590

587591
private final Protocol protocol;
588592
private final Sender sender;
@@ -1075,6 +1079,14 @@ public boolean forceAsync() {
10751079
return forceAsync;
10761080
}
10771081

1082+
private PacketType deprecatedIn(MinecraftVersion version) {
1083+
try {
1084+
return MinecraftVersion.getCurrentVersion().isAtLeast(version) ? deprecated() : this;
1085+
} catch (Throwable ex) {
1086+
return deprecated();
1087+
}
1088+
}
1089+
10781090
private PacketType deprecated() {
10791091
PacketType ret = clone();
10801092
ret.deprecated = true;

modules/API/src/main/java/com/comphenix/protocol/events/PacketContainer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,8 +1338,7 @@ public Class<WrappedChatComponent[]> getSpecificType() {
13381338
private static class ComponentArrayConverter implements EquivalentConverter<WrappedChatComponent[]> {
13391339
private static final EquivalentConverter<WrappedChatComponent[]> DELEGATE;
13401340
static {
1341-
Class<?> packetClass = PacketType.Play.Server.UPDATE_SIGN.getPacketClass();
1342-
if (packetClass.getName().contains("Sign")) {
1341+
if (!PacketType.Play.Server.UPDATE_SIGN.isDeprecated()) {
13431342
DELEGATE = new LegacyComponentConverter();
13441343
} else {
13451344
DELEGATE = new NBTComponentConverter();

0 commit comments

Comments
 (0)