mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-30 22:53:39 +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<>();
|
loaders = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: add addon reload
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all the addons from the addons folder
|
* 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);
|
Arrays.stream(Objects.requireNonNull(f.listFiles())).filter(x -> !x.isDirectory() && x.getName().endsWith(".jar")).forEach(this::loadAddon);
|
||||||
plugin.log("Loaded " + addons.size() + " addons.");
|
plugin.log("Loaded " + addons.size() + " addons.");
|
||||||
|
|
||||||
|
if (!addons.isEmpty()) {
|
||||||
sortAddons();
|
sortAddons();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables all the addons
|
* Enables all the addons
|
||||||
*/
|
*/
|
||||||
public void enableAddons() {
|
public void enableAddons() {
|
||||||
|
if (!addons.isEmpty()) {
|
||||||
plugin.log("Enabling addons...");
|
plugin.log("Enabling addons...");
|
||||||
addons.forEach(addon -> {
|
addons.forEach(addon -> {
|
||||||
try {
|
try {
|
||||||
@ -88,6 +94,7 @@ public class AddonsManager {
|
|||||||
});
|
});
|
||||||
plugin.log("Addons successfully enabled.");
|
plugin.log("Addons successfully enabled.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the addon by name
|
* Gets the addon by name
|
||||||
@ -149,8 +156,9 @@ public class AddonsManager {
|
|||||||
* Disable all the enabled addons
|
* Disable all the enabled addons
|
||||||
*/
|
*/
|
||||||
public void disableAddons() {
|
public void disableAddons() {
|
||||||
|
if (!addons.isEmpty()) {
|
||||||
plugin.log("Disabling addons...");
|
plugin.log("Disabling addons...");
|
||||||
// Unload addons
|
// Disable addons
|
||||||
addons.forEach(addon -> {
|
addons.forEach(addon -> {
|
||||||
if (addon.isEnabled()) {
|
if (addon.isEnabled()) {
|
||||||
addon.onDisable();
|
addon.onDisable();
|
||||||
@ -168,6 +176,7 @@ public class AddonsManager {
|
|||||||
});
|
});
|
||||||
plugin.log("Addons successfully disabled.");
|
plugin.log("Addons successfully disabled.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<Addon> getAddons() {
|
public List<Addon> getAddons() {
|
||||||
return addons;
|
return addons;
|
||||||
|
Loading…
Reference in New Issue
Block a user