Skip to content

Commit

Permalink
Merge branch 'beta' into base-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
CalMWolfs authored Jan 10, 2025
2 parents f98e8ad + e43ed6d commit 16474f2
Show file tree
Hide file tree
Showing 135 changed files with 232 additions and 237 deletions.
6 changes: 2 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,15 @@ format like "- #821" to illustrate the dependency.
- Mods that have reached their end of life. (Rip SBA, Dulkir and Soopy).
- The mod has, according to Hypixel rules, illegal features ("cheat mod/client").
- If you can improve the existing feature in a meaningful way.
- All new classes should be written in Kotlin, with a few exceptions:
- Config files in `at.hannibal2.skyhanni.config.features`
- All new classes should be written in Kotlin, with one exception:
- Mixin classes in `at.hannibal2.skyhanni.mixins.transformers`
- New features should be made in Kotlin objects unless there is a specific reason for it not to.
- If the feature needs to use forge events or a repo pattern, annotate it with `@SkyHanniModule`
- This will automatically register it to the forge event bus and load the repo patterns
- Avoid using deprecated functions.
- These functions are marked for removal in future versions.
- If you're unsure why a function is deprecated or how to replace it, please ask for guidance.
- Future JSON data objects should be made in kotlin and placed in the directory `at.hannibal2.skyhanni.data.jsonobjects`
- Config files should still be made in Java.
- JSON data objects are made in kotlin and put into the directory `at.hannibal2.skyhanni.data.jsonobjects`
- Please use the existing event system, or expand on it. Do not use Forge events.
- (We inject the calls with Mixin)
- Please use existing utils methods.
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.annotations.Expose
import net.minecraft.command.CommandBase
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.LinkedList
import java.util.regex.Matcher
import kotlin.time.Duration.Companion.seconds
Expand Down Expand Up @@ -93,7 +92,7 @@ object SkillAPI {
var showDisplay = false
var lastUpdate = SimpleTimeMark.farPast()

@SubscribeEvent
@HandleEvent
fun onSecondPassed(event: SecondPassedEvent) {
val activeSkill = activeSkill ?: return
val info = skillXPInfoMap[activeSkill] ?: return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RegexUtils.matches
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object CropAccessoryData {
Expand Down Expand Up @@ -46,7 +45,7 @@ object CropAccessoryData {
}
}

@SubscribeEvent
@HandleEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!event.repeatSeconds(5)) return
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/ElectionAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ object ElectionAPI {
*/
fun mayorNameWithColorCode(input: String) = mayorNameToColorCode(input) + input

@SubscribeEvent
@HandleEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!LorenzUtils.onHypixel) return
if (event.repeatSeconds(2)) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/data/EventCounter.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.SecondPassedEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
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

@SkyHanniModule
Expand All @@ -20,7 +20,7 @@ object EventCounter {

private var enabled = false

@SubscribeEvent
@HandleEvent
fun onSecondPassed(event: SecondPassedEvent) {
enabled = LorenzUtils.onHypixel && config.eventCounter
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object FixedRateTimerManager {
fixedRateTimer(name = "skyhanni-fixed-rate-timer-manager", period = 1000L) {
DelayedRun.onThread.execute {
if (!LorenzUtils.onHypixel) return@execute
SecondPassedEvent(totalSeconds).postAndCatch()
SecondPassedEvent(totalSeconds).post()
totalSeconds++
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package at.hannibal2.skyhanni.data

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.data.mob.Mob
import at.hannibal2.skyhanni.events.MobEvent
import at.hannibal2.skyhanni.events.entity.slayer.SlayerDeathEvent
import at.hannibal2.skyhanni.features.slayer.SlayerType
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.test.command.ErrorManager
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent

@SkyHanniModule
object OtherPlayersSlayerAPI {

@SubscribeEvent
@HandleEvent
fun onMobDespawn(event: MobEvent.DeSpawn.SkyblockMob) {
val mob = event.mob

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/QuiverAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ object QuiverAPI {
QuiverUpdateEvent(arrowType, currentAmount).post()
}

@SubscribeEvent
@HandleEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!isEnabled()) return
if (event.repeatSeconds(2)) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/data/SlayerAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.DebugDataCollectEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.SlayerChangeEvent
import at.hannibal2.skyhanni.events.SlayerProgressChangeEvent
import at.hannibal2.skyhanni.events.SlayerQuestCompleteEvent
import at.hannibal2.skyhanni.events.slayer.SlayerChangeEvent
import at.hannibal2.skyhanni.events.slayer.SlayerProgressChangeEvent
import at.hannibal2.skyhanni.features.slayer.SlayerType
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.nextAfter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.data.mob

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.MobEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
Expand All @@ -25,7 +26,7 @@ object LineToMobHandler {
lines[mob] = settings
}

@SubscribeEvent
@HandleEvent
fun onMobDeSpawn(event: MobEvent.DeSpawn) {
lines.remove(event.mob)
}
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/at/hannibal2/skyhanni/data/mob/MobData.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.data.mob

import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.events.MobEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.CollectionUtils.takeIfAllNotNull
Expand All @@ -8,7 +9,6 @@ import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.getLorenzVec
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.item.EntityArmorStand
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import java.util.TreeMap
import at.hannibal2.skyhanni.data.mob.Mob.Type as MobType

Expand Down Expand Up @@ -89,66 +89,66 @@ object MobData {
}
}

@SubscribeEvent
@HandleEvent
fun onMobEventSpawn(event: MobEvent.Spawn) {
entityToMob.putAll(event.mob.makeEntityToMobAssociation())
currentMobs.add(event.mob)
notSeenMobs.add(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onMobEventDeSpawn(event: MobEvent.DeSpawn) {
event.mob.fullEntityList().forEach { entityToMob.remove(it) }
currentMobs.remove(event.mob)
notSeenMobs.remove(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onSkyblockMobSpawnEvent(event: MobEvent.Spawn.SkyblockMob) {
skyblockMobs.add(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onSkyblockMobDeSpawnEvent(event: MobEvent.DeSpawn.SkyblockMob) {
skyblockMobs.remove(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onSummonSpawnEvent(event: MobEvent.Spawn.Summon) {
summoningMobs.add(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onSummonDeSpawnEvent(event: MobEvent.DeSpawn.Summon) {
summoningMobs.remove(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onSpecialSpawnEvent(event: MobEvent.Spawn.Special) {
special.add(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onSpecialDeSpawnEvent(event: MobEvent.DeSpawn.Special) {
special.remove(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onDisplayNPCSpawnEvent(event: MobEvent.Spawn.DisplayNPC) {
displayNPCs.add(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onDisplayNPCDeSpawnEvent(event: MobEvent.DeSpawn.DisplayNPC) {
displayNPCs.remove(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onRealPlayerSpawnEvent(event: MobEvent.Spawn.Player) {
players.add(event.mob)
}

@SubscribeEvent
@HandleEvent
fun onRealPlayerDeSpawnEvent(event: MobEvent.DeSpawn.Player) {
players.remove(event.mob)
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.data.mob

import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.api.event.HandleEvent
import at.hannibal2.skyhanni.config.features.dev.DebugMobConfig.HowToShow
import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent
import at.hannibal2.skyhanni.events.MobEvent
Expand Down Expand Up @@ -87,7 +88,7 @@ object MobDebug {
}
}

@SubscribeEvent
@HandleEvent
fun onMobEvent(event: MobEvent) {
if (!config.logEvents) return
val text = "Mob ${if (event is MobEvent.Spawn) "Spawn" else "Despawn"}: ${
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/at/hannibal2/skyhanni/data/mob/MobDetection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object MobDetection {
private fun mobDetectionReset() {
MobData.currentMobs.map {
it.createDeSpawnEvent()
}.forEach { it.postAndCatch() }
}.forEach { it.post() }
MobData.retries.clear()
}

Expand Down Expand Up @@ -167,15 +167,15 @@ object MobDetection {
Mob.Type.PROJECTILE -> MobEvent.FirstSeen.Projectile(mob)
Mob.Type.DISPLAY_NPC -> MobEvent.FirstSeen.DisplayNPC(mob)
Mob.Type.BASIC, Mob.Type.DUNGEON, Mob.Type.BOSS, Mob.Type.SLAYER -> MobEvent.FirstSeen.SkyblockMob(mob)
}.postAndCatch()
}.post()
}
return isVisible
}

/**@return a false means that it should try again (later)*/
private fun entitySpawn(entity: EntityLivingBase, roughType: Mob.Type): Boolean {
when (roughType) {
Mob.Type.PLAYER -> MobEvent.Spawn.Player(MobFactories.player(entity)).postAndCatch()
Mob.Type.PLAYER -> MobEvent.Spawn.Player(MobFactories.player(entity)).post()

Mob.Type.DISPLAY_NPC -> return MobFilter.createDisplayNPC(entity)
Mob.Type.BASIC -> {
Expand All @@ -197,7 +197,7 @@ object MobDetection {
Mob.Type.PROJECTILE -> MobEvent.Spawn.Projectile(mob)
Mob.Type.DISPLAY_NPC -> MobEvent.Spawn.DisplayNPC(mob) // Needed for some special cases
Mob.Type.PLAYER -> return mobDetectionError("An Player Ended Here. How?")
}.postAndCatch()
}.post()
}
}
}
Expand All @@ -223,7 +223,7 @@ object MobDetection {
val entity = EntityUtils.getEntityByID(id) as? EntityBat ?: return@drainForEach
if (MobData.entityToMob[entity] != null) return@drainForEach
removeRetry(entity)
MobEvent.Spawn.Projectile(MobFactories.projectile(entity, "Spirit Scepter Bat")).postAndCatch()
MobEvent.Spawn.Projectile(MobFactories.projectile(entity, "Spirit Scepter Bat")).post()
}

EntityPacketType.VILLAGER -> {
Expand All @@ -247,7 +247,7 @@ object MobDetection {
if (MobData.entityToMob[entity] != null) return@drainForEach
if (!entity.powered) return@drainForEach
removeRetry(entity)
MobEvent.Spawn.Special(MobFactories.special(entity, "Creeper Veil")).postAndCatch()
MobEvent.Spawn.Special(MobFactories.special(entity, "Creeper Veil")).post()
}
}
}
Expand Down Expand Up @@ -276,7 +276,7 @@ object MobDetection {
}

private fun entityDeSpawn(entity: EntityLivingBase) {
MobData.entityToMob[entity]?.createDeSpawnEvent()?.postAndCatch() ?: removeRetry(entity)
MobData.entityToMob[entity]?.createDeSpawnEvent()?.post() ?: removeRetry(entity)
allEntitiesViaPacketId.remove(entity.entityId)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/mob/MobFilter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ object MobFilter {
listOfClickArmorStand.contains(armorStand.name)
} ?: return false
val armorStand = MobUtils.getArmorStand(clickArmorStand, -1) ?: return false
MobEvent.Spawn.DisplayNPC(MobFactories.displayNPC(entity, armorStand, clickArmorStand)).postAndCatch()
MobEvent.Spawn.DisplayNPC(MobFactories.displayNPC(entity, armorStand, clickArmorStand)).post()
return true
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ enum class TabWidget(

private val FORCE_UPDATE_DELAY = 2.seconds

@SubscribeEvent
fun onSecond(event: SecondPassedEvent) {
@HandleEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (sentSinceWorldChange || !LorenzUtils.inSkyBlock) return
if (LorenzUtils.lastWorldSwitch.passedSince() < FORCE_UPDATE_DELAY) return
sentSinceWorldChange = true
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/events/MobEvent.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package at.hannibal2.skyhanni.events

import at.hannibal2.skyhanni.api.event.SkyHanniEvent
import at.hannibal2.skyhanni.data.mob.Mob

open class MobEvent(val mob: Mob) : LorenzEvent() {
open class MobEvent(val mob: Mob) : SkyHanniEvent() {
open class Spawn(mob: Mob) : MobEvent(mob) {
class SkyblockMob(mob: Mob) : Spawn(mob)
class Summon(mob: Mob) : Spawn(mob)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package at.hannibal2.skyhanni.events

class SecondPassedEvent(private val totalSeconds: Int) : LorenzEvent() {
import at.hannibal2.skyhanni.api.event.SkyHanniEvent

class SecondPassedEvent(private val totalSeconds: Int) : SkyHanniEvent() {
fun repeatSeconds(i: Int) = totalSeconds % i == 0
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.events

import at.hannibal2.skyhanni.api.event.GenericSkyHanniEvent
import net.minecraft.client.renderer.entity.RendererLivingEntity
import net.minecraft.entity.EntityLivingBase
import net.minecraftforge.fml.common.eventhandler.Cancelable
Expand All @@ -11,7 +12,7 @@ open class SkyHanniRenderEntityEvent<T : EntityLivingBase>(
val x: Double,
val y: Double,
val z: Double
) : LorenzEvent() {
) : GenericSkyHanniEvent<T>(entity.javaClass) {
class Pre<T : EntityLivingBase>(
entity: T,
renderer: RendererLivingEntity<out T>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.events
package at.hannibal2.skyhanni.events.fishing

import at.hannibal2.skyhanni.api.event.SkyHanniEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.features.fishing.SeaCreature

class SeaCreatureFishEvent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package at.hannibal2.skyhanni.events
package at.hannibal2.skyhanni.events.garden.farming

import at.hannibal2.skyhanni.api.event.SkyHanniEvent
import at.hannibal2.skyhanni.data.ClickType
Expand Down
Loading

0 comments on commit 16474f2

Please sign in to comment.