diff --git a/src/main/java/world/bentobox/bentobox/commands/BentoBoxReloadCommand.java b/src/main/java/world/bentobox/bentobox/commands/BentoBoxReloadCommand.java index 6dd73fabf..d035994a1 100644 --- a/src/main/java/world/bentobox/bentobox/commands/BentoBoxReloadCommand.java +++ b/src/main/java/world/bentobox/bentobox/commands/BentoBoxReloadCommand.java @@ -10,6 +10,7 @@ import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.commands.ConfirmableCommand; import world.bentobox.bentobox.api.events.BentoBoxReadyEvent; import world.bentobox.bentobox.api.user.User; +import world.bentobox.bentobox.commands.reload.BentoBoxReloadLocalesCommand; import world.bentobox.bentobox.listeners.PanelListenerManager; /** @@ -32,6 +33,8 @@ public class BentoBoxReloadCommand extends ConfirmableCommand { setPermission("bentobox.admin.reload"); setParametersHelp("commands.bentobox.reload.parameters"); setDescription("commands.bentobox.reload.description"); + + new BentoBoxReloadLocalesCommand(this); } @Override diff --git a/src/main/java/world/bentobox/bentobox/commands/reload/BentoBoxReloadLocalesCommand.java b/src/main/java/world/bentobox/bentobox/commands/reload/BentoBoxReloadLocalesCommand.java new file mode 100644 index 000000000..a4f8d016c --- /dev/null +++ b/src/main/java/world/bentobox/bentobox/commands/reload/BentoBoxReloadLocalesCommand.java @@ -0,0 +1,42 @@ +package world.bentobox.bentobox.commands.reload; + +import world.bentobox.bentobox.api.commands.CompositeCommand; +import world.bentobox.bentobox.api.user.User; +import world.bentobox.bentobox.commands.BentoBoxReloadCommand; +import world.bentobox.bentobox.listeners.PanelListenerManager; + +import java.util.List; + +/** + * Reloads locales files. + * + * @author Poslovitch + * @since 1.13.0 + */ +public class BentoBoxReloadLocalesCommand extends CompositeCommand { + + public BentoBoxReloadLocalesCommand(BentoBoxReloadCommand parent) { + super(parent, "locales"); + } + + @Override + public void setup() { + setPermission("bentobox.admin.reload"); + setDescription("commands.bentobox.reload.locales.description"); + } + + @Override + public boolean execute(User user, String label, List args) { + if (args.isEmpty()) { + // Close all open panels + PanelListenerManager.closeAllPanels(); + + // Reload locales + getPlugin().getLocalesManager().reloadLanguages(); + user.sendMessage("commands.bentobox.reload.locales-reloaded"); + } else { + showHelp(this, user); + } + return true; + } +} diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 9e5623b07..d91e0adac 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -401,6 +401,8 @@ commands: addon-reloaded: "[prefix_bentobox]&b [name] &2 reloaded." warning: "[prefix_bentobox]&c Warning: Reloading may cause instability, so if you see errors afterwards, restart the server." unknown-addon: "[prefix_bentobox]&c Unknown addon!" + locales: + description: "reloads locales" version: plugin-version: "&2 BentoBox version: &3 [version]" description: "displays BentoBox and addons versions"