From e259c56ba1f900b2af00215d093a292f61c5825a Mon Sep 17 00:00:00 2001 From: MrSam7K <64192417+MrSam7K@users.noreply.github.com> Date: Sat, 28 Sep 2024 00:52:41 +0300 Subject: [PATCH 1/6] /uuid and /name cmds + new util --- .../java/dev/dfonline/codeclient/Utility.java | 23 +++++ .../codeclient/command/CommandManager.java | 4 +- .../command/argument/PlayerArgumentType.java | 38 +++++++++ .../codeclient/command/impl/CommandName.java | 76 +++++++++++++++++ .../codeclient/command/impl/CommandUuid.java | 85 +++++++++++++++++++ .../dfonline/codeclient/config/Config.java | 14 +++ .../assets/codeclient/lang/en_us.json | 10 ++- 7 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 src/main/java/dev/dfonline/codeclient/command/argument/PlayerArgumentType.java create mode 100644 src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java create mode 100644 src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java diff --git a/src/main/java/dev/dfonline/codeclient/Utility.java b/src/main/java/dev/dfonline/codeclient/Utility.java index cd6decec..7127b4c7 100644 --- a/src/main/java/dev/dfonline/codeclient/Utility.java +++ b/src/main/java/dev/dfonline/codeclient/Utility.java @@ -291,4 +291,27 @@ public static String genAuthToken() { random.nextBytes(randomBytes); return HexFormat.of().formatHex(randomBytes); } + + + /** + * + * Turns trimmed UUID (without dashes) into a UUID with dashes + * @return A UUID with dashes + */ + public static String fromTrimmed(String trimmedUUID) { + if (trimmedUUID == null) + throw new IllegalArgumentException(); + + StringBuilder builder = new StringBuilder(trimmedUUID.trim()); + try { + builder.insert(20, "-"); + builder.insert(16, "-"); + builder.insert(12, "-"); + builder.insert(8, "-"); + } catch (StringIndexOutOfBoundsException e) { + throw new IllegalArgumentException(); + } + + return builder.toString(); + } } \ No newline at end of file diff --git a/src/main/java/dev/dfonline/codeclient/command/CommandManager.java b/src/main/java/dev/dfonline/codeclient/command/CommandManager.java index ef592a0b..7a4648bf 100644 --- a/src/main/java/dev/dfonline/codeclient/command/CommandManager.java +++ b/src/main/java/dev/dfonline/codeclient/command/CommandManager.java @@ -31,7 +31,9 @@ public class CommandManager { new CommandSwap(), new CommandTemplatePlacer(), new CommandWidthDump(), - new CommandWorldPlot() + new CommandWorldPlot(), + new CommandUuid(), + new CommandName() ); public static void init(CommandDispatcher dispatcher, CommandRegistryAccess registryAccess) { diff --git a/src/main/java/dev/dfonline/codeclient/command/argument/PlayerArgumentType.java b/src/main/java/dev/dfonline/codeclient/command/argument/PlayerArgumentType.java new file mode 100644 index 00000000..c7663ffb --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/command/argument/PlayerArgumentType.java @@ -0,0 +1,38 @@ +package dev.dfonline.codeclient.command.argument; + +import com.google.common.collect.Collections2; +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.arguments.ArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import com.mojang.brigadier.suggestion.Suggestions; +import com.mojang.brigadier.suggestion.SuggestionsBuilder; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.command.CommandSource; + +import java.util.concurrent.CompletableFuture; + +public class PlayerArgumentType implements ArgumentType { + + private PlayerArgumentType() {} + + public static PlayerArgumentType player() { + return new PlayerArgumentType(); + } + + @Override + public String parse(StringReader stringReader) throws CommandSyntaxException { + return stringReader.readUnquotedString(); + } + + @Override + public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { + if (context.getSource() instanceof FabricClientCommandSource clientCommandSource) + return CommandSource.suggestMatching(Collections2.transform( + clientCommandSource.getPlayer().networkHandler.getPlayerList(), + playerEntry -> playerEntry.getProfile().getName() + ), builder); + + return builder.buildFuture(); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java new file mode 100644 index 00000000..04694d5c --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java @@ -0,0 +1,76 @@ +package dev.dfonline.codeclient.command.impl; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import dev.dfonline.codeclient.ChatType; +import dev.dfonline.codeclient.CodeClient; +import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.command.Command; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.text.ClickEvent; +import net.minecraft.text.HoverEvent; +import net.minecraft.text.Style; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import org.apache.commons.io.IOUtils; + +import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +import static com.mojang.brigadier.arguments.StringArgumentType.word; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; + +public class CommandName extends Command { + @Override + public String name() { + return "name"; + } + + @Override + public LiteralArgumentBuilder create(LiteralArgumentBuilder cmd, CommandRegistryAccess registryAccess) { + return cmd.then(argument("uuid", word()) + .executes(context -> { + String uuid = context.getArgument("uuid", String.class); + + String url = "https://sessionserver.mojang.com/session/minecraft/profile/" + uuid; + + try { + String NameJson = IOUtils + .toString(new URL(url), StandardCharsets.UTF_8); + if (NameJson.isEmpty()) { + Utility.sendMessage(Text.translatable("codeclient.command.name.not_found", uuid), ChatType.FAIL); + return -1; + } + + JsonObject json = JsonParser.parseString(NameJson).getAsJsonObject(); + String fullName = json.get("name").getAsString(); + + String localUsername = Objects.requireNonNull(CodeClient.MC.player).getGameProfile().getName(); + + if(localUsername.equals(fullName)) { + Utility.sendMessage(Text.translatable("codeclient.command.name.own"), ChatType.SUCCESS); + return 0; + } else { + Text message = Text.empty() + .append(Text.translatable("codeclient.command.name", uuid)) + .append(Text.literal(fullName).formatted(Formatting.AQUA, Formatting.UNDERLINE)) + .append(Text.literal("!").formatted(Formatting.RESET)) + .fillStyle(Style.EMPTY + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to copy to clipboard"))) + .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fullName))); + + Utility.sendMessage(message, ChatType.SUCCESS); + return 0; + } + + } catch (IOException e) { + Utility.sendMessage(Text.translatable("codeclient.command.name.not_found", uuid), ChatType.FAIL); + return -1; + } + })); + } +} diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java new file mode 100644 index 00000000..b731493d --- /dev/null +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java @@ -0,0 +1,85 @@ +package dev.dfonline.codeclient.command.impl; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import dev.dfonline.codeclient.ChatType; +import dev.dfonline.codeclient.CodeClient; +import dev.dfonline.codeclient.Utility; +import dev.dfonline.codeclient.command.Command; +import dev.dfonline.codeclient.command.argument.PlayerArgumentType; +import dev.dfonline.codeclient.config.Config; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.client.MinecraftClient; +import net.minecraft.command.CommandRegistryAccess; +import net.minecraft.text.*; +import net.minecraft.util.Formatting; +import org.apache.commons.io.IOUtils; + +import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; + +public class CommandUuid extends Command { + @Override + public String name() { + return "uuid"; + } + + @Override + public LiteralArgumentBuilder create(LiteralArgumentBuilder cmd, CommandRegistryAccess registryAccess) { + return cmd.then(argument("username", PlayerArgumentType.player()) + .executes(context -> { + String name = context.getArgument("username", String.class); + return sendUuid(name); + })) + .executes(context -> { + String name = CodeClient.MC.getGameProfile().getName(); + return sendUuid(name); + }); + } + + private int sendUuid(String username) { + String url = "https://api.mojang.com/users/profiles/minecraft/" + username; + MinecraftClient mc = CodeClient.MC; + if(mc.getNetworkHandler() == null) return -1; + + try { + String UUIDJson = IOUtils + .toString(new URL(url), StandardCharsets.UTF_8); + if (UUIDJson.isEmpty()) { + Utility.sendMessage(Text.translatable("codeclient.command.uuid.not_found", username), ChatType.FAIL); + return -1; + } + JsonObject json = JsonParser.parseString(UUIDJson).getAsJsonObject(); + String uuid = json.get("id").getAsString(); + String fullUUID = Utility.fromTrimmed(uuid); + + String localUsername = Objects.requireNonNull(mc.player).getGameProfile().getName(); + Text displayMessage; + if(localUsername.equals(username)) + displayMessage = Text.translatable("codeclient.command.uuid.own"); + else displayMessage = Text.translatable("codeclient.command.uuid", username); + + Text message = Text.empty() + .append(displayMessage) + .append(Text.literal(fullUUID).formatted(Formatting.AQUA, Formatting.UNDERLINE)) + .append(Text.literal("!").formatted(Formatting.RESET)) + .fillStyle(Style.EMPTY + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to copy to clipboard"))) + .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fullUUID))); + + Utility.sendMessage(message, ChatType.SUCCESS); + if (CodeClient.location.name().equals("code") && Config.getConfig().GiveUuidNameStrings) { + mc.getNetworkHandler().sendCommand("str " + fullUUID); + } + } catch (IOException e) { + Utility.sendMessage(Text.translatable("codeclient.command.uuid.not_found", username), ChatType.FAIL); + } + + return 0; + } +} diff --git a/src/main/java/dev/dfonline/codeclient/config/Config.java b/src/main/java/dev/dfonline/codeclient/config/Config.java index bfb55e7f..8058410e 100644 --- a/src/main/java/dev/dfonline/codeclient/config/Config.java +++ b/src/main/java/dev/dfonline/codeclient/config/Config.java @@ -76,6 +76,7 @@ public class Config { public static DestroyItemReset DestroyItemResetMode = DestroyItemReset.OFF; public boolean ShowVariableScopeBelowName = true; public boolean DevNodes = false; + public boolean GiveUuidNameStrings = true; public Config() { } @@ -155,6 +156,7 @@ public void save() { object.addProperty("DestroyItemReset", DestroyItemResetMode.name()); object.addProperty("ShowVariableScopeBelowName", ShowVariableScopeBelowName); object.addProperty("DevNodes", DevNodes); + object.addProperty("GiveUuidNameStrings", GiveUuidNameStrings); FileManager.writeConfig(object.toString()); } catch (Exception e) { CodeClient.LOGGER.info("Couldn't save config: " + e); @@ -250,6 +252,18 @@ public YetAnotherConfigLib getLibConfig() { ) .controller(TickBoxControllerBuilder::create) .build()) + .option(Option.createBuilder(boolean.class) + .name(Text.translatable("codeclient.config.givestrings")) + .description(OptionDescription.createBuilder() + .text(Text.translatable("codeclient.config.givestrings.description")) + .build()) + .binding( + true, + () -> GiveUuidNameStrings, + opt -> GiveUuidNameStrings = opt + ) + .controller(TickBoxControllerBuilder::create) + .build()) // .group(OptionGroup.createBuilder() .name(Text.translatable("codeclient.config.autojoin")) diff --git a/src/main/resources/assets/codeclient/lang/en_us.json b/src/main/resources/assets/codeclient/lang/en_us.json index fcb52a4c..6386a825 100644 --- a/src/main/resources/assets/codeclient/lang/en_us.json +++ b/src/main/resources/assets/codeclient/lang/en_us.json @@ -34,6 +34,8 @@ "codeclient.config.chat_edits_vars.description": "Opening chat whilst holding a value will automatically put the contents in chat.", "codeclient.config.ccdbug": "CCDBUG", "codeclient.config.ccdbug.description": "Toggle CCDBUG, which is a variable and entity watcher for debugging.", + "codeclient.config.givestrings": "Give result", + "codeclient.config.givestrings.description": "If CodeClient should automatically give you result of /uuid and /name commands when in dev mode.", "codeclient.config.autojoin": "AutoJoin", "codeclient.config.autojoin.description": "If and where to auto join.", "codeclient.config.autojoin.enabled": "Enabled", @@ -278,5 +280,11 @@ "codeclient.command.dfgive.count_above_max": "Maximum stack size of %s is %s", "codeclient.command.dfgive.count_below_min": "Minimum stack size is 1", "codeclient.command.dfgive.clipboard_unavailable": "Unable to access the clipboard", - "codeclient.command.dfgive.clipboard_invalid": "Please copy a valid give command to your clipboard" + "codeclient.command.dfgive.clipboard_invalid": "Please copy a valid give command to your clipboard", + "codeclient.command.uuid.not_found": "Player %s was not found", + "codeclient.command.uuid": "UUID of %s is ", + "codeclient.command.uuid.own": "Your UUID is ", + "codeclient.command.name.not_found": "UUID %s was not found! Please check if you misspelled it and try again", + "codeclient.command.name": "Name of %s is ", + "codeclient.command.name.own": "The UUID is yours! What a surprise!" } \ No newline at end of file From 65f0971cf835a171e5888819cdc803d2128945c8 Mon Sep 17 00:00:00 2001 From: MrSam7K <64192417+MrSam7K@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:02:58 +0300 Subject: [PATCH 2/6] changed category --- .../dfonline/codeclient/config/Config.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/dev/dfonline/codeclient/config/Config.java b/src/main/java/dev/dfonline/codeclient/config/Config.java index 8058410e..e9a9a326 100644 --- a/src/main/java/dev/dfonline/codeclient/config/Config.java +++ b/src/main/java/dev/dfonline/codeclient/config/Config.java @@ -252,18 +252,6 @@ public YetAnotherConfigLib getLibConfig() { ) .controller(TickBoxControllerBuilder::create) .build()) - .option(Option.createBuilder(boolean.class) - .name(Text.translatable("codeclient.config.givestrings")) - .description(OptionDescription.createBuilder() - .text(Text.translatable("codeclient.config.givestrings.description")) - .build()) - .binding( - true, - () -> GiveUuidNameStrings, - opt -> GiveUuidNameStrings = opt - ) - .controller(TickBoxControllerBuilder::create) - .build()) // .group(OptionGroup.createBuilder() .name(Text.translatable("codeclient.config.autojoin")) @@ -577,6 +565,18 @@ public YetAnotherConfigLib getLibConfig() { ) .controller(nodeOption -> () -> new EnumController<>(nodeOption, Config.DestroyItemReset.class)) .build()) + .option(Option.createBuilder(boolean.class) + .name(Text.translatable("codeclient.config.givestrings")) + .description(OptionDescription.createBuilder() + .text(Text.translatable("codeclient.config.givestrings.description")) + .build()) + .binding( + true, + () -> GiveUuidNameStrings, + opt -> GiveUuidNameStrings = opt + ) + .controller(TickBoxControllerBuilder::create) + .build()) .build()) // // From 3ed1f0e94e59632067ffe861bf6ca10515cd718a Mon Sep 17 00:00:00 2001 From: MrSam7K <64192417+MrSam7K@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:04:45 +0300 Subject: [PATCH 3/6] /name actually gives string now --- .../dfonline/codeclient/command/impl/CommandName.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java index 04694d5c..721179fd 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java @@ -7,7 +7,9 @@ import dev.dfonline.codeclient.CodeClient; import dev.dfonline.codeclient.Utility; import dev.dfonline.codeclient.command.Command; +import dev.dfonline.codeclient.config.Config; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.minecraft.client.MinecraftClient; import net.minecraft.command.CommandRegistryAccess; import net.minecraft.text.ClickEvent; import net.minecraft.text.HoverEvent; @@ -35,6 +37,8 @@ public LiteralArgumentBuilder create(LiteralArgumentB return cmd.then(argument("uuid", word()) .executes(context -> { String uuid = context.getArgument("uuid", String.class); + MinecraftClient mc = CodeClient.MC; + if(mc.getNetworkHandler() == null) return -1; String url = "https://sessionserver.mojang.com/session/minecraft/profile/" + uuid; @@ -49,7 +53,7 @@ public LiteralArgumentBuilder create(LiteralArgumentB JsonObject json = JsonParser.parseString(NameJson).getAsJsonObject(); String fullName = json.get("name").getAsString(); - String localUsername = Objects.requireNonNull(CodeClient.MC.player).getGameProfile().getName(); + String localUsername = Objects.requireNonNull(mc.player).getGameProfile().getName(); if(localUsername.equals(fullName)) { Utility.sendMessage(Text.translatable("codeclient.command.name.own"), ChatType.SUCCESS); @@ -64,6 +68,10 @@ public LiteralArgumentBuilder create(LiteralArgumentB .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fullName))); Utility.sendMessage(message, ChatType.SUCCESS); + + if (CodeClient.location.name().equals("code") && Config.getConfig().GiveUuidNameStrings) + mc.getNetworkHandler().sendCommand("str " + fullName); + return 0; } From 501e3b5023324069d56a72c2ad35f8fea991f63b Mon Sep 17 00:00:00 2001 From: MrSam7K <64192417+MrSam7K@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:06:17 +0300 Subject: [PATCH 4/6] cleanup --- .../dev/dfonline/codeclient/command/impl/CommandUuid.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java index b731493d..4db79d87 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java @@ -73,9 +73,10 @@ private int sendUuid(String username) { .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fullUUID))); Utility.sendMessage(message, ChatType.SUCCESS); - if (CodeClient.location.name().equals("code") && Config.getConfig().GiveUuidNameStrings) { + + if (CodeClient.location.name().equals("code") && Config.getConfig().GiveUuidNameStrings) mc.getNetworkHandler().sendCommand("str " + fullUUID); - } + } catch (IOException e) { Utility.sendMessage(Text.translatable("codeclient.command.uuid.not_found", username), ChatType.FAIL); } From d1086e50c819d0587cd7075232eccde9e7df3309 Mon Sep 17 00:00:00 2001 From: MrSam7K <64192417+MrSam7K@users.noreply.github.com> Date: Sat, 28 Sep 2024 11:11:29 +0300 Subject: [PATCH 5/6] proper way of checking dev --- .../java/dev/dfonline/codeclient/command/impl/CommandName.java | 3 ++- .../java/dev/dfonline/codeclient/command/impl/CommandUuid.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java index 721179fd..6a56310c 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java @@ -8,6 +8,7 @@ import dev.dfonline.codeclient.Utility; import dev.dfonline.codeclient.command.Command; import dev.dfonline.codeclient.config.Config; +import dev.dfonline.codeclient.location.Dev; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.client.MinecraftClient; import net.minecraft.command.CommandRegistryAccess; @@ -69,7 +70,7 @@ public LiteralArgumentBuilder create(LiteralArgumentB Utility.sendMessage(message, ChatType.SUCCESS); - if (CodeClient.location.name().equals("code") && Config.getConfig().GiveUuidNameStrings) + if (CodeClient.location instanceof Dev && Config.getConfig().GiveUuidNameStrings) mc.getNetworkHandler().sendCommand("str " + fullName); return 0; diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java index 4db79d87..4c6a9877 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java @@ -9,6 +9,7 @@ import dev.dfonline.codeclient.command.Command; import dev.dfonline.codeclient.command.argument.PlayerArgumentType; import dev.dfonline.codeclient.config.Config; +import dev.dfonline.codeclient.location.Dev; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.client.MinecraftClient; import net.minecraft.command.CommandRegistryAccess; @@ -74,7 +75,7 @@ private int sendUuid(String username) { Utility.sendMessage(message, ChatType.SUCCESS); - if (CodeClient.location.name().equals("code") && Config.getConfig().GiveUuidNameStrings) + if (CodeClient.location instanceof Dev && Config.getConfig().GiveUuidNameStrings) mc.getNetworkHandler().sendCommand("str " + fullUUID); } catch (IOException e) { From 90ac040c822554200babfbf6021839da7cb31a8c Mon Sep 17 00:00:00 2001 From: MrSam7K <64192417+MrSam7K@users.noreply.github.com> Date: Sat, 28 Sep 2024 15:41:43 +0300 Subject: [PATCH 6/6] proper translations?! frfr --- .../codeclient/command/impl/CommandName.java | 9 ++++----- .../codeclient/command/impl/CommandUuid.java | 14 +++----------- .../resources/assets/codeclient/lang/en_us.json | 7 ++++--- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java index 6a56310c..5148661e 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandName.java @@ -60,12 +60,11 @@ public LiteralArgumentBuilder create(LiteralArgumentB Utility.sendMessage(Text.translatable("codeclient.command.name.own"), ChatType.SUCCESS); return 0; } else { - Text message = Text.empty() - .append(Text.translatable("codeclient.command.name", uuid)) - .append(Text.literal(fullName).formatted(Formatting.AQUA, Formatting.UNDERLINE)) - .append(Text.literal("!").formatted(Formatting.RESET)) + Text nameDisplay = Text.literal(fullName).formatted(Formatting.AQUA, Formatting.UNDERLINE); + + Text message = Text.translatable("codeclient.command.name", uuid, nameDisplay) .fillStyle(Style.EMPTY - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to copy to clipboard"))) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("codeclient.hover.click_to_copy"))) .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fullName))); Utility.sendMessage(message, ChatType.SUCCESS); diff --git a/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java b/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java index 4c6a9877..6b2c3af0 100644 --- a/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java +++ b/src/main/java/dev/dfonline/codeclient/command/impl/CommandUuid.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.util.Objects; import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument; @@ -59,18 +58,11 @@ private int sendUuid(String username) { String uuid = json.get("id").getAsString(); String fullUUID = Utility.fromTrimmed(uuid); - String localUsername = Objects.requireNonNull(mc.player).getGameProfile().getName(); - Text displayMessage; - if(localUsername.equals(username)) - displayMessage = Text.translatable("codeclient.command.uuid.own"); - else displayMessage = Text.translatable("codeclient.command.uuid", username); + Text uuidDisplay = Text.literal(fullUUID).formatted(Formatting.AQUA, Formatting.UNDERLINE); - Text message = Text.empty() - .append(displayMessage) - .append(Text.literal(fullUUID).formatted(Formatting.AQUA, Formatting.UNDERLINE)) - .append(Text.literal("!").formatted(Formatting.RESET)) + Text message = Text.translatable("codeclient.command.uuid", username, uuidDisplay) .fillStyle(Style.EMPTY - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to copy to clipboard"))) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("codeclient.hover.click_to_copy"))) .withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fullUUID))); Utility.sendMessage(message, ChatType.SUCCESS); diff --git a/src/main/resources/assets/codeclient/lang/en_us.json b/src/main/resources/assets/codeclient/lang/en_us.json index 6386a825..4fb048c6 100644 --- a/src/main/resources/assets/codeclient/lang/en_us.json +++ b/src/main/resources/assets/codeclient/lang/en_us.json @@ -215,6 +215,8 @@ "codeclient.warning.dev_mode": "You must be in dev mode!", "codeclient.warning.creative_mode": "You must be in creative mode!", + "codeclient.hover.click_to_copy": "Click to copy to clipboard", + "codeclient.search.results": "Search Results:", "codeclient.search.no_results": "No results.", "codeclient.search.hover.teleport": "Click to teleport\nx: %s, y: %s, z: %s", @@ -282,9 +284,8 @@ "codeclient.command.dfgive.clipboard_unavailable": "Unable to access the clipboard", "codeclient.command.dfgive.clipboard_invalid": "Please copy a valid give command to your clipboard", "codeclient.command.uuid.not_found": "Player %s was not found", - "codeclient.command.uuid": "UUID of %s is ", - "codeclient.command.uuid.own": "Your UUID is ", + "codeclient.command.uuid": "UUID of %s is %s!", "codeclient.command.name.not_found": "UUID %s was not found! Please check if you misspelled it and try again", - "codeclient.command.name": "Name of %s is ", + "codeclient.command.name": "Name of %s is %s!", "codeclient.command.name.own": "The UUID is yours! What a surprise!" } \ No newline at end of file