aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2024-08-13 21:35:10 +0300
committerRime <81419447+Emirlol@users.noreply.github.com>2024-08-13 21:35:29 +0300
commit6e6b19356140a047d44d3135e78caf8566d1cd10 (patch)
treea14b7ec4809a36db369067cefb8ece1cfc53098d /src/main/java
parentac08fb6514defbac92876dc70e1ba98f7504ae24 (diff)
downloadSkyblocker-6e6b19356140a047d44d3135e78caf8566d1cd10.tar.gz
Skyblocker-6e6b19356140a047d44d3135e78caf8566d1cd10.tar.bz2
Skyblocker-6e6b19356140a047d44d3135e78caf8566d1cd10.zip
Add minister to Utils and check if minister equals to Paul in DungeonScore for paul's 10 score bonus
Fixes #922
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScore.java5
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/Utils.java18
2 files changed, 16 insertions, 7 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScore.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScore.java
index d1fc08ec..eb214022 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScore.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/DungeonScore.java
@@ -1,9 +1,7 @@
package de.hysky.skyblocker.skyblock.dungeon;
-
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
-import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.config.configs.DungeonsConfig;
import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager;
@@ -21,6 +19,7 @@ import net.minecraft.entity.mob.ZombieEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.collection.DefaultedList;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -152,7 +151,7 @@ public class DungeonScore {
setCurrentFloor();
dungeonStarted = true;
puzzleCount = getPuzzleCount();
- isMayorPaul = Utils.getMayor().equals("Paul");
+ isMayorPaul = StringUtils.equalsAny("Paul", Utils.getMayor(), Utils.getMinister());
startingTime = System.currentTimeMillis();
floorRequirement = FloorRequirement.valueOf(currentFloor);
floorHasMimics = MIMIC_FLOORS_PATTERN.matcher(currentFloor).matches();
diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java
index d6c0fc5e..8336561f 100644
--- a/src/main/java/de/hysky/skyblocker/utils/Utils.java
+++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java
@@ -80,6 +80,7 @@ public class Utils {
private static boolean mayorTickScheduled = false;
private static int mayorTickRetryAttempts = 0;
private static String mayor = "";
+ private static String minister = "";
/**
* @implNote The parent text will always be empty, the actual text content is inside the text's siblings.
@@ -200,6 +201,14 @@ public class Utils {
return mayor;
}
+ /**
+ * @return the current minister as cached on skyblock join.
+ */
+ @NotNull
+ public static String getMinister() {
+ return minister;
+ }
+
public static void init() {
SkyblockEvents.JOIN.register(() -> {
if (!mayorTickScheduled) {
@@ -510,7 +519,7 @@ public class Utils {
if (!response.ok()) throw new HttpResponseException(response.statusCode(), response.content());
JsonObject json = JsonParser.parseString(response.content()).getAsJsonObject();
if (!json.get("success").getAsBoolean()) throw new RuntimeException("Request failed!"); //Can't find a more appropriate exception to throw here.
- return json.get("mayor").getAsJsonObject().get("name").getAsString();
+ return json.get("mayor").getAsJsonObject();
} catch (Exception e) {
throw new RuntimeException(e); //Wrap the exception to be handled by the exceptionally block
}
@@ -524,11 +533,12 @@ public class Utils {
} else {
LOGGER.warn("[Skyblocker] Failed to get mayor status after 5 retries! Stopping further retries until next reboot.");
}
- return ""; //Have to return a value for the thenAccept block.
+ return new JsonObject(); //Have to return a value for the thenAccept block.
}).thenAccept(result -> {
if (!result.isEmpty()) {
- mayor = result;
- LOGGER.info("[Skyblocker] Mayor set to {}.", mayor);
+ mayor = result.get("name").getAsString();
+ minister = result.getAsJsonObject("minister").get("name").getAsString();
+ LOGGER.info("[Skyblocker] Mayor set to {}, minister set to {}.", mayor, minister);
scheduleMayorTick(); //Ends up as a cyclic task with finer control over scheduled time
}
});