Skip to content

Commit

Permalink
Fix spigot 1.13-1.19 support
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueTree242 committed Jan 24, 2025
1 parent 5fc1b18 commit 436a0b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Config> confManager;
private Config config;


public static PlatformPlugin get() {
return platformPlugin;
}
Expand Down Expand Up @@ -97,10 +99,6 @@ public Group mergeGroups(List<Group> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 436a0b2

Please sign in to comment.