From 5e4a9a8c983d22fd4c99d1fcdc33bce08a048a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Sun, 25 Nov 2018 15:26:34 +0800 Subject: [PATCH] + fixed --- .../skymc/taboolib/common/function/TFunctionLoader.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/me/skymc/taboolib/common/function/TFunctionLoader.java b/src/main/java/me/skymc/taboolib/common/function/TFunctionLoader.java index a74fee2..9a3a387 100644 --- a/src/main/java/me/skymc/taboolib/common/function/TFunctionLoader.java +++ b/src/main/java/me/skymc/taboolib/common/function/TFunctionLoader.java @@ -6,6 +6,7 @@ import me.skymc.taboolib.TabooLibLoader; import org.bukkit.plugin.Plugin; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; /** * @Author sky @@ -19,6 +20,10 @@ public class TFunctionLoader implements TabooLibLoader.Loader { TFunction function = pluginClass.getAnnotation(TFunction.class); try { Method method = pluginClass.getDeclaredMethod(function.enable()); + if (!Modifier.isStatic(method.getModifiers())) { + TLogger.getGlobalLogger().error(method.getName() + " is not a static method."); + return; + } method.setAccessible(true); method.invoke(null); TabooLib.debug("Function " + pluginClass.getSimpleName() + " loaded. (" + plugin.getName() + ")"); @@ -36,6 +41,10 @@ public class TFunctionLoader implements TabooLibLoader.Loader { TFunction function = pluginClass.getAnnotation(TFunction.class); try { Method method = pluginClass.getDeclaredMethod(function.disable()); + if (!Modifier.isStatic(method.getModifiers())) { + TLogger.getGlobalLogger().error(method.getName() + " is not a static method."); + return; + } method.setAccessible(true); method.invoke(null); TabooLib.debug("Function " + pluginClass.getSimpleName() + " unloaded. (" + plugin.getName() + ")");