diff options
author | Luck <git@lucko.me> | 2021-05-31 20:30:07 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2021-05-31 20:30:07 +0100 |
commit | 8560c61770f93c8e68736206ba5989a5125b3f21 (patch) | |
tree | e6398facdedb4e6f6adeeeb33d650446bf768260 /spark-bukkit | |
parent | f5bb628319d57c8d1ed26e1673d9f781cc939f83 (diff) | |
download | spark-8560c61770f93c8e68736206ba5989a5125b3f21.tar.gz spark-8560c61770f93c8e68736206ba5989a5125b3f21.tar.bz2 spark-8560c61770f93c8e68736206ba5989a5125b3f21.zip |
Fix NoSuchMethodException in Bukkit class source reflection (#117)
Diffstat (limited to 'spark-bukkit')
-rw-r--r-- | spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitClassSourceLookup.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitClassSourceLookup.java b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitClassSourceLookup.java index a87be6f..6d8afda 100644 --- a/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitClassSourceLookup.java +++ b/spark-bukkit/src/main/java/me/lucko/spark/bukkit/BukkitClassSourceLookup.java @@ -24,17 +24,17 @@ import me.lucko.spark.common.util.ClassSourceLookup; import org.bukkit.plugin.java.JavaPlugin; -import java.lang.reflect.Method; +import java.lang.reflect.Field; public class BukkitClassSourceLookup extends ClassSourceLookup.ByClassLoader { private static final Class<?> PLUGIN_CLASS_LOADER; - private static final Method GET_PLUGIN_METHOD; + private static final Field PLUGIN_FIELD; static { try { PLUGIN_CLASS_LOADER = Class.forName("org.bukkit.plugin.java.PluginClassLoader"); - GET_PLUGIN_METHOD = PLUGIN_CLASS_LOADER.getDeclaredMethod("getPlugin"); - GET_PLUGIN_METHOD.setAccessible(true); + PLUGIN_FIELD = PLUGIN_CLASS_LOADER.getDeclaredField("plugin"); + PLUGIN_FIELD.setAccessible(true); } catch (ReflectiveOperationException e) { throw new ExceptionInInitializerError(e); } @@ -43,7 +43,7 @@ public class BukkitClassSourceLookup extends ClassSourceLookup.ByClassLoader { @Override public String identify(ClassLoader loader) throws ReflectiveOperationException { if (PLUGIN_CLASS_LOADER.isInstance(loader)) { - JavaPlugin plugin = (JavaPlugin) GET_PLUGIN_METHOD.invoke(loader); + JavaPlugin plugin = (JavaPlugin) PLUGIN_FIELD.get(loader); return plugin.getName(); } return null; |