Bungee can't differentiate between loaded and enabled
This commit is contained in:
parent
11a5c5140b
commit
dd99bad81c
2 changed files with 25 additions and 10 deletions
|
|
@ -97,11 +97,9 @@ public abstract class AbstractPluginManager<P, D extends ServerUtilsPluginDescri
|
|||
* Enables a list of plugins.
|
||||
*/
|
||||
public PluginResults<P> enablePlugins(List<P> plugins) {
|
||||
for (P plugin : plugins) {
|
||||
String pluginId = getPluginId(plugin);
|
||||
if (isPluginEnabled(pluginId)) {
|
||||
return new PluginResults<P>().addResult(pluginId, Result.ALREADY_ENABLED);
|
||||
}
|
||||
Optional<P> pluginOptional = checkPluginStates(plugins, false);
|
||||
if (pluginOptional.isPresent()) {
|
||||
return new PluginResults<P>().addResult(getPluginId(pluginOptional.get()), Result.ALREADY_ENABLED);
|
||||
}
|
||||
|
||||
return enableOrderedPlugins(determineLoadOrder(plugins));
|
||||
|
|
@ -115,6 +113,19 @@ public abstract class AbstractPluginManager<P, D extends ServerUtilsPluginDescri
|
|||
|
||||
public abstract boolean isPluginEnabled(String pluginId);
|
||||
|
||||
/**
|
||||
* Finds the first plugin where the enabled state does not match the given state it must be in.
|
||||
* This method can be overridden by implementations which don't support the enabled state.
|
||||
*/
|
||||
protected Optional<P> checkPluginStates(List<P> plugins, boolean enabled) {
|
||||
for (P plugin : plugins) {
|
||||
if (isPluginEnabled(plugin) != enabled) {
|
||||
return Optional.of(plugin);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the given plugin by name.
|
||||
*/
|
||||
|
|
@ -132,10 +143,9 @@ public abstract class AbstractPluginManager<P, D extends ServerUtilsPluginDescri
|
|||
* Disables a list of plugins.
|
||||
*/
|
||||
public PluginResults<P> disablePlugins(List<P> plugins) {
|
||||
for (P plugin : plugins) {
|
||||
if (!isPluginEnabled(plugin)) {
|
||||
return new PluginResults<P>().addResult(getPluginId(plugin), Result.ALREADY_DISABLED);
|
||||
}
|
||||
Optional<P> pluginOptional = checkPluginStates(plugins, true);
|
||||
if (pluginOptional.isPresent()) {
|
||||
return new PluginResults<P>().addResult(getPluginId(pluginOptional.get()), Result.ALREADY_DISABLED);
|
||||
}
|
||||
|
||||
List<P> orderedPlugins;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue