diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java b/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java index ad294c2..176bd3d 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/ZNpcsPlus.java @@ -151,7 +151,8 @@ public class ZNpcsPlus extends JavaPlugin { pluginManager.registerEvents(new UserListener(userManager), this); 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..."); if (configManager.getConfig().checkForUpdates()) { @@ -252,7 +253,8 @@ public class ZNpcsPlus extends JavaPlugin { private void registerCommands(NpcRegistryImpl npcRegistry, SkinCache skinCache, BukkitAudiences adventure, ActionRegistry actionRegistry, NpcTypeRegistryImpl typeRegistry, - EntityPropertyRegistryImpl propertyRegistry, DataImporterRegistry importerRegistry) { + EntityPropertyRegistryImpl propertyRegistry, DataImporterRegistry importerRegistry, + ConfigManager configManager) { Message incorrectUsageMessage = context -> context.send(Component.text("Incorrect usage: /" + context.getUsage(), NamedTextColor.RED)); CommandManager manager = new CommandManager(this, adventure, incorrectUsageMessage); @@ -272,6 +274,7 @@ public class ZNpcsPlus extends JavaPlugin { manager.registerCommand("npc", new MultiCommand(loadHelpMessage("root")) .addSubcommand("create", new CreateCommand(npcRegistry, typeRegistry)) + .addSubcommand("reloadconfig", new ReloadConfigCommand(configManager)) .addSubcommand("toggle", new ToggleCommand(npcRegistry)) .addSubcommand("skin", new SkinCommand(skinCache, npcRegistry, typeRegistry, propertyRegistry)) .addSubcommand("delete", new DeleteCommand(npcRegistry, adventure)) diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/commands/ReloadConfigCommand.java b/plugin/src/main/java/lol/pyr/znpcsplus/commands/ReloadConfigCommand.java new file mode 100644 index 0000000..2b9e12a --- /dev/null +++ b/plugin/src/main/java/lol/pyr/znpcsplus/commands/ReloadConfigCommand.java @@ -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)); + } +}