aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <romangraef@gmail.com>2022-09-27 06:00:06 +0200
committernea <romangraef@gmail.com>2022-09-27 06:00:06 +0200
commit4430161f95248f3ff8ecb1e608bc575b5fce5afb (patch)
tree3859f42df716a9876fb89d5c44aa6194762b3966
parent29bc3371a62a74d2eab4fe9b6d5c820d52dbbac4 (diff)
downloadNotEnoughUpdates-4430161f95248f3ff8ecb1e608bc575b5fce5afb.tar.gz
NotEnoughUpdates-4430161f95248f3ff8ecb1e608bc575b5fce5afb.tar.bz2
NotEnoughUpdates-4430161f95248f3ff8ecb1e608bc575b5fce5afb.zip
Add custom keystore and refactor HypixelApi.java
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/auction/APIManager.java113
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/commands/misc/PronounsCommand.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java71
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/cosmetics/GuiCosmetics.java23
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/BingoPage.java97
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/GuiProfileViewer.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java838
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java192
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java12
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java174
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/PronounDB.java81
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java11
-rw-r--r--src/main/resources/neukeystore.jksbin0 -> 101958 bytes
-rw-r--r--src/main/resources/neukeystore.txt17
-rw-r--r--src/main/resources/pronoundb.jksbin1457 -> 0 bytes
16 files changed, 862 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>> 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",
+ "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(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,
+ "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>() {
+ {
+ /* 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",
- "MELON",
- "SEEDS",
+ 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(
"MUSHROOM_COLLECTION",
- "INK_SACK:3",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.red_mushroom), EnumChatFormatting.YELLOW + "Mushroom")
+ );
+ put("INK_SACK:3", Utils.createItemStack(Items.dye, EnumChatFormatting.YELLOW + "Cocoa Beans", 3));
+ put(
"CACTUS",
- "SUGAR_CANE",
- "FEATHER",
- "LEATHER",
- "PORK",
- "RAW_CHICKEN",
- "MUTTON",
- "RABBIT",
- "NETHER_STALK"
- )
- );
- put(
- CAT_MINING,
- Utils.createList(
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.cactus), EnumChatFormatting.YELLOW + "Cactus")
+ );
+ put("SUGAR_CANE", Utils.createItemStack(Items.reeds, EnumChatFormatting.YELLOW + "Sugar Cane"));
+ put("FEATHER", Utils.createItemStack(Items.feather, EnumChatFormatting.YELLOW + "Feather"));
+ put("LEATHER", Utils.createItemStack(Items.leather, EnumChatFormatting.YELLOW + "Leather"));
+ put("PORK", Utils.createItemStack(Items.porkchop, EnumChatFormatting.YELLOW + "Raw Porkchop"));
+ put("RAW_CHICKEN", Utils.createItemStack(Items.chicken, EnumChatFormatting.YELLOW + "Raw Chicken"));
+ put("MUTTON", Utils.createItemStack(Items.mutton, EnumChatFormatting.YELLOW + "Mutton"));
+ put("RABBIT", Utils.createItemStack(Items.rabbit, EnumChatFormatting.YELLOW + "Raw Rabbit"));
+ put("NETHER_STALK", Utils.createItemStack(Items.nether_wart, EnumChatFormatting.YELLOW + "Nether Wart"));
+
+ /* MINING COLLECTIONS */
+ put(
"COBBLESTONE",
- "COAL",
- "IRON_INGOT",
- "GOLD_INGOT",
- "DIAMOND",
- "INK_SACK:4",
- "EMERALD",
- "REDSTONE",
- "QUARTZ",
+ 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"));
+ put("DIAMOND", Utils.createItemStack(Items.diamond, EnumChatFormatting.GRAY + "Diamond"));
+ put("INK_SACK:4", Utils.createItemStack(Items.dye, EnumChatFormatting.GRAY + "Lapis Lazuli", 4));
+ 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",
- "GLOWSTONE_DUST",
- "GRAVEL",
- "ICE",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.obsidian), EnumChatFormatting.GRAY + "Obsidian")
+ );
+ put("GLOWSTONE_DUST", Utils.createItemStack(Items.glowstone_dust, EnumChatFormatting.GRAY + "Glowstone Dust"));
+ put("GRAVEL", Utils.createItemStack(Item.getItemFromBlock(Blocks.gravel), EnumChatFormatting.GRAY + "Gravel"));
+ put("ICE", Utils.createItemStack(Item.getItemFromBlock(Blocks.ice), EnumChatFormatting.GRAY + "Ice"));
+ put(
"NETHERRACK",
- "SAND",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.netherrack), EnumChatFormatting.GRAY + "Netherrack")
+ );
+ put("SAND", Utils.createItemStack(Item.getItemFromBlock(Blocks.sand), EnumChatFormatting.GRAY + "Sand"));
+ put(
"ENDER_STONE",
- null,
- "MITHRIL_ORE",
+ 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(
"GEMSTONE_COLLECTION",
+ Utils.createSkull(
+ EnumChatFormatting.GRAY + "Gemstone",
+ "e942eb66-a350-38e5-aafa-0dfc3e17b4ac",
+ "ewogICJ0aW1lc3RhbXAiIDogMTYxODA4Mzg4ODc3MSwKICAicHJvZmlsZUlkIiA6ICJjNTBhZmE4YWJlYjk0ZTQ1OTRiZjFiNDI1YTk4MGYwMiIsCiAgInByb2ZpbGVOYW1lIiA6ICJUd29FQmFlIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2FhYzE1ZjZmY2YyY2U5NjNlZjRjYTcxZjFhODY4NWFkYjk3ZWI3NjllMWQxMTE5NGNiYmQyZTk2NGE4ODk3OGMiCiAgICB9CiAgfQp9"
+ )
+ );
+ put(
"MYCEL",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.mycelium), EnumChatFormatting.GRAY + "Mycelium")
+ );
+ put(
"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(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",
+ 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"));
+ put("BONE", Utils.createItemStack(Items.bone, EnumChatFormatting.RED + "Bone"));
+ put("STRING", Utils.createItemStack(Items.string, EnumChatFormatting.RED + "String"));
+ put("SPIDER_EYE", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.RED + "Spider Eye"));
+ put("SULPHUR", Utils.createItemStack(Items.gunpowder, EnumChatFormatting.RED + "Gunpowder"));
+ put("ENDER_PEARL", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.RED + "Ender Pearl"));
+ put("GHAST_TEAR", Utils.createItemStack(Items.ghast_tear, EnumChatFormatting.RED + "Ghast Tear"));
+ 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"
+ )
+ );
+
+ /* FORAGING COLLECTIONS */
+ put(
+ "LOG",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Oak Wood")
+ );
+ put(
+ "LOG:1",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Spruce Wood", 1)
+ );
+ put(
+ "LOG:2",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Birch Wood", 2)
+ );
+ put(
+ "LOG_2:1",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), EnumChatFormatting.DARK_GREEN + "Dark Oak Wood", 1)
+ );
+ put(
+ "LOG_2",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), EnumChatFormatting.DARK_GREEN + "Acacia Wood")
+ );
+ put(
+ "LOG:3",
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Jungle Wood", 3)
+ );
+
+ /* FISHING COLLECTIONS */
+ put("RAW_FISH", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Raw Fish"));
+ put("RAW_FISH:1", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Raw 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",
- "CLAY_BALL",
+ Utils.createItemStack(Items.prismarine_crystals, EnumChatFormatting.AQUA + "Prismarine Crystals")
+ );
+ put("CLAY_BALL", Utils.createItemStack(Items.clay_ball, EnumChatFormatting.AQUA + "Clay"));
+ put(
"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>() {
- {
- /* 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("MELON", Utils.createItemStack(Items.melon, EnumChatFormatting.YELLOW + "Melon"));
- put("SEEDS", Utils.createItemStack(Items.wheat_seeds, EnumChatFormatting.YELLOW + "Seeds"));
- put(
- "MUSHROOM_COLLECTION",
- Utils.createItemStack(Item.getItemFromBlock(Blocks.red_mushroom), EnumChatFormatting.YELLOW + "Mushroom")
- );
- put("INK_SACK:3", Utils.createItemStack(Items.dye, EnumChatFormatting.YELLOW + "Cocoa Beans", 3));
- put("CACTUS", Utils.createItemStack(Item.getItemFromBlock(Blocks.cactus), EnumChatFormatting.YELLOW + "Cactus"));
- put("SUGAR_CANE", Utils.createItemStack(Items.reeds, EnumChatFormatting.YELLOW + "Sugar Cane"));
- put("FEATHER", Utils.createItemStack(Items.feather, EnumChatFormatting.YELLOW + "Feather"));
- put("LEATHER", Utils.createItemStack(Items.leather, EnumChatFormatting.YELLOW + "Leather"));
- put("PORK", Utils.createItemStack(Items.porkchop, EnumChatFormatting.YELLOW + "Raw Porkchop"));
- put("RAW_CHICKEN", Utils.createItemStack(Items.chicken, EnumChatFormatting.YELLOW + "Raw Chicken"));
- put("MUTTON", Utils.createItemStack(Items.mutton, EnumChatFormatting.YELLOW + "Mutton"));
- put("RABBIT", Utils.createItemStack(Items.rabbit, EnumChatFormatting.YELLOW + "Raw Rabbit"));
- 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("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"));
- put("DIAMOND", Utils.createItemStack(Items.diamond, EnumChatFormatting.GRAY + "Diamond"));
- put("INK_SACK:4", Utils.createItemStack(Items.dye, EnumChatFormatting.GRAY + "Lapis Lazuli", 4));
- 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("GLOWSTONE_DUST", Utils.createItemStack(Items.glowstone_dust, EnumChatFormatting.GRAY + "Glowstone Dust"));
- 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("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("MITHRIL_ORE", Utils.createItemStack(Items.prismarine_crystals, EnumChatFormatting.GRAY + "Mithril"));
- put("HARD_STONE", Utils.createItemStack(Item.getItemFromBlock(Blocks.stone), EnumChatFormatting.GRAY + "Hard Stone"));
- put(
- "GEMSTONE_COLLECTION",
- Utils.createSkull(
- EnumChatFormatting.GRAY + "Gemstone",
- "e942eb66-a350-38e5-aafa-0dfc3e17b4ac",
- "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"));
- put("BONE", Utils.createItemStack(Items.bone, EnumChatFormatting.RED + "Bone"));
- put("STRING", Utils.createItemStack(Items.string, EnumChatFormatting.RED + "String"));
- put("SPIDER_EYE", Utils.createItemStack(Items.spider_eye, EnumChatFormatting.RED + "Spider Eye"));
- put("SULPHUR", Utils.createItemStack(Items.gunpowder, EnumChatFormatting.RED + "Gunpowder"));
- put("ENDER_PEARL", Utils.createItemStack(Items.ender_pearl, EnumChatFormatting.RED + "Ender Pearl"));
- put("GHAST_TEAR", Utils.createItemStack(Items.ghast_tear, EnumChatFormatting.RED + "Ghast Tear"));
- 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"
- )
- );
-
- /* FORAGING COLLECTIONS */
- put("LOG", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Oak Wood"));
- put("LOG:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Spruce Wood", 1));
- put("LOG:2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Birch Wood", 2));
- put("LOG_2:1", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), EnumChatFormatting.DARK_GREEN + "Dark Oak Wood", 1));
- put("LOG_2", Utils.createItemStack(Item.getItemFromBlock(Blocks.log2), EnumChatFormatting.DARK_GREEN + "Acacia Wood"));
- put("LOG:3", Utils.createItemStack(Item.getItemFromBlock(Blocks.log), EnumChatFormatting.DARK_GREEN + "Jungle Wood", 3));
-
- /* FISHING COLLECTIONS */
- put("RAW_FISH", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Raw Fish"));
- put("RAW_FISH:1", Utils.createItemStack(Items.fish, EnumChatFormatting.AQUA + "Raw 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("CLAY_BALL", Utils.createItemStack(Items.clay_ball, EnumChatFormatting.AQUA + "Clay"));
- put("WATER_LILY", Utils.createItemStack(Item.getItemFromBlock(Blocks.waterlily), EnumChatFormatting.AQUA + "Lily Pad"));
- put("INK_SACK", Utils.createItemStack(Items.dye, EnumChatFormatting.AQUA + "Ink Sac"));
- put("SPONGE", Utils.createItemStack(Item.getItemFromBlock(Blocks.sponge), EnumChatFormatting.AQUA + "Sponge"));
- put(
- "MAGMA_FISH",
- Utils.createSkull(
- EnumChatFormatting.AQUA + "Magmafish",
- "5c53195c-5b98-3476-9731-c32647b22723",
- "ewogICJ0aW1lc3RhbXAiIDogMTY0MjQ4ODA3MDY2NiwKICAicHJvZmlsZUlkIiA6ICIzNDkxZjJiOTdjMDE0MWE2OTM2YjFjMjJhMmEwMGZiNyIsCiAgInByb2ZpbGVOYW1lIiA6ICJKZXNzc3N1aGgiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjU2YjU5NTViMjk1NTIyYzk2ODk0ODE5NjBjMDFhOTkyY2ExYzc3NTRjZjRlZTMxM2M4ZGQwYzM1NmQzMzVmIgogICAgfQogIH0KfQ"
- )
- );
- }
- };
+ Utils.createItemStack(Item.getItemFromBlock(Blocks.waterlily), EnumChatFormatting.AQUA + "Lily Pad")
+ );
+ put("INK_SACK", Utils.createItemStack(Items.dye, EnumChatFormatting.AQUA + "Ink Sac"));
+ put("SPONGE", Utils.createItemStack(Item.getItemFromBlock(Blocks.sponge), EnumChatFormatting.AQUA + "Sponge"));
+ put(
+ "MAGMA_FISH",
+ Utils.createSkull(
+ EnumChatFormatting.AQUA + "Magmafish",
+ "5c53195c-5b98-3476-9731-c32647b22723",
+ "ewogICJ0aW1lc3RhbXAiIDogMTY0MjQ4ODA3MDY2NiwKICAicHJvZmlsZUlkIiA6ICIzNDkxZjJiOTdjMDE0MWE2OTM2YjFjMjJhMmEwMGZiNyIsCiAgInByb2ZpbGVOYW1lIiA6ICJKZXNzc3N1aGgiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjU2YjU5NTViMjk1NTIyYzk2ODk0ODE5NjBjMDFhOTkyY2ExYzc3NTRjZjRlZTMxM2M4ZGQwYzM1NmQzMzVmIgogICAgfQogIH0KfQ"
+ )
+ );
+ }
+ };
private static final AtomicBoolean updatingResourceCollection = new AtomicBoolean(false);
private static JsonObject resourceCollection = null;
private final NEUManager manager;
@@ -437,49 +511,42 @@ public class ProfileViewer {
updatingResourceCollection.set(true);
- HashMap<String, String> args = new HashMap<>();
- NotEnoughUpdates.INSTANCE.manager.hypixelApi.getHypixelApiAsync(
- NotEnoughUpdates.INSTANCE.config.apiData.apiKey,
- "resources/skyblock/collections",
- args,
- jsonObject -> {
+ NotEnoughUpdates.INSTANCE.manager.apiUtils
+ .newHypixelApiRequest("resources/skyblock/collections")
+ .requestJson()
+ .thenAccept(jsonObject -> {
updatingResourceCollection.set(false);
if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
resourceCollection = jsonObject.get("collections").getAsJsonObject();
}
- },
- () -> updatingResourceCollection.set(false)
- );
-
+ });
return null;
}
public void getHypixelProfile(String name, Consumer<JsonObject> callback) {
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()
- ) {
- nameToUuid.put(nameF, jsonObject.get("player").getAsJsonObject().get("uuid").getAsString());
- uuidToHypixelProfile.put(
- jsonObject.get("player").getAsJsonObject().get("uuid").getAsString(),
- jsonObject.get("player").getAsJsonObject()
- );
- if (callback != null) callback.accept(jsonObject);
- } else {
- if (callback != null) callback.accept(null);
+ manager.apiUtils
+ .newHypixelApiRequest("player")
+ .queryArgument("name", nameF)
+ .requestJson()
+ .thenAccept(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(),
+ jsonObject.get("player").getAsJsonObject()
+ );
+ if (callback != null) callback.accept(jsonObject);
+ } else {
+ if (callback != null) callback.accept(null);
+ }
}
- }
- );
+ );
}
public void putNameUuid(String name, String uuid) {
@@ -493,19 +560,20 @@ 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.apiUtils
+ .request()
+ .url("https://api.mojang.com/users/profiles/minecraft/" + nameF)
+ .requestJson()
+ .thenAccept(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)
- );
+ });
}
public void getProfileByName(String name, Consumer<Profile> callback) {
@@ -608,20 +676,18 @@ public class ProfileViewer {
HashMap<String, String> args = new HashMap<>();
args.put("uuid", "" + uuid);
- manager.hypixelApi.getHypixelApiAsync(
- NotEnoughUpdates.INSTANCE.config.apiData.apiKey,
- "status",
- args,
- jsonObject -> {
+ manager.apiUtils
+ .newHypixelApiRequest("status")
+ .queryArgument("uuid", "" + uuid)
+ .requestJson()
+ .handle((jsonObject, ex) -> {
updatingPlayerStatusState.set(false);
if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
playerStatus = jsonObject.get("session").getAsJsonObject();
}
- },
- () -> updatingPlayerStatusState.set(false)
- );
-
+ return null;
+ });
return null;
}
@@ -634,13 +700,11 @@ public class ProfileViewer {
lastBingoInfoState = currentTime;
updatingBingoInfo.set(true);
- HashMap<String, String> args = new HashMap<>();
- args.put("uuid", "" + uuid);
- NotEnoughUpdates.INSTANCE.manager.hypixelApi.getHypixelApiAsync(
- NotEnoughUpdates.INSTANCE.config.apiData.apiKey,
- "skyblock/bingo",
- args,
- jsonObject -> {
+ NotEnoughUpdates.INSTANCE.manager.apiUtils
+ .newHypixelApiRequest("skyblock/bingo")
+ .queryArgument("uuid", "" + uuid)
+ .requestJson()
+ .handle(((jsonObject, throwable) -> {
updatingBingoInfo.set(false);
if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
@@ -648,9 +712,8 @@ public class ProfileViewer {
} else {
bingoInformation = null;
}
- },
- () -> updatingBingoInfo.set(false)
- );
+ return null;
+ }));
return bingoInformation != null ? bingoInformation : null;
}
@@ -726,7 +789,8 @@ public class ProfileViewer {
}
}
}
- } catch (IOException ignored) {}
+ } catch (IOException ignored) {
+ }
int count = 1;
if (element.getAsJsonObject().has("count")) {
@@ -791,17 +855,15 @@ public class ProfileViewer {
lastPlayerInfoState = currentTime;
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 -> {
+ manager.apiUtils
+ .newHypixelApiRequest("skyblock/profiles")
+ .queryArgument("uuid", "" + uuid)
+ .requestJson()
+ .handle((jsonObject, throwable) -> {
updatingSkyblockProfilesState.set(false);
if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- if (!jsonObject.has("profiles")) return;
+ if (!jsonObject.has("profiles")) return null;
skyblockProfiles = jsonObject.get("profiles").getAsJsonArray();
String lastCuteName = null;
@@ -840,10 +902,8 @@ public class ProfileViewer {
if (runnable != null) runnable.run();
}
- },
- () -> updatingSkyblockProfilesState.set(false)
- );
-
+ return null;
+ });
return null;
}
@@ -856,26 +916,22 @@ public class ProfileViewer {
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.apiUtils
+ .newHypixelApiRequest("guild")
+ .queryArgument("player", "" + uuid)
+ .requestJson()
+ .handle((jsonObject, ex) -> {
updatingGuildInfoState.set(false);
if (jsonObject != null && jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) {
- if (!jsonObject.has("guild")) return;
+ if (!jsonObject.has("guild")) return null;
guildInformation = jsonObject.get("guild").getAsJsonObject();
if (runnable != null) runnable.run();
}
- },
- () -> updatingGuildInfoState.set(false)
- );
-
+ return null;
+ });
return null;
}
@@ -1013,11 +1069,11 @@ public class ProfileViewer {
int maxLevel =
getCap(leveling, skillName) +
- (
- skillName.equals("farming")
- ? Utils.getElementAsInt(Utils.getElement(profileInfo, "jacob2.perks.farming_level_cap"), 0)
- : 0
- );
+ (
+ skillName.equals("farming")
+ ? Utils.getElementAsInt(Utils.getElement(profileInfo, "jacob2.perks.farming_level_cap"), 0)
+ : 0
+ );
out.put(skillName, getLevel(levelingArray, skillExperience, maxLevel, false));
}
@@ -1065,7 +1121,10 @@ public class ProfileViewer {
List<String> slayers = Arrays.asList("zombie", "spider", "wolf", "enderman", "blaze");
for (String slayerName : slayers) {
- float slayerExperience = Utils.getElementAsFloat(Utils.getElement(profileInfo, "slayer_bosses." + slayerName + ".xp"), 0);
+ float slayerExperience = Utils.getElementAsFloat(Utils.getElement(
+ profileInfo,
+ "slayer_bosses." + slayerName + ".xp"
+ ), 0);
out.put(
slayerName,
getLevel(Utils.getElement(leveling, "slayer_xp." + slayerName).getAsJsonArray(), slayerExperience, 9, true)
@@ -1135,7 +1194,7 @@ public class ProfileViewer {
JsonObject inventoryInfo = new JsonObject();
- String[] inv_names = new String[] {
+ String[] inv_names = new String[]{
"inv_armor",
"fishing_bag",
"quiver",
@@ -1149,7 +1208,7 @@ public class ProfileViewer {
"candy_inventory_contents",
"equippment_contents",
};
- String[] inv_bytes = new String[] {
+ String[] inv_bytes = new String[]{
inv_armor_bytes,
fishing_bag_bytes,
quiver_bytes,
@@ -1244,7 +1303,8 @@ public class ProfileViewer {
JsonObject item = manager.getJsonFromNBTEntry(items.getCompoundTagAt(j));
contents.add(item);
}
- } catch (IOException ignored) {}
+ } catch (IOException ignored) {
+ }
}
JsonObject bundledReturn = new JsonObject();
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java
new file mode 100644
index 00000000..f8004345
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2022 NotEnoughUpdates contributors
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.util;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.message.BasicNameValuePair;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.zip.GZIPInputStream;
+
+public class ApiUtil {
+ private static final Gson gson = new Gson();
+ private static final ExecutorService executorService = Executors.newFixedThreadPool(3);
+ private static final String USER_AGENT = "NotEnoughUpdates/" + NotEnoughUpdates.VERSION;
+ private static SSLContext ctx;
+
+ static {
+ try {
+ KeyStore letsEncryptStore = KeyStore.getInstance("JKS");
+ letsEncryptStore.load(ApiUtil.class.getResourceAsStream("/neukeystore.jks"), "neuneu".toCharArray());
+ ctx = SSLContext.getInstance("TLS");
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ kmf.init(letsEncryptStore, null);
+ tmf.init(letsEncryptStore);
+ ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
+ } catch (KeyStoreException | NoSuchAlgorithmException | KeyManagementException | UnrecoverableKeyException |
+ IOException | CertificateException e) {
+ System.out.println("Failed to load NEU keystore. A lot of API requests won't work");
+ e.printStackTrace();
+ }
+ }
+
+ public static class Request {
+
+ private final List<NameValuePair> queryArguments = new ArrayList<>();
+ private String baseUrl = null;
+ private boolean shouldGunzip = false;
+ private String method = "GET";
+
+ public Request method(String method) {
+ this.method = method;
+ return this;
+ }
+
+ public Request url(String baseUrl) {
+ this.baseUrl = baseUrl;
+ return this;
+ }
+
+ public Request queryArgument(String key, String value) {
+ queryArguments.add(new BasicNameValuePair(key, value));
+ return this;
+ }
+
+ public Request queryArguments(Collection<NameValuePair> queryArguments) {
+ this.queryArguments.addAll(queryArguments);
+ return this;
+ }
+
+ public Request gunzip() {
+ shouldGunzip = true;
+ return this;
+ }
+
+ private CompletableFuture<URL> buildUrl() {
+ CompletableFuture<URL> fut = new CompletableFuture<>();
+ try {
+ fut.complete(new URIBuilder(baseUrl)
+ .addParameters(queryArguments)
+ .build()
+ .toURL());
+ } catch (URISyntaxException |
+ MalformedURLException |
+ NullPointerException e) { // Using CompletableFuture as an exception monad, isn't that exiting?
+ fut.completeExceptionally(e);
+ }
+ return fut;
+ }
+
+ public CompletableFuture<String> requestString() {
+ return buildUrl().thenApplyAsync(url -> {
+ try {
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ if (conn instanceof HttpsURLConnection && ctx != null) {
+ HttpsURLConnection sslConn = (HttpsURLConnection) conn;
+ sslConn.setSSLSocketFactory(ctx.getSocketFactory());
+ }
+ conn.setConnectTimeout(10000);
+ conn.setReadTimeout(10000);
+ conn.setRequestProperty("User-Agent", USER_AGENT);
+ conn.setRequestMethod(method);
+
+ InputStream inputStream = conn.getInputStream();
+
+ if (shouldGunzip) {
+ inputStream = new GZIPInputStream(inputStream);
+ }
+
+ // While the assumption of UTF8 isn't always true; it *should* always be true.
+ // Not in the sense that this will hold in most cases (although that as well),
+ // but in the sense that any violation of this better have a good reason.
+ return IOUtils.toString(inputStream, StandardCharsets.UTF_8);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e); // We can rethrow, since supplyAsync catches exceptions.
+ }
+ }, executorService);
+ }
+
+ public CompletableFuture<JsonObject> requestJson() {
+ return requestJson(JsonObject.class);
+ }
+
+ public <T> CompletableFuture<T> requestJson(Class<? extends T> clazz) {
+ return requestString().thenApply(str -> gson.fromJson(str, clazz));
+ }
+
+ }
+
+ public Request request() {
+ return new Request();
+ }
+
+ public Request newHypixelApiRequest(String apiPath) {
+ return newAnonymousHypixelApiRequest(apiPath)
+ .queryArgument("key", NotEnoughUpdates.INSTANCE.config.apiData.apiKey);
+ }
+
+ public Request newAnonymousHypixelApiRequest(String apiPath) {
+ return new Request()
+ .url("https://api.hypixel.net/" + apiPath);
+ }
+
+ public Request newMoulberryRequest(String path) {
+ return new Request()
+ .url(getMyApiURL() + path);
+ }
+
+ private String getMyApiURL() {
+ return String.format("https://%s/", NotEnoughUpdates.INSTANCE.config.apiData.moulberryCodesApi);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java
index c97a37d9..1968b51e 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HotmInformation.java
@@ -159,13 +159,11 @@ public class HotmInformation {
public synchronized void requestUpdate(boolean force) {
if (updateTask.isDone() || force) {
- updateTask = neu.manager.hypixelApi.getHypixelApiAsync(
- neu.config.apiData.apiKey,
- "skyblock/profiles",
- new HashMap<String, String>() {{
- put("uuid", Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""));
- }}
- ).thenAccept(this::updateInformation);
+ updateTask = neu.manager.apiUtils
+ .newHypixelApiRequest("skyblock/profiles")
+ .queryArgument("uuid", Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""))
+ .requestJson()
+ .thenAccept(this::updateInformation);
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
deleted file mode 100644
index 3e38fd2e..00000000
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
- *
- * This file is part of NotEnoughUpdates.
- *
- * NotEnoughUpdates is free software: you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation, either
- * version 3 of the License, or (at your option) any later version.
- *
- * NotEnoughUpdates is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package io.github.moulberry.notenoughupdates.util;
-
-import com.google.gson.Gson;
-import com.google.gson.JsonObject;
-import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import org.apache.commons.io.IOUtils;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.ConnectException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.function.Consumer;
-import java.util.zip.GZIPInputStream;
-
-public class HypixelApi {
- private final Gson gson = new Gson();
- private final ExecutorService es = Executors.newFixedThreadPool(3);
-
- public CompletableFuture<JsonObject> getHypixelApiAsync(String apiKey, String method, HashMap<String, String> args) {
- return getApiAsync(generateApiUrl(apiKey, method, args));
- }
-
- public void getHypixelApiAsync(
- String apiKey,
- String method,
- HashMap<String, String> args,
- Consumer<JsonObject> consumer
- ) {
- getHypixelApiAsync(apiKey, method, args, consumer, () -> {
- });
- }
-
- public void getHypixelApiAsync(
- String apiKey,
- String method,
- HashMap<String, String> args,
- Consumer<JsonObject> consumer,
- Runnable error
- ) {
- getApiAsync(generateApiUrl(apiKey, method, args), consumer, error);
- }
-
- private String getMyApiURL() {
- return String.format("https://%s/", NotEnoughUpdates.INSTANCE.config.apiData.moulberryCodesApi);
- }
-
- public CompletableFuture<JsonObject> getApiAsync(String urlS) {
- CompletableFuture<JsonObject> result = new CompletableFuture<>();
- es.submit(() -> {
- try {
- result.complete(getApiSync(urlS));
- } catch (Exception e) {
- result.completeExceptionally(e);
- }
- });
- return result;
- }
-
- public void getApiAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
- es.submit(() -> {
- try {
- consumer.accept(getApiSync(urlS));
- } catch (Exception e) {
- error.run();
- }
- });
- }
-
- public void getMyApiAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
- es.submit(() -> {
- try {
- consumer.accept(getApiSync(getMyApiURL() + urlS));
- } catch (Exception e) {
- if (NotEnoughUpdates.INSTANCE.config.hidden.dev) {
- e.printStackTrace();
- }
- error.run();
- }
- });
- }
-
- public void getMyApiGZIPAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
- es.submit(() -> {
- try {
- consumer.accept(getApiGZIPSync(getMyApiURL() + urlS));
- } catch (Exception e) {
- error.run();
- }
- });
- }
-
- public void getApiGZIPAsync(String urlS, Consumer<JsonObject> consumer, Runnable error) {
- es.submit(() -> {
- try {
- consumer.accept(getApiGZIPSync(urlS));
- } catch (Exception e) {
- error.run();
- }
- });
- }
-
- public JsonObject getApiSync(String urlS) throws IOException {
- URL url = new URL(urlS);
- URLConnection connection = url.openConnection();
- connection.setConnectTimeout(10000);
- connection.setReadTimeout(10000);
-
- String response = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);
-
- JsonObject json = gson.fromJson(response, JsonObject.class);
- if (json == null) throw new ConnectException("Invalid JSON");
- return json;
- }
-
- public JsonObject getApiGZIPSync(String urlS) throws IOException {
- URL url = new URL(urlS);
- URLConnection connection = url.openConnection();
- connection.setConnectTimeout(10000);
- connection.setReadTimeout(10000);
-
- String response = IOUtils.toString(new GZIPInputStream(connection.getInputStream()), StandardCharsets.UTF_8);
-
- JsonObject json = gson.fromJson(response, JsonObject.class);
- return json;
- }
-
- public String generateApiUrl(String apiKey, String method, HashMap<String, String> args) {
- if (apiKey != null)
- args.put("key", apiKey.trim());
- StringBuilder url = new StringBuilder("https://api.hypixel.net/" + method);
- boolean first = true;
- for (Map.Entry<String, String> entry : args.entrySet()) {
- if (first) {
- url.append("?");
- first = false;
- } else {
- url.append("&");
- }
- try {
- url.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8.name())).append("=")
- .append(URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.name()));
- } catch (UnsupportedEncodingException e) {
- }
- }
- return url.toString();
- }
-}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/PronounDB.java b/src/main/java/io/github/moulberry/notenoughupdates/util/PronounDB.java
index e7286721..625f92f7 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/PronounDB.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/PronounDB.java
@@ -21,50 +21,17 @@ package io.github.moulberry.notenoughupdates.util;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
-import io.github.moulberry.notenoughupdates.core.util.StringUtils;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManagerFactory;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
+
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
public class PronounDB {
- static SSLContext ctx;
-
- static {
- try {
- KeyStore ks = KeyStore.getInstance("JKS");
- ks.load(PronounDB.class.getResourceAsStream("/pronoundb.jks"), "pronoundb".toCharArray());
- ctx = SSLContext.getInstance("TLS");
- KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
- kmf.init(ks, null);
- tmf.init(ks);
- ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
- } catch (KeyStoreException | NoSuchAlgorithmException | KeyManagementException | UnrecoverableKeyException |
- IOException | CertificateException e) {
- System.out.println("Failed to load keystore. PronounDB requests will probably not work");
- e.printStackTrace();
- }
- }
-
private static boolean isDisabled() {
JsonObject disabled = Constants.DISABLE;
return disabled != null && disabled.has("pronoundb");
@@ -73,22 +40,15 @@ public class PronounDB {
/**
* Returns an Optional, since JVMs can be *very* funky with KeyStore loading
*/
- public static Optional<JsonObject> performPronouning(String platform, String id) {
- if (isDisabled()) return Optional.empty();
- try {
- URL url = new URL("https://pronoundb.org/api/v1/lookup" +
- "?platform=" + StringUtils.urlEncode(platform) +
- "&id=" + StringUtils.urlEncode(id));
- HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
- urlConnection.setSSLSocketFactory(ctx.getSocketFactory());
- return Optional.of(NotEnoughUpdates.INSTANCE.manager.gson.fromJson(
- new InputStreamReader(urlConnection.getInputStream()),
- JsonObject.class
- ));
- } catch (ClassCastException | IOException | JsonParseException e) {
- System.out.println("Failed to contact PronounDB: " + e);
- return Optional.empty();
- }
+ public static CompletableFuture<Optional<JsonObject>> performPronouning(String platform, String id) {
+ if (isDisabled()) return CompletableFuture.completedFuture(Optional.empty());
+ return NotEnoughUpdates.INSTANCE.manager.apiUtils
+ .request()
+ .url("https://pronoundb.org/api/v1/lookup")
+ .queryArgument("platform", platform)
+ .queryArgument("id", id)
+ .requestJson()
+ .handle((result, ex) -> Optional.ofNullable(result));
}
public enum Pronoun {
@@ -199,23 +159,20 @@ public class PronounDB {
return Optional.empty();
}
- public static Optional<PronounChoice> getPronounsFor(String platform, String name) {
- return performPronouning(platform, name).flatMap(PronounDB::parsePronouns);
+ public static CompletableFuture<Optional<PronounChoice>> getPronounsFor(String platform, String name) {
+ return performPronouning(platform, name).thenApply(it -> it.flatMap(PronounDB::parsePronouns));
}
- public static Optional<PronounChoice> getPronounsFor(UUID minecraftPlayer) {
- return performPronouning("minecraft", minecraftPlayer.toString() /* dashed UUID */)
- .flatMap(PronounDB::parsePronouns);
+ public static CompletableFuture<Optional<PronounChoice>> getPronounsFor(UUID minecraftPlayer) {
+ return getPronounsFor("minecraft", minecraftPlayer.toString() /* dashed UUID */);
}
public static void test() {
- try {
- System.out.println("Pronouning...");
- PronounChoice pronounsFor = getPronounsFor(UUID.fromString("842204e6-6880-487b-ae5a-0595394f9948")).get();
+ System.out.println("Pronouning...");
+ getPronounsFor(UUID.fromString("842204e6-6880-487b-ae5a-0595394f9948")).thenAccept(it -> {
+ PronounChoice pronounsFor = it.get();
pronounsFor.render().forEach(System.out::println);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ });
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
index 4e920aea..f3a09fcc 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java
@@ -61,8 +61,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -431,11 +429,10 @@ public class SBInfo {
}
public void updateMayor() {
- NotEnoughUpdates.INSTANCE.manager.hypixelApi.getHypixelApiAsync(
- NotEnoughUpdates.INSTANCE.config.apiData.apiKey,
- "resources/skyblock/election",
- new HashMap<>()
- ).thenAcceptAsync(newJson -> mayorJson = newJson);
+ NotEnoughUpdates.INSTANCE.manager.apiUtils
+ .newHypixelApiRequest("resources/skyblock/election")
+ .requestJson()
+ .thenAccept(newJson -> mayorJson = newJson);
}
diff --git a/src/main/resources/neukeystore.jks b/src/main/resources/neukeystore.jks
new file mode 100644
index 00000000..3a5a23b6
--- /dev/null
+++ b/src/main/resources/neukeystore.jks
Binary files differ
diff --git a/src/main/resources/neukeystore.txt b/src/main/resources/neukeystore.txt
new file mode 100644
index 00000000..5616f69b
--- /dev/null
+++ b/src/main/resources/neukeystore.txt
@@ -0,0 +1,17 @@
+neukeystore.jks
+===============
+
+This file should only ever be handled by a `keytool` binary from jdk 1.8u51 or below, as to be compatible with old java versions.
+
+The password to the keystore is `neuneu` and it contains every certificate from jdk 1.8u51 and the Let's Encrypt root CAs.
+
+Example for adding a new certificate:
+
+ ~/.jdks/jdk1.8.0_51/bin/keytool -keystore neukeystore.jks -storepass neuneu -alias ISRGROOTX1 -import -file isrgrootx1.der
+
+Please keep a list of added aliases below:
+
+ - ISRGROOTX1 (Let's Encrypt)
+ - ISRGROOTX2 (Let's Encrypt)
+
+
diff --git a/src/main/resources/pronoundb.jks b/src/main/resources/pronoundb.jks
deleted file mode 100644
index 1c279333..00000000
--- a/src/main/resources/pronoundb.jks
+++ /dev/null
Binary files differ