diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java index 2a80d722..f8b41109 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/ChannelOptions.java @@ -29,13 +29,15 @@ public final class ChannelOptions { private String color; @Setting - @Comment("The contexts for this channel, ") - private Map contexts = new HashMap<>(); // TODO: set defaults + @Comment("The contexts for this channel, which can modify the behaviour of channels and how/when players can use them.") + private Map contexts = new HashMap<>(); @Setting @Comment("The formats for this channel. The key is the name of the group as your permissions plugin reports it.") - private Map formats = new HashMap<>(); // TODO: set defaults - + private Map formats = new HashMap() {{ + put("default", "<> "); + }}; + @Setting @Comment("The name of the format that the plugin will fall back to when it cannot find a matching format for the player's groups.") private String defaultFormatName; diff --git a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SharedChannelOptions.java b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SharedChannelOptions.java index eb7cacf8..b310de4d 100644 --- a/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SharedChannelOptions.java +++ b/CarbonChat-API/src/main/java/net/draycia/carbon/api/config/SharedChannelOptions.java @@ -15,8 +15,11 @@ import java.util.Map; public final class SharedChannelOptions { @Setting private String color = "#FFFFFF"; - @Setting private Map contexts = new HashMap<>(); // TODO: set defaults - @Setting private Map formats = new HashMap<>(); // TODO: set defaults + @Setting private Map contexts = new HashMap<>(); + @Setting private Map formats = new HashMap() {{ + put("default", "<> "); + put("staff", "<#00CED1>[Staff] <> "); + }}; @Setting private String defaultFormatName = "default"; @Setting private boolean ignorable = true; @Setting private boolean crossServer = true; diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonWhisperChannel.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonWhisperChannel.java index efe276ab..bd137c29 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonWhisperChannel.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/channels/CarbonWhisperChannel.java @@ -62,7 +62,6 @@ public class CarbonWhisperChannel implements WhisperChannel { public @NonNull Map parseMessage(@NonNull final PlayerUser user, @NonNull final Collection<@NonNull PlayerUser> recipients, @NonNull final String message, final boolean fromRemote) { - // TODO: extract to method, this is just the same thing but twice final Map result = new HashMap<>(); // Formats diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ClearChatCommand.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ClearChatCommand.java index 06515320..72f6d9df 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ClearChatCommand.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ClearChatCommand.java @@ -6,6 +6,8 @@ import net.draycia.carbon.api.CarbonChat; import net.draycia.carbon.api.CarbonChatProvider; import net.draycia.carbon.api.users.CarbonUser; import net.draycia.carbon.api.commands.settings.CommandSettings; +import net.draycia.carbon.api.users.PlayerUser; +import net.draycia.carbon.common.commands.arguments.PlayerUserArgument; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; import org.checkerframework.checker.nullness.qual.NonNull; @@ -32,7 +34,15 @@ public class ClearChatCommand { .build() ); - // TODO: /clearchat [player] + commandManager.command( + commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(), + commandManager.createDefaultCommandMeta()) + .senderType(CarbonUser.class) // player & console + .permission("carbonchat.clearchat.clear.player") + .argument(PlayerUserArgument.requiredPlayerUserArgument()) + .handler(this::clearChatPlayer) + .build() + ); } private void clearChat(@NonNull final CommandContext context) { @@ -41,22 +51,35 @@ public class ClearChatCommand { final Component component = this.carbonChat.messageProcessor().processMessage(format, "br", "\n"); for (final CarbonUser user : this.carbonChat.userService().onlineUsers()) { - if (user.hasPermission("carbonchat.clearchat.exempt")) { - final String message = this.carbonChat.translations().clearExempt(); - user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor() - .processMessage(message, "player", sender)); - } else { - for (int i = 0; i < this.carbonChat.moderationSettings().clearChat().messageCount(); i++) { - user.sendMessage(Identity.nil(), component); - } - } + this.clearUserChat(user, component, sender); + } + } - if (user.hasPermission("carbonchat.clearchat.notify")) { - final String message = this.carbonChat.translations().clearNotify(); - user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor() - .processMessage(message, "player", sender)); + private void clearChatPlayer(@NonNull final CommandContext context) { + final PlayerUser target = context.get("user"); + final String sender = context.getSender().name(); + final String format = this.carbonChat.moderationSettings().clearChat().message(); + final Component component = this.carbonChat.messageProcessor().processMessage(format, "br", "\n"); + + this.clearUserChat(target, component, sender); + } + + private void clearUserChat(@NonNull final CarbonUser user, @NonNull final Component component, @NonNull final String sender) { + if (user.hasPermission("carbonchat.clearchat.exempt")) { + final String message = this.carbonChat.translations().clearExempt(); + user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor() + .processMessage(message, "player", sender)); + } else { + for (int i = 0; i < this.carbonChat.moderationSettings().clearChat().messageCount(); i++) { + user.sendMessage(Identity.nil(), component); } } + + if (user.hasPermission("carbonchat.clearchat.notify")) { + final String message = this.carbonChat.translations().clearNotify(); + user.sendMessage(Identity.nil(), this.carbonChat.messageProcessor() + .processMessage(message, "player", sender)); + } } } diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/IgnoreCommand.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/IgnoreCommand.java index ba89c91f..18cff92b 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/IgnoreCommand.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/IgnoreCommand.java @@ -46,7 +46,6 @@ public class IgnoreCommand { sender.sendMessage(Identity.nil(), this.carbonChat.messageProcessor().processMessage( this.carbonChat.translations().notIgnoringUser(), "player", targetUser.displayName())); } else { - // TODO: schedule task because sync permission checks final String format; if (sender.hasPermission("carbonchat.ignore.exempt")) { diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/MuteCommand.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/MuteCommand.java index f15a5543..2628a7b9 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/MuteCommand.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/MuteCommand.java @@ -49,7 +49,6 @@ public class MuteCommand { user.sendMessage(Identity.nil(), message); } else { - // TODO: schedule task because LuckPerms doesn't like sync offline permission checks final String format; if (target.hasPermission("carbonchat.mute.exempt")) { diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/SetColorCommand.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/SetColorCommand.java index 66ee7c56..9b1ef9a9 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/SetColorCommand.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/SetColorCommand.java @@ -1,6 +1,7 @@ package net.draycia.carbon.common.commands; import cloud.commandframework.CommandManager; +import cloud.commandframework.arguments.StaticArgument; import net.draycia.carbon.api.CarbonChat; import net.draycia.carbon.api.CarbonChatProvider; import net.draycia.carbon.api.channels.ChatChannel; @@ -25,13 +26,14 @@ public class SetColorCommand { return; } - // TODO: Test and fix for (final ChatChannel channel : this.carbonChat.channelRegistry()) { commandManager.command( commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(), commandManager.createDefaultCommandMeta()) .senderType(PlayerUser.class) // player .permission("carbonchat.setcolor") + .argument(StaticArgument.of(channel.key())) + // TODO: register command for each channel with the channel key as a literal, with permission // TODO: colorArgument (cloud 1.1.0-SNAPSHOT) //.argument(CommandUtils.colorArgument()) .handler(context -> { diff --git a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ShadowMuteCommand.java b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ShadowMuteCommand.java index 4de0f684..7208265a 100644 --- a/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ShadowMuteCommand.java +++ b/CarbonChat-Common/src/main/java/net/draycia/carbon/common/commands/ShadowMuteCommand.java @@ -49,7 +49,6 @@ public class ShadowMuteCommand { user.sendMessage(Identity.nil(), message); } else { - // TODO: schedule task because LuckPerms doesn't like sync offline permission checks final String format; if (target.hasPermission("carbonchat.mute.exempt")) {