diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/OtherPlayersSlayerAPI.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/OtherPlayersSlayerAPI.kt | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/OtherPlayersSlayerAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/OtherPlayersSlayerAPI.kt new file mode 100644 index 000000000..0401746c4 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/OtherPlayersSlayerAPI.kt @@ -0,0 +1,36 @@ +package at.hannibal2.skyhanni.data + +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 + fun onMobDespawn(event: MobEvent.DeSpawn.SkyblockMob) { + val mob = event.mob + + // no death, rather despawn because too far away + if (mob.baseEntity.health != 0f) return + + if (mob.mobType != Mob.Type.SLAYER) return + + val owner = mob.owner?.ownerName + val tier = mob.levelOrTier + val name = mob.name + val slayerType = SlayerType.getByName(name) ?: run { + ErrorManager.logErrorStateWithData( + "Unknown slayer type found", "unknown slayer", + "name" to name, + ) + return + } + + SlayerDeathEvent(slayerType, tier, owner).post() + } +} |