Add "depending plugin" warning
This commit is contained in:
parent
d1aa18b30b
commit
1b4997869d
17 changed files with 257 additions and 43 deletions
|
|
@ -4,7 +4,7 @@ version = rootProject.version
|
|||
archivesBaseName = rootProject.name + '-Bukkit'
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.FrankHeijden.cloud:cloud-paper:fea4605277'
|
||||
implementation "com.github.FrankHeijden.cloud:cloud-paper:${rootProject.cloudVersion}"
|
||||
implementation 'org.bstats:bstats-bukkit:2.2.1'
|
||||
implementation project(":Common")
|
||||
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import net.frankheijden.serverutils.bukkit.reflection.RDedicatedServer;
|
|||
import net.frankheijden.serverutils.bukkit.utils.ReloadHandler;
|
||||
import net.frankheijden.serverutils.bukkit.utils.VersionReloadHandler;
|
||||
import net.frankheijden.serverutils.common.commands.CommandServerUtils;
|
||||
import net.frankheijden.serverutils.common.commands.arguments.PluginsArgument;
|
||||
import net.frankheijden.serverutils.common.entities.results.PluginResults;
|
||||
import net.frankheijden.serverutils.common.utils.FormatBuilder;
|
||||
import net.frankheijden.serverutils.common.utils.ForwardFilter;
|
||||
|
|
@ -76,7 +77,11 @@ public class BukkitCommandServerUtils extends CommandServerUtils<BukkitPlugin, P
|
|||
.argument(getArgument("plugins"))
|
||||
.handler(this::handleEnablePlugin));
|
||||
manager.command(buildSubcommand(builder, "disableplugin")
|
||||
.argument(getArgument("plugins"))
|
||||
.argument(new PluginsArgument<>(
|
||||
true,
|
||||
"plugins",
|
||||
new PluginsArgument.PluginsParser<>(plugin, arrayCreator, getRawPath("disableplugin"))
|
||||
))
|
||||
.handler(this::handleDisablePlugin));
|
||||
manager.command(buildSubcommand(builder, "reloadconfig")
|
||||
.argument(getArgument("config"))
|
||||
|
|
@ -95,6 +100,10 @@ public class BukkitCommandServerUtils extends CommandServerUtils<BukkitPlugin, P
|
|||
BukkitCommandSender sender = context.getSender();
|
||||
List<Plugin> plugins = Arrays.asList(context.get("plugins"));
|
||||
|
||||
if (checkDependingPlugins(context, sender, plugins, "disableplugin")) {
|
||||
return;
|
||||
}
|
||||
|
||||
PluginResults<Plugin> result = plugin.getPluginManager().disablePlugins(plugins);
|
||||
result.sendTo(sender, "disabl");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,16 +131,17 @@ public class BukkitPluginManager extends AbstractPluginManager<Plugin, BukkitPlu
|
|||
RSimplePluginManager.getPlugins(Bukkit.getPluginManager()).remove(plugin);
|
||||
RSimplePluginManager.removeLookupName(Bukkit.getPluginManager(), pluginId);
|
||||
|
||||
ClassLoader loader = RJavaPlugin.getClassLoader(plugin);
|
||||
RPluginClassLoader.clearClassLoader(loader);
|
||||
addIfInstance(closeables, (Closeable) () -> {
|
||||
Map<String, Class<?>> classes = RPluginClassLoader.getClasses(loader);
|
||||
getPluginLoader(getPluginFile(plugin)).ifPresent(pluginLoader -> {
|
||||
RJavaPluginLoader.removeClasses(pluginLoader, classes.keySet());
|
||||
});
|
||||
});
|
||||
addIfInstance(closeables, loader);
|
||||
addIfInstance(closeables, RJavaPlugin.clearJavaPlugin(plugin));
|
||||
ClassLoader classLoader = plugin.getClass().getClassLoader();
|
||||
RPluginClassLoader.clearClassLoader(classLoader);
|
||||
|
||||
PluginLoader loader = RPluginClassLoader.getLoader(classLoader);
|
||||
Map<String, Class<?>> classes = RPluginClassLoader.getClasses(classLoader);
|
||||
RJavaPluginLoader.removeClasses(loader, classes.keySet());
|
||||
|
||||
RJavaPlugin.clearJavaPlugin(plugin);
|
||||
|
||||
addIfInstance(closeables, RPluginClassLoader.getLibraryLoader(classLoader));
|
||||
addIfInstance(closeables, classLoader);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return unloadResults.addResult(pluginId, Result.ERROR);
|
||||
|
|
|
|||
|
|
@ -29,10 +29,6 @@ public class RJavaPlugin {
|
|||
public static Closeable clearJavaPlugin(Object instance) {
|
||||
reflection.set(instance, "loader", null);
|
||||
reflection.set(instance, "classLoader", null);
|
||||
Class<?> clazz = reflection.invoke(instance, "getClass");
|
||||
if (clazz != null && clazz.getClassLoader() instanceof Closeable) {
|
||||
return (Closeable) clazz.getClassLoader();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package net.frankheijden.serverutils.bukkit.reflection;
|
||||
|
||||
import dev.frankheijden.minecraftreflection.MinecraftReflection;
|
||||
import dev.frankheijden.minecraftreflection.exceptions.MinecraftReflectionException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import dev.frankheijden.minecraftreflection.exceptions.MinecraftReflectionException;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
|
||||
public class RJavaPluginLoader {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package net.frankheijden.serverutils.bukkit.reflection;
|
||||
|
||||
import dev.frankheijden.minecraftreflection.MinecraftReflection;
|
||||
import dev.frankheijden.minecraftreflection.MinecraftReflectionVersion;
|
||||
import java.util.Map;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
|
||||
public class RPluginClassLoader {
|
||||
|
||||
|
|
@ -23,12 +25,23 @@ public class RPluginClassLoader {
|
|||
}
|
||||
}
|
||||
|
||||
public static PluginLoader getLoader(ClassLoader loader) {
|
||||
if (loader == null) return null;
|
||||
return reflection.get(loader, "loader");
|
||||
}
|
||||
|
||||
public static ClassLoader getLibraryLoader(ClassLoader loader) {
|
||||
if (loader == null && MinecraftReflectionVersion.MINOR <= 16) return null;
|
||||
return reflection.get(loader, "libraryLoader");
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the plugin fields from the specified PluginClassLoader.
|
||||
* @param pluginLoader The plugin loader instance.
|
||||
*/
|
||||
public static void clearPluginClassLoader(Object pluginLoader) {
|
||||
if (pluginLoader == null) return;
|
||||
|
||||
reflection.set(pluginLoader, "plugin", null);
|
||||
reflection.set(pluginLoader, "pluginInit", null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,16 @@
|
|||
],
|
||||
"permission": "serverutils.disableplugin",
|
||||
"description": "Disables the specified plugin(s).",
|
||||
"display-in-help": true
|
||||
"display-in-help": true,
|
||||
"flags": {
|
||||
"force": {
|
||||
"main": "force",
|
||||
"aliases": ["f"],
|
||||
"permission": "serverutils.disableplugin",
|
||||
"description": "Force disables the specified plugin(s).",
|
||||
"display-in-help": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"reloadconfig": {
|
||||
"main": "reloadconfig",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue