Skip to content

Commit

Permalink
Merge pull request #14 from TRMMax/uuid-command-fix
Browse files Browse the repository at this point in the history
minor command fixes (/name, /uuid, /node and /dfgive)
  • Loading branch information
homchom committed Oct 27, 2022
2 parents 3c0560a + ade8308 commit 0d85e9c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Expand Up @@ -59,7 +59,7 @@ public void register(Minecraft mc, CommandDispatcher<FabricClientCommandSource>
clipboard = clipboard.substring(3);
}

this.sendCommand(mc, "/dfgive " + clipboard);
this.sendCommand(mc, "dfgive " + clipboard);
return 1;
})
)
Expand Down
Expand Up @@ -31,7 +31,7 @@ public void register(Minecraft mc, CommandDispatcher<FabricClientCommandSource>

for (Map.Entry<String, String> node : NODE_MAP.entrySet()) {
cmd.then(ArgBuilder.literal(node.getKey()).executes((ctx) -> {
this.sendCommand(mc, "/server " + node.getValue());
this.sendCommand(mc, "server " + node.getValue());
return 1;
}));
}
Expand Down
Expand Up @@ -33,26 +33,26 @@ public void register(Minecraft mc, CommandDispatcher<FabricClientCommandSource>
.executes(ctx -> {
LegacyRecode.executor.submit(() -> {
String uuid = ctx.getArgument("uuid", String.class);
String url = "https://api.mojang.com/user/profiles/" + uuid + "/names";
String url = "https://sessionserver.mojang.com/session/minecraft/profile/" + uuid;
try {
String NameJson = IOUtils
.toString(new URL(url), StandardCharsets.UTF_8);
if (NameJson.isEmpty()) {
ChatUtil.sendMessage("Player with that UUID was not found! Please check if you misspelled it and try again.", ChatType.FAIL);
return;
}
List<Map> json = new Gson().fromJson(NameJson, List.class);
String nameData = json.get(json.size()-1).get("name").toString();
String fullName = nameData;

JsonObject json = JsonParser.parseString(NameJson).getAsJsonObject();
String fullName = json.get("name").getAsString();

Component text = Component.literal("§eName of §6" + uuid + " §eis §b" + fullName + "§e!")
.withStyle(s -> s.withHoverEvent(
new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("§eClick to copy to clipboard."))
).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fullName)));
this.sendMessage(mc, text);

if (this.isCreative(mc) && DFInfo.isOnDF() && DFInfo.currentState.getMode() == LegacyState.Mode.DEV) {
this.sendCommand(mc, "/txt " + fullName);
if (mc.player != null && mc.player.isCreative() && DFInfo.isOnDF() && DFInfo.currentState.getMode() == LegacyState.Mode.DEV) {
this.sendCommand(mc, "txt " + fullName);
}
} catch (IOException e) {
ChatUtil.sendMessage("§cUUID §6" + uuid + "§c was not found. Please check if you misspelled it and try again.");
Expand Down
Expand Up @@ -38,7 +38,7 @@ public void register(Minecraft mc, CommandDispatcher<FabricClientCommandSource>
ChatUtil.sendMessage("Player was not found!", ChatType.FAIL);
return;
}
JsonObject json = new JsonParser().parse(UUIDJson).getAsJsonObject();
JsonObject json = JsonParser.parseString(UUIDJson).getAsJsonObject();
String uuid = json.get("id").getAsString();
String fullUUID = StringUtil.fromTrimmed(uuid);

Expand All @@ -48,8 +48,8 @@ public void register(Minecraft mc, CommandDispatcher<FabricClientCommandSource>
).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, fullUUID)));
this.sendMessage(mc, text);

if (this.isCreative(mc) && DFInfo.isOnDF() && DFInfo.currentState.getMode() == LegacyState.Mode.DEV) {
this.sendCommand(mc, "/txt " + fullUUID);
if (mc.player != null && mc.player.isCreative() && DFInfo.isOnDF() && DFInfo.currentState.getMode() == LegacyState.Mode.DEV) {
this.sendCommand(mc, "txt " + fullUUID);
}
} catch (IOException e) {
ChatUtil.sendMessage("§cUser §6" + username + "§c was not found.");
Expand Down

0 comments on commit 0d85e9c

Please sign in to comment.