mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 19:45:21 +01:00
Print plugin name in unsupported software matching
This commit is contained in:
parent
7b0160d6c3
commit
8864b161f9
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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("");
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user