Skip to content

Commit 263ec8a

Browse files
committed
Add FLYING packet back for backwards compat
Fixes #1275
1 parent af46ba4 commit 263ec8a

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public static class Client extends PacketTypeEnum {
351351
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x11, "Flying$PacketPlayInPosition", "Flying$Position", "CPacketPlayer$Position");
352352
public static final PacketType POSITION_LOOK = new PacketType(PROTOCOL, SENDER, 0x12, "Flying$PacketPlayInPositionLook", "Flying$PositionLook", "CPacketPlayer$PositionRotation");
353353
public static final PacketType LOOK = new PacketType(PROTOCOL, SENDER, 0x13, "Flying$PacketPlayInLook", "Flying$Look", "CPacketPlayer$Rotation");
354-
public static final PacketType GROUND = new PacketType(PROTOCOL, SENDER, 0x14, "Flying$d", "Flying", "CPacketPlayer");
354+
public static final PacketType GROUND = new PacketType(PROTOCOL, SENDER, 0x14, "Flying$d");
355355
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x15, "VehicleMove", "CPacketVehicleMove");
356356
public static final PacketType BOAT_MOVE = new PacketType(PROTOCOL, SENDER, 0x16, "BoatMove", "CPacketSteerBoat");
357357
public static final PacketType PICK_ITEM = new PacketType(PROTOCOL, SENDER, 0x17, "PickItem");
@@ -386,6 +386,12 @@ public static class Client extends PacketTypeEnum {
386386
@Deprecated
387387
public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 255, "Transaction", "CPacketConfirmTransaction");
388388

389+
/**
390+
* @deprecated Removed in 1.17
391+
*/
392+
@Deprecated
393+
public static final PacketType FLYING = new PacketType(PROTOCOL, SENDER, 254, "Flying", "CPacketPlayer");
394+
389395
private final static Client INSTANCE = new Client();
390396

391397
// Prevent accidental construction

src/main/java/com/comphenix/protocol/ProtocolLogger.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.logging.Level;
2121
import java.util.logging.Logger;
2222

23+
import com.comphenix.protocol.utility.MinecraftVersion;
2324
import org.bukkit.plugin.Plugin;
2425

2526
/**
@@ -82,4 +83,10 @@ public static void debug(String message, Throwable ex) {
8283
logger.log(Level.WARNING, "[Debug] " + message, ex);
8384
}
8485
}
86+
87+
public static void warnAbove(MinecraftVersion version, String message, Object... args) {
88+
if (version.atOrAbove()) {
89+
log(Level.WARNING, message, args);
90+
}
91+
}
8592
}

src/main/java/com/comphenix/protocol/injector/packet/PacketRegistry.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ public static Optional<Class<?>> tryGetPacketClass(PacketType type) {
358358

359359
// Then try looking up the class names
360360
Class<?> clazz = searchForPacket(type.getClassNames());
361+
if (clazz != null) {
362+
// we'd like for it to be associated correctly from the get-go; this is OK on older versions though
363+
ProtocolLogger.warnAbove(type.getCurrentVersion(), "Updating associated class for {0} to {1}", type.name(), clazz);
364+
}
361365

362366
// cache it for next time
363367
associate(type, clazz);

src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ private static Class<?> getEnum(Class<?> clazz, int index) {
565565
List<Field> enumFields = FuzzyReflection.fromClass(clazz, true).getFieldListByType(Enum.class);
566566
if (enumFields.size() <= index) {
567567
// also probably not supported
568+
ProtocolLogger.debug("Enum field not found at index {0} of {1}", index, clazz);
568569
return null;
569570
}
570571

0 commit comments

Comments
 (0)