diff options
Diffstat (limited to 'src')
3 files changed, 31 insertions, 12 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java index 001f34d8..f49759e0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java @@ -139,7 +139,7 @@ public class Mining { "\u00a73Gemstone Powder: \u00a7d6,243", "\u00a73Forge 1) \u00a79Diamonite\u00a77: \u00a7aReady!", "\u00a73Pickaxe CD: \u00a7a78s", - "\u00a73Star Cult In: \u00a7a78s" + "\u00a73Star Cult: \u00a7a78s" } ) @ConfigAccordionId(id = 2) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java index b63456f2..025d4e21 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MiningOverlay.java @@ -427,8 +427,8 @@ public class MiningOverlay extends TextTabOverlay { break; case 5: overlayStrings.add( - DARK_AQUA + "Star Cult In: " + GREEN + - Utils.prettyTime(StarCultCalculator.getNextStarCult() - System.currentTimeMillis())); + DARK_AQUA + "Star Cult: " + GREEN + + StarCultCalculator.getNextStarCult()); break; } } @@ -455,12 +455,12 @@ public class MiningOverlay extends TextTabOverlay { if (NotEnoughUpdates.INSTANCE.config.mining.starCultDisplayEnabledLocations == 1 && !SBInfo.getInstance().isInDungeon) { overlayStrings.add( - DARK_AQUA + "Star Cult In: " + GREEN + - Utils.prettyTime(StarCultCalculator.getNextStarCult() - System.currentTimeMillis())); + DARK_AQUA + "Star Cult: " + GREEN + + StarCultCalculator.getNextStarCult()); } else if (NotEnoughUpdates.INSTANCE.config.mining.starCultDisplayEnabledLocations == 2) { overlayStrings.add( - DARK_AQUA + "Star Cult In: " + GREEN + - Utils.prettyTime(StarCultCalculator.getNextStarCult() - System.currentTimeMillis())); + DARK_AQUA + "Star Cult: " + GREEN + + StarCultCalculator.getNextStarCult()); } } } @@ -709,7 +709,7 @@ public class MiningOverlay extends TextTabOverlay { .get("DIAMOND_PICKAXE")) ); put( - "Star Cult In", + "Star Cult", NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager .getItemInformation() .get("FALLEN_STAR_HAT")) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/StarCultCalculator.java b/src/main/java/io/github/moulberry/notenoughupdates/util/StarCultCalculator.java index 61aae416..02ec5ad3 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/StarCultCalculator.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/StarCultCalculator.java @@ -51,13 +51,17 @@ public class StarCultCalculator { return (int) (currentYear + 1); } - public static long getNextStarCult() { + private static boolean active = false; + private static long activeTill = 0; + + public static String getNextStarCult() { Instant instantNow = Instant.now(); long nowEpoch = instantNow.toEpochMilli(); long currentOffset = (nowEpoch - YEAR_0) % YEAR_MS; int currentMonth = (int) Math.floorDiv(currentOffset, MONTH_MS); int currentDay = (int) Math.floorDiv((currentOffset - (long) currentMonth * MONTH_MS) % MONTH_MS, DAY_MS) + 1; + int out = 7; if (currentDay > 21) { out = 28; @@ -66,9 +70,8 @@ public class StarCultCalculator { } else if (currentDay > 7) { out = 14; } - out--; Instant cultStart = Instant.ofEpochMilli( - YEAR_0 + (getSkyblockYear() - 1) * YEAR_MS + currentMonth * MONTH_MS + out * DAY_MS); + YEAR_0 + (getSkyblockYear() - 1) * YEAR_MS + currentMonth * MONTH_MS + (out - 1) * DAY_MS); if (cultStart.isBefore(instantNow)) { int curYearCult = getSkyblockYear() - 1; if (out == 28) { @@ -82,10 +85,26 @@ public class StarCultCalculator { } else { out += 7; } + out--; cultStart = Instant.ofEpochMilli(YEAR_0 + (curYearCult) * YEAR_MS + currentMonth * MONTH_MS + out * DAY_MS); } - return cultStart.toEpochMilli(); + long l = System.currentTimeMillis(); + if (cultStart.toEpochMilli() - l <= 1000) { + active = true; + activeTill = l + 300000; + } + + if (l > activeTill) { + active = false; + activeTill = 0; + } + + if (active && activeTill != 0) { + return "Active!"; + } + + return Utils.prettyTime(cultStart.toEpochMilli() - l); } } |