diff --git a/src/main/java/me/partlysanestudios/partlysaneskies/features/mining/MiningEvents.java b/src/main/java/me/partlysanestudios/partlysaneskies/features/mining/MiningEvents.java deleted file mode 100644 index 077393248..000000000 --- a/src/main/java/me/partlysanestudios/partlysaneskies/features/mining/MiningEvents.java +++ /dev/null @@ -1,200 +0,0 @@ -// -// Written by J10a1n15. -// See LICENSE for copyright and license notices. -// -// Time spend afking in the mines: ~4h -// - -package me.partlysanestudios.partlysaneskies.features.mining; - -import me.partlysanestudios.partlysaneskies.PartlySaneSkies; -import me.partlysanestudios.partlysaneskies.render.gui.hud.BannerRenderer; -import me.partlysanestudios.partlysaneskies.render.gui.hud.PSSBanner; -import me.partlysanestudios.partlysaneskies.system.SystemNotification; -import net.minecraftforge.client.event.ClientChatReceivedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import org.lwjgl.opengl.Display; - -public class MiningEvents { - // TODO: lmao this needs a rewrite - // I was almost gonna convert to kt and then I realized I would have to rewrite it - private static boolean showBanner = false; - - @SubscribeEvent - public void onChat(ClientChatReceivedEvent event) { - if (!PartlySaneSkies.Companion.getConfig().getMiningEventsToggle()) return; - - String displayText = ""; - - String message = event.message.getFormattedText(); - - // 2x Powder - if (message.contains("The §b2x Powder §eevent starts in §a20 §eseconds!") && PartlySaneSkies.Companion.getConfig().getMining2xPowderSound() && PartlySaneSkies.Companion.getConfig().getMiningWarn20sBeforeEvent()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "2x Powder Event in 20s!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("2x Powder Event in 20s!"); - } - - if (message.contains("§l2X POWDER STARTED!") && PartlySaneSkies.Companion.getConfig().getMining2xPowderSound()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "2x Powder Event Started!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("2x Powder Event Started!"); - } - - // Gone with the wind - if (message.contains("The §9Gone with the Wind §eevent starts in §a20 §eseconds!") && PartlySaneSkies.Companion.getConfig().getMiningGoneWithTheWindSound() && PartlySaneSkies.Companion.getConfig().getMiningWarn20sBeforeEvent()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Gone with the Wind Event in 20s!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Gone with the Wind Event in 20s!"); - } - - if (message.contains("§r§9§lGONE WITH THE WIND STARTED!") && PartlySaneSkies.Companion.getConfig().getMiningGoneWithTheWindSound()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Gone with the Wind Event Started!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Gone with the Wind Event Started!"); - } - - // Better Together - if (message.contains("The §dBetter Together §eevent starts in §a20 §eseconds!") && PartlySaneSkies.Companion.getConfig().getMiningBetterTogetherSound() && PartlySaneSkies.Companion.getConfig().getMiningWarn20sBeforeEvent()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Better Together Event in 20s!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Better Together Event in 20s!"); - } - - if (message.contains("§r§d§lBETTER TOGETHER STARTED!") && PartlySaneSkies.Companion.getConfig().getMiningBetterTogetherSound()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Better Together Event Started!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Better Together Event Started!"); - } - - // Goblin Raid - if (message.contains("§eThe §cGoblin Raid §eevent starts in §a20 §eseconds!") && PartlySaneSkies.Companion.getConfig().getMiningGoblinRaidSound() && PartlySaneSkies.Companion.getConfig().getMiningWarn20sBeforeEvent()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Goblin Raid Event in 20s!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Goblin Raid Event in 20s!"); - } - - if (message.contains("§r§c§lGOBLIN RAID STARTED!") && PartlySaneSkies.Companion.getConfig().getMiningGoblinRaidSound()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Goblin Raid Event Started!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Goblin Raid Event Started!"); - } - - // Raffle - if (message.contains("The §6Raffle §eevent starts in §a20 §eseconds!") && PartlySaneSkies.Companion.getConfig().getMiningRaffleSound() && PartlySaneSkies.Companion.getConfig().getMiningWarn20sBeforeEvent()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Raffle Event in 20s!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Raffle Event in 20s!"); - } - - if (message.contains("§r§6§lRAFFLE STARTED!") && PartlySaneSkies.Companion.getConfig().getMiningRaffleSound()) { - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Raffle Event Started!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Raffle Event Started!"); - } - - // Gourmand - if (message.contains("§eThe §bMithril Gourmand §eevent starts in §a20 §eseconds!") && PartlySaneSkies.Companion.getConfig().getMiningMithrilGourmandSound() && PartlySaneSkies.Companion.getConfig().getMiningWarn20sBeforeEvent()){ - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Mithril Gourmand Event in 20s!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Mithril Gourmand Event in 20s!"); - } - - if (message.contains("§r§b§lMITHRIL GOURMAND STARTED!") && PartlySaneSkies.Companion.getConfig().getMiningMithrilGourmandSound()){ - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Mithril Gourmand Event Started!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Mithril Gourmand Event Started!"); - } - - // Powder Ghast - if (message.contains("§6The sound of pickaxes clashing against the rock has attracted the attention of the §r§6§lPOWDER GHAST!") && PartlySaneSkies.Companion.getConfig().getMiningPowderGhastSound()){ - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Powder Ghast Spawned!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Powder Ghast Spawned!"); - } - - // Fallen Star - if (message.contains("§eA §r§5Fallen Star §r§ehas crashed at") && PartlySaneSkies.Companion.getConfig().getMiningFallenStarSound()){ - showBanner = true; - PartlySaneSkies.Companion.getMinecraft().thePlayer.playSound("partlysaneskies:bell", 100, 1); - if (PartlySaneSkies.Companion.getConfig().getMiningShowEventBanner()) displayText = "Fallen Star Spawned!"; - if (PartlySaneSkies.Companion.getConfig().getMiningSendSystemNotifications() && !Display.isActive()) SystemNotification.INSTANCE.showNotification("Fallen Star Spawned!"); - } - - if (showBanner) { - BannerRenderer.INSTANCE.renderNewBanner(new PSSBanner(displayText, (long) (PartlySaneSkies.Companion.getConfig().getMiningEventBannerTime() * 1000), 4.0f, PartlySaneSkies.Companion.getConfig().getMiningEventBannerColor().toJavaColor())); - } - showBanner = false; - } -} - -/* ALL THE MINING EVENTS RELATED MESSAGES - - **MAJOR EVENTS** - - 2x POWDER - §b⚑ §eThe §b2x Powder §eevent starts in §a20 §eseconds! - §eThis is a passive event! §bIt's happening everywhere in the §bCrystal Hollows!§r - - §r§r§r §r§b§l2X POWDER STARTED!§r - - - WIND - §9⚑ §eThe §9Gone with the Wind §eevent starts in §a20 §eseconds! - §eThis is a passive event! §bIt's happening everywhere in the §bCrystal Hollows!§r - - §r§r§r §r§9§lGONE WITH THE WIND STARTED!§r - - - BETTER TOGETHER - §d⚑ §eThe §dBetter Together §eevent starts in §a20 §eseconds! - §eThis is a passive event! §bIt's happening everywhere in the §bCrystal Hollows!§r - - §r§r§r §r§d§lBETTER TOGETHER STARTED!§r - - - RAID - §c⚑ §eThe §cGoblin Raid §eevent starts in §a20 §eseconds! - §aClick here §eto teleport to §bGarry §eand prepare!§r - - §r§r§r §r§c§lGOBLIN RAID STARTED!§r - - - RAFFLE - §6⚑ §eThe §6Raffle §eevent starts in §a20 §eseconds! - §aClick here §eto teleport to §bGarry §eand prepare!§r - - §r§r§r §r§6§lRAFFLE STARTED!§r - - - GOURMAND - §b⚑ §eThe §bMithril Gourmand §eevent starts in §a20 §eseconds! - §aClick here §eto teleport to §bGarry §eand prepare!§r - - §r§r§r §r§b§lMITHRIL GOURMAND STARTED!§r - - - **MINOR EVENTS** - - POWDER GHAST - §r§6The sound of pickaxes clashing against the rock has attracted the attention of the §r§6§lPOWDER GHAST!§r - §r§eFind the §r§6Powder Ghast§r§e near the §r§bCliffside Veins§r§e!§r - - - FALLEN STAR - §r§5§l✯ §r§eA §r§5Fallen Star §r§ehas crashed at §r§bRoyal Mines§r§e! Nearby ore and Powder drops are amplified!§r - - */ diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/PartlySaneSkies.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/PartlySaneSkies.kt index 9c24325bd..7fe170d62 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/PartlySaneSkies.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/PartlySaneSkies.kt @@ -83,11 +83,11 @@ import me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner.DropW import me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner.RareDropGUIManager import me.partlysanestudios.partlysaneskies.features.gui.mainmenu.PSSMainMenu import me.partlysanestudios.partlysaneskies.features.information.WikiArticleOpener -import me.partlysanestudios.partlysaneskies.features.mining.MiningEvents import me.partlysanestudios.partlysaneskies.features.mining.PickaxeWarning import me.partlysanestudios.partlysaneskies.features.mining.crystalhollows.WormWarning import me.partlysanestudios.partlysaneskies.features.mining.crystalhollows.gemstonewaypoints.GemstoneData import me.partlysanestudios.partlysaneskies.features.mining.crystalhollows.gemstonewaypoints.GemstoneWaypointRender +import me.partlysanestudios.partlysaneskies.features.mining.events.MiningEventNotifier import me.partlysanestudios.partlysaneskies.features.security.PrivacyMode import me.partlysanestudios.partlysaneskies.features.security.modschecker.ModChecker import me.partlysanestudios.partlysaneskies.features.skills.BestiaryLevelUpWebhook @@ -236,7 +236,6 @@ class PartlySaneSkies { registerEvent(this) registerEvent(PartyManager()) registerEvent(PartyFriendManager()) - registerEvent(MiningEvents()) registerEvent(MinionData()) registerEvent(SkyblockDataManager) registerEvent(DropBannerDisplay) @@ -279,6 +278,7 @@ class PartlySaneSkies { registerEvent(PSSMainMenu) registerEvent(WrongToolCropWarning.CropToolData) registerEvent(PetAlert) + registerEvent(MiningEventNotifier) registerEvent(SkillUpgradeWebhook) registerEvent(CropMilestoneWebhook) registerEvent(BestiaryMilestoneWebhook) diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/config/OneConfigScreen.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/config/OneConfigScreen.kt index 8ab1fa63d..8a16da657 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/config/OneConfigScreen.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/config/OneConfigScreen.kt @@ -1257,13 +1257,6 @@ object OneConfigScreen : Config( //Events - @Info( - type = InfoType.INFO, - text = "Some Events may not trigger, not all have been tested. If you find an event that doesn't trigger, please report it on our discord server.", - category = "Mining", - subcategory = "Events", - size = 2 - ) @Switch(name = "Main Toggle", description = "Toggles the events.", category = "Mining", subcategory = "Events") var miningEventsToggle = true @@ -1365,14 +1358,6 @@ object OneConfigScreen : Config( ) var miningEventBannerTime = 3.5f - @Color( - name = "Event Banner Color", - description = "The color of the event banner text.", - category = "Mining", - subcategory = "Events" - ) - var miningEventBannerColor = OneColor(255, 255, 255) - // ------------- Category: Farming --------------------------------- // Hoes @Switch( diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/data/skyblockdata/IslandType.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/data/skyblockdata/IslandType.kt index 67b57a278..1d84c1490 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/data/skyblockdata/IslandType.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/data/skyblockdata/IslandType.kt @@ -22,17 +22,16 @@ enum class IslandType(val islandName: String) { DEEP_CAVERNS("Deep Caverns"), DWARVEN_MINES("Dwarven Mines"), CRYSTAL_HOLLOWS("Crystal Hollows"), + MINESHAFT("Mineshaft"), FARMING_ISLAND("The Farming Islands"), - WINTER_ISLAND("Jerry's Workshop"), // value by sh, unconfirmed + WINTER_ISLAND("Jerry's Workshop"), RIFT("The Rift"), CATACOMBS("Catacombs"), KUUDRA("Kuudra"), NONE(""); - fun onIsland(): Boolean { - return this == IslandType.getCurrentIsland() - } + fun onIsland() = this == IslandType.getCurrentIsland() companion object { /** diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/EventManager.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/EventManager.kt index fcf8b4d1d..e6fc985a6 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/EventManager.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/EventManager.kt @@ -9,6 +9,7 @@ package me.partlysanestudios.partlysaneskies.events import me.partlysanestudios.partlysaneskies.events.minecraft.render.RenderWaypointEvent import me.partlysanestudios.partlysaneskies.events.skyblock.dungeons.DungeonEndEvent import me.partlysanestudios.partlysaneskies.events.skyblock.dungeons.DungeonStartEvent +import me.partlysanestudios.partlysaneskies.events.skyblock.mining.MinesEvent import me.partlysanestudios.partlysaneskies.utils.SystemUtils.log import net.minecraftforge.client.event.ClientChatReceivedEvent import net.minecraftforge.client.event.RenderWorldLastEvent @@ -33,7 +34,7 @@ object EventManager { if (functionParameters.size != 2) { // if there is not only 1 parameter (param 1 is always the instance parameter log( Level.WARN, - "Unable to add ${function.name} due to incorrect number of function parameters (${functionParameters.size}" + "Unable to add ${function.name} due to incorrect number of function parameters (${functionParameters.size}", ) continue } @@ -49,18 +50,16 @@ object EventManager { @SubscribeEvent fun onScreenRender(event: RenderWorldLastEvent) { - RenderWaypointEvent.onEventCall( - event.partialTicks, - registeredFunctions[RenderWaypointEvent::class] ?: ArrayList() - ) + RenderWaypointEvent.onEventCall(event.partialTicks, registeredFunctions[RenderWaypointEvent::class] ?: ArrayList()) } @SubscribeEvent - fun onChatRecievedEvent(event: ClientChatReceivedEvent) { + fun onChatReceivedEvent(event: ClientChatReceivedEvent) { val message = event.message.formattedText - DungeonStartEvent.onMessageRecieved(registeredFunctions[DungeonStartEvent::class] ?: ArrayList(), message) - DungeonEndEvent.onMessageRecieved(registeredFunctions[DungeonEndEvent::class] ?: ArrayList(), message) + DungeonStartEvent.onMessageReceived(registeredFunctions[DungeonStartEvent::class] ?: ArrayList(), message) + DungeonEndEvent.onMessageReceived(registeredFunctions[DungeonEndEvent::class] ?: ArrayList(), message) + MinesEvent.onMessageReceived(registeredFunctions[MinesEvent::class] ?: ArrayList(), message) } internal class EventFunction(val obj: Any, val function: KFunction<*>) -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/data/LoadPublicDataEvent.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/data/LoadPublicDataEvent.kt index ba30318a0..0de34ffbc 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/data/LoadPublicDataEvent.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/data/LoadPublicDataEvent.kt @@ -20,8 +20,6 @@ class LoadPublicDataEvent { function.function.call(function.obj, event) } catch (e: Exception) { e.printStackTrace() - } finally { - } } }.start() diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/dungeons/DungeonEndEvent.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/dungeons/DungeonEndEvent.kt index 9a72fbde7..cf213ccf5 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/dungeons/DungeonEndEvent.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/dungeons/DungeonEndEvent.kt @@ -4,7 +4,7 @@ import me.partlysanestudios.partlysaneskies.events.EventManager class DungeonEndEvent { companion object { - internal fun onMessageRecieved(functionList: List, formattedMessage: String) { + internal fun onMessageReceived(functionList: List, formattedMessage: String) { if (formattedMessage.contains("§r§c☠ §r§eDefeated §r")) { for (function in functionList) { try { @@ -16,4 +16,4 @@ class DungeonEndEvent { } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/dungeons/DungeonStartEvent.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/dungeons/DungeonStartEvent.kt index bc7485002..eef8b9a25 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/dungeons/DungeonStartEvent.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/dungeons/DungeonStartEvent.kt @@ -12,7 +12,7 @@ import me.partlysanestudios.partlysaneskies.utils.StringUtils.removeColorCodes class DungeonStartEvent { companion object { - internal fun onMessageRecieved(functionList: List, formattedMessage: String) { + internal fun onMessageReceived(functionList: List, formattedMessage: String) { val message = formattedMessage.removeColorCodes() if (message.contains("Starting in 1 second.") && IslandType.CATACOMBS.onIsland()) { for (function in functionList) { @@ -25,4 +25,4 @@ class DungeonStartEvent { } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/mining/MinesEvent.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/mining/MinesEvent.kt new file mode 100644 index 000000000..171902cfc --- /dev/null +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/events/skyblock/mining/MinesEvent.kt @@ -0,0 +1,31 @@ +// +// Written by J10a1n15. +// See LICENSE for copyright and license notices. +// + + +package me.partlysanestudios.partlysaneskies.events.skyblock.mining + +import me.partlysanestudios.partlysaneskies.events.EventManager +import me.partlysanestudios.partlysaneskies.features.mining.events.MiningEvent +import me.partlysanestudios.partlysaneskies.utils.HypixelUtils.inAdvancedMiningIsland + +class MinesEvent(val miningEvent: MiningEvent) { + companion object { + internal fun onMessageReceived(functionList: List, formattedMessage: String) { + if (!inAdvancedMiningIsland()) return + + MiningEvent.entries + .firstOrNull { it.triggeredEvent(formattedMessage) } + ?.let { event -> + for (function in functionList) { + try { + function.function.call(function.obj, MinesEvent(event)) + } catch (e: Exception) { + e.printStackTrace() + } + } + } + } + } +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/mining/events/MiningEvent.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/mining/events/MiningEvent.kt new file mode 100644 index 000000000..82fb3c75b --- /dev/null +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/mining/events/MiningEvent.kt @@ -0,0 +1,160 @@ +// +// Written by J10a1n15. +// See LICENSE for copyright and license notices. +// + + +package me.partlysanestudios.partlysaneskies.features.mining.events + +import me.partlysanestudios.partlysaneskies.PartlySaneSkies.Companion.config + +enum class MiningEvent( + val event: String, + val color: String, + val triggeredEvent: (String) -> Boolean, + val config: () -> Boolean, +) { + POWDER( + "2x Powder", + "§b⚑", + { it.contains("§l2X POWDER STARTED!") }, + { config.mining2xPowderSound }, + ), + POWDER20( + "2x Powder Event in 20s!", + "§b⚑", + { it.contains("The §b2x Powder §eevent starts in §a20 §eseconds!") }, + { config.mining2xPowderSound && config.miningWarn20sBeforeEvent }, + ), + WIND( + "Gone with the Wind", + "§9⚑", + { it.contains("§r§9§lGONE WITH THE WIND STARTED!") }, + { config.miningGoneWithTheWindSound }, + ), + WIND20( + "Gone with the Wind Event in 20s!", + "§9⚑", + { it.contains("The §9Gone with the Wind §eevent starts in §a20 §eseconds!") }, + { config.miningGoneWithTheWindSound && config.miningWarn20sBeforeEvent }, + ), + BETTER_TOGETHER( + "Better Together", + "§d⚑", + { it.contains("§r§d§lBETTER TOGETHER STARTED!") }, + { config.miningBetterTogetherSound }, + ), + BETTER_TOGETHER20( + "Better Together Event in 20s!", + "§d⚑", + { it.contains("The §dBetter Together §eevent starts in §a20 §eseconds!") }, + { config.miningBetterTogetherSound && config.miningWarn20sBeforeEvent }, + ), + RAID( + "Goblin Raid", + "§c⚑", + { it.contains("§r§c§lGOBLIN RAID STARTED!") }, + { config.miningGoblinRaidSound }, + ), + RAID20( + "Goblin Raid Event in 20s!", + "§c⚑", + { it.contains("The §cGoblin Raid §eevent starts in §a20 §eseconds!") }, + { config.miningGoblinRaidSound && config.miningWarn20sBeforeEvent }, + ), + RAFFLE( + "Raffle", + "§6⚑", + { it.contains("§r§6§lRAFFLE STARTED!") }, + { config.miningRaffleSound }, + ), + RAFFLE20( + "Raffle Event in 20s!", + "§6⚑", + { it.contains("The §6Raffle §eevent starts in §a20 §eseconds!") }, + { config.miningRaffleSound && config.miningWarn20sBeforeEvent }, + ), + GOURMAND( + "Mithril Gourmand", + "§b⚑", + { it.contains("§r§b§lMITHRIL GOURMAND STARTED!") }, + { config.miningMithrilGourmandSound }, + ), + GOURMAND20( + "Mithril Gourmand Event in 20s!", + "§b⚑", + { it.contains("The §bMithril Gourmand §eevent starts in §a20 §eseconds!") }, + { config.miningMithrilGourmandSound && config.miningWarn20sBeforeEvent }, + ), + + POWDER_GHAST( + "Powder Ghast", + "§r§6", + { it.contains("§r§6§lPOWDER GHAST!") }, + { config.miningPowderGhastSound }, + ), + FALLEN_STAR( + "Fallen Star", + "§r§5", + { it.contains("§r§5§l✯ §r§eA §r§5Fallen Star §r§ehas crashed at ") }, + { config.miningFallenStarSound }, + ), +} + +/* ALL THE MINING EVENTS RELATED MESSAGES + + **MAJOR EVENTS** + + 2x POWDER + §b⚑ §eThe §b2x Powder §eevent starts in §a20 §eseconds! + §eThis is a passive event! §bIt's happening everywhere in the §bCrystal Hollows!§r + + §r§r§r §r§b§l2X POWDER STARTED!§r + + + WIND + §9⚑ §eThe §9Gone with the Wind §eevent starts in §a20 §eseconds! + §eThis is a passive event! §bIt's happening everywhere in the §bCrystal Hollows!§r + + §r§r§r §r§9§lGONE WITH THE WIND STARTED!§r + + + BETTER TOGETHER + §d⚑ §eThe §dBetter Together §eevent starts in §a20 §eseconds! + §eThis is a passive event! §bIt's happening everywhere in the §bCrystal Hollows!§r + + §r§r§r §r§d§lBETTER TOGETHER STARTED!§r + + + RAID + §c⚑ §eThe §cGoblin Raid §eevent starts in §a20 §eseconds! + §aClick here §eto teleport to §bGarry §eand prepare!§r + + §r§r§r §r§c§lGOBLIN RAID STARTED!§r + + + RAFFLE + §6⚑ §eThe §6Raffle §eevent starts in §a20 §eseconds! + §aClick here §eto teleport to §bGarry §eand prepare!§r + + §r§r§r §r§6§lRAFFLE STARTED!§r + + + GOURMAND + §b⚑ §eThe §bMithril Gourmand §eevent starts in §a20 §eseconds! + §aClick here §eto teleport to §bGarry §eand prepare!§r + + §r§r§r §r§b§lMITHRIL GOURMAND STARTED!§r + + + **MINOR EVENTS** + + POWDER GHAST + §r§6The sound of pickaxes clashing against the rock has attracted the attention of the §r§6§lPOWDER GHAST!§r + §r§eFind the §r§6Powder Ghast§r§e near the §r§bCliffside Veins§r§e!§r + + + FALLEN STAR + §r§5§l✯ §r§eA §r§5Fallen Star §r§ehas crashed at §r§bRoyal Mines§r§e! Nearby ore and Powder drops are amplified!§r + + */ diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/mining/events/MiningEventNotifier.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/mining/events/MiningEventNotifier.kt new file mode 100644 index 000000000..9392105a8 --- /dev/null +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/mining/events/MiningEventNotifier.kt @@ -0,0 +1,35 @@ +// +// Written by J10a1n15. +// See LICENSE for copyright and license notices. +// + +package me.partlysanestudios.partlysaneskies.features.mining.events + +import me.partlysanestudios.partlysaneskies.PartlySaneSkies.Companion.config +import me.partlysanestudios.partlysaneskies.PartlySaneSkies.Companion.minecraft +import me.partlysanestudios.partlysaneskies.events.SubscribePSSEvent +import me.partlysanestudios.partlysaneskies.events.skyblock.mining.MinesEvent +import me.partlysanestudios.partlysaneskies.render.gui.hud.BannerRenderer.renderNewBanner +import me.partlysanestudios.partlysaneskies.render.gui.hud.PSSBanner +import me.partlysanestudios.partlysaneskies.system.SystemNotification.showNotification +import me.partlysanestudios.partlysaneskies.utils.StringUtils.removeColorCodes +import org.lwjgl.opengl.Display + +object MiningEventNotifier { + + @SubscribePSSEvent + fun onMiningEvent(event: MinesEvent) { + if (!config.miningEventsToggle) return + + if (event.miningEvent.config().not()) return + + minecraft.thePlayer.playSound("partlysaneskies:bell", 100F, 1F) + val text = event.miningEvent.color + event.miningEvent.event + if (config.miningSendSystemNotifications && !Display.isActive()) { + showNotification(text.removeColorCodes()) + } + if (config.miningShowEventBanner) { + renderNewBanner(PSSBanner(text, (config.miningEventBannerTime * 1000).toLong(), 4f)) + } + } +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/utils/HypixelUtils.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/utils/HypixelUtils.kt index fb7dfb1ea..2e0d0d792 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/utils/HypixelUtils.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/utils/HypixelUtils.kt @@ -7,6 +7,7 @@ package me.partlysanestudios.partlysaneskies.utils import me.partlysanestudios.partlysaneskies.PartlySaneSkies +import me.partlysanestudios.partlysaneskies.data.skyblockdata.IslandType import me.partlysanestudios.partlysaneskies.utils.StringUtils.removeColorCodes import me.partlysanestudios.partlysaneskies.utils.StringUtils.stripLeading import me.partlysanestudios.partlysaneskies.utils.StringUtils.stripTrailing @@ -136,4 +137,7 @@ object HypixelUtils { fun ItemStack.getItemAttributes(): NBTTagCompound? { return this.tagCompound?.getCompoundTag("ExtraAttributes") } + + fun inAdvancedMiningIsland() = + IslandType.DWARVEN_MINES.onIsland() || IslandType.CRYSTAL_HOLLOWS.onIsland() || IslandType.MINESHAFT.onIsland() } \ No newline at end of file