From 09ab147d3b34dbc49b2a901c73a8530ca89fc1aa Mon Sep 17 00:00:00 2001 From: Draycia Date: Wed, 1 Dec 2021 16:16:46 -0800 Subject: [PATCH] Cleanup permisisons and translations --- .../command/commands/ClearChatCommand.java | 2 +- .../command/commands/ContinueCommand.java | 2 +- .../command/commands/MuteInfoCommand.java | 2 +- .../command/commands/NicknameCommand.java | 14 ++- .../common/command/commands/ReplyCommand.java | 2 +- .../command/commands/WhisperCommand.java | 4 +- .../common/messages/CarbonMessageService.java | 20 +++-- .../common/users/WrappedCarbonPlayer.java | 2 +- .../locale/messages-en_US.properties | 87 +++++++++---------- 9 files changed, 76 insertions(+), 59 deletions(-) diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/ClearChatCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/ClearChatCommand.java index 9b334acd..8f3b16f5 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/ClearChatCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/ClearChatCommand.java @@ -37,7 +37,7 @@ public class ClearChatCommand { final PrimaryConfig config ) { final var command = commandManager.commandBuilder("clearchat", "chatclear", "cc") - .permission("carbon.clearchat") + .permission("carbon.clearchat.clear") .senderType(PlayerCommander.class) .handler(handler -> { // Not fond of having to send 50 messages to each player diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java index ebdebbf1..dd2a8feb 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/ContinueCommand.java @@ -74,7 +74,7 @@ public class ContinueCommand { if (!recipient.online() || (!sender.awareOf(recipient) - && !sender.hasPermission("carbon.seevanish.whisper")) + && !sender.hasPermission("carbon.whisper.vanished")) ) { final var rawNameInput = CloudUtils.rawInputByMatchingName(handler.getRawInput(), recipient); final var exception = new CarbonPlayerArgument.PlayerParseException(rawNameInput); diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/MuteInfoCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/MuteInfoCommand.java index bd1ece82..019a04ec 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/MuteInfoCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/MuteInfoCommand.java @@ -49,7 +49,7 @@ public class MuteInfoCommand { .withAliases("u") .withArgument(UUIDArgument.optional("uuid")) ) - .permission("carbon.mute.muteinfo") + .permission("carbon.mute.info") .senderType(PlayerCommander.class) .handler(handler -> { final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer(); diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/NicknameCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/NicknameCommand.java index a6bcbe87..07f388da 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/NicknameCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/NicknameCommand.java @@ -58,7 +58,7 @@ public class NicknameCommand { ) .flag(commandManager.flagBuilder("reset") .withAliases("r") - .withPermission(Permission.of("carbon.nickname.reset")) + .withPermission(Permission.of("carbon.nickname.set")) ) .permission("carbon.nickname") .senderType(PlayerCommander.class) @@ -93,6 +93,12 @@ public class NicknameCommand { messageService.nicknameSetOthers(sender, target.username(), nickname); } else { // Setting own nickname + // TODO: Require .set and .self + if (!sender.hasPermission("carbon.nickname.self")) { + messageService.nicknameCannotSetOwn(sender); + return; + } + sender.displayName(nickname); messageService.nicknameSet(sender, nickname); } @@ -106,7 +112,13 @@ public class NicknameCommand { messageService.nicknameShowOthersUnset(sender, target.username()); } } else { + // TODO: Require .see and .self // Checking own nickname + if (!sender.hasPermission("carbon.nickname.self")) { + messageService.nicknameCannotSeeOwn(sender); + return; + } + if (sender.displayName() != null) { messageService.nicknameShow(sender, sender.username(), sender.displayName()); } else { diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java index f9f7fb5c..974e03cf 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/ReplyCommand.java @@ -76,7 +76,7 @@ public class ReplyCommand { if (!recipient.online() || (!sender.awareOf(recipient) - && !sender.hasPermission("carbon.seevanish.whisper")) + && !sender.hasPermission("carbon.whisper.vanished")) ) { final var rawNameInput = CloudUtils.rawInputByMatchingName(handler.getRawInput(), recipient); final var exception = new CarbonPlayerArgument.PlayerParseException(rawNameInput); diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java index f51e7d8e..91e73c25 100644 --- a/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java +++ b/common/src/main/java/net/draycia/carbon/common/command/commands/WhisperCommand.java @@ -41,7 +41,7 @@ public class WhisperCommand { final var command = commandManager.commandBuilder("whisper", "w", "message", "msg") .argument(carbonPlayerArgument.newInstance(true, "recipient", CarbonPlayerArgument.NO_SENDER)) .argument(StringArgument.greedy("message")) - .permission("carbon.whisper.send") // TODO: carbon.whisper.spy + .permission("carbon.whisper.message") // TODO: carbon.whisper.spy .senderType(PlayerCommander.class) .handler(handler -> { final CarbonPlayer sender = ((PlayerCommander) handler.getSender()).carbonPlayer(); @@ -61,7 +61,7 @@ public class WhisperCommand { if (!recipient.online() || (!sender.awareOf(recipient) - && !sender.hasPermission("carbon.seevanish.whisper")) + && !sender.hasPermission("carbon.whisper.vanished")) ) { final var rawNameInput = CloudUtils.rawInputByMatchingName(handler.getRawInput(), recipient); final var exception = new CarbonPlayerArgument.PlayerParseException(rawNameInput); diff --git a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageService.java b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageService.java index 47e167f7..d867f493 100644 --- a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageService.java +++ b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageService.java @@ -80,7 +80,7 @@ public interface CarbonMessageService { final @Placeholder("sender_display_name") Component senderDisplayName ); - @Message("continue.target.missing") + @Message("whisper.continue.target_missing") void whisperTargetNotSet( final Audience audience, final @Placeholder("sender_display_name") Component senderDisplayName @@ -134,6 +134,12 @@ public interface CarbonMessageService { final @Placeholder String target ); + @Message("nickname.set.self.error") + void nicknameCannotSetOwn(final Audience audience); + + @Message("nickname.see.self.error") + void nicknameCannotSeeOwn(final Audience audience); + @Message("mute.exempt") void muteExempt(final Audience audience); @@ -180,29 +186,29 @@ public interface CarbonMessageService { @Message("config.reload.failed") void configReloadFailed(final Audience audience); - @Message("muteinfo.self.muted") + @Message("mute.info.self.muted") void muteInfoSelfMuted(final Audience audience); - @Message("muteinfo.self.not_muted") + @Message("mute.info.self.not_muted") void muteInfoSelfNotMuted(final Audience audience); - @Message("muteinfo.not_muted") + @Message("mute.info.not_muted") void muteInfoNotMuted( final Audience audience, final @Placeholder Component target ); - @Message("muteinfo.muted") + @Message("mute.info.muted") void muteInfoMuted( final Audience audience, final @Placeholder Component target, final @Placeholder boolean muted ); - @Message("unmute.alert.target") + @Message("mute.unmute.alert.target") void unmuteAlertRecipient(final Audience audience); - @Message("unmute.alert.players") + @Message("mute.unmute.alert.players") void unmuteAlertPlayers(final Audience audience, final @Placeholder Component target); @Message("mute.alert.target") diff --git a/common/src/main/java/net/draycia/carbon/common/users/WrappedCarbonPlayer.java b/common/src/main/java/net/draycia/carbon/common/users/WrappedCarbonPlayer.java index 338f1a1b..0e6ad67c 100644 --- a/common/src/main/java/net/draycia/carbon/common/users/WrappedCarbonPlayer.java +++ b/common/src/main/java/net/draycia/carbon/common/users/WrappedCarbonPlayer.java @@ -49,7 +49,7 @@ public abstract class WrappedCarbonPlayer implements CarbonPlayer { @Override public boolean awareOf(final CarbonPlayer other) { if (other.vanished()) { - return this.hasPermission("carbon.seevanished"); + return this.hasPermission("carbon.whisper.vanished"); } return true; diff --git a/common/src/main/resources/locale/messages-en_US.properties b/common/src/main/resources/locale/messages-en_US.properties index dd0e2b81..20610bce 100644 --- a/common/src/main/resources/locale/messages-en_US.properties +++ b/common/src/main/resources/locale/messages-en_US.properties @@ -1,54 +1,53 @@ +channel.change=You are now messaging channel.format.basic=\: -mute.spy.prefix=MutedM -channel.change=You are now messaging chat! -whisper.to=[You] -> [] -whisper.from=[] -> [You] -reply.target.missing=You have no-one to reply to. -reply.target.self=You cannot whisper to yourself. -continue.target.missing=You have no one to whisper. -nickname.set=Your nickname has been set to . -nickname.set.others=You set 's nickname to . -nickname.show.others='s nickname is . -nickname.show.others.unset= does not have a nickname set. -nickname.show=Your nickname is . -nickname.show.unset=You do not have a nickname set. -mute.exempt=That player is exempt from being muted! -error.command.no_permission=I'm sorry, but you do not have permission to perform this command.\nPlease contact the server administrators if you believe that this is in error. -error.command.command_execution=\n\n Click to copy">>An internal error occurred while attempting to perform this command. -error.command.argument_parsing=Invalid command argument: -error.command.invalid_sender=Invalid command sender. You must be of type -error.command.invalid_syntax=Invalid command syntax. Correct command syntax is: / -nickname.reset=Your nickname was reset. -nickname.reset.others='s nickname was reset. -nickname.reset.temporary=Your temporary nickname was reset. -nickname.reset.others.temporary='s temporary nickname was reset. -command.help.help=Help -command.help.command=Command -command.help.description=Description -command.help.no_description=No description command.help.arguments=Arguments -command.help.optional=Optional -command.help.showing_results_for_query=Showing search results for query -command.help.no_results_for_query=No results for query command.help.available_commands=Available Commands -command.help.click_to_show_help=Click to show help for this command -command.help.page_out_of_range=Error: Page is not in range. Must be in range [1, ] command.help.click_for_next_page=Click for next page command.help.click_for_previous_page=Click for previous page +command.help.click_to_show_help=Click to show help for this command +command.help.command=Command +command.help.description=Description +command.help.help=Help +command.help.no_description=No description +command.help.no_results_for_query=No results for query +command.help.optional=Optional +command.help.page_out_of_range=Error: Page is not in range. Must be in range [1, ] +command.help.showing_results_for_query=Showing search results for query +config.reload.failed=Config failed to reload +config.reload.success=Config reloaded successfully +error.command.argument_parsing=Invalid command argument: +error.command.command_execution=\n\n Click to copy">>An internal error occurred while attempting to perform this command. +error.command.invalid_sender=Invalid command sender. You must be of type +error.command.invalid_syntax=Invalid command syntax. Correct command syntax is: / +error.command.no_permission=I'm sorry, but you do not have permission to perform this command.\nPlease contact the server administrators if you believe that this is in error. ignore.exempt=You cannot ignore +ignore.invalid_target=No target found ignore.now_ignoring=You are now ignoring ignore.no_longer_ignoring=You are no longer ignoring -ignore.invalid_target=No target found -whisper.ignoring_target=You are ignoring -whisper.ignored_by_target= is ignoring you -config.reload.success=Config reloaded successfully -config.reload.failed=Config failed to reload -muteinfo.self.not_muted=You are not muted -muteinfo.self.muted=You are muted -muteinfo.not_muted= is not muted -muteinfo.muted= is muted -unmute.alert.target=You have been unmuted -unmute.alert.players= has been unmuted -mute.alert.target=You have been muted mute.alert.players= has been muted +mute.alert.target=You have been muted mute.cannot_speak=You cannot speak when muted +mute.exempt=That player is exempt from being muted +mute.info.muted= is muted +mute.info.not_muted= is not muted +mute.info.self.muted=You are muted +mute.info.self.not_muted=You are not muted +mute.spy.prefix=MutedM +mute.unmute.alert.players= has been unmuted +mute.unmute.alert.target=You have been unmuted +nickname.reset.others='s nickname was reset +nickname.reset=Your nickname was reset +nickname.set.others=You set 's nickname to +nickname.see.self.error=You cannot see your own nickname +nickname.set=Your nickname has been set to +nickname.show.others.unset= does not have a nickname set +nickname.show.others='s nickname is +nickname.show.unset=You do not have a nickname set +nickname.show=Your nickname is +reply.target.missing=You have no-one to reply to +reply.target.self=You cannot whisper to yourself +whisper.continue.target_missing=You have no one to whisper +whisper.from=[] -> [You] +whisper.ignored_by_target= is ignoring you +whisper.ignoring_target=You are ignoring +whisper.to=[You] -> []