Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Print plugin name in unsupported software matching
Dieser Commit ist enthalten in:
Ursprung
7b0160d6c3
Commit
8864b161f9
@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.platform;
|
package com.viaversion.viaversion.api.platform;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public interface UnsupportedSoftware {
|
public interface UnsupportedSoftware {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,10 +40,19 @@ public interface UnsupportedSoftware {
|
|||||||
*/
|
*/
|
||||||
String getReason();
|
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.
|
* Returns whether the unsupported software is present.
|
||||||
*
|
*
|
||||||
* @return true if the unsupported software is found
|
* @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() {
|
private void unsupportedSoftwareWarning() {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (final UnsupportedSoftware software : platform.getUnsupportedSoftwareClasses()) {
|
for (final UnsupportedSoftware software : platform.getUnsupportedSoftwareClasses()) {
|
||||||
if (!software.findMatch()) {
|
final String match = software.match();
|
||||||
|
if (match == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +250,7 @@ public class ViaManagerImpl implements ViaManager {
|
|||||||
found = true;
|
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(software.getReason());
|
||||||
platform.getLogger().severe("");
|
platform.getLogger().severe("");
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import com.viaversion.viaversion.api.platform.UnsupportedSoftware;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class UnsupportedPlugin implements UnsupportedSoftware {
|
public final class UnsupportedPlugin implements UnsupportedSoftware {
|
||||||
|
|
||||||
@ -50,13 +51,13 @@ public final class UnsupportedPlugin implements UnsupportedSoftware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean findMatch() {
|
public final @Nullable String match() {
|
||||||
for (final String identifier : identifiers) {
|
for (final String identifier : identifiers) {
|
||||||
if (Via.getPlatform().hasPlugin(identifier)) {
|
if (Via.getPlatform().hasPlugin(identifier)) {
|
||||||
return true;
|
return identifier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
@ -24,6 +24,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public final class UnsupportedServerSoftware implements UnsupportedSoftware {
|
public final class UnsupportedServerSoftware implements UnsupportedSoftware {
|
||||||
|
|
||||||
@ -53,20 +54,20 @@ public final class UnsupportedServerSoftware implements UnsupportedSoftware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean findMatch() {
|
public final @Nullable String match() {
|
||||||
for (String className : classNames) {
|
for (String className : classNames) {
|
||||||
try {
|
try {
|
||||||
Class.forName(className);
|
Class.forName(className);
|
||||||
return true;
|
return name;
|
||||||
} catch (ClassNotFoundException ignored) {
|
} catch (ClassNotFoundException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (UnsupportedMethods method : methods) {
|
for (UnsupportedMethods method : methods) {
|
||||||
if (method.findMatch()) {
|
if (method.findMatch()) {
|
||||||
return true;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren