@@ -5,7 +5,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import meteordevelopment.meteorclient.systems.commands.Command;
|
||||
import meteordevelopment.meteorclient.systems.commands.arguments.PlayerArgumentType;
|
||||
import meteordevelopment.meteorclient.systems.commands.arguments.PlayerListEntryArgumentType;
|
||||
import meteordevelopment.meteorclient.utils.network.Http;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -20,12 +20,13 @@ import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
|
||||
|
||||
public class SaveSkinCommand extends Command {
|
||||
|
||||
private final static SimpleCommandExceptionType IO_EXCEPTION = new SimpleCommandExceptionType(Text.literal("An IOException occurred"));
|
||||
private final static SimpleCommandExceptionType IO_EXCEPTION = new SimpleCommandExceptionType(Text.literal("An exception occurred"));
|
||||
|
||||
private final PointerBuffer filters;
|
||||
private final Gson GSON = new Gson();
|
||||
@@ -43,13 +44,13 @@ public class SaveSkinCommand extends Command {
|
||||
|
||||
@Override
|
||||
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||
builder.then(argument("player", PlayerArgumentType.create()).executes(ctx -> {
|
||||
PlayerEntity playerEntity = ctx.getArgument("player", PlayerEntity.class);
|
||||
builder.then(argument("player", PlayerListEntryArgumentType.create()).executes(ctx -> {
|
||||
UUID id = PlayerListEntryArgumentType.get(ctx).getProfile().getId();
|
||||
String path = TinyFileDialogs.tinyfd_saveFileDialog("Save image", null, filters, null);
|
||||
if (path == null) IO_EXCEPTION.create();
|
||||
if (path != null) {
|
||||
if (!path.endsWith(".png")) path += ".png";
|
||||
saveSkin(playerEntity.getUuidAsString(),path);
|
||||
saveSkin(id.toString(),path);
|
||||
}
|
||||
|
||||
return SINGLE_SUCCESS;
|
||||
@@ -90,7 +91,7 @@ public class SaveSkinCommand extends Command {
|
||||
FileOutputStream fos = new FileOutputStream(file.getPath());
|
||||
fos.write(response);
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | NullPointerException e) {
|
||||
throw IO_EXCEPTION.create();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class AntiVanish extends Module {
|
||||
final String url = "https://api.mojang.com/user/profiles/" + uuidstr.replace("-", "") + "/names";
|
||||
try {
|
||||
JsonArray res = Http.get(url).sendJson(JsonArray.class);
|
||||
return res.get(0).getAsJsonObject().get("name").getAsString();
|
||||
return res.get(res.size() - 1).getAsJsonObject().get("name").getAsString();
|
||||
} catch (Exception e) {
|
||||
return uuidstr;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,12 @@ public class NoRenderModifier {
|
||||
public static Setting<Boolean> disableToasts;
|
||||
|
||||
public static boolean noCommandSuggestions() {
|
||||
if (noCommandSuggestions == null || Modules.get() == null || Modules.get().get(NoRender.class) == null) return false;
|
||||
return Modules.get().get(NoRender.class).isActive() && noCommandSuggestions.get();
|
||||
}
|
||||
|
||||
public static boolean disableToasts() {
|
||||
if (disableToasts == null || Modules.get() == null || Modules.get().get(NoRender.class) == null) return false;
|
||||
return Modules.get().get(NoRender.class).isActive() && disableToasts.get();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user