3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 09:00:09 +01:00

Make UnsupportedSoftware hold a list of class names

Dieser Commit ist enthalten in:
KennyTV 2021-05-08 10:05:43 +02:00
Ursprung fe3f247eb1
Commit cb7a7254a6
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 32 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -22,15 +22,24 @@
*/ */
package com.viaversion.viaversion.api.platform; package com.viaversion.viaversion.api.platform;
import java.util.Collections;
import java.util.List;
public final class UnsupportedSoftware { public final class UnsupportedSoftware {
private final String name; private final String name;
private final String className; private final List<String> classNames;
private final String reason; private final String reason;
public UnsupportedSoftware(String name, List<String> classNames, String reason) {
this.name = name;
this.classNames = Collections.unmodifiableList(classNames);
this.reason = reason;
}
public UnsupportedSoftware(String name, String className, String reason) { public UnsupportedSoftware(String name, String className, String reason) {
this.name = name; this.name = name;
this.className = className; this.classNames = Collections.singletonList(className);
this.reason = reason; this.reason = reason;
} }
@ -44,12 +53,12 @@ public final class UnsupportedSoftware {
} }
/** /**
* Returns the fully qualified class name. * Returns an immutable list of the fully qualified class name.
* *
* @return fully qualified class name * @return immutable list of fully qualified class name
*/ */
public String getClassName() { public List<String> getClassNames() {
return className; return classNames;
} }
/** /**
@ -61,6 +70,22 @@ public final class UnsupportedSoftware {
return reason; return reason;
} }
/**
* Returns whether at least one of the held class names exists.
*
* @return true if at least one of the classes exists
*/
public boolean findMatch() {
for (String className : classNames) {
try {
Class.forName(className);
return true;
} catch (ClassNotFoundException ignored) {
}
}
return false;
}
public static final class Reason { public static final class Reason {
public static final String DANGEROUS_SERVER_SOFTWARE = "You are using server software that - outside of possibly breaking ViaVersion - can also cause severe damage to your server's integrity as a whole."; public static final String DANGEROUS_SERVER_SOFTWARE = "You are using server software that - outside of possibly breaking ViaVersion - can also cause severe damage to your server's integrity as a whole.";

Datei anzeigen

@ -207,9 +207,7 @@ public class ViaManagerImpl implements ViaManager {
private void unsupportedSoftwareWarning() { private void unsupportedSoftwareWarning() {
boolean found = false; boolean found = false;
for (UnsupportedSoftware software : platform.getUnsupportedSoftwareClasses()) { for (UnsupportedSoftware software : platform.getUnsupportedSoftwareClasses()) {
try { if (!software.findMatch()) {
Class.forName(software.getClassName());
} catch (ClassNotFoundException ignored) {
continue; continue;
} }