diff --git a/src/main/java/world/bentobox/bentobox/commands/BentoBoxReloadCommand.java b/src/main/java/world/bentobox/bentobox/commands/BentoBoxReloadCommand.java index c50365f35..092476f7c 100644 --- a/src/main/java/world/bentobox/bentobox/commands/BentoBoxReloadCommand.java +++ b/src/main/java/world/bentobox/bentobox/commands/BentoBoxReloadCommand.java @@ -7,7 +7,7 @@ import world.bentobox.bentobox.api.user.User; /** - * Displays information about Gamemodes, Addons and versioning. + * Reloads addons and localization. * * @author tastybento */ @@ -29,17 +29,15 @@ public void setup() { @Override public boolean execute(User user, String label, List args) { - this.askConfirmation(user, () -> reloadLocales(user)); + this.askConfirmation(user, () -> { + // Reload addons + getPlugin().getAddonsManager().reloadAddons(); + user.sendMessage("commands.bentobox.reload.addons-reloaded"); + + // Reload locales + getPlugin().getLocalesManager().reloadLanguages(); + user.sendMessage("commands.bentobox.reload.locales-reloaded"); + }); return false; } - - /** - * Reloads the languages - * @param user - */ - public void reloadLocales(User user) { - getPlugin().getLocalesManager().reloadLanguages(); - user.sendMessage("commands.bentobox.reload.locales-reloaded"); - } - } diff --git a/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java b/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java index 713a24796..4e9a316ea 100644 --- a/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/AddonsManager.java @@ -44,8 +44,6 @@ public AddonsManager(BentoBox plugin) { loaders = new HashMap<>(); } - //TODO: add addon reload - /** * Loads all the addons from the addons folder */ @@ -95,6 +93,20 @@ public void enableAddons() { } } + /** + * Reloads all the enabled addons + */ + public void reloadAddons() { + if (!addons.isEmpty()) { + plugin.log("Reloading addons..."); + addons.stream().filter(Addon::isEnabled).forEach(addon -> { + plugin.log("Reloading " + addon.getDescription().getName() + "..."); + addon.onReload(); + }); + plugin.log("Addons successfully reloaded."); + } + } + /** * Gets the addon by name * @param name - addon name @@ -260,5 +272,4 @@ private void sortAddons() { addons.addAll(sortedAddons.values()); } - } diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index b51ef0823..b37503e59 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -216,6 +216,7 @@ commands: reload: description: "reloads all locale files" locales-reloaded: "&2Languages reloaded" + addons-reloaded: "&2Addons reloaded" version: plugin-version: "&2Bentobox version: &3[name]" description: "display info"