aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
index 881c5c215..dd90c744e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionFeatures.kt
@@ -65,8 +65,7 @@ class MinionFeatures {
@SubscribeEvent
fun onPlayerInteract(event: PlayerInteractEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
+ if (!enableWithHub()) return
if (event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) return
val lookingAt = event.pos.offset(event.face).toLorenzVec()
@@ -83,8 +82,7 @@ class MinionFeatures {
@SubscribeEvent
fun onClick(event: InputEvent.MouseInputEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
+ if (!enableWithHub()) return
if (!Mouse.getEventButtonState()) return
if (Mouse.getEventButton() != 1) return
@@ -102,8 +100,7 @@ class MinionFeatures {
@SubscribeEvent
fun onRenderLastClickedMinion(event: LorenzRenderWorldEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
+ if (!enableWithHub()) return
if (!config.lastClickedMinion.display) return
val special = config.lastClickedMinion.color
@@ -127,8 +124,7 @@ class MinionFeatures {
@SubscribeEvent
fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
+ if (!enableWithHub()) return
if (!event.inventoryName.contains("Minion ")) return
event.inventoryItems[48]?.let {
@@ -144,6 +140,7 @@ class MinionFeatures {
@SubscribeEvent
fun onInventoryUpdated(event: InventoryUpdatedEvent) {
+ if (!enableWithHub()) return
if (minionInventoryOpen) {
MinionOpenEvent(event.inventoryName, event.inventoryItems).postAndCatch()
}
@@ -156,7 +153,7 @@ class MinionFeatures {
val openInventory = event.inventoryName
val name = getMinionName(openInventory)
- if (!minions.contains(entity)) {
+ if (!minions.contains(entity) && LorenzUtils.skyBlockIsland != IslandType.HUB) {
MinionFeatures.minions = minions.editCopy {
this[entity] = Storage.ProfileSpecific.MinionConfig().apply {
displayName = name
@@ -164,8 +161,10 @@ class MinionFeatures {
}
}
} else {
- if (minions[entity]!!.displayName != name) {
- minions[entity]!!.displayName = name
+ minions[entity]?.let {
+ if (it.displayName != name) {
+ it.displayName = name
+ }
}
}
lastMinion = entity
@@ -197,7 +196,7 @@ class MinionFeatures {
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
- if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
+ if (!enable()) return
if (coinsPerDay != "") return
if (Minecraft.getMinecraft().currentScreen is GuiChest && config.hopperProfitDisplay) {
@@ -250,8 +249,7 @@ class MinionFeatures {
@SubscribeEvent
fun onChatMessage(event: LorenzChatEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
+ if (!enable()) return
val message = event.message
if (minionCoinPattern.matches(message) && System.currentTimeMillis() - lastInventoryClosed < 2_000) {
@@ -287,8 +285,7 @@ class MinionFeatures {
@SubscribeEvent
fun onRenderLastEmptied(event: LorenzRenderWorldEvent) {
- if (!LorenzUtils.inSkyBlock) return
- if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
+ if (!enable()) return
val playerLocation = LocationUtils.playerLocation()
val minions = minions ?: return
@@ -318,8 +315,7 @@ class MinionFeatures {
@SubscribeEvent(priority = EventPriority.HIGH)
fun onRenderLiving(event: RenderLivingEvent.Specials.Pre<EntityLivingBase>) {
- if (!LorenzUtils.inSkyBlock) return
- if (LorenzUtils.skyBlockIsland != IslandType.PRIVATE_ISLAND) return
+ if (!enable()) return
if (!config.hideMobsNametagNearby) return
val entity = event.entity
@@ -336,6 +332,12 @@ class MinionFeatures {
}
}
+ private fun enable() =
+ LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.PRIVATE_ISLAND
+
+ private fun enableWithHub() =
+ enable() || (LorenzUtils.inSkyBlock && LorenzUtils.skyBlockIsland == IslandType.HUB)
+
@SubscribeEvent(priority = EventPriority.LOWEST)
fun renderOverlay(event: GuiScreenEvent.BackgroundDrawnEvent) {
if (!LorenzUtils.inSkyBlock) return