aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/skyblock/api/ProfileUtils.java
diff options
context:
space:
mode:
authorKevin <92656833+kevinthegreat1@users.noreply.github.com>2023-07-13 12:51:16 +0800
committerGitHub <noreply@github.com>2023-07-13 12:51:16 +0800
commit83e59a85d6a7a131d2d744b05c28172c51a743d6 (patch)
tree25fa431ed02ef89fa1ac323c0c026d827c920cc9 /src/main/java/me/xmrvizzy/skyblocker/skyblock/api/ProfileUtils.java
parent4e5b4fb480339e303e0b31ab0a3a07c90c3912fc (diff)
parent80a57fa12f23b31552fe75a98c8708288e6354df (diff)
downloadSkyblocker-83e59a85d6a7a131d2d744b05c28172c51a743d6.tar.gz
Skyblocker-83e59a85d6a7a131d2d744b05c28172c51a743d6.tar.bz2
Skyblocker-83e59a85d6a7a131d2d744b05c28172c51a743d6.zip
Merge pull request #151 from TacoMonkey11/clean-up
Clean up
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/api/ProfileUtils.java')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/skyblock/api/ProfileUtils.java107
1 files changed, 0 insertions, 107 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/api/ProfileUtils.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/api/ProfileUtils.java
deleted file mode 100644
index dfa6f6dc..00000000
--- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/api/ProfileUtils.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package me.xmrvizzy.skyblocker.skyblock.api;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonObject;
-import me.xmrvizzy.skyblocker.skyblock.api.records.PlayerProfiles;
-import me.xmrvizzy.skyblocker.skyblock.itemlist.ItemFixerUpper;
-import net.minecraft.item.ItemStack;
-import net.minecraft.item.Items;
-import net.minecraft.nbt.*;
-import net.minecraft.text.Text;
-
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
-
-public class ProfileUtils {
- public static PlayerProfiles getProfiles(String name){
- try {
- URL url = new URL("https://sky.shiiyu.moe/api/v2/profile/" + name);
- InputStreamReader reader = new InputStreamReader(url.openStream());
- Gson gson = new GsonBuilder()
- .serializeNulls()
- .create();
- return gson.fromJson(reader, PlayerProfiles.class);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public static List<ItemStack> itemsFromApiInventory(me.xmrvizzy.skyblocker.skyblock.api.records.Items.Item[] items){
- List<ItemStack> inventory = new ArrayList<>();
- for (me.xmrvizzy.skyblocker.skyblock.api.records.Items.Item item : items){
- try{
- if (item.tag() != null){
- JsonObject obj = new Gson().fromJson(Files.readString(Path.of("./config/skyblocker/items-repo/items/" + item.tag().extraAttributes().id() + ".json")), JsonObject.class);
-
- NbtCompound root = new NbtCompound();
- root.put("Count", NbtByte.of(item.count()));
- root.put("id", NbtString.of(ItemFixerUpper.convertItemId(obj.get("itemid").getAsString(), obj.get("damage").getAsInt())));
- NbtCompound tag = new NbtCompound();
- root.put("tag", tag);
-
- if (item.tag().ench() != null){
- NbtList enchantments = new NbtList();
- enchantments.add(new NbtCompound());
- tag.put("Enchantments", enchantments);
- }
-
- NbtCompound extraAttributes = new NbtCompound();
- tag.put("ExtraAttributes", extraAttributes);
- extraAttributes.put("id", NbtString.of(item.tag().extraAttributes().id()));
- if (item.tag().extraAttributes().enchantments() != null){
- NbtCompound enchantments = new NbtCompound();
- extraAttributes.put("enchantments", enchantments);
- for (String enchant : item.tag().extraAttributes().enchantments().keySet()){
- enchantments.put(enchant, NbtInt.of(item.tag().extraAttributes().enchantments().get(enchant)));
- }
- }
-
- NbtCompound display = new NbtCompound();
- tag.put("display", display);
- display.put("Name", NbtString.of(Text.Serializer.toJson(Text.of(item.tag().display().name()))));
- if (item.tag().display().lore() != null){
- NbtList lore = new NbtList();
- display.put("Lore", lore);
- for (int i = 0; i < item.tag().display().lore().length; i++) {
- if (i < item.tag().display().lore().length - 1)
- lore.add(i, NbtString.of(Text.Serializer.toJson(Text.of(Arrays.stream(item.tag().display().lore()).toArray()[i].toString()))));
- }
- }
- if (item.tag().display().color() != null){
- display.put("color", NbtInt.of(item.tag().display().color()));
- }
-
- if (item.tag().skullOwner() != null){
- NbtCompound skullOwner = new NbtCompound();
- tag.put("SkullOwner", skullOwner);
- UUID uuid = UUID.fromString(item.tag().skullOwner().id());
- skullOwner.put("Id", NbtHelper.fromUuid(uuid));
- skullOwner.put("Name", NbtString.of(item.tag().extraAttributes().id()));
-
- NbtCompound properties = new NbtCompound();
- skullOwner.put("Properties", properties);
- NbtList textures = new NbtList();
- properties.put("textures", textures);
- NbtCompound texture = new NbtCompound();
- textures.add(texture);
- texture.put("Value", NbtString.of(item.tag().skullOwner().properties().textures()[0].get("Value")));
- }
- inventory.add(ItemStack.fromNbt(root));
- } else {
- inventory.add(Items.AIR.getDefaultStack());
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- return inventory;
- }
-}