This commit is contained in:
Draycia committed 2020-08-27 04:29:23 -07:00
1 parent 6956dc04f6
commit 570edcffc0
3 files changed
+34 -20

No files matched your search

@@ -1,10 +1,8 @@
package net.draycia.carbon.commands; package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.CommandAlias; import dev.jorel.commandapi.CommandAPICommand;
import co.aikar.commands.annotation.CommandPermission; import dev.jorel.commandapi.CommandPermission;
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.storage.ChatUser; import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@@ -12,15 +10,26 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandAlias("clearchat|cc") import java.util.List;
@CommandPermission("carbonchat.clearchat.clear")
public class ClearChatCommand extends BaseCommand {
@Dependency public class ClearChatCommand {
private CarbonChat carbonChat;
@Default private final CarbonChat carbonChat;
public void baseCommand(CommandSender issuer) {
public ClearChatCommand(CarbonChat carbonChat) {
this.carbonChat = carbonChat;
String commandName = carbonChat.getConfig().getString("commands.clearchat.name", "clearchat");
List<String> commandAliases = carbonChat.getConfig().getStringList("commands.clearchat.aliases");
new CommandAPICommand(commandName)
.withAliases(commandAliases.toArray(new String[0]))
.withPermission(CommandPermission.fromString("carbonchat.clearchat.clear"))
.executes(this::execute)
.register();
}
private void execute(CommandSender sender, Object[] args) {
String format = carbonChat.getModConfig().getString("clear-chat.message", ""); String format = carbonChat.getModConfig().getString("clear-chat.message", "");
Component component = carbonChat.getAdventureManager().processMessage(format, "br", "\n"); Component component = carbonChat.getAdventureManager().processMessage(format, "br", "\n");
@@ -37,12 +46,12 @@ public class ClearChatCommand extends BaseCommand {
if (player.hasPermission("carbonchat.clearchat.notify")) { if (player.hasPermission("carbonchat.clearchat.notify")) {
String message = carbonChat.getLanguage().getString("clear-notify"); String message = carbonChat.getLanguage().getString("clear-notify");
audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", issuer.getName())); audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", sender.getName()));
} }
if (player.hasPermission("carbonchat.clearchat.exempt")) { if (player.hasPermission("carbonchat.clearchat.exempt")) {
String message = carbonChat.getLanguage().getString("clear-exempt"); String message = carbonChat.getLanguage().getString("clear-exempt");
audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", issuer.getName())); audience.sendMessage(carbonChat.getAdventureManager().processMessage(message, "player", sender.getName()));
} }
} }
} }
@@ -81,21 +81,20 @@ public class CommandManager {
} }
public void reloadCommands(CarbonChat carbonChat) { public void reloadCommands(CarbonChat carbonChat) {
this.commandManager.registerCommand(new ToggleCommand());
this.commandManager.registerCommand(new ChannelCommand()); this.commandManager.registerCommand(new ChannelCommand());
this.commandManager.registerCommand(new ChannelListCommand()); this.commandManager.registerCommand(new ChannelListCommand());
this.commandManager.registerCommand(new IgnoreCommand());
this.commandManager.registerCommand(new ChatReloadCommand()); this.commandManager.registerCommand(new ChatReloadCommand());
new ClearChatCommand(carbonChat);
this.commandManager.registerCommand(new IgnoreCommand());
this.commandManager.registerCommand(new MeCommand()); this.commandManager.registerCommand(new MeCommand());
this.commandManager.registerCommand(new MessageCommand()); this.commandManager.registerCommand(new MessageCommand());
new MuteCommand(carbonChat);
new NicknameCommand(carbonChat); new NicknameCommand(carbonChat);
new ReplyCommand(carbonChat); new ReplyCommand(carbonChat);
new SetColorCommand(carbonChat); new SetColorCommand(carbonChat);
this.commandManager.registerCommand(new SpyChannelCommand());
this.commandManager.registerCommand(new ClearChatCommand());
new MuteCommand(carbonChat);
new ShadowMuteCommand(carbonChat); new ShadowMuteCommand(carbonChat);
this.commandManager.registerCommand(new SpyChannelCommand());
this.commandManager.registerCommand(new ToggleCommand());
} }
public BukkitCommandManager getCommandManager() { public BukkitCommandManager getCommandManager() {
+6
View File
@@ -159,3 +159,9 @@ commands:
nickname: nickname:
name: 'nickname' name: 'nickname'
aliases: ['nick'] aliases: ['nick']
mute:
name: 'mute'
aliases: ['m']
clearchat:
name: 'clearchat'
aliases: ['clear', 'cc']