Merge remote-tracking branch 'origin/master'

This commit is contained in:
坏黑 2018-10-03 15:23:56 +08:00
commit 6b45d144c2

View File

@ -9,6 +9,8 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.event.Event;
import org.bukkit.plugin.*;
import org.bukkit.plugin.java.JavaPlugin;
import java.lang.reflect.Method;
import java.io.File;
import java.io.IOException;
@ -30,18 +32,13 @@ public class PluginUtils {
}
public static File getPluginFile(Plugin plugin) {
for (File pluginFile : new File("plugins").listFiles()) {
if (pluginFile.getName().endsWith(".jar")) {
try {
PluginDescriptionFile desc = Main.getInst().getPluginLoader().getPluginDescription(pluginFile);
if (desc.getName().equalsIgnoreCase(plugin.getName())) {
return pluginFile;
Method method = plugin.getClass().getDeclaredMethod("getFile");
method.setAccessible(true);
return (File) method.invoke(plugin);
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Could not get plugin file", e);
}
} catch (InvalidDescriptionException ignored) {
}
}
}
return null;
}
public static boolean isPluginExists(String name) {