diff options
| author | nea <romangraef@gmail.com> | 2022-09-27 06:00:06 +0200 |
|---|---|---|
| committer | nea <romangraef@gmail.com> | 2022-09-27 06:00:06 +0200 |
| commit | 4430161f95248f3ff8ecb1e608bc575b5fce5afb (patch) | |
| tree | 3859f42df716a9876fb89d5c44aa6194762b3966 /src/main/java | |
| parent | 29bc3371a62a74d2eab4fe9b6d5c820d52dbbac4 (diff) | |
| download | NotEnoughUpdates-4430161f95248f3ff8ecb1e608bc575b5fce5afb.tar.gz NotEnoughUpdates-4430161f95248f3ff8ecb1e608bc575b5fce5afb.tar.bz2 NotEnoughUpdates-4430161f95248f3ff8ecb1e608bc575b5fce5afb.zip | |
Add custom keystore and refactor HypixelApi.java
Diffstat (limited to 'src/main/java')
13 files changed, 845 insertions, 786 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 7a2389d4..598ecc2e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -36,7 +36,7 @@ import io.github.moulberry.notenoughupdates.recipes.Ingredient; import io.github.moulberry.notenoughupdates.recipes.NeuRecipe; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.HotmInformation; -import io.github.moulberry.notenoughupdates.util.HypixelApi; +import io.github.moulberry.notenoughupdates.util.ApiUtil; import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -124,9 +124,7 @@ public class NEUManager { public String viewItemAttemptID = null; public long viewItemAttemptTime = 0; - private final String currentProfile = ""; - private final String currentProfileBackup = ""; - public final HypixelApi hypixelApi = new HypixelApi(); + public final ApiUtil apiUtils = new ApiUtil(); private final Map<String, ItemStack> itemstackCache = new HashMap<>(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java index 2dc02b7e..1b6896db 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java @@ -287,23 +287,26 @@ public class APIManager { } public void updateLowestBin() { - manager.hypixelApi.getMyApiGZIPAsync("lowestbin.json.gz", (jsonObject) -> { - if (lowestBins == null) { - lowestBins = new JsonObject(); - } - if (!jsonObject.entrySet().isEmpty()) { - lastLowestBinUpdate = System.currentTimeMillis(); - } - for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) { - lowestBins.add(entry.getKey(), entry.getValue()); - } - if (!didFirstUpdate) { - ItemPriceInformation.updateAuctionableItemsList(); - didFirstUpdate = true; - } - GuiPriceGraph.addToCache(lowestBins, false); - }, () -> { - }); + manager.apiUtils + .newMoulberryRequest("lowestbin.json.gz") + .gunzip() + .requestJson() + .thenAccept(jsonObject -> { + if (lowestBins == null) { + lowestBins = new JsonObject(); + } + if (!jsonObject.entrySet().isEmpty()) { + lastLowestBinUpdate = System.currentTimeMillis(); + } + for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) { + lowestBins.add(entry.getKey(), entry.getValue()); + } + if (!didFirstUpdate) { + ItemPriceInformation.updateAuctionableItemsList(); + didFirstUpdate = true; + } + GuiPriceGraph.addToCache(lowestBins, false); + }); } private void ahNotification() { @@ -460,20 +463,23 @@ public class APIManager { } }; - manager.hypixelApi.getMyApiGZIPAsync("auctionLast.json.gz", process, () -> - System.out.println("Error downloading auction from Moulberry's jank API. :(")); + manager.apiUtils.newMoulberryRequest("auctionLast.json.gz") + .gunzip().requestJson().thenAccept(process); - manager.hypixelApi.getMyApiGZIPAsync("auction.json.gz", jsonObject -> { - if (jsonObject.get("success").getAsBoolean()) { - long apiUpdate = (long) jsonObject.get("time").getAsFloat(); - if (lastApiUpdate == apiUpdate) { - lastAuctionUpdate -= 30 * 1000; - } - lastApiUpdate = apiUpdate; + manager.apiUtils + .newMoulberryRequest("auction.json.gz") + .gunzip().requestJson() + .thenAccept(jsonObject -> { + if (jsonObject.get("success").getAsBoolean()) { + long apiUpdate = (long) jsonObject.get("time").getAsFloat(); + if (lastApiUpdate == apiUpdate) { + lastAuctionUpdate -= 30 * 1000; + } + lastApiUpdate = apiUpdate; - process.accept(jsonObject); - } - }, () -> System.out.println("Error downloading auction from Moulberry's jank API. :(")); + process.accept(jsonObject); + } + }); } @@ -673,8 +679,10 @@ public class APIManager { //System.out.println("Trying to update page: " + page); HashMap<String, String> args = new HashMap<>(); args.put("page", "" + page); - manager.hypixelApi.getHypixelApiAsync(null, "skyblock/auctions", - args, jsonObject -> { + manager.apiUtils + .newAnonymousHypixelApiRequest("skyblock/auctions") + .requestJson() + .thenAccept(jsonObject -> { if (jsonObject == null) return; if (jsonObject.get("success").getAsBoolean()) { @@ -701,8 +709,13 @@ public class APIManager { } else { pagesToDownload.addLast(page); } - }, () -> pagesToDownload.addLast(page) - ); + }) + .handle((ignored, ex) -> { + if (ex != null) { + pagesToDownload.addLast(page); + } + return null; + }); } private static final Pattern BAZAAR_ENCHANTMENT_PATTERN = Pattern.compile("ENCHANTMENT_(\\D*)_(\\d+)"); @@ -716,11 +729,10 @@ public class APIManager { } public void updateBazaar() { - manager.hypixelApi.getHypixelApiAsync( - NotEnoughUpdates.INSTANCE.config.apiData.apiKey, - "skyblock/bazaar", - new HashMap<>(), - (jsonObject) -> { + manager.apiUtils + .newHypixelApiRequest("skyblock/bazaar") + .requestJson() + .thenAccept(jsonObject -> { if (!jsonObject.get("success").getAsBoolean()) return; craftCost.clear(); @@ -755,20 +767,23 @@ public class APIManager { } } GuiPriceGraph.addToCache(bazaarJson, true); - } - ); + }); } public void updateAvgPrices() { - manager.hypixelApi.getMyApiGZIPAsync("auction_averages/3day.json.gz", (jsonObject) -> { - craftCost.clear(); - auctionPricesJson = jsonObject; - lastAuctionAvgUpdate = System.currentTimeMillis(); - }, () -> { - }); - manager.hypixelApi.getMyApiGZIPAsync("auction_averages_lbin/1day.json.gz", (jsonObject) -> - auctionPricesAvgLowestBinJson = jsonObject, () -> { - }); + manager.apiUtils + .newMoulberryRequest("auction_averages/3day.json.gz") + .gunzip().requestJson().thenAccept((jsonObject) -> { + craftCost.clear(); + auctionPricesJson = jsonObject; + lastAuctionAvgUpdate = System.currentTimeMillis(); + }); + manager.apiUtils + .newMoulberryRequest("auction_averages_lbin/1day.json.gz") + .gunzip().requestJson() + .thenAccept((jsonObject) -> { + auctionPricesAvgLowestBinJson = jsonObject; + }); } public Set<String> getItemAuctionInfoKeySet() { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java index 6d0ee88d..5a4f1400 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java @@ -25,7 +25,6 @@ import io.github.moulberry.notenoughupdates.util.MinecraftExecutor; import io.github.moulberry.notenoughupdates.util.PronounDB; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiNewChat; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; @@ -75,9 +74,9 @@ public class PronounsCommand extends ClientCommandBase { c.complete(Utils.parseDashlessUUID(uuidString)); } }); - pronouns = c.thenApplyAsync(PronounDB::getPronounsFor); + pronouns = c.thenCompose(PronounDB::getPronounsFor); } else { - pronouns = CompletableFuture.supplyAsync(() -> PronounDB.getPronounsFor(platform, user)); + pronouns = PronounDB.getPronounsFor(platform, user); } pronouns.handleAsync((pronounChoice, throwable) -> { if (throwable != null || !pronounChoice.isPresent()) { @@ -85,7 +84,8 @@ public class PronounsCommand extends ClientCommandBase { return null; } PronounDB.PronounChoice betterPronounChoice = pronounChoice.get(); - nc.printChatMessageWithOptionalDeletion(new ChatComponentText("§e[NEU] Pronouns for §b" + user + " §eon §b" + platform + "§e:"), id); + nc.printChatMessageWithOptionalDeletion(new ChatComponentText( + "§e[NEU] Pronouns for §b" + user + " §eon §b" + platform + "§e:"), id); betterPronounChoice.render().forEach(it -> nc.printChatMessage(new ChatComponentText("§e[NEU] §a" + it))); return null; }, MinecraftExecutor.INSTANCE); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java index 293535e7..7a609a2a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -145,46 +145,53 @@ public class CapeManager { } private void updateCapes() { - NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("activecapes.json", (jsonObject) -> { - if (jsonObject.get("success").getAsBoolean()) { - lastJsonSync = jsonObject; - - lastCapeSynced = System.currentTimeMillis(); - capeMap.clear(); - for (JsonElement active : jsonObject.get("active").getAsJsonArray()) { - if (active.isJsonObject()) { - JsonObject activeObj = (JsonObject) active; - setCape(activeObj.get("_id").getAsString(), activeObj.get("capeType").getAsString(), false); + NotEnoughUpdates.INSTANCE.manager.apiUtils + .newMoulberryRequest("activecapes.json") + .requestJson() + .thenAccept(jsonObject -> { + if (jsonObject.get("success").getAsBoolean()) { + lastJsonSync = jsonObject; + + lastCapeSynced = System.currentTimeMillis(); + capeMap.clear(); + for (JsonElement active : jsonObject.get("active").getAsJsonArray()) { + if (active.isJsonObject()) { + JsonObject activeObj = (JsonObject) active; + setCape(activeObj.get("_id").getAsString(), activeObj.get("capeType").getAsString(), false); + } } } - } - }, () -> System.out.println("[MBAPI] Update capes errored")); + }); if (Minecraft.getMinecraft().thePlayer != null && permSyncTries > 0) { String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""); permSyncTries--; - NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync("permscapes.json", (jsonObject) -> { - if (!jsonObject.get("success").getAsBoolean()) return; - - permSyncTries = 0; - availableCapes.clear(); - for (JsonElement permPlayer : jsonObject.get("perms").getAsJsonArray()) { - if (!permPlayer.isJsonObject()) continue; - String playerUuid = permPlayer.getAsJsonObject().get("_id").getAsString(); - if (!(playerUuid != null && playerUuid.equals(uuid))) continue; - for (JsonElement perm : permPlayer.getAsJsonObject().get("perms").getAsJsonArray()) { - if (!perm.isJsonPrimitive()) continue; - String cape = perm.getAsString(); - if (cape.equals("*")) { - allAvailable = true; - } else { - availableCapes.add(cape); - } + NotEnoughUpdates.INSTANCE.manager.apiUtils + .newMoulberryRequest("permscapes.json") + .requestJson() + .thenAccept(jsonObject -> { + if (!jsonObject.get("success").getAsBoolean()) return; + + permSyncTries = 0; + availableCapes.clear(); + for (JsonElement permPlayer : jsonObject.get("perms").getAsJsonArray()) { + if (!permPlayer.isJsonObject()) continue; + String playerUuid = permPlayer.getAsJsonObject().get("_id").getAsString(); + if (!(playerUuid != null && playerUuid.equals(uuid))) continue; + for (JsonElement perm : permPlayer.getAsJsonObject().get("perms").getAsJsonArray()) { + if (!perm.isJsonPrimitive()) continue; + String cape = perm.getAsString(); + if (cape.equals("*")) { + allAvailable = true; + } else { + availableCapes.add(cape); + } + } + return; } - return; - } - }, () -> System.out.println("[MBAPI] Update capes errored - perms")); + + }); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java index 0e37bed3..12d8c92d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java @@ -404,21 +404,14 @@ public class GuiCosmetics extends GuiScreen { .getSession() .getProfile(), accessToken, serverId); - if (wantToEquipCape == null) { - NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync( - "cgi-bin/changecape.py?capeType=null&serverId=" + - serverId + "&username=" + userName, - System.out::println, - () -> System.out.println("Change cape error") - ); - } else { - NotEnoughUpdates.INSTANCE.manager.hypixelApi.getMyApiAsync( - "cgi-bin/changecape.py?capeType=" + wantToEquipCape + "&serverId=" + - serverId + "&username=" + userName, - System.out::println, - () -> System.out.println("Change cape error") - ); - } + String toEquipName = wantToEquipCape == null ? "null" : wantToEquipCape; + NotEnoughUpdates.INSTANCE.manager.apiUtils + .newMoulberryRequest("cgi-bin/changecape.py") + .queryArgument("capeType", toEquipName) + .queryArgument("serverId", serverId) + .queryArgument("username", userName) + .requestString() + .thenAccept(System.out::println); } catch (Exception e) { System.out.println("Exception while generating mojang shared secret"); e.printStackTrace(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java index 27b9b363..ab80afab 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java @@ -24,9 +24,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.util.Utils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; @@ -39,6 +36,9 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; +import java.util.ArrayList; +import java.util.List; + public class BingoPage extends GuiProfileViewerPage { private static final ResourceLocation BINGO_GUI_TEXTURE = new ResourceLocation("notenoughupdates:pv_bingo_tab.png"); @@ -153,16 +153,23 @@ public class BingoPage extends GuiProfileViewerPage { } else { personalGoalsString = EnumChatFormatting.AQUA + - "Personal Goals: " + - EnumChatFormatting.WHITE + - completedGoals.size() + - EnumChatFormatting.GOLD + - "/" + - EnumChatFormatting.WHITE + - 20; + "Personal Goals: " + + EnumChatFormatting.WHITE + + completedGoals.size() + + EnumChatFormatting.GOLD + + "/" + + EnumChatFormatting.WHITE + + 20; } Utils.drawStringF(totalPointsString, Minecraft.getMinecraft().fontRendererObj, guiLeft + 22, guiTop + 19, true, 0); - Utils.drawStringF(personalGoalsString, Minecraft.getMinecraft().fontRendererObj, guiLeft + 22, guiTop + 31, true, 0); + Utils.drawStringF( + personalGoalsString, + Minecraft.getMinecraft().fontRendererObj, + guiLeft + 22, + guiTop + 31, + true, + 0 + ); GlStateManager.enableLighting(); } @@ -218,7 +225,9 @@ public class BingoPage extends GuiProfileViewerPage { } finalTier++; } - double nextTier = finalTier < totalTiers ? tiers.get(totalTiers - 1).getAsLong() : tiers.get(finalTier - 1).getAsLong(); + double nextTier = finalTier < totalTiers ? tiers.get(totalTiers - 1).getAsLong() : tiers + .get(finalTier - 1) + .getAsLong(); int progressToNextTier = (int) Math.round(progress / nextTier * 100); if (progressToNextTier > 100) progressToNextTier = 100; String progressBar = generateProgressIndicator(progress, nextTier); @@ -232,34 +241,37 @@ public class BingoPage extends GuiProfileViewerPage { tooltip.add(""); tooltip.add( EnumChatFormatting.GRAY + - "Progress to " + - name + - " " + - nextTierNum + - ": " + - EnumChatFormatting.YELLOW + - progressToNextTier + - EnumChatFormatting.GOLD + - "%" + "Progress to " + + name + + " " + + nextTierNum + + ": " + + EnumChatFormatting.YELLOW + + progressToNextTier + + EnumChatFormatting.GOLD + + "%" ); tooltip.add( progressBar + - EnumChatFormatting.YELLOW + - " " + - progressString + - EnumChatFormatting.GOLD + - "/" + - EnumChatFormatting.YELLOW + - nextTierString + EnumChatFormatting.YELLOW + + " " + + progressString + + EnumChatFormatting.GOLD + + "/" + + EnumChatFormatting.YELLOW + + nextTierString ); tooltip.add(""); tooltip.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "Community Goals are"); - tooltip.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "collaborative - anyone with a"); - tooltip.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "Bingo profile can help to reach"); + tooltip.add( + EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "collaborative - anyone with a"); + tooltip.add( + EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "Bingo profile can help to reach"); tooltip.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "the goal!"); tooltip.add(""); tooltip.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "The more you contribute"); - tooltip.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "towards the goal, the more you"); + tooltip.add( + EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "towards the goal, the more you"); tooltip.add(EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "will be rewarded"); if (finalTier == totalTiers) { @@ -287,7 +299,14 @@ public class BingoPage extends GuiProfileViewerPage { private void showMissingDataMessage(int guiLeft, int guiTop) { String message = EnumChatFormatting.RED + "No Bingo data for current event!"; - Utils.drawStringCentered(message, Minecraft.getMinecraft().fontRendererObj, guiLeft + 431 / 2f, guiTop + 101, true, 0); + Utils.drawStringCentered( + message, + Minecraft.getMinecraft().fontRendererObj, + guiLeft + 431 / 2f, + guiTop + 101, + true, + 0 + ); } private List<String> jsonArrayToStringList(JsonArray completedGoals) { @@ -314,18 +333,14 @@ public class BingoPage extends GuiProfileViewerPage { if (currentTime - lastResourceRequest < 120 * 1000 && bingoGoals != null) return; lastResourceRequest = currentTime; - HashMap<String, String> args = new HashMap<>(); - NotEnoughUpdates.INSTANCE.manager.hypixelApi.getHypixelApiAsync( - NotEnoughUpdates.INSTANCE.config.apiData.apiKey, - "resources/skyblock/bingo", - args, - jsonObject -> { + NotEnoughUpdates.INSTANCE.manager.apiUtils + .newAnonymousHypixelApiRequest("resources/skyblock/bingo") + .requestJson() + .thenAccept(jsonObject -> { if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) { bingoGoals = jsonArrayToJsonObjectList(jsonObject.get("goals").getAsJsonArray()); currentEventId = jsonObject.get("id").getAsInt(); } - }, - () -> {} - ); + }); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java index 8576f141..a71c16cd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java @@ -55,7 +55,6 @@ import org.lwjgl.opengl.GL14; import org.lwjgl.opengl.GL20; import java.awt.*; -import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -166,7 +165,9 @@ public class GuiProfileViewer extends GuiScreen { NotEnoughUpdates.INSTANCE.config.profileViewer.showPronounsInPv ? Optional.ofNullable(profile).map(it -> Utils.parseDashlessUUID(it.getUuid())) : Optional.<UUID>empty(), - uuid -> CompletableFuture.supplyAsync(() -> uuid.flatMap(PronounDB::getPronounsFor)) + uuid -> uuid.isPresent() + ? PronounDB.getPronounsFor(uuid.get()) + : CompletableFuture.completedFuture(Optional.empty()) ); public final GuiElementTextField playerNameTextField; public final GuiElementTextField inventoryTextField = new GuiElementTextField("", GuiElementTextField.SCALE_TEXT); 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 c9bd92a3..ec68071e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -27,6 +27,16 @@ 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; @@ -41,15 +51,6 @@ 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 { @@ -63,311 +64,384 @@ public class ProfileViewer { 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( - "enchanting", - Utils.createItemStack(Item.getItemFromBlock(Blocks.enchanting_table), EnumChatFormatting.GREEN + "Enchanting") - ); - put( - "carpentry", - Utils.createItemStack(Item.getItemFromBlock(Blocks.crafting_table), EnumChatFormatting.DARK_RED + "Carpentry") - ); - 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 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( + "enchanting", + Utils.createItemStack(Item.getItemFromBlock(Blocks.enchanting_table), EnumChatFormatting.GREEN + "Enchanting") + ); + put( + "carpentry", + Utils.createItemStack(Item.getItemFromBlock(Blocks.crafting_table), EnumChatFormatting.DARK_RED + "Carpentry") + ); + 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( - CAT_FARMING, - Utils.createList( - "WHEAT", - "CARROT_ITEM", - "POTATO_ITEM", + private static final ItemStack CAT_FISHING = Utils.createItemStack( + Items.fishing_rod, + EnumChatFormatting.AQUA + "Fishing" + ); + private static final LinkedHashMap<ItemStack, List<String>> collectionCatToC |
