mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-20 07:24:16 +00:00
Skip other versions' NMS bindings when preloading classes on disable
Older servers such as Paper 1.20.1 cannot read the Java 25 classes of the 26.x binding and logged a conversion error for each of them on shutdown. Bindings for other versions are never used, so they are not loaded at all. Model used: Claude Opus 5.5
This commit is contained in:
@@ -94,6 +94,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
private static VolmitSender sender;
|
||||
private static Thread shutdownHook;
|
||||
private static final String STUDIO_WORLDS_FOLDER = "iris";
|
||||
private static final String NMS_BINDINGS_PACKAGE = "com.volmit.iris.core.nms.v";
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -569,7 +570,15 @@ public class Iris extends VolmitPlugin implements Listener {
|
||||
postShutdown.forEach(Runnable::run);
|
||||
super.onDisable();
|
||||
|
||||
J.attempt(new JarScanner(instance.getJarFile(), "", false)::scanAll);
|
||||
J.attempt(() -> new JarScanner(instance.getJarFile(), "", false).scanAll(Iris::isForRunningServer));
|
||||
}
|
||||
|
||||
private static boolean isForRunningServer(String className) {
|
||||
// Older servers log errors for the bindings compiled for a newer Java version.
|
||||
if (!className.startsWith(NMS_BINDINGS_PACKAGE)) {
|
||||
return true;
|
||||
}
|
||||
return className.startsWith(INMS.get().getClass().getPackageName() + ".");
|
||||
}
|
||||
|
||||
private static boolean isPaperServer() {
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.volmit.iris.util.collection.KSet;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@@ -84,6 +85,10 @@ public class JarScanner {
|
||||
}
|
||||
|
||||
public void scanAll() throws IOException {
|
||||
scanAll(c -> true);
|
||||
}
|
||||
|
||||
public void scanAll(Predicate<String> classFilter) throws IOException {
|
||||
classes.clear();
|
||||
FileInputStream fin = new FileInputStream(jar);
|
||||
ZipInputStream zip = new ZipInputStream(fin);
|
||||
@@ -91,7 +96,7 @@ public class JarScanner {
|
||||
if (!entry.isDirectory() && entry.getName().endsWith(".class")) {
|
||||
String c = entry.getName().replaceAll("/", ".").replace(".class", "");
|
||||
|
||||
if (c.startsWith(superPackage)) {
|
||||
if (c.startsWith(superPackage) && classFilter.test(c)) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(c);
|
||||
classes.add(clazz);
|
||||
|
||||
Reference in New Issue
Block a user