aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/fishing/ChumBucketHiderConfig.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt7
5 files changed, 25 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index fb0b49742..64b331a08 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.data.ChatManager
import at.hannibal2.skyhanni.data.CropAccessoryData
import at.hannibal2.skyhanni.data.EntityData
import at.hannibal2.skyhanni.data.EntityMovementData
+import at.hannibal2.skyhanni.data.EventCounter
import at.hannibal2.skyhanni.data.FameRanks
import at.hannibal2.skyhanni.data.FixedRateTimerManager
import at.hannibal2.skyhanni.data.FriendAPI
@@ -563,6 +564,7 @@ class SkyHanniMod {
loadModule(ContributorManager)
loadModule(TabComplete)
loadModule(HypixelBazaarFetcher)
+ loadModule(EventCounter)
// APIs
loadModule(BazaarApi())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/ChumBucketHiderConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/ChumBucketHiderConfig.java
index 560947428..39ed3c4ae 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/fishing/ChumBucketHiderConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/fishing/ChumBucketHiderConfig.java
@@ -12,7 +12,7 @@ public class ChumBucketHiderConfig {
@ConfigOption(name = "Enable", desc = "Hide the Chum/Chumcap Bucket name tags for other players.")
@ConfigEditorBoolean
@FeatureToggle
- public Property<Boolean> enabled = Property.of(true);
+ public Property<Boolean> enabled = Property.of(false);
@Expose
@ConfigOption(name = "Hide Bucket", desc = "Hide the Chum/Chumcap Bucket.")
diff --git a/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt b/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt
index f7a730a65..28f1e254b 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt
@@ -1,10 +1,12 @@
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
object EventCounter {
@@ -14,8 +16,15 @@ object EventCounter {
private var map = mutableMapOf<String, Int>()
private var lastUpdate = SimpleTimeMark.farPast()
+ private var enabled = false
+
+ @SubscribeEvent
+ fun onSecondPassed(event: SecondPassedEvent) {
+ enabled = LorenzUtils.onHypixel && config.eventCounter
+ }
+
fun count(eventName: String) {
- if (!isEnabled()) return
+ if (!enabled) return
map.addOrPut(eventName, 1)
@@ -42,6 +51,4 @@ object EventCounter {
println("")
println("total: ${total.addSeparators()}")
}
-
- private fun isEnabled() = LorenzUtils.onHypixel && config.eventCounter
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt
index d4b741472..4ba88f1cd 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/ChumBucketHider.kt
@@ -7,16 +7,18 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.TimeLimitedSet
import at.hannibal2.skyhanni.utils.getLorenzVec
import net.minecraft.entity.Entity
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
class ChumBucketHider {
private val config get() = SkyHanniMod.feature.fishing.chumBucketHider
- private val titleEntity = mutableListOf<Entity>()
- private val hiddenEntities = mutableListOf<Entity>()
+ private val titleEntity = TimeLimitedSet<Entity>(5.seconds)
+ private val hiddenEntities = TimeLimitedSet<Entity>(5.seconds)
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
@@ -50,7 +52,7 @@ class ChumBucketHider {
// Second text line
if (name.contains("/10 §aChums")) {
val entityLocation = entity.getLorenzVec()
- for (title in titleEntity) {
+ for (title in titleEntity.toSet()) {
if (entityLocation.equalsIgnoreY(title.getLorenzVec())) {
hiddenEntities.add(entity)
event.isCanceled = true
@@ -62,7 +64,7 @@ class ChumBucketHider {
// Chum Bucket
if (config.hideBucket.get() && entity.inventory.any { it != null && (it.name == "§fEmpty Chum Bucket" || it.name == "§aEmpty Chumcap Bucket") }) {
val entityLocation = entity.getLorenzVec()
- for (title in titleEntity) {
+ for (title in titleEntity.toSet()) {
if (entityLocation.equalsIgnoreY(title.getLorenzVec())) {
hiddenEntities.add(entity)
event.isCanceled = true
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt
index 2e06ba423..fb596bea7 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyblockSeason.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.UtilsPatterns.seasonPattern
+import kotlin.time.Duration.Companion.seconds
enum class SkyblockSeason(
val season: String,
@@ -20,7 +21,11 @@ enum class SkyblockSeason(
companion object {
- fun getCurrentSeason(): SkyblockSeason? = getSeasonByName(SkyBlockTime.now().monthName)
+ fun getCurrentSeason(): SkyblockSeason? = currentSeason.getValue()
+
+ private val currentSeason = RecalculatingValue(1.seconds) {
+ getSeasonByName(SkyBlockTime.now().monthName)
+ }
private fun getSeasonByName(name: String): SkyblockSeason? =
seasonPattern.matchMatcher(name) { entries.find { it.season.endsWith(group("season")) } }