mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-27 14:30:14 +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:
1 parent
475f72a300
commit
2fc4c2faf9
2 files changed
+16
-2
No files matched your search
@@ -94,6 +94,7 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
private static VolmitSender sender;
|
private static VolmitSender sender;
|
||||||
private static Thread shutdownHook;
|
private static Thread shutdownHook;
|
||||||
private static final String STUDIO_WORLDS_FOLDER = "iris";
|
private static final String STUDIO_WORLDS_FOLDER = "iris";
|
||||||
|
private static final String NMS_BINDINGS_PACKAGE = "com.volmit.iris.core.nms.v";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
@@ -569,7 +570,15 @@ public class Iris extends VolmitPlugin implements Listener {
|
|||||||
postShutdown.forEach(Runnable::run);
|
postShutdown.forEach(Runnable::run);
|
||||||
super.onDisable();
|
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() {
|
private static boolean isPaperServer() {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.volmit.iris.util.collection.KSet;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.function.Predicate;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
@@ -84,6 +85,10 @@ public class JarScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void scanAll() throws IOException {
|
public void scanAll() throws IOException {
|
||||||
|
scanAll(c -> true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void scanAll(Predicate<String> classFilter) throws IOException {
|
||||||
classes.clear();
|
classes.clear();
|
||||||
FileInputStream fin = new FileInputStream(jar);
|
FileInputStream fin = new FileInputStream(jar);
|
||||||
ZipInputStream zip = new ZipInputStream(fin);
|
ZipInputStream zip = new ZipInputStream(fin);
|
||||||
@@ -91,7 +96,7 @@ public class JarScanner {
|
|||||||
if (!entry.isDirectory() && entry.getName().endsWith(".class")) {
|
if (!entry.isDirectory() && entry.getName().endsWith(".class")) {
|
||||||
String c = entry.getName().replaceAll("/", ".").replace(".class", "");
|
String c = entry.getName().replaceAll("/", ".").replace(".class", "");
|
||||||
|
|
||||||
if (c.startsWith(superPackage)) {
|
if (c.startsWith(superPackage) && classFilter.test(c)) {
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName(c);
|
Class<?> clazz = Class.forName(c);
|
||||||
classes.add(clazz);
|
classes.add(clazz);
|
||||||
|
|||||||
Reference in new issue
Block a user