aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle.kts2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt77
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt16
-rw-r--r--src/main/resources/assets/skyhanni/sounds.json11
-rw-r--r--src/main/resources/assets/skyhanni/sounds/itstimetopunchwheat.oggbin0 -> 18944 bytes
9 files changed, 138 insertions, 1 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 2c5742c05..ade832df3 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -19,7 +19,7 @@ java {
}
sourceSets.main {
- output.setResourcesDir(file("$buildDir/classes/java/main"))
+ output.setResourcesDir(file("$buildDir/classes/kotlin/main"))
}
repositories {
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 650f334df..5b0806042 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.features.commands.WikiCommand
import at.hannibal2.skyhanni.features.cosmetics.CosmeticFollowingLine
import at.hannibal2.skyhanni.features.damageindicator.DamageIndicatorManager
import at.hannibal2.skyhanni.features.dungeon.*
+import at.hannibal2.skyhanni.features.event.anniversary.ActivePlayerTimer
import at.hannibal2.skyhanni.features.event.diana.*
import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder
import at.hannibal2.skyhanni.features.fame.CityProjectFeatures
@@ -145,6 +146,7 @@ class SkyHanniMod {
loadModule(EntityMovementData())
loadModule(TestExportTools)
loadModule(ItemClickData())
+ loadModule(ActivePlayerTimer)
loadModule(MinecraftData())
loadModule(TitleUtils())
loadModule(ItemTipHelper())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index acd280967..85cb33f8a 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -8,6 +8,7 @@ import at.hannibal2.skyhanni.data.GuiEditManager
import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay
import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper
import at.hannibal2.skyhanni.features.chat.Translator
+import at.hannibal2.skyhanni.features.event.anniversary.ActivePlayerTimer
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper
import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare
import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder
@@ -36,6 +37,7 @@ import at.hannibal2.skyhanni.test.TestBingo
import at.hannibal2.skyhanni.test.command.*
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.TimeMark
import net.minecraft.client.Minecraft
import net.minecraft.command.ICommandSender
import net.minecraft.event.ClickEvent
@@ -247,6 +249,10 @@ object Commands {
"shtestmessage",
"Sends a custom chat message client side in the chat"
) { TestChatCommand.command(it) }
+ // TODO: remove for commit
+ registerCommand("shtestcenturytimer", "bleh") {
+ ActivePlayerTimer.lastTimerReceived = TimeMark(System.currentTimeMillis() - 19 * 60 * 1000L - 40 * 1000L)
+ }
}
private fun internalCommands() {
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
index 0ee81c801..3830f175b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/MiscConfig.java
@@ -1037,4 +1037,28 @@ public class MiscConfig {
@Expose
public Position inventoryLoadPos = new Position(394, 124, false, true);
+
+
+ @ConfigOption(name = "300þ Anniversary Celebration", desc = "Features for the 300þ year of SkyBlock")
+ @Accordion
+ @Expose
+ public Century century = new Century();
+
+ public static class Century {
+
+ @ConfigOption(name = "Enable Active Player Timer", desc = "Show a HUD telling you how much longer you have to wait to be eligible for another free ticket")
+ @Expose
+ @ConfigEditorBoolean
+ public boolean enableActiveTimer = true;
+
+ @Expose
+ public Position activeTimerPosition = new Position(100, 100, false, true);
+
+ @ConfigOption(name = "Enable Active Player Alert", desc = "Loudly proclaim when it is time to break some wheat")
+ @Expose
+ @ConfigEditorBoolean
+ public boolean enableActiveAlert = false;
+ }
+
+
}
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..eb8d330a0
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/anniversary/ActivePlayerTimer.kt
@@ -0,0 +1,77 @@
+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.renderStringsAndItems
+import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.SoundUtils.playSound
+import at.hannibal2.skyhanni.utils.TimeMark
+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 {
+
+ var lastTimerReceived = TimeMark.never()
+ var lastTimeAlerted = TimeMark.never()
+
+ var overlay: List<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.renderStringsAndItems(
+ 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(
+ listOf(
+ Renderable.itemStack(NEUItems.getItemStackOrNull("EPOCH_CAKE_ORANGE") ?: ItemStack(Items.clock)),
+ Renderable.string("§eTime Left: $timeLeft")
+ )
+ )
+ }
+
+
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
index 7fd9d228f..64f10d514 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt
@@ -9,6 +9,7 @@ import net.minecraft.util.ResourceLocation
object SoundUtils {
private val beepSound by lazy { createSound("random.orb", 1f) }
private val clickSound by lazy { createSound("gui.button.press", 1f) }
+ val centuryActiveTimerAlert by lazy { createSound("skyhanni:centurytimer.active", 1f) }
fun ISound.playSound() {
Minecraft.getMinecraft().addScheduledTask {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt b/src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt
new file mode 100644
index 000000000..83285550d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/utils/TimeMark.kt
@@ -0,0 +1,16 @@
+package at.hannibal2.skyhanni.utils
+
+import kotlin.time.Duration
+import kotlin.time.Duration.Companion.milliseconds
+
+
+data class TimeMark(val long: Long) {
+
+ fun hasNeverHappened() = long == 0L
+ fun passedTime() = if (long == 0L) Duration.Companion.INFINITE else (System.currentTimeMillis() - long).milliseconds
+
+ companion object {
+ fun never() = TimeMark(0)
+ fun now() = TimeMark(System.currentTimeMillis())
+ }
+} \ No newline at end of file
diff --git a/src/main/resources/assets/skyhanni/sounds.json b/src/main/resources/assets/skyhanni/sounds.json
new file mode 100644
index 000000000..7c017cb0d
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/sounds.json
@@ -0,0 +1,11 @@
+{
+ "centurytimer.active": {
+ "category": "neutral",
+ "sounds": [
+ {
+ "name": "itstimetopunchwheat",
+ "stream": false
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/src/main/resources/assets/skyhanni/sounds/itstimetopunchwheat.ogg b/src/main/resources/assets/skyhanni/sounds/itstimetopunchwheat.ogg
new file mode 100644
index 000000000..b7bd98137
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/sounds/itstimetopunchwheat.ogg
Binary files differ