This commit is contained in:
坏黑 2018-11-25 15:26:34 +08:00
parent 0094bdf3b6
commit 5e4a9a8c98

View File

@ -6,6 +6,7 @@ import me.skymc.taboolib.TabooLibLoader;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
/** /**
* @Author sky * @Author sky
@ -19,6 +20,10 @@ public class TFunctionLoader implements TabooLibLoader.Loader {
TFunction function = pluginClass.getAnnotation(TFunction.class); TFunction function = pluginClass.getAnnotation(TFunction.class);
try { try {
Method method = pluginClass.getDeclaredMethod(function.enable()); 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.setAccessible(true);
method.invoke(null); method.invoke(null);
TabooLib.debug("Function " + pluginClass.getSimpleName() + " loaded. (" + plugin.getName() + ")"); TabooLib.debug("Function " + pluginClass.getSimpleName() + " loaded. (" + plugin.getName() + ")");
@ -36,6 +41,10 @@ public class TFunctionLoader implements TabooLibLoader.Loader {
TFunction function = pluginClass.getAnnotation(TFunction.class); TFunction function = pluginClass.getAnnotation(TFunction.class);
try { try {
Method method = pluginClass.getDeclaredMethod(function.disable()); 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.setAccessible(true);
method.invoke(null); method.invoke(null);
TabooLib.debug("Function " + pluginClass.getSimpleName() + " unloaded. (" + plugin.getName() + ")"); TabooLib.debug("Function " + pluginClass.getSimpleName() + " unloaded. (" + plugin.getName() + ")");