mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 05:35:44 +01:00
Only enable/disable addons if there is at least one addon loaded
This commit is contained in:
parent
bfa19dcec2
commit
58541831b6
@ -45,6 +45,8 @@ public class AddonsManager {
|
||||
loaders = new HashMap<>();
|
||||
}
|
||||
|
||||
//TODO: add addon reload
|
||||
|
||||
/**
|
||||
* Loads all the addons from the addons folder
|
||||
*/
|
||||
@ -57,13 +59,17 @@ public class AddonsManager {
|
||||
}
|
||||
Arrays.stream(Objects.requireNonNull(f.listFiles())).filter(x -> !x.isDirectory() && x.getName().endsWith(".jar")).forEach(this::loadAddon);
|
||||
plugin.log("Loaded " + addons.size() + " addons.");
|
||||
|
||||
if (!addons.isEmpty()) {
|
||||
sortAddons();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables all the addons
|
||||
*/
|
||||
public void enableAddons() {
|
||||
if (!addons.isEmpty()) {
|
||||
plugin.log("Enabling addons...");
|
||||
addons.forEach(addon -> {
|
||||
try {
|
||||
@ -88,6 +94,7 @@ public class AddonsManager {
|
||||
});
|
||||
plugin.log("Addons successfully enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the addon by name
|
||||
@ -149,8 +156,9 @@ public class AddonsManager {
|
||||
* Disable all the enabled addons
|
||||
*/
|
||||
public void disableAddons() {
|
||||
if (!addons.isEmpty()) {
|
||||
plugin.log("Disabling addons...");
|
||||
// Unload addons
|
||||
// Disable addons
|
||||
addons.forEach(addon -> {
|
||||
if (addon.isEnabled()) {
|
||||
addon.onDisable();
|
||||
@ -168,6 +176,7 @@ public class AddonsManager {
|
||||
});
|
||||
plugin.log("Addons successfully disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
public List<Addon> getAddons() {
|
||||
return addons;
|
||||
|
Loading…
Reference in New Issue
Block a user