diff --git a/common/src/main/java/net/draycia/carbon/common/channels/BasicChatChannel.java b/common/src/main/java/net/draycia/carbon/common/channels/BasicChatChannel.java index c1c8775f..0cae0556 100644 --- a/common/src/main/java/net/draycia/carbon/common/channels/BasicChatChannel.java +++ b/common/src/main/java/net/draycia/carbon/common/channels/BasicChatChannel.java @@ -114,7 +114,7 @@ public final class BasicChatChannel implements ChatChannel { @Override public ChannelPermissionResult hearingPermitted(final CarbonPlayer player) { - return ChannelPermissionResult.allowedIf(Component.empty(), () -> !player.leftChannels().contains(this)); + return ChannelPermissionResult.allowedIf(Component.empty(), () -> !player.leftChannels().contains(this.key)); } @Override diff --git a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java index 0dc26392..9fd4097f 100644 --- a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java +++ b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java @@ -209,7 +209,7 @@ public final class ConfigChatChannel implements ChatChannel { @Override public ChannelPermissionResult hearingPermitted(final CarbonPlayer player) { - return ChannelPermissionResult.allowedIf(empty(), () -> player.hasPermission(this.permission() + ".see") && !player.leftChannels().contains(this)); + return ChannelPermissionResult.allowedIf(empty(), () -> player.hasPermission(this.permission() + ".see") && !player.leftChannels().contains(this.key)); } @Override diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/JoinCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/JoinCommand.java index ff8718d1..45df0ef1 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/JoinCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/JoinCommand.java @@ -77,25 +77,24 @@ public class JoinCommand extends CarbonCommand { RichDescription.of(this.carbonMessages.commandWhisperArgumentMessage())) .permission("carbon.join") .senderType(PlayerCommander.class) - .meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandIgnoreDescription()) + .meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandJoinDescription()) .handler(handler -> { final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer(); final @Nullable ChatChannel channel = ChannelUtils.locateChannel(handler.get("channel")); if (channel == null) { - // send a message + this.carbonMessages.channelNotFound(sender); return; } if (!channel.speechPermitted(sender).permitted()) { - // send a message + this.carbonMessages.channelNoPermission(sender); return; } - if (!sender.leftChannels().contains(channel.key())) { - // send a message + this.carbonMessages.channelNotLeft(sender); return; } sender.joinChannel(channel); - // send a message + this.carbonMessages.channelJoined(sender); }) .build(); diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/LeaveCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/LeaveCommand.java index 50c1fee2..2ee18612 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/LeaveCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/LeaveCommand.java @@ -77,26 +77,24 @@ public class LeaveCommand extends CarbonCommand { RichDescription.of(this.carbonMessages.commandWhisperArgumentMessage())) .permission("carbon.join") .senderType(PlayerCommander.class) - .meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandIgnoreDescription()) + .meta(MinecraftExtrasMetaKeys.DESCRIPTION, this.carbonMessages.commandLeaveDescription()) .handler(handler -> { final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer(); final @Nullable ChatChannel channel = ChannelUtils.locateChannel(handler.get("channel")); if (channel == null) { - // send a message + this.carbonMessages.channelNotFound(sender); return; } if (!channel.speechPermitted(sender).permitted()) { - // send a message + this.carbonMessages.channelNoPermission(sender); return; } - if (sender.leftChannels().contains(channel.key())) { - // send a message + this.carbonMessages.channelAlreadyLeft(sender); return; } - sender.joinChannel(channel); - // send a message - + sender.leaveChannel(channel); + this.carbonMessages.channelLeft(sender); }) .build(); diff --git a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessages.java b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessages.java index 85a6ef07..8bae7ab9 100644 --- a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessages.java +++ b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessages.java @@ -49,6 +49,24 @@ public interface CarbonMessages { @Message("channel.radius.empty_recipients") void emptyRecipients(final Audience audience); + @Message("channel.not_found") + void channelNotFound(final Audience audience); + + @Message("channel.not_left") + void channelNotLeft(final Audience audience); + + @Message("channel.already_left") + void channelAlreadyLeft(final Audience audience); + + @Message("channel.no_permission") + void channelNoPermission(final Audience audience); + + @Message("channel.left") + void channelLeft(final Audience audience); + + @Message("channel.joined") + void channelJoined(final Audience audience); + /* * ============================================================= * =========================== Mutes =========================== @@ -275,6 +293,12 @@ public interface CarbonMessages { @Message("command.ignore.description") Component commandIgnoreDescription(); + @Message("command.join.description") + Component commandJoinDescription(); + + @Message("command.leave.description") + Component commandLeaveDescription(); + @Message("command.mute.argument.player") Component commandMuteArgumentPlayer(); diff --git a/common/src/main/resources/locale/messages-en_US.properties b/common/src/main/resources/locale/messages-en_US.properties index a6646a5e..a4f6ea11 100644 --- a/common/src/main/resources/locale/messages-en_US.properties +++ b/common/src/main/resources/locale/messages-en_US.properties @@ -23,6 +23,8 @@ command.help.misc.showing_results_for_query=Showing search results for query command.ignore.argument.player=The name of the player to ignore. command.ignore.argument.uuid=The UUID of the player to ignore. command.ignore.description=Hides all incoming messages from ignored players. +command.join.description=Join a channel you have previously left. +command.leave.description=Leave a channel that you currently have access to. command.mute.argument.player=The name of the player to mute. command.mute.argument.uuid=The UUID of the player to mute. command.mute.description=Mutes players, preventing them from using chat or whispering other players. @@ -95,3 +97,10 @@ whisper.ignored_by_target= is ignoring you whisper.ignoring_target=You are ignoring whisper.to=[You] -> [] channel.radius.empty_recipients=You're not close enough to anyone to send a message +channel.joined=You have rejoined the channel +channel.left=You have left the channel +channel.no_permission=You do not have permission to use this channel +channel.already_left=You have already left this channel +channel.not_left=You have not left this channel +channel.not_found=Channel not found +