fix: update to changes in 1.21 class paths (#4546)

This commit is contained in:
Jordan
2024-12-06 16:52:17 +00:00
committed by GitHub
parent c46b4ddeaa
commit bc4e2c51da
3 changed files with 14 additions and 6 deletions

View File

@ -1171,7 +1171,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
@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

View File

@ -49,9 +49,14 @@ public class SingleWorldListener implements Listener {
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);
}