diff --git a/pom.xml b/pom.xml index d5b18aa..9dfcd80 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.warp CoordinatesObfuscator - 1.4.1 + 1.4.2 CoordinatesObfuscator @@ -52,7 +52,7 @@ com.comphenix.protocol ProtocolLib - 4.7.0-SNAPSHOT + 4.7.0 provided diff --git a/src/main/java/org/warp/coordinatesobfuscator/CoordinatesObfuscator.java b/src/main/java/org/warp/coordinatesobfuscator/CoordinatesObfuscator.java index 3ee48f1..2d27ef4 100644 --- a/src/main/java/org/warp/coordinatesobfuscator/CoordinatesObfuscator.java +++ b/src/main/java/org/warp/coordinatesobfuscator/CoordinatesObfuscator.java @@ -43,6 +43,7 @@ public void onDisable() { } + @SuppressWarnings("CommentedOutCode") @Override public void onEnable() { this.logger = getLogger(); @@ -97,22 +98,35 @@ public void onEnable() { packets.add(PacketType.Play.Server.WINDOW_DATA); packets.add(PacketType.Play.Server.SET_SLOT); + packets.add(Server.TILE_ENTITY_DATA); + + //todo: these packets shouldn't have position. Check if some of them must be translated + // packets.add(Server.ENTITY_DESTROY); + // packets.add(Server.ENTITY_EQUIPMENT); + // packets.add(Server.ENTITY_LOOK); + // packets.add(Server.ENTITY_EFFECT); + // packets.add(Server.ENTITY_HEAD_ROTATION); + // packets.add(Server.ENTITY_SOUND); + // packets.add(Server.ENTITY_STATUS); + // packets.add(Server.ENTITY_VELOCITY); + // packets.add(Server.REL_ENTITY_MOVE); + // packets.add(Server.REL_ENTITY_MOVE_LOOK); + // packets.add(Server.ATTACH_ENTITY); + paramsServer.types(packets); pm.addPacketListener(new PacketAdapter(paramsServer) { + @SuppressWarnings("DuplicateBranchesInSwitch") @Override public void onPacketSending(final PacketEvent event) { PacketContainer packet; - packet = event.getPacket().shallowClone(); - switch (packet.getType().name()) { - case "TILE_ENTITY_DATA": - cloneTileEntityData(packet); - break; - case "MAP_CHUNK": - cloneMapChunkEntitiesData(packet); - break; + switch (event.getPacket().getType().name()) { + case "LIGHT_UPDATE" -> packet = event.getPacket().shallowClone(); + case "TILE_ENTITY_DATA" -> packet = cloneTileEntityData(event.getPacket()); + case "MAP_CHUNK" -> packet = cloneMapChunkEntitiesData(event.getPacket()); + default -> packet = event.getPacket().shallowClone(); } Player player = event.getPlayer(); @@ -187,7 +201,8 @@ public void onPlayerJoin(final PlayerJoinEvent event) { } - private PacketContainer cloneTileEntityData(final PacketContainer packet) { + private PacketContainer cloneTileEntityData(PacketContainer packet) { + packet = packet.shallowClone(); int i = 0; for (final NbtBase obj : packet.getNbtModifier().getValues()) { packet.getNbtModifier().write(i, obj.deepClone()); @@ -198,6 +213,7 @@ private PacketContainer cloneTileEntityData(final PacketContainer packet) { } private PacketContainer cloneMapChunkEntitiesData(PacketContainer packet) { + packet = packet.shallowClone(); int i = 0; for (final List> obj : packet.getListNbtModifier().getValues()) { ArrayList> newList = new ArrayList>(obj.size());