9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-29 11:59:21 +00:00

fix: improve nms version checker

This commit is contained in:
LoJoSho
2023-10-14 14:47:05 -05:00
parent 8ef6692198
commit e0b2f0f6b1
2 changed files with 8 additions and 1 deletions

View File

@@ -61,7 +61,7 @@ public final class HMCCosmeticsPlugin extends JavaPlugin {
Metrics metrics = new Metrics(this, pluginId);
// NMS version check
if (!NMSHandlers.getHandler().getSupported()) {
if (NMSHandlers.isVersionSupported()) {
getLogger().severe("This version is not supported! Consider switching versions?");
getServer().getPluginManager().disablePlugin(this);
return;

View File

@@ -3,6 +3,7 @@ package com.hibiscusmc.hmccosmetics.nms;
import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.util.MessagesUtil;
import lombok.Getter;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
@@ -14,6 +15,7 @@ public class NMSHandlers {
@Getter
private static String version;
@Nullable
public static NMSHandler getHandler() {
if (handler != null) {
return handler;
@@ -23,6 +25,11 @@ public class NMSHandlers {
return handler;
}
public static boolean isVersionSupported() {
if (getHandler() == null) return false;
return getHandler().getSupported();
}
public static void setup() {
if (handler != null) return;
final String packageName = HMCCosmeticsPlugin.getInstance().getServer().getClass().getPackage().getName();