mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 13:15:28 +01:00
Fixes PlAddon disabling issue. (#1847)
There was a bug that did not unload PlAddon classes from JVM. This change should fix it, as it will unload PlAddons via pluginLoader.
This commit is contained in:
parent
938940199d
commit
23e3554c4d
@ -54,4 +54,13 @@ public abstract class Pladdon extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method enables marks pladdons as enabled.
|
||||||
|
* By default, enable status is not set because onEnable and onLoad is not triggered.
|
||||||
|
*/
|
||||||
|
public void setEnabled() {
|
||||||
|
this.setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,8 @@ public class AddonsManager {
|
|||||||
@NonNull
|
@NonNull
|
||||||
private final Map<@NonNull Addon, @Nullable AddonClassLoader> loaders;
|
private final Map<@NonNull Addon, @Nullable AddonClassLoader> loaders;
|
||||||
@NonNull
|
@NonNull
|
||||||
|
private final Map<@NonNull Addon, @Nullable Plugin> pladdons;
|
||||||
|
@NonNull
|
||||||
private final Map<String, Class<?>> classes;
|
private final Map<String, Class<?>> classes;
|
||||||
private final BentoBox plugin;
|
private final BentoBox plugin;
|
||||||
private @NonNull
|
private @NonNull
|
||||||
@ -79,6 +81,7 @@ public class AddonsManager {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
addons = new ArrayList<>();
|
addons = new ArrayList<>();
|
||||||
loaders = new HashMap<>();
|
loaders = new HashMap<>();
|
||||||
|
pladdons = new HashMap<>();
|
||||||
classes = new HashMap<>();
|
classes = new HashMap<>();
|
||||||
listeners = new HashMap<>();
|
listeners = new HashMap<>();
|
||||||
worldNames = new HashMap<>();
|
worldNames = new HashMap<>();
|
||||||
@ -161,6 +164,9 @@ public class AddonsManager {
|
|||||||
if (pladdon instanceof Pladdon) {
|
if (pladdon instanceof Pladdon) {
|
||||||
addon = ((Pladdon) pladdon).getAddon();
|
addon = ((Pladdon) pladdon).getAddon();
|
||||||
addon.setDescription(AddonClassLoader.asDescription(data));
|
addon.setDescription(AddonClassLoader.asDescription(data));
|
||||||
|
// Mark pladdon as enabled.
|
||||||
|
((Pladdon) pladdon).setEnabled();
|
||||||
|
pladdons.put(addon, pladdon);
|
||||||
} else {
|
} else {
|
||||||
plugin.logError("Could not load pladdon!");
|
plugin.logError("Could not load pladdon!");
|
||||||
return;
|
return;
|
||||||
@ -403,6 +409,7 @@ public class AddonsManager {
|
|||||||
plugin.getCommandsManager().unregisterCommands();
|
plugin.getCommandsManager().unregisterCommands();
|
||||||
// Clear all maps
|
// Clear all maps
|
||||||
listeners.clear();
|
listeners.clear();
|
||||||
|
pladdons.clear();
|
||||||
addons.clear();
|
addons.clear();
|
||||||
loaders.clear();
|
loaders.clear();
|
||||||
classes.clear();
|
classes.clear();
|
||||||
@ -620,7 +627,11 @@ public class AddonsManager {
|
|||||||
addon.setState(State.DISABLED);
|
addon.setState(State.DISABLED);
|
||||||
loaders.remove(addon);
|
loaders.remove(addon);
|
||||||
}
|
}
|
||||||
|
// Disable pladdons
|
||||||
|
if (pladdons.containsKey(addon)) {
|
||||||
|
this.pluginLoader.disablePlugin(Objects.requireNonNull(this.pladdons.get(addon)));
|
||||||
|
pladdons.remove(addon);
|
||||||
|
}
|
||||||
// Remove it from the addons list
|
// Remove it from the addons list
|
||||||
addons.remove(addon);
|
addons.remove(addon);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user