diff --git a/core/src/main/java/dev/bluetree242/advancedplhide/PlatformPlugin.java b/core/src/main/java/dev/bluetree242/advancedplhide/PlatformPlugin.java index 82dbfbd..cb0ca3e 100644 --- a/core/src/main/java/dev/bluetree242/advancedplhide/PlatformPlugin.java +++ b/core/src/main/java/dev/bluetree242/advancedplhide/PlatformPlugin.java @@ -45,12 +45,14 @@ * @see PlatformPlugin#get() */ public abstract class PlatformPlugin { + private static final HttpClient client = HttpClient.newBuilder() + .withBaseURL("https://advancedplhide.bluetree242.dev") + .withEntityMapper(new EntityMapper().registerSerializer(HTTPRequestMultipartBody.class, new HTTPRequestMultipartBody.MultiPartSerializer())) + .build(); private static PlatformPlugin platformPlugin = null; - private ConfManager confManager; private Config config; - public static PlatformPlugin get() { return platformPlugin; } @@ -97,10 +99,6 @@ public Group mergeGroups(List groups) { return new Group(name, tabcomplete); } - private static final HttpClient client = HttpClient.newBuilder() - .withBaseURL("https://advancedplhide.bluetree242.dev") - .withEntityMapper(new EntityMapper().registerSerializer(HTTPRequestMultipartBody.class, new HTTPRequestMultipartBody.MultiPartSerializer())) - .build(); public UpdateCheckResult updateCheck() throws Throwable { HTTPRequestMultipartBody multipartBody = new HTTPRequestMultipartBody.Builder() .addPart("version", PluginInfo.VERSION) diff --git a/spigot/src/main/java/dev/bluetree242/advancedplhide/spigot/AdvancedPlHideSpigot.java b/spigot/src/main/java/dev/bluetree242/advancedplhide/spigot/AdvancedPlHideSpigot.java index f149353..faff031 100644 --- a/spigot/src/main/java/dev/bluetree242/advancedplhide/spigot/AdvancedPlHideSpigot.java +++ b/spigot/src/main/java/dev/bluetree242/advancedplhide/spigot/AdvancedPlHideSpigot.java @@ -24,6 +24,7 @@ import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolManager; +import com.comphenix.protocol.events.PacketEvent; import dev.bluetree242.advancedplhide.Group; import dev.bluetree242.advancedplhide.PlatformPlugin; import dev.bluetree242.advancedplhide.impl.version.UpdateCheckResult; @@ -81,9 +82,16 @@ public void onEnable() { getServer().getPluginManager().registerEvents(new SpigotEventListener(this), this); String mv = Bukkit.getServer().getBukkitVersion(); legacy = (mv.startsWith("1.8") || mv.startsWith("1.9") || mv.startsWith("1.10") || mv.startsWith("1.11") || mv.startsWith("1.12")); - boolean modernNeeded = !(mv.startsWith("1.13") || mv.startsWith("1.14") || mv.startsWith("1.15") || mv.startsWith("1.16") || mv.startsWith("1.17") || mv.startsWith("1.18")); - if (!legacy && modernNeeded) { - if (mv.startsWith("1.19.1")) { + if (!legacy) { + boolean modernNeeded = !(mv.startsWith("1.13") || mv.startsWith("1.14") || mv.startsWith("1.15") || mv.startsWith("1.16") || mv.startsWith("1.17") || mv.startsWith("1.18")); + if (!modernNeeded) { + modernHandler = new ModernHandler() { + @Override + public void handleCommands(PacketEvent packetEvent, Group group, boolean whitelist) { + throw new UnsupportedOperationException(); + } + }; + } else if (mv.startsWith("1.19.1")) { modernHandler = new V1_19_Handler(); } else if (mv.startsWith("1.19.3") || mv.startsWith("1.19.4") || (mv.startsWith("1.20") && Integer.parseInt(mv.substring(5, 6)) <= 4)) { // Expect 1.19.3+ modernHandler = new V1_19_3_Handler();