aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-09-09 14:01:10 +0200
committerLorenz <lo.scherf@gmail.com>2022-09-09 14:01:10 +0200
commita402490155575059f5a335ad0568f92d49bc86e3 (patch)
treeccb67b4c6dfd90b717f0127ea61689e916e3eab8 /src/main/java
parent0e7363d2c24902ec2817cf47f2cfe8510a0544c3 (diff)
downloadNotEnoughUpdates-a402490155575059f5a335ad0568f92d49bc86e3.tar.gz
NotEnoughUpdates-a402490155575059f5a335ad0568f92d49bc86e3.tar.bz2
NotEnoughUpdates-a402490155575059f5a335ad0568f92d49bc86e3.zip
show api error message
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java4
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java14
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java6
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java4
4 files changed, 24 insertions, 4 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
index 50a267a4..8df6cebf 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
@@ -88,6 +88,10 @@ public class MinionHelperManager {
return !repo.isReadyToUse() || !api.isReadyToUse();
}
+ public boolean isInvalidApiKey() {
+ return api.isInvalidApiKey();
+ }
+
public Minion getMinionById(String internalName) {
if (minions.containsKey(internalName)) {
return minions.get(internalName);
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java
index 3b3ed64c..adaf782b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java
@@ -53,6 +53,7 @@ public class MinionHelperApiLoader {
private ApiData apiData = null;
private boolean notifyNoCollectionApi = false;
private long lastLoaded = 0;
+ private boolean invalidApiKey = false;
public MinionHelperApiLoader(MinionHelperManager manager) {
this.manager = manager;
@@ -84,7 +85,6 @@ public class MinionHelperApiLoader {
}
private void load() {
- System.out.println("load");
lastLoaded = System.currentTimeMillis();
EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer;
if (thePlayer == null) return;
@@ -104,7 +104,12 @@ public class MinionHelperApiLoader {
}
private void updateInformation(JsonObject entireApiResponse) {
- System.out.println("updateInformation");
+ if (entireApiResponse == null) {
+ invalidApiKey = true;
+ return;
+ }
+ invalidApiKey = false;
+
if (!entireApiResponse.has("success") || !entireApiResponse.get("success").getAsBoolean()) return;
JsonArray profiles = entireApiResponse.getAsJsonArray("profiles");
for (JsonElement element : profiles) {
@@ -124,7 +129,6 @@ public class MinionHelperApiLoader {
}
private void readData(JsonObject player, JsonObject members) {
- System.out.println("readData");
int magesReputation = 0;
int barbariansReputation = 0;
if (player.has("nether_island_player_data")) {
@@ -290,4 +294,8 @@ public class MinionHelperApiLoader {
public boolean isNotifyNoCollectionApi() {
return notifyNoCollectionApi;
}
+
+ public boolean isInvalidApiKey() {
+ return invalidApiKey;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java
index 36113418..afefd1b2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/render/MinionHelperOverlay.java
@@ -87,6 +87,12 @@ public class MinionHelperOverlay {
public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event) {
if (!manager.inCraftedMinionsInventory()) return;
if (!NotEnoughUpdates.INSTANCE.config.minionHelper.gui) return;
+ if (manager.isInvalidApiKey()) {
+ LinkedHashMap<String, OverviewLine> map = new LinkedHashMap<>();
+ map.put("§cInvalid API Key!", new OverviewText(Collections.emptyList(), () -> {}));
+ render(map);
+ return;
+ }
if (manager.notReady()) {
LinkedHashMap<String, OverviewLine> map = new LinkedHashMap<>();
map.put("§cLoading...", new OverviewText(Collections.emptyList(), () -> {}));
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
index 3e38fd2e..eb4ca90b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/HypixelApi.java
@@ -77,7 +77,9 @@ public class HypixelApi {
try {
result.complete(getApiSync(urlS));
} catch (Exception e) {
- result.completeExceptionally(e);
+ //I don't think that it is supposed to work this way, but completeExceptionally causes this method to never return and complete null does work for me needs
+ result.complete(null);
+// result.completeExceptionally(e);
}
});
return result;