diff options
| author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-09-16 12:34:18 +0200 |
|---|---|---|
| committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-09-16 12:34:18 +0200 |
| commit | 4293cfd919c3c93d4532534f722c407d7ad1370d (patch) | |
| tree | f9f612f021ef7f4283d74312edfaca30badc6749 /src/main/java/at/hannibal2/skyhanni/features/event | |
| parent | 538e3ceb76f8e0b590291ce9aa90aa94896cdcb6 (diff) | |
| parent | 024ba52fb69b6cd44b4e31542867f802de656f15 (diff) | |
| download | SkyHanni-cum.tar.gz SkyHanni-cum.tar.bz2 SkyHanni-cum.zip | |
Merge branch 'beta' into cumcum
# Conflicts:
# src/main/java/at/hannibal2/skyhanni/config/ConfigManager.kt
# src/main/java/at/hannibal2/skyhanni/config/features/AshfangConfig.java
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/event')
5 files changed, 91 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt new file mode 100644 index 000000000..a83def532 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt @@ -0,0 +1,76 @@ +package at.hannibal2.skyhanni.features.event.anniversary + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems +import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.SoundUtils.playSound +import at.hannibal2.skyhanni.utils.TimeMark +import at.hannibal2.skyhanni.utils.TimeUtils.format +import at.hannibal2.skyhanni.utils.renderables.Renderable +import io.github.moulberry.notenoughupdates.util.SkyBlockTime +import net.minecraft.init.Items +import net.minecraft.item.ItemStack +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.time.Instant +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds + +object ActivePlayerTimer { + val displayItem by lazy { NEUItems.getItemStackOrNull("EPOCH_CAKE_ORANGE") ?: ItemStack(Items.clock) } + + private var lastTimerReceived = TimeMark.never() + private var lastTimeAlerted = TimeMark.never() + + private var overlay: List<Any>? = null + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (event.message == "§6§lACTIVE PLAYER! §eYou gained §b+1 Raffle Ticket§e!") { + lastTimerReceived = TimeMark.now() + } + } + + fun isEnabled(): Boolean { + return SkyHanniMod.feature.misc.century.enableActiveTimer && + Instant.now().isBefore(SkyBlockTime(301).toInstant()) && + LorenzUtils.inSkyBlock + } + + + @SubscribeEvent + fun onRender(event: GuiRenderEvent.GameOverlayRenderEvent) { + SkyHanniMod.feature.misc.century.activeTimerPosition.renderSingleLineWithItems( + overlay ?: return, + posLabel = "300þ Anniversary Active Timer" + ) + } + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!isEnabled()) { + overlay = null + return + } + val p = lastTimerReceived.passedTime() + val timeLeft = if (p > 20.minutes) { + 0.seconds + } else { + 20.minutes - p + } + if (p.isFinite() && timeLeft < 1.seconds && lastTimeAlerted.passedTime() > 5.minutes && SkyHanniMod.feature.misc.century.enableActiveAlert) { + SoundUtils.centuryActiveTimerAlert.playSound() + lastTimeAlerted = TimeMark.now() + } + overlay = listOf( + Renderable.itemStack(displayItem), + Renderable.string("§eTime Left: ${timeLeft.format()}") + ) + } + + +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt index c58ff7d90..fe9efd09a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/BurrowWarpHelper.kt @@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent import org.lwjgl.input.Keyboard class BurrowWarpHelper { + private val config get() = SkyHanniMod.feature.diana private var lastWarpTime = 0L private var lastWarp: WarpPoint? = null @@ -20,11 +21,11 @@ class BurrowWarpHelper { fun onKeyBindPressed(event: KeyInputEvent) { if (!LorenzUtils.inSkyBlock) return if (LorenzUtils.skyBlockIsland != IslandType.HUB) return - if (!SkyHanniMod.feature.diana.burrowNearestWarp) return + if (!config.burrowNearestWarp) return if (!Keyboard.getEventKeyState()) return val key = if (Keyboard.getEventKey() == 0) Keyboard.getEventCharacter().code + 256 else Keyboard.getEventKey() - if (SkyHanniMod.feature.diana.keyBindWarp == key) { + if (config.keyBindWarp == key) { currentWarp?.let { if (System.currentTimeMillis() > lastWarpTime + 5_000) { lastWarpTime = System.currentTimeMillis() @@ -43,7 +44,7 @@ class BurrowWarpHelper { val time = System.currentTimeMillis() - lastWarpTime if (time < 1_000) { lastWarp?.let { - it.enabled = false + it.unlocked = false LorenzUtils.chat( "§e[SkyHanni] Detected not having access to warp point §b${it.displayName}§e!\n" + "§e[SkyHanni] Use §c/shresetburrowwarps §eonce you have activated this travel scroll." @@ -73,13 +74,12 @@ class BurrowWarpHelper { } } - private fun getNearestWarpPoint(location: LorenzVec): WarpPoint { - val map = WarpPoint.entries.filter { it.enabled }.map { it to it.distance(location) } - return map.sorted().first().first - } + private fun getNearestWarpPoint(location: LorenzVec) = + WarpPoint.entries.filter { it.unlocked && !it.ignored() }.map { it to it.distance(location) } + .sorted().first().first fun resetDisabledWarps() { - WarpPoint.entries.forEach { it.enabled = true } + WarpPoint.entries.forEach { it.unlocked = true } LorenzUtils.chat("§e[SkyHanni] Reset disabled burrow warps.") } } @@ -88,15 +88,15 @@ class BurrowWarpHelper { val displayName: String, private val location: LorenzVec, private val extraBlocks: Int, - var enabled: Boolean = true, + val ignored: () -> Boolean = { false }, + var unlocked: Boolean = true, ) { HUB("Hub", LorenzVec(-3, 70, -70), 2), CASTLE("Castle", LorenzVec(-250, 130, 45), 10), - - // CRYPT("Crypt", LorenzVec(-190, 74, -88), 25), + CRYPT("Crypt", LorenzVec(-190, 74, -88), 15, { SkyHanniMod.feature.diana.ignoredWarps.crypt }), DA("Dark Auction", LorenzVec(91, 74, 173), 2), MUSEUM("Museum", LorenzVec(-75, 76, 81), 2), - WIZARD("Wizard", LorenzVec(42.5, 122.0, 69.0), 5), + WIZARD("Wizard", LorenzVec(42.5, 122.0, 69.0), 5, { SkyHanniMod.feature.diana.ignoredWarps.wizard }), ; fun distance(other: LorenzVec): Double = other.distance(location) + extraBlocks diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt index 0b7097091..31571b30b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt @@ -53,7 +53,7 @@ class GriffinBurrowParticleFinder { // // @SubscribeEvent // fun onChatPacket(event: ReceiveParticleEvent) { -// if (!LorenzUtils.inSkyblock) return +// if (!LorenzUtils.inSkyBlock) return // if (!SkyHanniMod.feature.dev.debugEnabled) return // // val particleType = getParticleType(event) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt index f979894c4..5a578590f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinPetWarning.kt @@ -24,7 +24,7 @@ class GriffinPetWarning { if (!DianaAPI.hasGriffinPet()) { if (lastWarnTime.passedSince() > 30.seconds) { lastWarnTime = SimpleTimeMark.now() - TitleUtils.sendTitle("§cGriffin Pet!", 3_000) + TitleUtils.sendTitle("§cGriffin Pet!", 3.seconds) LorenzUtils.chat("§e[SkyHanni] Reminder to use a Griffin pet for Mythological Ritual!") } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index 272ec5f61..7a8ea5d2b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -226,7 +226,7 @@ object InquisitorWaypointShare { if (!waypoints.containsKey(cleanName)) { LorenzUtils.chat("§e[SkyHanni] $playerName §l§efound an inquisitor at §l§c$x $y $z!") if (cleanName != LorenzUtils.getPlayerName()) { - TitleUtils.sendTitle("§dINQUISITOR §efrom §b$cleanName", 5_000) + TitleUtils.sendTitle("§dINQUISITOR §efrom §b$cleanName", 5.seconds) SoundUtils.playBeepSound() } } |
