Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor command fixes (/name, /uuid, /node and /dfgive) #14

Merged
merged 5 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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