diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index 5ad6adfa..08c2b6f7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -25,8 +25,8 @@ import com.onarandombox.MultiverseCore.api.LocationManipulation; import com.onarandombox.MultiverseCore.api.MVConfig; import com.onarandombox.MultiverseCore.api.MVCore; import com.onarandombox.MultiverseCore.api.MVWorld; -import com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.api.MVWorldManager; +import com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.commands.CheckCommand; import com.onarandombox.MultiverseCore.commands.CloneCommand; import com.onarandombox.MultiverseCore.commands.ConfirmCommand; @@ -35,6 +35,7 @@ import com.onarandombox.MultiverseCore.commands.DebugCommand; import com.onarandombox.MultiverseCore.commands.DeleteCommand; import com.onarandombox.MultiverseCore.commands.LoadCommand; import com.onarandombox.MultiverseCore.commands.RegenCommand; +import com.onarandombox.MultiverseCore.commands.ReloadCommand; import com.onarandombox.MultiverseCore.commands.TeleportCommand; import com.onarandombox.MultiverseCore.commands.UnloadCommand; import com.onarandombox.MultiverseCore.commandtools.MVCommandManager; @@ -208,6 +209,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore { this.commandManager.registerCommand(new DeleteCommand(this)); this.commandManager.registerCommand(new LoadCommand(this)); this.commandManager.registerCommand(new RegenCommand(this)); + this.commandManager.registerCommand(new ReloadCommand(this)); this.commandManager.registerCommand(new TeleportCommand(this)); this.commandManager.registerCommand(new UnloadCommand(this)); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ReloadCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ReloadCommand.java new file mode 100644 index 00000000..7d3be7c1 --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ReloadCommand.java @@ -0,0 +1,42 @@ +package com.onarandombox.MultiverseCore.commands; + +import java.util.ArrayList; +import java.util.List; + +import co.aikar.commands.BukkitCommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Description; +import co.aikar.commands.annotation.Subcommand; +import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.event.MVConfigReloadEvent; +import org.bukkit.ChatColor; +import org.jetbrains.annotations.NotNull; + +@CommandAlias("mv") +public class ReloadCommand extends MultiverseCommand { + public ReloadCommand(@NotNull MultiverseCore plugin) { + super(plugin); + } + + @Subcommand("reload") + @CommandPermission("multiverse.core.reload") + @Description("Reloads config files for all multiverse modules.") + public void onReloadCommand(@NotNull BukkitCommandIssuer issuer) { + issuer.sendMessage(ChatColor.GOLD + "Reloading all Multiverse Plugin configs..."); + this.plugin.loadConfigs(); + this.plugin.getAnchorManager().loadAnchors(); + this.plugin.getMVWorldManager().loadWorlds(true); + + List configsLoaded = new ArrayList<>(); + configsLoaded.add("Multiverse-Core - config.yml"); + configsLoaded.add("Multiverse-Core - worlds.yml"); + configsLoaded.add("Multiverse-Core - anchors.yml"); + + MVConfigReloadEvent configReload = new MVConfigReloadEvent(configsLoaded); + this.plugin.getServer().getPluginManager().callEvent(configReload); + + configReload.getAllConfigsLoaded().forEach(issuer::sendMessage); + issuer.sendMessage(String.format("%sReload Complete!", ChatColor.GREEN)); + } +}