diff --git a/build.gradle b/build.gradle index a6da89b..0c6097c 100644 --- a/build.gradle +++ b/build.gradle @@ -44,8 +44,8 @@ allprojects { } java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } } diff --git a/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/ViaVersionHook.java b/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/ViaVersionHook.java index b8fc7cf..33ced75 100644 --- a/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/ViaVersionHook.java +++ b/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/ViaVersionHook.java @@ -7,8 +7,8 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; -import java.util.StringJoiner; public class ViaVersionHook implements Hook { @@ -32,19 +32,19 @@ public String getPluginName() { @Override public void register() { ServerVersion serverVersion = PacketEvents.getAPI().getServerManager().getVersion(); - for (Class> modifier : modifiers) { + Iterator>> iterator = modifiers.iterator(); + while (iterator.hasNext()) try { + Class> modifier = iterator.next(); ViaProtocolModifier modifierInstance = modifier.getDeclaredConstructor().newInstance(); if (serverVersion.is(modifierInstance.getComparison(), modifierInstance.getVersion())) { modifierInstance.modify(); registeredModifiers.add(modifierInstance); - modifiers.remove(modifier); AntiPopup.getInstance().getLogger().info(() -> getRegisteredMessage(modifierInstance)); } } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | InstantiationException ignored) {} - } } private String getRegisteredMessage(ViaProtocolModifier modifier) { diff --git a/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/Via_1_19_to_1_19_1.java b/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/Via_1_19_to_1_19_1.java index b91d3f8..395e831 100644 --- a/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/Via_1_19_to_1_19_1.java +++ b/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/Via_1_19_to_1_19_1.java @@ -15,10 +15,7 @@ public Via_1_19_to_1_19_1() { @Override public void modify() { protocol.appendClientbound(ClientboundPackets1_19.SERVER_DATA, (wrapper) -> { - wrapper.passthrough(Type.OPTIONAL_COMPONENT); - wrapper.passthrough(Type.OPTIONAL_STRING); - wrapper.passthrough(Type.BOOLEAN); - wrapper.write(Type.BOOLEAN, true); + wrapper.set(Type.BOOLEAN, 1, true); }); } diff --git a/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/Via_1_20_4_to_1_20_5.java b/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/Via_1_20_4_to_1_20_5.java index 869f151..0eae0a2 100644 --- a/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/Via_1_20_4_to_1_20_5.java +++ b/spigot/src/main/java/com/github/kaspiandev/antipopup/spigot/hook/viaversion/Via_1_20_4_to_1_20_5.java @@ -15,25 +15,7 @@ public Via_1_20_4_to_1_20_5() { @Override public void modify() { protocol.appendClientbound(ClientboundPackets1_20_3.JOIN_GAME, (wrapper) -> { - wrapper.passthrough(Type.INT); // Entity ID - wrapper.passthrough(Type.BOOLEAN); // Hardcore - wrapper.passthrough(Type.STRING_ARRAY); // World List - wrapper.passthrough(Type.VAR_INT); // Max players - wrapper.passthrough(Type.VAR_INT); // View distance - wrapper.passthrough(Type.VAR_INT); // Simulation distance - wrapper.passthrough(Type.BOOLEAN); // Reduced debug info - wrapper.passthrough(Type.BOOLEAN); // Show death screen - wrapper.passthrough(Type.BOOLEAN); // Limited crafting - wrapper.passthrough(Type.VAR_INT); // Dimension - wrapper.passthrough(Type.STRING); // World - wrapper.passthrough(Type.LONG); // Seed - wrapper.passthrough(Type.BYTE); // Gamemode - wrapper.passthrough(Type.BYTE); // Previous gamemode - wrapper.passthrough(Type.BOOLEAN); // Debug - wrapper.passthrough(Type.BOOLEAN); // Flat - wrapper.passthrough(Type.OPTIONAL_GLOBAL_POSITION); // Last death location - wrapper.passthrough(Type.VAR_INT); // Portal cooldown - wrapper.write(Type.BOOLEAN, true); // Enforces secure chat + wrapper.set(Type.BOOLEAN, 6, true); // Enforces secure chat }); }