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;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.Dependency;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.Argument;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.util.CarbonUtils;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
@CommandAlias("chatreload|creload")
@CommandPermission("carbonchat.reload")
public class ChatReloadCommand extends BaseCommand {
import java.util.LinkedHashMap;
import java.util.List;
@Dependency
private CarbonChat carbonChat;
public class ChatReloadCommand {
@Default
public void baseCommand(CommandSender sender) {
private final CarbonChat carbonChat;
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.getChannelManager().reload();
@@ -29,6 +44,8 @@ public class ChatReloadCommand extends BaseCommand {
// TODO: Ensure the command list is updated when reloading.
// 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"))
.executes(this::executeOther)
.register();
}
private void executeSelf(Player player, Object[] args) {
@@ -83,7 +83,7 @@ public class CommandManager {
public void reloadCommands(CarbonChat carbonChat) {
this.commandManager.registerCommand(new ChannelCommand());
this.commandManager.registerCommand(new ChannelListCommand());
this.commandManager.registerCommand(new ChatReloadCommand());
new ChatReloadCommand(carbonChat);
new ClearChatCommand(carbonChat);
this.commandManager.registerCommand(new IgnoreCommand());
this.commandManager.registerCommand(new MeCommand());