diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index 0ed057e394..afffbf79ab 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -1171,7 +1171,9 @@ public void setGenerator(final @NonNull String worldName) { @Override public @NonNull String serverNativePackage() { final String name = Bukkit.getServer().getClass().getPackage().getName(); - return name.substring(name.lastIndexOf('.') + 1); + String ver = name.substring(name.lastIndexOf('.') + 1); + // org.bukkit.craftbukkit is no longer suffixed by a version + return ver.equals("craftbukkit") ? "" : ver; } @Override diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java index ea460be839..8036b94e25 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/SingleWorldListener.java @@ -49,9 +49,14 @@ public SingleWorldListener() throws Exception { this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle").getRealMethod(); } catch (NoSuchMethodException ignored) { try { - ReflectionUtils.RefClass classChunkStatus = getRefClass("net.minecraft.world.level.chunk.ChunkStatus"); + String chunkStatus = PlotSquared.platform().serverVersion()[1] < 21 + ? "net.minecraft.world.level.chunk" + ".ChunkStatus" + : "net.minecraft.world.level.chunk.status.ChunkStatus"; + ReflectionUtils.RefClass classChunkStatus = getRefClass(chunkStatus); this.objChunkStatusFull = classChunkStatus.getRealClass().getField("n").get(null); - this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle", classChunkStatus.getRealClass()).getRealMethod(); + this.methodGetHandleChunk = classCraftChunk + .getMethod("getHandle", classChunkStatus.getRealClass()) + .getRealMethod(); } catch (NoSuchMethodException ex) { throw new RuntimeException(ex); } diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java index 8477a2fb43..af94ed1dde 100644 --- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java +++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java @@ -206,7 +206,8 @@ public PlotSquared( GlobalFlagContainer.setup(); try { - new ReflectionUtils(this.platform.serverNativePackage()); + String ver = this.platform.serverNativePackage(); + new ReflectionUtils(ver.isEmpty() ? null : ver); try { URL logurl = PlotSquared.class.getProtectionDomain().getCodeSource().getLocation(); this.jarFile = new File( @@ -214,7 +215,7 @@ public PlotSquared( logurl.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")) .getPath()); } catch (URISyntaxException | SecurityException e) { - e.printStackTrace(); + LOGGER.error(e); this.jarFile = new File(this.platform.getDirectory().getParentFile(), "PlotSquared.jar"); if (!this.jarFile.exists()) { this.jarFile = new File( @@ -238,7 +239,7 @@ public PlotSquared( copyFile("skyblock.template", Settings.Paths.TEMPLATES); showDebug(); } catch (Throwable e) { - e.printStackTrace(); + LOGGER.error(e); } }