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

Print plugin name in unsupported software matching

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-04-02 09:40:35 +02:00
Ursprung 7b0160d6c3
Commit 8864b161f9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
4 geänderte Dateien mit 24 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -22,6 +22,8 @@
*/
package com.viaversion.viaversion.api.platform;
import org.checkerframework.checker.nullness.qual.Nullable;
public interface UnsupportedSoftware {
/**
@ -38,10 +40,19 @@ public interface UnsupportedSoftware {
*/
String getReason();
/**
* Returns the name of unsupported software if present.
*
* @return name of unsupported software if it is matched, else null
*/
@Nullable String match();
/**
* Returns whether the unsupported software is present.
*
* @return true if the unsupported software is found
*/
boolean findMatch();
default boolean findMatch() {
return match() != null;
}
}

Datei anzeigen

@ -237,7 +237,8 @@ public class ViaManagerImpl implements ViaManager {
private void unsupportedSoftwareWarning() {
boolean found = false;
for (final UnsupportedSoftware software : platform.getUnsupportedSoftwareClasses()) {
if (!software.findMatch()) {
final String match = software.match();
if (match == null) {
continue;
}
@ -249,7 +250,7 @@ public class ViaManagerImpl implements ViaManager {
found = true;
}
platform.getLogger().severe("We strongly advise against using " + software.getName() + ":");
platform.getLogger().severe("We strongly advise against using " + match + ":");
platform.getLogger().severe(software.getReason());
platform.getLogger().severe("");
}

Datei anzeigen

@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.platform.UnsupportedSoftware;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class UnsupportedPlugin implements UnsupportedSoftware {
@ -50,13 +51,13 @@ public final class UnsupportedPlugin implements UnsupportedSoftware {
}
@Override
public final boolean findMatch() {
public final @Nullable String match() {
for (final String identifier : identifiers) {
if (Via.getPlatform().hasPlugin(identifier)) {
return true;
return identifier;
}
}
return false;
return null;
}
public static final class Builder {

Datei anzeigen

@ -24,6 +24,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class UnsupportedServerSoftware implements UnsupportedSoftware {
@ -53,20 +54,20 @@ public final class UnsupportedServerSoftware implements UnsupportedSoftware {
}
@Override
public final boolean findMatch() {
public final @Nullable String match() {
for (String className : classNames) {
try {
Class.forName(className);
return true;
return name;
} catch (ClassNotFoundException ignored) {
}
}
for (UnsupportedMethods method : methods) {
if (method.findMatch()) {
return true;
return name;
}
}
return false;
return null;
}
public static final class Builder {