aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java1081
1 files changed, 544 insertions, 537 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
index 1b5c8950..911b74f8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java
@@ -27,19 +27,10 @@ import io.github.moulberry.notenoughupdates.NEUManager;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.util.Constants;
import io.github.moulberry.notenoughupdates.util.Utils;
-import net.minecraft.init.Blocks;
-import net.minecraft.init.Items;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompressedStreamTools;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.util.EnumChatFormatting;
-
-import javax.annotation.Nullable;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
@@ -50,103 +41,236 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.annotation.Nullable;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.CompressedStreamTools;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.EnumChatFormatting;
public class ProfileViewer {
- private static final HashMap<String, String> petRarityToNumMap = new HashMap<String, String>() {{
- put("COMMON", "0");
- put("UNCOMMON", "1");
- put("RARE", "2");
- put("EPIC", "3");
- put("LEGENDARY", "4");
- put("MYTHIC", "5");
- }};
- private static final LinkedHashMap<String, ItemStack> skillToSkillDisplayMap =
- new LinkedHashMap<String, ItemStack>() {{
- put("skill_taming", Utils.createItemStack(Items.spawn_egg, EnumChatFormatting.LIGHT_PURPLE + "Taming"));
- put("skill_mining", Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY + "Mining"));
- put(
- "skill_foraging",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN + "Foraging")
- );
+
+ private static final HashMap<String, String> petRarityToNumMap = new HashMap<String, String>() {
+ {
+ put("COMMON", "0");
+ put("UNCOMMON", "1");
+ put("RARE", "2");
+ put("EPIC", "3");
+ put("LEGENDARY", "4");
+ put("MYTHIC", "5");
+ }
+ };
+ private static final LinkedHashMap<String, ItemStack> skillToSkillDisplayMap = new LinkedHashMap<String, ItemStack>() {
+ {
+ put("taming", Utils.createItemStack(Items.spawn_egg, EnumChatFormatting.LIGHT_PURPLE + "Taming"));
+ put("mining", Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY + "Mining"));
+ put("foraging", Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN + "Foraging"));
put(
- "skill_enchanting",
+ "enchanting",
Utils.createItemStack(Item.getItemFromBlock(Blocks.enchanting_table), EnumChatFormatting.GREEN + "Enchanting")
);
put(
- "skill_carpentry",
+ "carpentry",
Utils.createItemStack(Item.getItemFromBlock(Blocks.crafting_table), EnumChatFormatting.DARK_RED + "Carpentry")
);
- put("skill_farming", Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW + "Farming"));
- put("skill_combat", Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED + "Combat"));
- put("skill_fishing", Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA + "Fishing"));
- put("skill_alchemy", Utils.createItemStack(Items.brewing_stand, EnumChatFormatting.BLUE + "Alchemy"));
+ put("farming", Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW + "Farming"));
+ put("combat", Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED + "Combat"));
+ put("fishing", Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA + "Fishing"));
+ put("alchemy", Utils.createItemStack(Items.brewing_stand, EnumChatFormatting.BLUE + "Alchemy"));
+ put("runecrafting", Utils.createItemStack(Items.magma_cream, EnumChatFormatting.DARK_PURPLE + "Runecrafting"));
+ put("social", Utils.createItemStack(Items.emerald, EnumChatFormatting.DARK_GREEN + "Social"));
+ // put("catacombs", Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush), EnumChatFormatting.GOLD+"Catacombs"));
+ put("zombie", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.GOLD + "Rev Slayer"));
+ put("spider", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.GOLD + "Tara Slayer"));
+ put("wolf", Utils.createItemStack(Items.bone, EnumChatFormatting.GOLD + "Sven Slayer"));
+ put("enderman", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.GOLD + "Ender Slayer"));
+ put("blaze", Utils.createItemStack(Items.blaze_rod, EnumChatFormatting.GOLD + "Blaze Slayer"));
+ }
+ };
+ private static final ItemStack CAT_FARMING = Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW + "Farming");
+ private static final ItemStack CAT_MINING = Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY + "Mining");
+ private static final ItemStack CAT_COMBAT = Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED + "Combat");
+ private static final ItemStack CAT_FORAGING = Utils.createItemStack(
+ Item.getItemFromBlock(Blocks.sapling),
+ EnumChatFormatting.DARK_GREEN + "Foraging"
+ );
+ private static final ItemStack CAT_FISHING = Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA + "Fishing");
+ private static final LinkedHashMap<ItemStack, List<String>> collectionCatToCollectionMap = new LinkedHashMap<ItemStack, List<String>>() {
+ {
put(
- "skill_runecrafting",
- Utils.createItemStack(Items.magma_cream, EnumChatFormatting.DARK_PURPLE + "Runecrafting")
+ CAT_FARMING,
+ Utils.createList(
+ "WHEAT",
+ "CARROT_ITEM",
+ "POTATO_ITEM",
+ "PUMPKIN",
+ "MELON",
+ "SEEDS",
+ "MUSHROOM_COLLECTION",
+ "INK_SACK:3",
+ "CACTUS",
+ "SUGAR_CANE",
+ "FEATHER",
+ "LEATHER",
+ "PORK",
+ "RAW_CHICKEN",
+ "MUTTON",
+ "RABBIT",
+ "NETHER_STALK"
+ )
+ );
+ put(
+ CAT_MINING,
+ Utils.createList(
+ "COBBLESTONE",
+ "COAL",
+ "IRON_INGOT",
+ "GOLD_INGOT",
+ "DIAMOND",
+ "INK_SACK:4",
+ "EMERALD",
+ "REDSTONE",
+ "QUARTZ",
+ "OBSIDIAN",
+ "GLOWSTONE_DUST",
+ "GRAVEL",
+ "ICE",
+ "NETHERRACK",
+ "SAND",
+ "ENDER_STONE",
+ null,
+ "MITHRIL_ORE",
+ "HARD_STONE",
+ "GEMSTONE_COLLECTION",
+ "MYCEL",
+ "SAND:1",
+ "SULPHUR_ORE"
+ )
+ );
+ put(
+ CAT_COMBAT,
+ Utils.createList(
+ "ROTTEN_FLESH",
+ "BONE",
+ "STRING",
+ "SPIDER_EYE",
+ "SULPHUR",
+ "ENDER_PEARL",
+ "GHAST_TEAR",
+ "SLIME_BALL",
+ "BLAZE_ROD",
+ "MAGMA_CREAM",
+ null,
+ null,
+ null,
+ null,
+ "CHILI_PEPPER"
+ )
);
- put("skill_social2", Utils.createItemStack(Items.emerald, EnumChatFormatting.DARK_GREEN + "Social"));
- // put("skill_catacombs", Utils.createItemStack(Item.getItemFromBlock(Blocks.deadbush), EnumChatFormatting.GOLD+"Catacombs"));
- put("slayer_zombie", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.GOLD + "Rev Slayer"));
- put("slayer_spider", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.GOLD + "Tara Slayer"));
- put("slayer_wolf", Utils.createItemStack(Items.bone, EnumChatFormatting.GOLD + "Sven Slayer"));
- put("slayer_enderman", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.GOLD + "Ender Slayer"));
- put("slayer_blaze", Utils.createItemStack(Items.blaze_rod, EnumChatFormatting.GOLD + "Blaze Slayer"));
- }};
- private static final ItemStack CAT_FARMING =
- Utils.createItemStack(Items.golden_hoe, EnumChatFormatting.YELLOW + "Farming");
- private static final ItemStack CAT_MINING =
- Utils.createItemStack(Items.stone_pickaxe, EnumChatFormatting.GRAY + "Mining");
- private static final ItemStack CAT_COMBAT =
- Utils.createItemStack(Items.stone_sword, EnumChatFormatting.RED + "Combat");
- private static final ItemStack CAT_FORAGING =
- Utils.createItemStack(Item.getItemFromBlock(Blocks.sapling), EnumChatFormatting.DARK_GREEN + "Foraging");
- private static final ItemStack CAT_FISHING =
- Utils.createItemStack(Items.fishing_rod, EnumChatFormatting.AQUA + "Fishing");
- private static final LinkedHashMap<ItemStack, List<String>> collectionCatToCollectionMap =
- new LinkedHashMap<ItemStack, List<String>>() {{
- put(CAT_FARMING, Utils.createList("WHEAT", "CARROT_ITEM", "POTATO_ITEM", "PUMPKIN", "MELON", "SEEDS",
- "MUSHROOM_COLLECTION", "INK_SACK:3", "CACTUS", "SUGAR_CANE", "FEATHER", "LEATHER", "PORK", "RAW_CHICKEN",
- "MUTTON", "RABBIT", "NETHER_STALK"
- ));
- put(CAT_MINING, Utils.createList("COBBLESTONE", "COAL", "IRON_INGOT", "GOLD_INGOT", "DIAMOND", "INK_SACK:4",
- "EMERALD", "REDSTONE", "QUARTZ", "OBSIDIAN", "GLOWSTONE_DUST", "GRAVEL", "ICE", "NETHERRACK", "SAND",
- "ENDER_STONE", null, "MITHRIL_ORE", "HARD_STONE", "GEMSTONE_COLLECTION"
- ));
- put(CAT_COMBAT, Utils.createList("ROTTEN_FLESH", "BONE", "STRING", "SPIDER_EYE", "SULPHUR", "ENDER_PEARL",
- "GHAST_TEAR", "SLIME_BALL", "BLAZE_ROD", "MAGMA_CREAM", null, null, null, null, "CHILI_PEPPER"
- ));
put(CAT_FORAGING, Utils.createList("LOG", "LOG:1", "LOG:2", "LOG_2:1", "LOG_2", "LOG:3", null));
- put(CAT_FISHING, Utils.createList("RAW_FISH", "RAW_FISH:1", "RAW_FISH:2", "RAW_FISH:3", "PRISMARINE_SHARD",
- "PRISMARINE_CRYSTALS", "CLAY_BALL", "WATER_LILY", "INK_SACK", "SPONGE", "MAGMA_FISH"
- ));
-
- }};
- private static final LinkedHashMap<ItemStack, List<String>> collectionCatToMinionMap =
- new LinkedHashMap<ItemStack, List<String>>() {{
- put(CAT_FARMING, Utils.createList("WHEAT", "CARROT", "POTATO", "PUMPKIN", "MELON", null, "MUSHROOM",
- "COCOA", "CACTUS", "SUGAR_CANE", "CHICKEN", "COW", "PIG", null, "SHEEP", "RABBIT", "NETHER_WARTS"
- ));
- put(CAT_MINING, Utils.createList("COBBLESTONE", "COAL", "IRON", "GOLD", "DIAMOND", "LAPIS", "EMERALD",
- "REDSTONE", "QUARTZ", "OBSIDIAN", "GLOWSTONE", "GRAVEL", "ICE", null, "SAND", "ENDER_STONE", "SNOW",
- "MITHRIL", "HARD_STONE", null
- ));
- put(CAT_COMBAT, Utils.createList("ZOMBIE", "SKELETON", "SPIDER", "CAVESPIDER", "CREEPER", "ENDERMAN",
- "GHAST", "SLIME", "BLAZE", "MAGMA_CUBE", "REVENANT", "TARANTULA", "VOIDLING", "INFERNO"
- ));
+ put(
+ CAT_FISHING,
+ Utils.createList(
+ "RAW_FISH",
+ "RAW_FISH:1",
+ "RAW_FISH:2",
+ "RAW_FISH:3",
+ "PRISMARINE_SHARD",
+ "PRISMARINE_CRYSTALS",
+ "CLAY_BALL",
+ "WATER_LILY",
+ "INK_SACK",
+ "SPONGE",
+ "MAGMA_FISH"
+ )
+ );
+ }
+ };
+ private static final LinkedHashMap<ItemStack, List<String>> collectionCatToMinionMap = new LinkedHashMap<ItemStack, List<String>>() {
+ {
+ put(
+ CAT_FARMING,
+ Utils.createList(
+ "WHEAT",
+ "CARROT",
+ "POTATO",
+ "PUMPKIN",
+ "MELON",
+ null,
+ "MUSHROOM",
+ "COCOA",
+ "CACTUS",
+ "SUGAR_CANE",
+ "CHICKEN",
+ "COW",
+ "PIG",
+ null,
+ "SHEEP",
+ "RABBIT",
+ "NETHER_WARTS"
+ )
+ );
+ put(
+ CAT_MINING,
+ Utils.createList(
+ "COBBLESTONE",
+ "COAL",
+ "IRON",
+ "GOLD",
+ "DIAMOND",
+ "LAPIS",
+ "EMERALD",
+ "REDSTONE",
+ "QUARTZ",
+ "OBSIDIAN",
+ "GLOWSTONE",
+ "GRAVEL",
+ "ICE",
+ null,
+ "SAND",
+ "ENDER_STONE",
+ "SNOW",
+ "MITHRIL",
+ "HARD_STONE",
+ null,
+ "MYCELIUM",
+ "RED_SAND",
+ null
+ )
+ );
+ put(
+ CAT_COMBAT,
+ Utils.createList(
+ "ZOMBIE",
+ "SKELETON",
+ "SPIDER",
+ "CAVESPIDER",
+ "CREEPER",
+ "ENDERMAN",
+ "GHAST",
+ "SLIME",
+ "BLAZE",
+ "MAGMA_CUBE",
+ "REVENANT",
+ "TARANTULA",
+ "VOIDLING",
+ "INFERNO"
+ )
+ );
put(CAT_FORAGING, Utils.createList("OAK", "SPRUCE", "BIRCH", "DARK_OAK", "ACACIA", "JUNGLE", "FLOWER"));
put(CAT_FISHING, Utils.createList("FISHING", null, null, null, null, null, "CLAY", null, null, null));
-
- }};
- private static final LinkedHashMap<String, ItemStack> collectionToCollectionDisplayMap =
- new LinkedHashMap<String, ItemStack>() {{
+ }
+ };
+ private static final LinkedHashMap<String, ItemStack> collectionToCollectionDisplayMap = new LinkedHashMap<String, ItemStack>() {
+ {
/* FARMING COLLECTIONS */
put("WHEAT", Utils.createItemStack(Items.wheat, EnumChatFormatting.YELLOW + "Wheat"));
put("CARROT_ITEM", Utils.createItemStack(Items.carrot, EnumChatFormatting.YELLOW + "Carrot"));
put("POTATO_ITEM", Utils.createItemStack(Items.potato, EnumChatFormatting.YELLOW + "Potato"));
- put(
- "PUMPKIN",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.pumpkin), EnumChatFormatting.YELLOW + "Pumpkin")
- );
+ put("PUMPKIN", Utils.createItemStack(Item.getItemFromBlock(Blocks.pumpkin), EnumChatFormatting.YELLOW + "Pumpkin"));
put("MELON", Utils.createItemStack(Items.melon, EnumChatFormatting.YELLOW + "Melon"));
put("SEEDS", Utils.createItemStack(Items.wheat_seeds, EnumChatFormatting.YELLOW + "Seeds"));
put(
@@ -165,10 +289,7 @@ public class ProfileViewer {
put("NETHER_STALK", Utils.createItemStack(Items.nether_wart, EnumChatFormatting.YELLOW + "Nether Wart"));
/* MINING COLLECTIONS */
- put(
- "COBBLESTONE",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.cobblestone), EnumChatFormatting.GRAY + "Cobblestone")
- );
+ put("COBBLESTONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.cobblestone), EnumChatFormatting.GRAY + "Cobblestone"));
put("COAL", Utils.createItemStack(Items.coal, EnumChatFormatting.GRAY + "Coal"));
put("IRON_INGOT", Utils.createItemStack(Items.iron_ingot, EnumChatFormatting.GRAY + "Iron Ingot"));
put("GOLD_INGOT", Utils.createItemStack(Items.gold_ingot, EnumChatFormatting.GRAY + "Gold Ingot"));
@@ -177,27 +298,15 @@ public class ProfileViewer {
put("EMERALD", Utils.createItemStack(Items.emerald, EnumChatFormatting.GRAY + "Emerald"));
put("REDSTONE", Utils.createItemStack(Items.redstone, EnumChatFormatting.GRAY + "Redstone"));
put("QUARTZ", Utils.createItemStack(Items.quartz, EnumChatFormatting.GRAY + "Nether Quartz"));
- put(
- "OBSIDIAN",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.obsidian), EnumChatFormatting.GRAY + "Obsidian")
- );
+ put("OBSIDIAN", Utils.createItemStack(Item.getItemFromBlock(Blocks.obsidian), EnumChatFormatting.GRAY + "Obsidian"));
put("GLOWSTONE_DUST", Utils.createItemStack(Items.glowstone_dust, EnumChatFormatting.GRAY + "Glowstone"));
put("GRAVEL", Utils.createItemStack(Item.getItemFromBlock(Blocks.gravel), EnumChatFormatting.GRAY + "Gravel"));
put("ICE", Utils.createItemStack(Item.getItemFromBlock(Blocks.ice), EnumChatFormatting.GRAY + "Ice"));
- put(
- "NETHERRACK",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.netherrack), EnumChatFormatting.GRAY + "Netherrack")
- );
+ put("NETHERRACK", Utils.createItemStack(Item.getItemFromBlock(Blocks.netherrack), EnumChatFormatting.GRAY + "Netherrack"));
put("SAND", Utils.createItemStack(Item.getItemFromBlock(Blocks.sand), EnumChatFormatting.GRAY + "Sand"));
- put(
- "ENDER_STONE",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.end_stone), EnumChatFormatting.GRAY + "End Stone")
- );
+ put("ENDER_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.end_stone), EnumChatFormatting.GRAY + "End Stone"));
put("MITHRIL_ORE", Utils.createItemStack(Items.prismarine_crystals, EnumChatFormatting.GRAY + "Mithril"));
- put(
- "HARD_STONE",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.stone), EnumChatFormatting.GRAY + "Hard Stone")
- );
+ put("HARD_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.stone), EnumChatFormatting.GRAY + "Hard Stone"));
put(
"GEMSTONE_COLLECTION",
Utils.createSkull(
@@ -206,6 +315,9 @@ public class ProfileViewer {
"ewogICJ0aW1lc3RhbXAiIDogMTYxODA4Mzg4ODc3MSwKICAicHJvZmlsZUlkIiA6ICJjNTBhZmE4YWJlYjk0ZTQ1OTRiZjFiNDI1YTk4MGYwMiIsCiAgInByb2ZpbGVOYW1lIiA6ICJUd29FQmFlIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FhYzE1ZjZmY2YyY2U5NjNlZjRjYTcxZjFhODY4NWFkYjk3ZWI3NjllMWQxMTE5NGNiYmQyZTk2NGE4ODk3OGMiCiAgICB9CiAgfQp9"
)
);
+ put("MYCEL", Utils.createItemStack(Item.getItemFromBlock(Blocks.mycelium), EnumChatFormatting.GRAY + "Mycelium"));
+ put("SAND:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.sand), EnumChatFormatting.GRAY + "Red Sand", 1));
+ put("SULPHUR_ORE", Utils.createItemStack(Items.glowstone_dust, EnumChatFormatting.GRAY + "Sulphur"));
/* COMBAT COLLECTIONS */
put("ROTTEN_FLESH", Utils.createItemStack(Items.rotten_flesh, EnumChatFormatting.RED + "Rotten Flesh"));
@@ -218,50 +330,32 @@ public class ProfileViewer {
put("SLIME_BALL", Utils.createItemStack(Items.slime_ball, EnumChatFormatting.RED + "Slimeball"));
put("BLAZE_ROD", Utils.createItemStack(Items.blaze_rod, EnumChatFormatting.RED + "Blaze Rod"));
put("MAGMA_CREAM", Utils.createItemStack(Items.magma_cream, EnumChatFormatting.RED + "Magma Cream"));
- put("CHILI_PEPPER", Utils.createSkull(
- EnumChatFormatting.RED + "Chili Pepper",
- "3d47abaa-b40b-3826-b20c-d83a7f053bd9",
- "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjg1OWM4ZGYxMTA5YzA4YTc1NjI3NWYxZDI4ODdjMjc0ODA0OWZlMzM4Nzc3NjlhN2I0MTVkNTZlZGE0NjlkOCJ9fX0"
- ));
+ put(
+ "CHILI_PEPPER",
+ Utils.createSkull(
+ EnumChatFormatting.RED + "Chili Pepper",
+ "3d47abaa-b40b-3826-b20c-d83a7f053bd9",
+ "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjg1OWM4ZGYxMTA5YzA4YTc1NjI3NWYxZDI4ODdjMjc0ODA0OWZlMzM4Nzc3NjlhN2I0MTVkNTZlZGE0NjlkOCJ9fX0"
+ )
+ );
/* FORAGING COLLECTIONS */
put("LOG", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Oak"));
- put(
- "LOG:1",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Spruce", 1)
- );
- put(
- "LOG:2",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Birch", 2)
- );
- put(
- "LOG_2:1",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), EnumChatFormatting.DARK_GREEN + "Dark Oak", 1)
- );
+ put("LOG:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Spruce", 1));
+ put("LOG:2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Birch", 2));
+ put("LOG_2:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), EnumChatFormatting.DARK_GREEN + "Dark Oak", 1));
put("LOG_2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), EnumChatFormatting.DARK_GREEN + "Acacia"));
- put(
- "LOG:3",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Jungle", 3)
- );
+ put("LOG:3", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Jungle", 3));
/* FISHING COLLECTIONS */
put("RAW_FISH", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Fish"));
put("RAW_FISH:1", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Salmon", 1));
put("RAW_FISH:2", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Clownfish", 2));
put("RAW_FISH:3", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Pufferfish", 3));
- put(
- "PRISMARINE_SHARD",
- Utils.createItemStack(Items.prismarine_shard, EnumChatFormatting.AQUA + "Prismarine Shard")
- );
- put(
- "PRISMARINE_CRYSTALS",
- Utils.createItemStack(Items.prismarine_crystals, EnumChatFormatting.AQUA + "Prismarine Crystals")
- );
+ put("PRISMARINE_SHARD", Utils.createItemStack(Items.prismarine_shard, EnumChatFormatting.AQUA + "Prismarine Shard"));
+ put("PRISMARINE_CRYSTALS", Utils.createItemStack(Items.prismarine_crystals, EnumChatFormatting.AQUA + "Prismarine Crystals"));
put("CLAY_BALL", Utils.createItemStack(Items.clay_ball, EnumChatFormatting.AQUA + "Clay"));
- put(
- "WATER_LILY",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.waterlily), EnumChatFormatting.AQUA + "Lilypad")
- );
+ put("WATER_LILY", Utils.createItemStack(Item.getItemFromBlock(Blocks.waterlily), EnumChatFormatting.AQUA + "Lilypad"));
put("INK_SACK", Utils.createItemStack(Items.dye, EnumChatFormatting.AQUA + "Ink Sack"));
put("SPONGE", Utils.createItemStack(Item.getItemFromBlock(Blocks.sponge), EnumChatFormatting.AQUA + "Sponge"));
put(
@@ -272,11 +366,11 @@ public class ProfileViewer {
"ewogICJ0aW1lc3RhbXAiIDogMTY0MjQ4ODA3MDY2NiwKICAicHJvZmlsZUlkIiA6ICIzNDkxZjJiOTdjMDE0MWE2OTM2YjFjMjJhMmEwMGZiNyIsCiAgInByb2ZpbGVOYW1lIiA6ICJKZXNzc3N1aGgiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjU2YjU5NTViMjk1NTIyYzk2ODk0ODE5NjBjMDFhOTkyY2ExYzc3NTRjZjRlZTMxM2M4ZGQwYzM1NmQzMzVmIgogICAgfQogIH0KfQ"
)
);
- }};
+ }
+ };
private static final AtomicBoolean updatingResourceCollection = new AtomicBoolean(false);
private static JsonObject resourceCollection = null;
private final NEUManager manager;
- private final HashMap<String, JsonObject> nameToHypixelProfile = new HashMap<>();
private final HashMap<String, JsonObject> uuidToHypixelProfile = new HashMap<>();
private final HashMap<String, Profile> uuidToProfileMap = new HashMap<>();
private final HashMap<String, String> nameToUuid = new HashMap<>();
@@ -303,31 +397,36 @@ public class ProfileViewer {
public static Level getLevel(JsonArray levelingArray, float xp, int levelCap, boolean cumulative) {
Level levelObj = new Level();
+ levelObj.totalXp = xp;
+ levelObj.maxLevel = levelCap;
+
for (int level = 0; level < levelingArray.size(); level++) {
float levelXp = levelingArray.get(level).getAsFloat();
+
if (levelXp > xp) {
if (cumulative) {
- float previous = 0;
- if (level > 0) previous = levelingArray.get(level - 1).getAsFloat();
+ float previous = level > 0 ? levelingArray.get(level - 1).getAsFloat() : 0;
levelObj.maxXpForLevel = (levelXp - previous);
levelObj.level = 1 + level + (xp - levelXp) / levelObj.maxXpForLevel;
} else {
levelObj.maxXpForLevel = levelXp;
levelObj.level = level + xp / levelXp;
}
+
if (levelObj.level > levelCap) {
levelObj.level = levelCap;
levelObj.maxed = true;
}
+
return levelObj;
} else {
- if (!cumulative) xp -= levelXp;
+ if (!cumulative) {
+ xp -= levelXp;
+ }
}
}
- levelObj.level = levelingArray.size();
- if (levelObj.level > levelCap) {
- levelObj.level = levelCap;
- }
+
+ levelObj.level = Math.min(levelingArray.size(), levelCap);
levelObj.maxed = true;
return levelObj;
}
@@ -359,10 +458,17 @@ public class ProfileViewer {
String nameF = name.toLowerCase();
HashMap<String, String> args = new HashMap<>();
args.put("name", "" + nameF);
- manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiData.apiKey, "player",
- args, jsonObject -> {
- if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()
- && jsonObject.get("player").isJsonObject()) {
+ manager.hypixelApi.getHypixelApiAsync(
+ NotEnoughUpdates.INSTANCE.config.apiData.apiKey,
+ "player",
+ args,
+ jsonObject -> {
+ if (
+ jsonObject != null &&
+ jsonObject.has("success") &&
+ jsonObject.get("success").getAsBoolean() &&
+ jsonObject.get("player").isJsonObject()
+ ) {
nameToUuid.put(nameF, jsonObject.get("player").getAsJsonObject().get("uuid").getAsString());
uuidToHypixelProfile.put(
jsonObject.get("player").getAsJsonObject().get("uuid").getAsString(),
@@ -387,17 +493,18 @@ public class ProfileViewer {
return;
}
- manager.hypixelApi.getApiAsync("https://api.mojang.com/users/profiles/minecraft/" + nameF,
- (jsonObject) -> {
- if (jsonObject.has("id") && jsonObject.get("id").isJsonPrimitive() &&
- ((JsonPrimitive) jsonObject.get("id")).isString()) {
+ manager.hypixelApi.getApiAsync(
+ "https://api.mojang.com/users/profiles/minecraft/" + nameF,
+ jsonObject -> {
+ if (jsonObject.has("id") && jsonObject.get("id").isJsonPrimitive() && ((JsonPrimitive) jsonObject.get("id")).isString()) {
String uuid = jsonObject.get("id").getAsString();
nameToUuid.put(nameF, uuid);
uuidCallback.accept(uuid);
return;
}
uuidCallback.accept(null);
- }, () -> uuidCallback.accept(null)
+ },
+ () -> uuidCallback.accept(null)
);
}
@@ -409,40 +516,37 @@ public class ProfileViewer {
return;
}
- getPlayerUUID(nameF, (uuid) -> {
- if (uuid == null) {
- getHypixelProfile(nameF, jsonObject -> {
- if (jsonObject != null) {
- callback.accept(getProfileReset(nameToUuid.get(nameF), ignored -> {
- }));
- } else {
- callback.accept(null);
- nameToUuid.put(nameF, null);
+ getPlayerUUID(
+ nameF,
+ uuid -> {
+ if (uuid == null) {
+ getHypixelProfile(
+ nameF,
+ jsonObject -> {
+ if (jsonObject != null) {
+ callback.accept(getProfileReset(nameToUuid.get(nameF), ignored -> {}));
+ } else {
+ callback.accept(null);
+ nameToUuid.put(nameF, null);
+ }
+ }
+ );
+ } else {
+ if (!uuidToHypixelProfile.containsKey(uuid)) {
+ getHypixelProfile(nameF, jsonObject -> {});
}
- });
- } else {
- if (!uuidToHypixelProfile.containsKey(uuid)) {
- getHypixelProfile(nameF, jsonObject -> {
- });
+ callback.accept(getProfileReset(uuid, ignored -> {}));
}
- callback.accept(getProfileReset(uuid, ignored -> {
- }));
}
- });
-
- return;
- }
-
- public Profile getProfileRaw(String uuid) {
- return uuidToProfileMap.get(uuid);
+ );
}
public Profile getProfile(String uuid, Consumer<Profile> callback) {
Profile profile = uuidToProfileMap.computeIfAbsent(uuid, k -> new Profile(uuid));
- if (profile.playerInformation != null) {
+ if (profile.skyblockProfiles != null) {
callback.accept(profile);
} else {
- profile.getPlayerInformation(() -> callback.accept(profile));
+ profile.getSkyblockProfiles(() -> callback.accept(profile));
}
return profile;
}
@@ -453,34 +557,35 @@ public class ProfileViewer {
}
public static class Level {
+
public float level = 0;
public float maxXpForLevel = 0;
public boolean maxed = false;
- public double totalXp;
+ public int maxLevel;
+ public float totalXp;
}
public class Profile {
+
private final String uuid;
private final HashMap<String, JsonObject> profileMap = new HashMap<>();
private final HashMap<String, JsonObject> petsInfoMap = new HashMap<>();
private final HashMap<String, List<JsonObject>> coopProfileMap = new HashMap<>();
- private final HashMap<String, JsonObject> skillInfoMap = new HashMap<>();
- private final HashMap<String, JsonObject> inventoryInfoMap = new HashMap<>();
+ private final HashMap<String, Map<String, Level>> skyblockInfoCache = new HashMap<>();
+ private final HashMap<String, JsonObject> inventoryCacheMap = new HashMap<>();
private final HashMap<String, JsonObject> collectionInfoMap = new HashMap<>();
- private final List<String> profileIds = new ArrayList<>();
+ private final List<String> profileNames = new ArrayList<>();
private final HashMap<String, PlayerStats.Stats> stats = new HashMap<>();
private final HashMap<String, PlayerStats.Stats> passiveStats = new HashMap<>();
private final HashMap<String, Long> networth = new HashMap<>();
- private final AtomicBoolean updatingPlayerInfoState = new AtomicBoolean(false);
- private final AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingSkyblockProfilesState = new AtomicBoolean(false);
private final AtomicBoolean updatingGuildInfoState = new AtomicBoolean(false);
- private final AtomicBoolean updatingGuildStatusState = new AtomicBoolean(false);
+ private final AtomicBoolean updatingPlayerStatusState = new AtomicBoolean(false);
private final AtomicBoolean updatingBingoInfo = new AtomicBoolean(false);
- private final Pattern COLL_TIER_PATTERN = Pattern.compile("_(-?[0-9]+)");
+ private final Pattern COLL_TIER_PATTERN = Pattern.compile("_(-?\\d+)");
private String latestProfile = null;
- private JsonArray playerInformation = null;
+ private JsonArray skyblockProfiles = null;
private JsonObject guildInformation = null;
- private JsonObject basicInfo = null;
private JsonObject playerStatus = null;
private JsonObject bingoInformation = null;
private long lastPlayerInfoState = 0;
@@ -499,18 +604,22 @@ public class ProfileViewer {
long currentTime = System.currentTimeMillis();
if (currentTime - lastStatusInfoState < 15 * 1000) return null;
lastStatusInfoState = currentTime;
+ updatingPlayerStatusState.set(true);
HashMap<String, String> args = new HashMap<>();
args.put("uuid", "" + uuid);
- manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiData.apiKey, "status",
- args, jsonObject -> {
- if (jsonObject == null) return;
-
+ manager.hypixelApi.getHypixelApiAsync(
+ NotEnoughUpdates.INSTANCE.config.apiData.apiKey,
+ "status",
+ args,
+ jsonObject -> {
updatingPlayerStatusState.set(false);
- if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
playerStatus = jsonObject.get("session").getAsJsonObject();
}
- }, () -> updatingPlayerStatusState.set(false)
+ },
+ () -> updatingPlayerStatusState.set(false)
);
return null;
@@ -532,26 +641,27 @@ public class ProfileViewer {
"skyblock/bingo",
args,
jsonObject -> {
- if (jsonObject == null) return;
- if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ updatingBingoInfo.set(false);
+
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
bingoInformation = jsonObject;
} else {
bingoInformation = null;
}
- updatingBingoInfo.set(false);
- }, () -> updatingBingoInfo.set(false)
+ },
+ () -> updatingBingoInfo.set(false)
);
return bingoInformation != null ? bingoInformation : null;
}
- public long getNetWorth(String profileId) {
- if (profileId == null) profileId = latestProfile;
- if (networth.get(profileId) != null) return networth.get(profileId);
- if (getProfileInformation(profileId) == null) return -1;
- if (getInventoryInfo(profileId) == null) return -1;
+ public long getNetWorth(String profileName) {
+ if (profileName == null) profileName = latestProfile;
+ if (networth.get(profileName) != null) return networth.get(profileName);
+ if (getProfileInformation(profileName) == null) return -1;
+ if (getInventoryInfo(profileName) == null) return -1;
- JsonObject inventoryInfo = getInventoryInfo(profileId);
- JsonObject profileInfo = getProfileInformation(profileId);
+ JsonObject inventoryInfo = getInventoryInfo(profileName);
+ JsonObject profileInfo = getProfileInformation(profileName);
HashMap<String, Long> mostExpensiveInternal = new HashMap<>();
@@ -616,8 +726,7 @@ public class ProfileViewer {
}
}
}
- } catch (IOException ignored) {
- }
+ } catch (IOException ignored) {}
int count = 1;
if (element.getAsJsonObject().has("count")) {
@@ -636,7 +745,7 @@ public class ProfileViewer {
networth = (int) (networth * 1.3f);
- JsonObject petsInfo = getPetsInfo(profileId);
+ JsonObject petsInfo = getPetsInfo(profileName);
if (petsInfo != null && petsInfo.has("pets")) {
if (petsInfo.get("pets").isJsonArray()) {
JsonArray pets = petsInfo.get("pets").getAsJsonArray();
@@ -665,7 +774,7 @@ public class ProfileViewer {
networth += bankBalance + purseBalance;
- this.networth.put(profileId, networth);
+ this.networth.put(profileName, networth);
return networth;
}
@@ -673,33 +782,35 @@ public class ProfileViewer {
return latestProfile;
}
- public JsonArray getPlayerInformation(Runnable runnable) {
- if (playerInformation != null) return playerInformation;
+ public JsonArray getSkyblockProfiles(Runnable runnable) {
+ if (skyblockProfiles != null) return skyblockProfiles;
long currentTime = System.currentTimeMillis();
- if (currentTime - lastPlayerInfoState < 15 * 1000 && updatingPlayerInfoState.get()) return null;
-
+ if (currentTime - lastPlayerInfoState < 15 * 1000 && updatingSkyblockProfilesState.get()) return null;
lastPlayerInfoState = currentTime;
- updatingPlayerInfoState.set(true);
+ updatingSkyblockProfilesState.set(true);
HashMap<String, String> args = new HashMap<>();
args.put("uuid", "" + uuid);
- manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiData.apiKey, "skyblock/profiles",
- args, jsonObject -> {
- updatingPlayerInfoState.set(false);
+ manager.hypixelApi.getHypixelApiAsync(
+ NotEnoughUpdates.INSTANCE.config.apiData.apiKey,
+ "skyblock/profiles",
+ args,
+ jsonObject -> {
+ updatingSkyblockProfilesState.set(false);
+
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ if (!jsonObject.has("profiles")) return;
+ skyblockProfiles = jsonObject.get("profiles").getAsJsonArray();
- if (jsonObject == null) return;
- if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- playerInformation = jsonObject.get("profiles").getAsJsonArray();
- if (playerInformation == null) return;
- String backup = null;
- long backupLastSave = 0;
+ String lastCuteName = null;
+ long lastLastSave = 0;
- profileIds.clear();
+ profileNames.clear();
- for (int i = 0; i < playerInformation.size(); i++) {
- JsonObject profile = playerInformation.get(i).getAsJsonObject();
+ for (JsonElement profileEle : skyblockProfiles) {
+ JsonObject profile = profileEle.getAsJsonObject();
if (!profile.has("members")) continue;
JsonObject members = profile.get("members").getAsJsonObject();
@@ -708,80 +819,83 @@ public class ProfileViewer {
JsonObject member = members.get(uuid).getAsJsonObject();
if (member.has("coop_invitation")) {
- JsonObject coop_invitation = member.get("coop_invitation").getAsJsonObject();
- if (!coop_invitation.get("confirmed").getAsBoolean()) {
+ if (!member.get("coop_invitation").getAsJsonObject().get("confirmed").getAsBoolean()) {
continue;
}
}
- String cute_name = profile.get("cute_name").getAsString();
- if (backup == null) backup = cute_name;
- profileIds.add(cute_name);
+ String cuteName = profile.get("cute_name").getAsString();
+ if (lastCuteName == null) lastCuteName = cuteName;
+ profileNames.add(cuteName);
if (member.has("last_save")) {
- long last_save = member.get("last_save").getAsLong();
- if (last_save > backupLastSave) {
- backupLastSave = last_save;
- backup = cute_name;
+ long lastSave = member.get("last_save").getAsLong();
+ if (lastSave > lastLastSave) {
+ lastLastSave = lastSave;
+ lastCuteName = cuteName;
}
}
-
}
}
- latestProfile = backup;
+ latestProfile = lastCuteName;
+
if (runnable != null) runnable.run();
}
- }, () -> updatingPlayerInfoState.set(false)
+ },
+ () -> updatingSkyblockProfilesState.set(false)
);
return null;
}
- public JsonObject getGuildInfo(Runnable runnable) {
+ public JsonObject getGuildInformation(Runnable runnable) {
if (guildInformation != null) return guildInformation;
long currentTime = System.currentTimeMillis();
- if (currentTime - lastGuildInfoState < 15 * 1000) return null;
+ if (currentTime - lastGuildInfoState < 15 * 1000 && updatingGuildInfoState.get()) return null;
lastGuildInfoState = currentTime;
-
updatingGuildInfoState.set(true);
HashMap<String, String> args = new HashMap<>();
args.put("player", "" + uuid);
- manager.hypixelApi.getHypixelApiAsync(NotEnoughUpdates.INSTANCE.config.apiData.apiKey, "guild",
- args, jsonObject -> {
+ manager.hypixelApi.getHypixelApiAsync(
+ NotEnoughUpdates.INSTANCE.config.apiData.apiKey,
+ "guild",
+ args,
+ jsonObject -> {
updatingGuildInfoState.set(false);
- if (jsonObject == null) return;
- if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
+ if (!jsonObject.has("guild")) return;
+
guildInformation = jsonObject.get("guild").getAsJsonObject();
- if (guildInformation == null) return;
+
if (runnable != null) runnable.run();