From caf08e83c66653436b4db8671a133cc620811f53 Mon Sep 17 00:00:00 2001 From: ev chang Date: Thu, 20 Jun 2024 23:13:14 +0700 Subject: [PATCH] Add lobbysounds migration + fix autogg migration --- .../club/sk1er/lobbysounds/config/Sounds.java | 58 +++++++ .../mods/autogg/config/AutoGGConfig.java | 17 ++- .../polyfrost/hytils/config/HytilsConfig.java | 141 ++++++++++++++++-- 3 files changed, 198 insertions(+), 18 deletions(-) create mode 100644 src/dummy/java/club/sk1er/lobbysounds/config/Sounds.java diff --git a/src/dummy/java/club/sk1er/lobbysounds/config/Sounds.java b/src/dummy/java/club/sk1er/lobbysounds/config/Sounds.java new file mode 100644 index 0000000..befb866 --- /dev/null +++ b/src/dummy/java/club/sk1er/lobbysounds/config/Sounds.java @@ -0,0 +1,58 @@ +/* + * Hytils Reborn - Hypixel focused Quality of Life mod. + * Copyright (C) 2020, 2021, 2022, 2023 Polyfrost, Sk1er LLC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package club.sk1er.lobbysounds.config; + +public class Sounds { + + public static boolean DISABLE_SLIME_SOUNDS; + + public static boolean DISABLE_DRAGON_SOUNDS; + + public static boolean DISABLE_WITHER_SOUNDS; + + public static boolean DISABLE_ITEM_PICKUP_SOUNDS; + + public static boolean DISABLE_EXPERIENCE_SOUNDS; + + public static boolean DISABLE_TNT_PRIME_SOUNDS; + + public static boolean DISABLE_EXPLOSION_SOUNDS; + + public static boolean DISABLE_DELIVERY_MAN_SOUNDS; + + public static boolean DISABLE_NOTE_SOUNDS; + + public static boolean DISABLE_FIREWORKS_SOUNDS; + + public static boolean DISABLE_LEVELUP_SOUNDS; + + public static boolean DISABLE_STEP_SOUNDS; + + public static boolean DISABLE_ARROW_SOUNDS; + + public static boolean DISABLE_BAT_SOUNDS; + + public static boolean DISABLE_FIRE_SOUNDS; + + public static boolean DISABLE_ENDERMEN_SOUNDS; + + public void markDirty() {} + + public void writeData() {} +} diff --git a/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java b/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java index 3507d12..da715fa 100644 --- a/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java +++ b/src/dummy/java/club/sk1er/mods/autogg/config/AutoGGConfig.java @@ -20,16 +20,15 @@ public class AutoGGConfig { - // these arent the actual default values private boolean autoGGEnabled = true; - private boolean casualAutoGGEnabled = true; - private boolean antiGGEnabled = true; - private boolean antiKarmaEnabled = true; - private int autoGGDelay = 5; + private boolean casualAutoGGEnabled; + private boolean antiGGEnabled; + private boolean antiKarmaEnabled; + private int autoGGDelay = 1; private int autoGGPhrase = 0; - private boolean secondaryEnabled = true; + private boolean secondaryEnabled; private int autoGGPhrase2 = 0; - private int secondaryDelay = 5; + private int secondaryDelay = 1; public boolean isModEnabled() { return autoGGEnabled; @@ -66,4 +65,8 @@ public int getAutoGGPhrase2() { public int getSecondaryDelay() { return secondaryDelay; } + + public void markDirty() {} + + public void writeData() {} } diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index 5ff47e6..e2333bd 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -19,6 +19,7 @@ package org.polyfrost.hytils.config; import cc.polyfrost.oneconfig.config.Config; +import cc.polyfrost.oneconfig.config.annotations.Checkbox; import cc.polyfrost.oneconfig.config.annotations.*; import cc.polyfrost.oneconfig.config.core.OneColor; import cc.polyfrost.oneconfig.config.data.InfoType; @@ -27,13 +28,14 @@ import cc.polyfrost.oneconfig.config.data.PageLocation; import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator; import cc.polyfrost.oneconfig.utils.Notifications; +import club.sk1er.lobbysounds.config.Sounds; import club.sk1er.mods.autogg.AutoGG; -import org.polyfrost.hytils.HytilsReborn; -import org.polyfrost.hytils.handlers.chat.modules.modifiers.GameStartCompactor; -import org.polyfrost.hytils.util.DarkColorUtils; import com.google.common.collect.Lists; import net.minecraft.client.Minecraft; import org.apache.commons.io.FileUtils; +import org.polyfrost.hytils.HytilsReborn; +import org.polyfrost.hytils.handlers.chat.modules.modifiers.GameStartCompactor; +import org.polyfrost.hytils.util.DarkColorUtils; import java.awt.Color; import java.io.File; @@ -1254,23 +1256,140 @@ public HytilsConfig() { HytilsReborn.INSTANCE.isSk1erAutoGG = true; - autoGG = AutoGG.INSTANCE.getAutoGGConfig().isModEnabled(); - autoGGSecondMessage = AutoGG.INSTANCE.getAutoGGConfig().isSecondaryEnabled(); - casualAutoGG = AutoGG.INSTANCE.getAutoGGConfig().isCasualAutoGGEnabled(); - autoGGMessage = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase(); - autoGGFirstPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGDelay(); - autoGGMessage2 = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase2(); - autoGGSecondPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getSecondaryDelay(); + if (AutoGG.INSTANCE.getAutoGGConfig().isModEnabled()) { + autoGG = true; + } + if (AutoGG.INSTANCE.getAutoGGConfig().isSecondaryEnabled()) { + autoGGSecondMessage = true; + } + if (AutoGG.INSTANCE.getAutoGGConfig().isCasualAutoGGEnabled()) { + casualAutoGG = true; + } + if (AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase() != 0) { + autoGGMessage = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase(); + } + if (AutoGG.INSTANCE.getAutoGGConfig().getAutoGGDelay() != 1) { + autoGGFirstPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGDelay(); + } + if (AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase2() != 0) { + autoGGMessage2 = AutoGG.INSTANCE.getAutoGGConfig().getAutoGGPhrase2(); + } + if (AutoGG.INSTANCE.getAutoGGConfig().getSecondaryDelay() != 1) { + autoGGSecondPhraseDelay = AutoGG.INSTANCE.getAutoGGConfig().getSecondaryDelay(); + } + if (AutoGG.INSTANCE.getAutoGGConfig().isAntiGGEnabled()) { + antiGG = true; + } + if (AutoGG.INSTANCE.getAutoGGConfig().isAntiKarmaEnabled()) { + hideKarmaMessages = true; + } try { Field sk1erEnabled = clazz.getDeclaredField("autoGGEnabled"); sk1erEnabled.setAccessible(true); sk1erEnabled.set(AutoGG.INSTANCE.getAutoGGConfig(), false); + + AutoGG.INSTANCE.getAutoGGConfig().markDirty(); + AutoGG.INSTANCE.getAutoGGConfig().writeData(); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } - Notifications.INSTANCE.send("Hytils Reborn", "AutoGG settings have been migrated to Hytils Reborn. You can now configure them in the Hytils Reborn settings.", 5); + Notifications.INSTANCE.send("Hytils Reborn", "AutoGG settings have been migrated to Hytils Reborn. You can now configure them in the Hytils Reborn settings, and remove Sk1erLLC's AutoGG.", 5); + } catch (ClassNotFoundException ignored) { + + } + try { + Class.forName("club.sk1er.lobbysounds.config.Sounds"); + boolean modified = false; + if (Sounds.DISABLE_SLIME_SOUNDS) { + lobbyDisableSlimeSounds = true; + modified = true; + } + if (Sounds.DISABLE_DRAGON_SOUNDS) { + lobbyDisableDragonSounds = true; + modified = true; + } + if (Sounds.DISABLE_WITHER_SOUNDS) { + lobbyDisableWitherSounds = true; + modified = true; + } + if (Sounds.DISABLE_ITEM_PICKUP_SOUNDS) { + lobbyDisableItemPickupSounds = true; + modified = true; + } + if (Sounds.DISABLE_EXPERIENCE_SOUNDS) { + lobbyDisableExperienceOrbSounds = true; + modified = true; + } + if (Sounds.DISABLE_TNT_PRIME_SOUNDS) { + lobbyDisablePrimedTntSounds = true; + modified = true; + } + if (Sounds.DISABLE_EXPLOSION_SOUNDS) { + lobbyDisableExplosionSounds = true; + modified = true; + } + if (Sounds.DISABLE_DELIVERY_MAN_SOUNDS) { + lobbyDisableDeliveryManSounds = true; + modified = true; + } + if (Sounds.DISABLE_NOTE_SOUNDS) { + lobbyDisableNoteBlockSounds = true; + modified = true; + } + if (Sounds.DISABLE_FIREWORKS_SOUNDS) { + lobbyDisableFireworkSounds = true; + modified = true; + } + if (Sounds.DISABLE_LEVELUP_SOUNDS) { + lobbyDisableLevelupSounds = true; + modified = true; + } + if (Sounds.DISABLE_ARROW_SOUNDS) { + lobbyDisableArrowSounds = true; + modified = true; + } + if (Sounds.DISABLE_BAT_SOUNDS) { + lobbyDisableBatSounds = true; + modified = true; + } + if (Sounds.DISABLE_FIRE_SOUNDS) { + lobbyDisableFireSounds = true; + modified = true; + } + if (Sounds.DISABLE_ENDERMEN_SOUNDS) { + lobbyDisableEndermanSounds = true; + modified = true; + } + if (Sounds.DISABLE_STEP_SOUNDS) { + lobbyDisableSteppingSounds = true; + modified = true; + } + + if (Sounds.DISABLE_SLIME_SOUNDS && + Sounds.DISABLE_DRAGON_SOUNDS && + Sounds.DISABLE_WITHER_SOUNDS && + Sounds.DISABLE_ITEM_PICKUP_SOUNDS && + Sounds.DISABLE_EXPERIENCE_SOUNDS && + Sounds.DISABLE_TNT_PRIME_SOUNDS && + Sounds.DISABLE_EXPLOSION_SOUNDS && + Sounds.DISABLE_DELIVERY_MAN_SOUNDS && + Sounds.DISABLE_NOTE_SOUNDS && + Sounds.DISABLE_FIREWORKS_SOUNDS && + Sounds.DISABLE_LEVELUP_SOUNDS && + Sounds.DISABLE_ARROW_SOUNDS && + Sounds.DISABLE_BAT_SOUNDS && + Sounds.DISABLE_FIRE_SOUNDS && + Sounds.DISABLE_ENDERMEN_SOUNDS && + Sounds.DISABLE_STEP_SOUNDS) { + silentLobby = true; + lobbyDisableDoorSounds = true; + } + + if (modified) { + Notifications.INSTANCE.send("Hytils Reborn", "Lobby Sounds settings have been migrated to Hytils Reborn. You can now configure them in the Hytils Reborn settings, and remove Sk1erLLC's Lobby Sounds.", 5); + } } catch (ClassNotFoundException ignored) { }