Skip to content

Commit

Permalink
0.0001ms optimization!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
not-coded committed Aug 26, 2024
1 parent dc80ab3 commit 7798b6f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,15 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
.then(ClientCommandManager.argument("player/uuid", string())
.suggests((context, builder) -> suggestMatching(context.getSource().getPlayerNames(), builder))
.executes(ctx -> {
if(getString(ctx, "player/uuid").length() == 32 || getString(ctx, "player/uuid").length() == 36){
return getCapesUUID(ctx.getSource(), getString(ctx, "player/uuid"));
String playerOrUUID = getString(ctx, "player/uuid");
if(playerOrUUID.length() == 32 || playerOrUUID.length() == 36){
return getCapesUUID(ctx.getSource(), playerOrUUID);
}
return getCapesPlayer(ctx.getSource(), getString(ctx, "player/uuid"));
return getCapesPlayer(ctx.getSource(), playerOrUUID);
})));
}

private static String identifyCape(@NotNull String url) {

System.out.println(url);

String cape;
for (int i = 0; i < capes.size(); i++){
cape = capes.get(url);
Expand Down Expand Up @@ -88,7 +86,7 @@ private static void handleResponse(FabricClientCommandSource source, String resp
}

private static int getCapesUUID(@NotNull FabricClientCommandSource source, @NotNull String uuid) {
if(uuid.length() == 32 || uuid.length() == 36 || isUsingPlayerName){
if((uuid.length() == 32 || uuid.length() == 36) || isUsingPlayerName){
String url = "https://sessionserver.mojang.com/session/minecraft/profile/" + uuid;

//? if >=1.19 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
.then(ClientCommandManager.argument("player/uuid", string())
.suggests((context, builder) -> suggestMatching(context.getSource().getPlayerNames(), builder))
.executes(ctx -> {
if(getString(ctx, "player/uuid").length() == 32 || getString(ctx, "player/uuid").length() == 36){
return getSkinsUUID(ctx.getSource(), getString(ctx, "player/uuid"));
String playerOrUUID = getString(ctx, "player/uuid");
if(playerOrUUID.length() == 32 || playerOrUUID.length() == 36){
return getSkinsUUID(ctx.getSource(), playerOrUUID);
}
return getSkinsPlayer(ctx.getSource(), getString(ctx, "player/uuid"));
return getSkinsPlayer(ctx.getSource(), playerOrUUID);
})));
}

Expand Down Expand Up @@ -70,18 +71,16 @@ private static void handleResponse(FabricClientCommandSource source, String resp
return;
}

String finalSkinURL = skinurl;

if(finalSkinURL == null) {
if(skinurl == null) {
sendError(source, "command.all.error");
return;
}

sendFeedback(source, "command.getskin.success", playerName, webLinkText(finalSkinURL));
sendFeedback(source, "command.getskin.success", playerName, webLinkText(skinurl));
}

private static int getSkinsUUID(FabricClientCommandSource source, String uuid) {
if(uuid.length() == 32 || uuid.length() == 36 || isUsingPlayerName) {
if((uuid.length() == 32 || uuid.length() == 36) || isUsingPlayerName) {
String url = "https://sessionserver.mojang.com/session/minecraft/profile/" + uuid;

//? if >=1.19 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
}

private static int execute(CommandContext<FabricClientCommandSource> ctx) {
String playerUUID = getString(ctx, "player/uuid");
if (playerUUID.length() == 32 || playerUUID.length() == 36) {
return getNamesUUID(ctx.getSource(), playerUUID);
} else {
return getUUIDName(ctx.getSource(), playerUUID);
String playerOrUUID = getString(ctx, "player/uuid");
if (playerOrUUID.length() == 32 || playerOrUUID.length() == 36) {
return getNamesUUID(ctx.getSource(), playerOrUUID);
}
return getUUIDName(ctx.getSource(), playerOrUUID);
}

private static int getNamesUUID(FabricClientCommandSource source, @NotNull String uuid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
.then(ClientCommandManager.argument("player/uuid", string())
.suggests((context, builder) -> suggestMatching(context.getSource().getPlayerNames(), builder))
.executes(ctx -> {
if(getString(ctx, "player/uuid").length() == 32 || getString(ctx, "player/uuid").length() == 36){
return getNamesUUID(ctx.getSource(), getString(ctx, "player/uuid"));
} else {
return getNamesPlayer(ctx.getSource(), getString(ctx, "player/uuid"));
String playerOrUUID = getString(ctx, "player/uuid");
if(playerOrUUID.length() == 32 || playerOrUUID.length() == 36){
return getNamesUUID(ctx.getSource(), playerOrUUID);
}
return getNamesPlayer(ctx.getSource(), playerOrUUID);
})));
}

Expand Down Expand Up @@ -73,7 +73,6 @@ private static int getNamesUUID(FabricClientCommandSource source, String uuid) {
//?} elif <1.19 {
/*handleResponse(source, HttpAPI.get(url)); *///?}


} else {
sendError(source, "command.all.invalid.uuid");
return 0;
Expand Down

0 comments on commit 7798b6f

Please sign in to comment.