add reload config command
This commit is contained in:
parent
a56096d4d6
commit
2c8b96f295
2 changed files with 27 additions and 2 deletions
|
@ -151,7 +151,8 @@ public class ZNpcsPlus extends JavaPlugin {
|
||||||
pluginManager.registerEvents(new UserListener(userManager), this);
|
pluginManager.registerEvents(new UserListener(userManager), this);
|
||||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
|
|
||||||
registerCommands(npcRegistry, skinCache, adventure, actionRegistry, typeRegistry, propertyRegistry, importerRegistry);
|
registerCommands(npcRegistry, skinCache, adventure, actionRegistry,
|
||||||
|
typeRegistry, propertyRegistry, importerRegistry, configManager);
|
||||||
|
|
||||||
log(ChatColor.WHITE + " * Starting tasks...");
|
log(ChatColor.WHITE + " * Starting tasks...");
|
||||||
if (configManager.getConfig().checkForUpdates()) {
|
if (configManager.getConfig().checkForUpdates()) {
|
||||||
|
@ -252,7 +253,8 @@ public class ZNpcsPlus extends JavaPlugin {
|
||||||
|
|
||||||
private void registerCommands(NpcRegistryImpl npcRegistry, SkinCache skinCache, BukkitAudiences adventure,
|
private void registerCommands(NpcRegistryImpl npcRegistry, SkinCache skinCache, BukkitAudiences adventure,
|
||||||
ActionRegistry actionRegistry, NpcTypeRegistryImpl typeRegistry,
|
ActionRegistry actionRegistry, NpcTypeRegistryImpl typeRegistry,
|
||||||
EntityPropertyRegistryImpl propertyRegistry, DataImporterRegistry importerRegistry) {
|
EntityPropertyRegistryImpl propertyRegistry, DataImporterRegistry importerRegistry,
|
||||||
|
ConfigManager configManager) {
|
||||||
|
|
||||||
Message<CommandContext> incorrectUsageMessage = context -> context.send(Component.text("Incorrect usage: /" + context.getUsage(), NamedTextColor.RED));
|
Message<CommandContext> incorrectUsageMessage = context -> context.send(Component.text("Incorrect usage: /" + context.getUsage(), NamedTextColor.RED));
|
||||||
CommandManager manager = new CommandManager(this, adventure, incorrectUsageMessage);
|
CommandManager manager = new CommandManager(this, adventure, incorrectUsageMessage);
|
||||||
|
@ -272,6 +274,7 @@ public class ZNpcsPlus extends JavaPlugin {
|
||||||
|
|
||||||
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
|
manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root"))
|
||||||
.addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry))
|
.addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry))
|
||||||
|
.addSubcommand("reloadconfig", new ReloadConfigCommand(configManager))
|
||||||
.addSubcommand("toggle", new ToggleCommand(npcRegistry))
|
.addSubcommand("toggle", new ToggleCommand(npcRegistry))
|
||||||
.addSubcommand("skin", new SkinCommand(skinCache, npcRegistry, typeRegistry, propertyRegistry))
|
.addSubcommand("skin", new SkinCommand(skinCache, npcRegistry, typeRegistry, propertyRegistry))
|
||||||
.addSubcommand("delete", new DeleteCommand(npcRegistry, adventure))
|
.addSubcommand("delete", new DeleteCommand(npcRegistry, adventure))
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package lol.pyr.znpcsplus.commands;
|
||||||
|
|
||||||
|
import lol.pyr.director.adventure.command.CommandContext;
|
||||||
|
import lol.pyr.director.adventure.command.CommandHandler;
|
||||||
|
import lol.pyr.director.common.command.CommandExecutionException;
|
||||||
|
import lol.pyr.znpcsplus.config.ConfigManager;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
|
public class ReloadConfigCommand implements CommandHandler {
|
||||||
|
private final ConfigManager configManager;
|
||||||
|
|
||||||
|
public ReloadConfigCommand(ConfigManager configManager) {
|
||||||
|
this.configManager = configManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(CommandContext context) throws CommandExecutionException {
|
||||||
|
configManager.reload();
|
||||||
|
context.send(Component.text("Plugin configuration reloaded successfully", NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue