mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 11:45:31 +01:00
parent
c7a85c2b5a
commit
be91e137a8
@ -7,7 +7,7 @@ import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||
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 class BentoBoxReloadCommand extends ConfirmableCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> 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");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,8 +44,6 @@ public class AddonsManager {
|
||||
loaders = new HashMap<>();
|
||||
}
|
||||
|
||||
//TODO: add addon reload
|
||||
|
||||
/**
|
||||
* Loads all the addons from the addons folder
|
||||
*/
|
||||
@ -95,6 +93,20 @@ public class AddonsManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ public class AddonsManager {
|
||||
addons.addAll(sortedAddons.values());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user