diff options
Diffstat (limited to 'src/main')
4 files changed, 32 insertions, 2 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 6fd01cf8..ae4882f2 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/EventNotificationsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/EventNotificationsCategory.java @@ -24,6 +24,13 @@ public class EventNotificationsCategory { shouldPlaySound = false; return ConfigCategory.createBuilder() .name(Text.translatable("skyblocker.config.eventNotifications")) + .option(Option.<EventNotificationsConfig.Criterion>createBuilder() + .binding(defaults.eventNotifications.criterion, + () -> config.eventNotifications.criterion, + criterion -> config.eventNotifications.criterion = criterion) + .controller(ConfigUtils::createEnumCyclingListController) + .name(Text.translatable("skyblocker.config.eventNotifications.criterion")) + .build()) .option(Option.<EventNotificationsConfig.Sound>createBuilder() .binding(defaults.eventNotifications.reminderSound, () -> config.eventNotifications.reminderSound, diff --git a/src/main/java/de/hysky/skyblocker/config/configs/EventNotificationsConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/EventNotificationsConfig.java index c43ae7a6..1fa7016c 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/EventNotificationsConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/EventNotificationsConfig.java @@ -9,6 +9,8 @@ import java.util.HashMap; import java.util.Map; public class EventNotificationsConfig { + @SerialEntry + public Criterion criterion = Criterion.SKYBLOCK; @SerialEntry public Sound reminderSound = Sound.PLING; @@ -16,6 +18,13 @@ public class EventNotificationsConfig { @SerialEntry public Map<String, IntList> eventsReminderTimes = new HashMap<>(); + public enum Criterion { + NONE, + SKYBLOCK, + HYPIXEL, + EVERYWHERE + } + public enum Sound { NONE(null), BELL(SoundEvents.BLOCK_BELL_USE), 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 0fd41969..da2a0c2f 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/events/EventNotifications.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/events/EventNotifications.java @@ -10,6 +10,7 @@ import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.events.SkyblockEvents; import de.hysky.skyblocker.utils.Http; +import de.hysky.skyblocker.utils.Utils; import de.hysky.skyblocker.utils.scheduler.Scheduler; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; @@ -23,7 +24,10 @@ import net.minecraft.sound.SoundEvent; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; -import java.util.*; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.concurrent.CompletableFuture; public class EventNotifications { @@ -140,7 +144,7 @@ public class EventNotifications { if (reminderTimes.isEmpty()) continue; for (Integer reminderTime : reminderTimes) { - if (currentTime + reminderTime < skyblockEvent.start() && newTime + reminderTime >= skyblockEvent.start()) { + if (criterionMet() && currentTime + reminderTime < skyblockEvent.start() && newTime + reminderTime >= skyblockEvent.start()) { MinecraftClient instance = MinecraftClient.getInstance(); if (eventName.equals(JACOBS)) { instance.getToastManager().add( @@ -161,6 +165,15 @@ public class EventNotifications { currentTime = newTime; } + private static boolean criterionMet() { + return switch (SkyblockerConfigManager.get().eventNotifications.criterion) { + case NONE -> false; + case SKYBLOCK -> Utils.isOnSkyblock(); + case HYPIXEL -> Utils.isOnHypixel(); + case EVERYWHERE -> true; + }; + } + public record SkyblockEvent(long start, int duration, String[] extras, @Nullable String warpCommand) { public static SkyblockEvent of(JsonObject jsonObject) { String location = jsonObject.get("location").getAsString(); diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 7b589243..133923fb 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -400,6 +400,7 @@ "skyblocker.config.eventNotifications": "Event Notifications", + "skyblocker.config.eventNotifications.criterion": "Notification Criterion", "skyblocker.config.eventNotifications.monologue": "can you pls log onto skyblock rq pls? that would be cool cuz like if you are seeing dis then it means that ur config either got cleared or that this is ur first time using the mod if so then thanks for choosing it and hopefully you enjoy it! so yea this is where you will be able to set reminders for all events in skyblock they will be added as you encounter so you first need to log onto skyblock so yea hope you enjoy the mod and all that", "skyblocker.config.eventNotifications.notificationSound": "Notification Sound", "skyblocker.config.eventNotifications.@Tooltip[0]": "Configure how much time before an event you will be reminded with a notification toast! For example if you set '5m' and '30s' in the list, you will receive a notification 5 minutes before and another 30 seconds before an event starts.", |