From 8c8a058f387856c72ed08e6db2d2c5665edfe9e0 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Thu, 22 May 2025 20:35:51 +0700 Subject: [PATCH] fix: limit AuthCommand a bit... it seem dumb idea :( --- build-number.txt | 2 +- .../chomens_bot/commands/AuthCommand.java | 29 +++---------------- src/main/resources/language-en_us.json | 4 +-- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/build-number.txt b/build-number.txt index e4da9ac1..f0445af8 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -3278 \ No newline at end of file +3281 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/AuthCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/AuthCommand.java index 2cc4cdf0..b7e094e9 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/AuthCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/AuthCommand.java @@ -5,11 +5,8 @@ import me.chayapak1.chomens_bot.command.Command; import me.chayapak1.chomens_bot.command.CommandContext; import me.chayapak1.chomens_bot.command.CommandException; import me.chayapak1.chomens_bot.command.TrustLevel; -import me.chayapak1.chomens_bot.data.player.PlayerEntry; import net.kyori.adventure.text.Component; -import java.util.Arrays; - public class AuthCommand extends Command { public AuthCommand () { super( @@ -18,38 +15,20 @@ public class AuthCommand extends Command { new String[] {}, TrustLevel.TRUSTED ); - - final String trustLevels = String.join(" | ", Arrays.stream(TrustLevel.values()).map(Enum::name).toList()); - - this.usages = new String[] { "[player] [" + trustLevels + "]" }; } @Override public Component execute (final CommandContext context) throws CommandException { + context.checkOverloadArgs(0); + final Bot bot = context.bot; - final String playerString = context.getString(false, false); - - PlayerEntry player = null; - if (!playerString.isEmpty()) player = bot.players.getEntry(playerString); - if (player == null) player = context.sender; - - TrustLevel trustLevel = context.getEnum(false, TrustLevel.class); - if (trustLevel == null) trustLevel = context.trustLevel; - - if (trustLevel.level > context.trustLevel.level) throw new CommandException( - Component.translatable( - "commands.auth.error.privilege_escalate" - ) - ); - - player.authenticatedTrustLevel = trustLevel; + context.sender.authenticatedTrustLevel = context.trustLevel; return Component.translatable( "commands.auth.output", bot.colorPalette.defaultColor, - Component.text(player.profile.getName(), bot.colorPalette.username), - player.authenticatedTrustLevel.component + context.sender.authenticatedTrustLevel.component ); } } diff --git a/src/main/resources/language-en_us.json b/src/main/resources/language-en_us.json index 777ac73d..2106a306 100644 --- a/src/main/resources/language-en_us.json +++ b/src/main/resources/language-en_us.json @@ -34,8 +34,8 @@ "commands.generic.error.database_disabled": "Database is not enabled in the bot's configuration", "commands.generic.error.discord_disabled": "The bot's Discord integration has to be enabled to use this command", - "commands.auth.description": "Authenticates yourself or a player so you don't have to input the hash every time you use the bot", - "commands.auth.output": "Player %s has been authenticated with trust level %s", + "commands.auth.description": "Authenticates yourself so you don't have to input the hash every time you use the bot", + "commands.auth.output": "You been authenticated with trust level %s", "commands.auth.error.privilege_escalate": "You cannot escalate privileges!", "commands.botvisibility.description": "Changes the bot's visibility",