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
|
|
@ -124,7 +124,12 @@ public class BungeePluginManager extends AbstractPluginManager<Plugin, BungeePlu
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPluginEnabled(String pluginId) {
|
public boolean isPluginEnabled(String pluginId) {
|
||||||
return false; // Not supported on BungeeCord.
|
return getPlugin(pluginId).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Optional<Plugin> checkPluginStates(List<Plugin> plugins, boolean enabled) {
|
||||||
|
return Optional.empty(); // Bungee can't differentiate between "loaded" and "enabled"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -97,11 +97,9 @@ public abstract class AbstractPluginManager<P, D extends ServerUtilsPluginDescri
|
||||||
* Enables a list of plugins.
|
* Enables a list of plugins.
|
||||||
*/
|
*/
|
||||||
public PluginResults<P> enablePlugins(List<P> plugins) {
|
public PluginResults<P> enablePlugins(List<P> plugins) {
|
||||||
for (P plugin : plugins) {
|
Optional<P> pluginOptional = checkPluginStates(plugins, false);
|
||||||
String pluginId = getPluginId(plugin);
|
if (pluginOptional.isPresent()) {
|
||||||
if (isPluginEnabled(pluginId)) {
|
return new PluginResults<P>().addResult(getPluginId(pluginOptional.get()), Result.ALREADY_ENABLED);
|
||||||
return new PluginResults<P>().addResult(pluginId, Result.ALREADY_ENABLED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return enableOrderedPlugins(determineLoadOrder(plugins));
|
return enableOrderedPlugins(determineLoadOrder(plugins));
|
||||||
|
|
@ -115,6 +113,19 @@ public abstract class AbstractPluginManager<P, D extends ServerUtilsPluginDescri
|
||||||
|
|
||||||
public abstract boolean isPluginEnabled(String pluginId);
|
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.
|
* Disables the given plugin by name.
|
||||||
*/
|
*/
|
||||||
|
|
@ -132,10 +143,9 @@ public abstract class AbstractPluginManager<P, D extends ServerUtilsPluginDescri
|
||||||
* Disables a list of plugins.
|
* Disables a list of plugins.
|
||||||
*/
|
*/
|
||||||
public PluginResults<P> disablePlugins(List<P> plugins) {
|
public PluginResults<P> disablePlugins(List<P> plugins) {
|
||||||
for (P plugin : plugins) {
|
Optional<P> pluginOptional = checkPluginStates(plugins, true);
|
||||||
if (!isPluginEnabled(plugin)) {
|
if (pluginOptional.isPresent()) {
|
||||||
return new PluginResults<P>().addResult(getPluginId(plugin), Result.ALREADY_DISABLED);
|
return new PluginResults<P>().addResult(getPluginId(pluginOptional.get()), Result.ALREADY_DISABLED);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<P> orderedPlugins;
|
List<P> orderedPlugins;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue