aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-04-04 20:30:46 +0200
committerGitHub <noreply@github.com>2024-04-04 20:30:46 +0200
commit704b90b4a25a88cb3ad33fa77a1b9423caaf472d (patch)
treef53caad245fdff5f733c80cc28b04bb8c25bcce2 /src/main/java/at/hannibal2
parentd48cf0126f9c163dd85c860004f658167912c85c (diff)
downloadskyhanni-704b90b4a25a88cb3ad33fa77a1b9423caaf472d.tar.gz
skyhanni-704b90b4a25a88cb3ad33fa77a1b9423caaf472d.tar.bz2
skyhanni-704b90b4a25a88cb3ad33fa77a1b9423caaf472d.zip
Feature: No Bits Warning (#1286)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt22
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/BitsUpdateEvent.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt30
6 files changed, 61 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index e749f688f..f322f0424 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -286,6 +286,7 @@ import at.hannibal2.skyhanni.features.misc.LockMouseLook
import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager
import at.hannibal2.skyhanni.features.misc.MiscFeatures
import at.hannibal2.skyhanni.features.misc.MovementSpeedDisplay
+import at.hannibal2.skyhanni.features.misc.NoBitsWarning
import at.hannibal2.skyhanni.features.misc.NonGodPotEffectDisplay
import at.hannibal2.skyhanni.features.misc.ParticleHider
import at.hannibal2.skyhanni.features.misc.PartyMemberOutlines
@@ -817,6 +818,7 @@ class SkyHanniMod {
loadModule(RareDropMessages())
loadModule(CraftMaterialsFromBazaar())
loadModule(PestProfitTracker)
+ loadModule(NoBitsWarning())
init()
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
index 5d58664fc..70593baf7 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
@@ -131,6 +131,12 @@ public class MiscConfig {
public boolean colorMonthNames = false;
@Expose
+ @ConfigOption(name = "No Bits Warning", desc = "Alerts you when you have no bits available.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean noBitsWarning = true;
+
+ @Expose
@ConfigOption(name = "Explosions Hider", desc = "Hide explosions.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java
index 1f9be2875..862dfea45 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/storage/Storage.java
@@ -46,6 +46,6 @@ public class Storage {
public Map<UUID, PlayerSpecificStorage> players = new HashMap<>();
@Expose
- public String currentFameRank = null;
+ public String currentFameRank = "New player";
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt
index 65af5b8bd..54131f4bf 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/BitsAPI.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.FameRanks.getFameRankByNameOrNull
+import at.hannibal2.skyhanni.events.BitsUpdateEvent
import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.ScoreboardChangeEvent
@@ -117,8 +118,8 @@ object BitsAPI {
if (amount > bits) {
bitsToClaim -= amount - bits
ChatUtils.debug("You have gained §3${amount - bits} Bits §7according to the scoreboard!")
+ sendEvent()
}
- bits = amount
return
}
@@ -133,12 +134,14 @@ object BitsAPI {
bitsFromFameRankUpChatPattern.matchMatcher(message) {
val amount = group("amount").formatInt()
bitsToClaim += amount
+ sendEvent()
return
}
boosterCookieAte.matchMatcher(message) {
bitsToClaim += (defaultcookiebits * (currentFameRank?.bitsMultiplier ?: return)).toInt()
+ sendEvent()
return
}
@@ -161,7 +164,11 @@ object BitsAPI {
for (line in cookieStack.getLore()) {
bitsAvailableMenuPattern.matchMatcher(line) {
- bitsToClaim = group("toClaim").formatInt()
+ val amount = group("toClaim").formatInt()
+ if (bitsToClaim != amount) {
+ bitsToClaim = amount
+ sendEvent()
+ }
return
}
@@ -207,7 +214,12 @@ object BitsAPI {
line@ for (line in bitsStack.getLore()) {
bitsAvailableMenuPattern.matchMatcher(line) {
- bitsToClaim = group("toClaim").formatInt()
+ val amount = group("toClaim").formatInt()
+ if (amount != bitsToClaim) {
+ bitsToClaim = amount
+ sendEvent()
+ }
+
continue@line
}
@@ -215,6 +227,10 @@ object BitsAPI {
}
}
+ private fun sendEvent() {
+ BitsUpdateEvent(bits, bitsToClaim).postAndCatch()
+ }
+
fun isEnabled() = LorenzUtils.inSkyBlock && profileStorage != null
class FameRankNotFoundException(rank: String) : Exception("FameRank not found: $rank")
diff --git a/src/main/java/at/hannibal2/skyhanni/events/BitsUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BitsUpdateEvent.kt
new file mode 100644
index 000000000..3bdbf286d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/BitsUpdateEvent.kt
@@ -0,0 +1,3 @@
+package at.hannibal2.skyhanni.events
+
+class BitsUpdateEvent(val bits: Int, val bitsToClaim: Int) : LorenzEvent()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt
new file mode 100644
index 000000000..0b2e6069e
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NoBitsWarning.kt
@@ -0,0 +1,30 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.BitsUpdateEvent
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.SoundUtils.createSound
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
+
+class NoBitsWarning {
+
+ private val config get() = SkyHanniMod.feature.misc.noBitsWarning
+
+ @SubscribeEvent
+ fun onBitsUpdate(event: BitsUpdateEvent) {
+ if (!isEnabled()) return
+ if (event.bitsToClaim != 0) return
+
+ ChatUtils.clickableChat(
+ "§bNo Bits Available! §eClick to run /bz booster cookie.",
+ "bz booster cookie"
+ )
+ LorenzUtils.sendTitle("§bNo Bits Available", 5.seconds)
+ SoundUtils.repeatSound(100,10, createSound("note.pling", 0.6f))
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config
+}