diff options
author | vicisacat <victor.branchu@gmail.com> | 2024-04-24 18:28:11 +0200 |
---|---|---|
committer | viciscat <51047087+viciscat@users.noreply.github.com> | 2024-06-02 13:26:45 +0200 |
commit | 0e55c9e00b406e8cec007e551e4661d80f6c1b2e (patch) | |
tree | 9425637374b82e03eb3e1bf0b3d016ae348c0c54 /src/main/java/de/hysky | |
parent | a2c9ef1192f903c4aaf3e048da621e53b600ec5e (diff) | |
download | Skyblocker-0e55c9e00b406e8cec007e551e4661d80f6c1b2e.tar.gz Skyblocker-0e55c9e00b406e8cec007e551e4661d80f6c1b2e.tar.bz2 Skyblocker-0e55c9e00b406e8cec007e551e4661d80f6c1b2e.zip |
GOAT HORN YEA BABY
Diffstat (limited to 'src/main/java/de/hysky')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/config/categories/EventNotificationsCategory.java | 28 | ||||
-rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/events/EventNotifications.java | 9 |
2 files changed, 30 insertions, 7 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/EventNotificationsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/EventNotificationsCategory.java index 5b33f7cf..af30f502 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/EventNotificationsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/EventNotificationsCategory.java @@ -1,12 +1,12 @@ package de.hysky.skyblocker.config.categories; +import de.hysky.skyblocker.config.ConfigUtils; import de.hysky.skyblocker.config.SkyblockerConfig; import de.hysky.skyblocker.skyblock.events.EventNotifications; import de.hysky.skyblocker.utils.config.DurationController; -import dev.isxander.yacl3.api.ConfigCategory; -import dev.isxander.yacl3.api.ListOption; -import dev.isxander.yacl3.api.OptionDescription; -import dev.isxander.yacl3.api.OptionGroup; +import dev.isxander.yacl3.api.*; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.text.Text; import java.util.ArrayList; @@ -15,9 +15,27 @@ import java.util.Map; public class EventNotificationsCategory { - public static ConfigCategory create(SkyblockerConfig config) { + private static boolean shouldPlaySound = false; + + public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig config) { + shouldPlaySound = false; return ConfigCategory.createBuilder() .name(Text.literal("Event Notifications")) + .option(Option.<SkyblockerConfig.EventNotifications.Sound>createBuilder() + .binding(defaults.eventNotifications.reminderSound, + () -> config.eventNotifications.reminderSound, + sound -> config.eventNotifications.reminderSound = sound) + .controller(ConfigUtils::createEnumCyclingListController) + .name(Text.literal("Notification Sound")) + .listener((soundOption, sound) -> { + if (!shouldPlaySound) { + shouldPlaySound = true; + return; + } + if (sound.getSoundEvent() != null) + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(sound.getSoundEvent(), 1f, 1f)); + }) + .build()) .groups(createGroups(config)) .build(); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/events/EventNotifications.java b/src/main/java/de/hysky/skyblocker/skyblock/events/EventNotifications.java index f7f82afb..c62fed21 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/events/EventNotifications.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/events/EventNotifications.java @@ -14,8 +14,10 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.sound.PositionedSoundInstance; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.sound.SoundEvent; import org.apache.commons.lang3.builder.ToStringBuilder; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; @@ -129,16 +131,19 @@ public class EventNotifications { for (Integer reminderTime : reminderTimes) { if (currentTime + reminderTime < skyblockEvent.start() && newTime + reminderTime >= skyblockEvent.start()) { + MinecraftClient instance = MinecraftClient.getInstance(); if (eventName.equals("Jacob's Farming Contest")) { - MinecraftClient.getInstance().getToastManager().add( + instance.getToastManager().add( new JacobEventToast(skyblockEvent.start(), eventName, skyblockEvent.extras()) ); } else { - MinecraftClient.getInstance().getToastManager().add( + instance.getToastManager().add( new EventToast(skyblockEvent.start(), eventName, eventIcons.getOrDefault(eventName, new ItemStack(Items.PAPER))) ); } + SoundEvent soundEvent = SkyblockerConfigManager.get().eventNotifications.reminderSound.getSoundEvent(); + if (soundEvent != null) instance.getSoundManager().play(PositionedSoundInstance.master(soundEvent, 1f, 1f)); break; } } |