diff options
Diffstat (limited to 'src/main/java/at')
6 files changed, 48 insertions, 44 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java index c539d4c3a..0bc133a87 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java @@ -661,6 +661,22 @@ public class Garden { public boolean nextJacobContestOtherGuis = false; @Expose + @ConfigOption(name = "Warning", desc = "Show a warning shortly before a new jacob contest starts.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 14) + public boolean nextJacobContestWarn = false; + + @Expose + @ConfigOption(name = "Warning Time", desc = "Set the warning time in seconds before the Jacobs contest begins.") + @ConfigEditorSlider( + minValue = 10, + maxValue = 60 * 5, + minStep = 1 + ) + @ConfigAccordionId(id = 21) + public int nextJacobContestWarnTime = 60 * 2; + + @Expose public Position nextJacobContestPos = new Position(-278, 11, false, true); @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt index c534534a9..95bf9c30a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/BarnFishingTimer.kt @@ -5,12 +5,8 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.RenderUtils.renderString -import at.hannibal2.skyhanni.utils.SoundUtils.playSound import net.minecraft.client.Minecraft -import net.minecraft.client.audio.ISound -import net.minecraft.client.audio.PositionedSound import net.minecraft.entity.item.EntityArmorStand -import net.minecraft.util.ResourceLocation import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent @@ -23,15 +19,6 @@ class BarnFishingTimer { private var currentCount = 0 private var startTime = 0L - private val sound = object : PositionedSound(ResourceLocation("random.orb")) { - init { - volume = 50f - repeat = false - repeatDelay = 0 - attenuationType = ISound.AttenuationType.NONE - } - } - @SubscribeEvent fun onTick(event: TickEvent.ClientTickEvent) { if (event.phase != TickEvent.Phase.START) return @@ -55,7 +42,7 @@ class BarnFishingTimer { val duration = System.currentTimeMillis() - startTime val barnTimerAlertTime = SkyHanniMod.feature.fishing.barnTimerAlertTime * 1_000 if (duration > barnTimerAlertTime && duration < barnTimerAlertTime + 3_000) { - sound.playSound() + SoundUtils.playBeepSound() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index 4be321a0f..c9eff68ed 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -16,12 +16,9 @@ import at.hannibal2.skyhanni.utils.BlockUtils.isBabyCrop import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.utils.SoundUtils.playSound +import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUtils -import net.minecraft.client.audio.ISound -import net.minecraft.client.audio.PositionedSound import net.minecraft.item.ItemStack -import net.minecraft.util.ResourceLocation import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.* @@ -35,15 +32,6 @@ class GardenCropMilestoneDisplay { private val bestCropTime = GardenBestCropTime() // val cropMilestoneLevelUpPattern = Pattern.compile(" §r§b§lGARDEN MILESTONE §3(.*) §8XXIII➜§3(.*)") - private val sound = object : PositionedSound(ResourceLocation("random.orb")) { - init { - volume = 50f - repeat = false - repeatDelay = 0 - attenuationType = ISound.AttenuationType.NONE - } - } - private var lastPlaySoundTime = 0L private var needsInventory = false @@ -307,7 +295,7 @@ class GardenCropMilestoneDisplay { if (millis < 5_900) { if (System.currentTimeMillis() > lastPlaySoundTime + 1_000) { lastPlaySoundTime = System.currentTimeMillis() - sound.playSound() + SoundUtils.playBeepSound() } SendTitleHelper.sendTitle("§b${crop.cropName} $nextTier in $duration", 1_500) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt index 5786cae72..ec2bd680c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon import at.hannibal2.skyhanni.utils.ItemUtils.getLore @@ -8,6 +9,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings +import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.TimeUtils import io.github.moulberry.notenoughupdates.util.SkyBlockTime import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -27,6 +29,7 @@ class GardenNextJacobContest { private val maxContestsPerYear = 124 private val contestDuration = 1_000 * 60 * 20 + private var lastWarningTime = 0L @SubscribeEvent fun onTabListUpdate(event: TabListUpdateEvent) { @@ -189,6 +192,7 @@ class GardenNextJacobContest { } else { list.add("§eNext: ") duration -= contestDuration + warn(duration, nextContest.crops) } for (crop in nextContest.crops) { list.add(" ") @@ -201,6 +205,19 @@ class GardenNextJacobContest { return list } + private fun warn(timeInMillis: Long, crops: List<CropType>) { + if (!config.nextJacobContestWarn) return + if (config.nextJacobContestWarnTime <= timeInMillis / 1000) return + + if (System.currentTimeMillis() < lastWarningTime) return + lastWarningTime = System.currentTimeMillis() + 60_000 * 40 + + val cropText = crops.joinToString("§7, ") { "§a${it.cropName}" } + LorenzUtils.chat("§e[SkyHanni] Next farming contest: $cropText") + SendTitleHelper.sendTitle("§eFarming Contest!", 5_000) + SoundUtils.playBeepSound() + } + @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!isEnabled()) return @@ -218,7 +235,10 @@ class GardenNextJacobContest { if (!inCalendar) return if (display.isNotEmpty()) { - SkyHanniMod.feature.misc.inventoryLoadPos.renderSingleLineWithItems(display, posLabel = "Load SkyBlock Calendar") + SkyHanniMod.feature.misc.inventoryLoadPos.renderSingleLineWithItems( + display, + posLabel = "Load SkyBlock Calendar" + ) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt index 66042304d..ab6c2420d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/WrongFungiCutterWarning.kt @@ -7,26 +7,13 @@ import at.hannibal2.skyhanni.events.BlockClickEvent import at.hannibal2.skyhanni.events.GardenToolChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.SoundUtils.playSound -import net.minecraft.client.audio.ISound -import net.minecraft.client.audio.PositionedSound +import at.hannibal2.skyhanni.utils.SoundUtils import net.minecraft.item.ItemStack -import net.minecraft.util.ResourceLocation import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class WrongFungiCutterWarning { private var mode = FungiMode.UNKNOWN - private var lastPlaySoundTime = 0L - private val sound = object : PositionedSound(ResourceLocation("random.orb")) { - init { - volume = 50f - repeat = false - repeatDelay = 0 - attenuationType = ISound.AttenuationType.NONE - } - } - @SubscribeEvent fun onChatMessage(event: LorenzChatEvent) { @@ -62,7 +49,7 @@ class WrongFungiCutterWarning { SendTitleHelper.sendTitle("§cWrong Fungi Cutter Mode!", 2_000) if (System.currentTimeMillis() > lastPlaySoundTime + 3_00) { lastPlaySoundTime = System.currentTimeMillis() - sound.playSound() + SoundUtils.playBeepSound() } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt index 23d3fb603..9eb476666 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt @@ -7,6 +7,8 @@ import net.minecraft.client.audio.SoundCategory import net.minecraft.util.ResourceLocation object SoundUtils { + private val beepSound by lazy { createSound("random.orb", 1f) } + fun ISound.playSound() { val gameSettings = Minecraft.getMinecraft().gameSettings val oldLevel = gameSettings.getSoundLevel(SoundCategory.PLAYERS) @@ -40,4 +42,8 @@ object SoundUtils { } return sound } + + fun playBeepSound() { + beepSound.playSound() + } }
\ No newline at end of file |