This commit is contained in:
Draycia committed 2020-08-28 00:20:57 -07:00
1 parent 7247be5ffb
commit 6ef710084b
3 files changed
+30 -15

No files matched your search

@@ -1,23 +1,38 @@
package net.draycia.carbon.commands; package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand; import dev.jorel.commandapi.CommandAPICommand;
import co.aikar.commands.annotation.CommandAlias; import dev.jorel.commandapi.CommandPermission;
import co.aikar.commands.annotation.CommandPermission; import dev.jorel.commandapi.arguments.Argument;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.Dependency;
import net.draycia.carbon.CarbonChat; import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.util.CarbonUtils;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@CommandAlias("chatreload|creload") import java.util.LinkedHashMap;
@CommandPermission("carbonchat.reload") import java.util.List;
public class ChatReloadCommand extends BaseCommand {
@Dependency public class ChatReloadCommand {
private CarbonChat carbonChat;
@Default private final CarbonChat carbonChat;
public void baseCommand(CommandSender sender) {
public ChatReloadCommand(CarbonChat carbonChat) {
this.carbonChat = carbonChat;
String commandName = carbonChat.getConfig().getString("commands.reload.name", "chatreload");
List<String> commandAliases = carbonChat.getConfig().getStringList("commands.reload.aliases");
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
channelArguments.put("channel", CarbonUtils.channelArgument());
new CommandAPICommand(commandName)
.withArguments(channelArguments)
.withAliases(commandAliases.toArray(new String[0]))
.withPermission(CommandPermission.fromString("carbonchat.reload"))
.executes(this::execute)
.register();
}
private void execute(CommandSender sender, Object[] args) {
carbonChat.reloadConfig(); carbonChat.reloadConfig();
carbonChat.getChannelManager().reload(); carbonChat.getChannelManager().reload();
@@ -29,6 +44,8 @@ public class ChatReloadCommand extends BaseCommand {
// TODO: Ensure the command list is updated when reloading. // TODO: Ensure the command list is updated when reloading.
// If new channels are added, their commands should appear to players. // If new channels are added, their commands should appear to players.
// TODO: Ensure moderation filters ETC are updated when reloading.
} }
} }
@@ -44,8 +44,6 @@ public class ToggleCommand {
.withPermission(CommandPermission.fromString("carbonchat.toggle")) .withPermission(CommandPermission.fromString("carbonchat.toggle"))
.executes(this::executeOther) .executes(this::executeOther)
.register(); .register();
} }
private void executeSelf(Player player, Object[] args) { private void executeSelf(Player player, Object[] args) {
@@ -83,7 +83,7 @@ public class CommandManager {
public void reloadCommands(CarbonChat carbonChat) { public void reloadCommands(CarbonChat carbonChat) {
this.commandManager.registerCommand(new ChannelCommand()); this.commandManager.registerCommand(new ChannelCommand());
this.commandManager.registerCommand(new ChannelListCommand()); this.commandManager.registerCommand(new ChannelListCommand());
this.commandManager.registerCommand(new ChatReloadCommand()); new ChatReloadCommand(carbonChat);
new ClearChatCommand(carbonChat); new ClearChatCommand(carbonChat);
this.commandManager.registerCommand(new IgnoreCommand()); this.commandManager.registerCommand(new IgnoreCommand());
this.commandManager.registerCommand(new MeCommand()); this.commandManager.registerCommand(new MeCommand());