feat: Add reload command

This commit is contained in:
Ben Woo 2023-02-10 16:09:31 +08:00
parent 16096acc34
commit 19ad1db5fb
2 changed files with 45 additions and 1 deletions

View File

@ -25,8 +25,8 @@ import com.onarandombox.MultiverseCore.api.LocationManipulation;
import com.onarandombox.MultiverseCore.api.MVConfig; import com.onarandombox.MultiverseCore.api.MVConfig;
import com.onarandombox.MultiverseCore.api.MVCore; import com.onarandombox.MultiverseCore.api.MVCore;
import com.onarandombox.MultiverseCore.api.MVWorld; import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.commands.CheckCommand; import com.onarandombox.MultiverseCore.commands.CheckCommand;
import com.onarandombox.MultiverseCore.commands.CloneCommand; import com.onarandombox.MultiverseCore.commands.CloneCommand;
import com.onarandombox.MultiverseCore.commands.ConfirmCommand; 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.DeleteCommand;
import com.onarandombox.MultiverseCore.commands.LoadCommand; import com.onarandombox.MultiverseCore.commands.LoadCommand;
import com.onarandombox.MultiverseCore.commands.RegenCommand; import com.onarandombox.MultiverseCore.commands.RegenCommand;
import com.onarandombox.MultiverseCore.commands.ReloadCommand;
import com.onarandombox.MultiverseCore.commands.TeleportCommand; import com.onarandombox.MultiverseCore.commands.TeleportCommand;
import com.onarandombox.MultiverseCore.commands.UnloadCommand; import com.onarandombox.MultiverseCore.commands.UnloadCommand;
import com.onarandombox.MultiverseCore.commandtools.MVCommandManager; 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 DeleteCommand(this));
this.commandManager.registerCommand(new LoadCommand(this)); this.commandManager.registerCommand(new LoadCommand(this));
this.commandManager.registerCommand(new RegenCommand(this)); this.commandManager.registerCommand(new RegenCommand(this));
this.commandManager.registerCommand(new ReloadCommand(this));
this.commandManager.registerCommand(new TeleportCommand(this)); this.commandManager.registerCommand(new TeleportCommand(this));
this.commandManager.registerCommand(new UnloadCommand(this)); this.commandManager.registerCommand(new UnloadCommand(this));
} }

View File

@ -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<String> 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));
}
}