From 51cb660e5c1153b905821523018b864a7d179137 Mon Sep 17 00:00:00 2001 From: MicrocontrollersDev <66657148+MicrocontrollersDev@users.noreply.github.com> Date: Wed, 19 Jun 2024 07:38:56 -0700 Subject: [PATCH] add lobbysounds (#90) --- .../polyfrost/hytils/config/HytilsConfig.java | 127 ++++++++++++++++++ .../handlers/lobby/sound/SilentLobby.java | 79 ++++++++++- 2 files changed, 203 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java index fa13ae0..c8de3a0 100644 --- a/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java +++ b/src/main/java/org/polyfrost/hytils/config/HytilsConfig.java @@ -1001,6 +1001,125 @@ public class HytilsConfig extends Config { ) public static boolean silentLobby; + @Switch( + name = "Disable Stepping Sounds", + description = "Remove sounds created by stepping.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableSteppingSounds; + + @Switch( + name = "Disable Slime Sounds", + description = "Remove sounds created by slimes.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableSlimeSounds; + + @Switch( + name = "Disable Dragon Sounds", + description = "Remove sounds created by dragons.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableDragonSounds; + + @Switch( + name = "Disable Wither Sounds", + description = "Remove sounds created by withers & wither skeletons.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableWitherSounds; + + @Switch( + name = "Disable Item Pickup Sounds", + description = "Remove sounds created by picking up an item.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableItemPickupSounds; + + @Switch( + name = "Disable Experience Orb Sounds", + description = "Remove sounds created by experience orbs.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableExperienceOrbSounds; + + @Switch( + name = "Disable Primed TNT Sounds", + description = "Remove sounds created by primed TNT.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisablePrimedTntSounds; + + @Switch( + name = "Disable Explosion Sounds", + description = "Remove sounds created by explosions.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableExplosionSounds; + + @Switch( + name = "Disable Delivery Man Sounds", + description = "Remove sounds created by delivery man events.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableDeliveryManSounds; + + @Switch( + name = "Disable Mystery Box Sounds", + description = "Remove sounds created by mystery boxes.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableMysteryBoxSounds; + + @Switch( + name = "Disable Firework Sounds", + description = "Remove sounds created by fireworks.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableFireworkSounds; + + @Switch( + name = "Disable Levelup Sounds", + description = "Remove sounds created by someone leveling up.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableLevelupSounds; + + @Switch( + name = "Disable Arrow Sounds", + description = "Remove sounds created by arrows.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableArrowSounds; + + @Switch( + name = "Disable Bat Sounds", + description = "Remove sounds created by bats.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableBatSounds; + + @Switch( + name = "Disable Fire Sounds", + description = "Remove sounds created by fire.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableFireSounds; + + @Switch( + name = "Disable Enderman Sounds", + description = "Remove sounds created by endermen.", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableEndermanSounds; + + @Switch( + name = "Disable Door Sounds", + description = "Disable sounds caused by doors, trapdoors, and fence gates", + category = "Lobby", subcategory = "Sounds" + ) + public static boolean lobbyDisableDoorSounds; + @Switch( name = "Remove Limbo AFK Title", description = "Remove the AFK title when you get sent to limbo for being AFK.", @@ -1123,6 +1242,14 @@ public HytilsConfig() { //addDependency("editHeightOverlay", "heightOverlay"); addDependency("manuallyEditHeightOverlay", "heightOverlay"); //addDependency("editHeightOverlay", "manuallyEditHeightOverlay"); + + Arrays.asList( + "lobbyDisableSteppingSounds", "lobbyDisableSlimeSounds", "lobbyDisableDragonSounds", "lobbyDisableWitherSounds", + "lobbyDisableItemPickupSounds", "lobbyDisableExperienceOrbSounds", "lobbyDisablePrimedTntSounds", + "lobbyDisableExplosionSounds", "lobbyDisableDeliveryManSounds", "lobbyDisableMysteryBoxSounds", + "lobbyDisableFireworkSounds", "lobbyDisableLevelupSounds", "lobbyDisableArrowSounds", "lobbyDisableBatSounds", + "lobbyDisableFireSounds", "lobbyDisableEndermanSounds", "lobbyDisableDoorSounds" + ).forEach(property -> addDependency(property, "Silent Lobby", () -> !silentLobby)); } public void hideTabulous() { diff --git a/src/main/java/org/polyfrost/hytils/handlers/lobby/sound/SilentLobby.java b/src/main/java/org/polyfrost/hytils/handlers/lobby/sound/SilentLobby.java index 60abad7..056ac0c 100644 --- a/src/main/java/org/polyfrost/hytils/handlers/lobby/sound/SilentLobby.java +++ b/src/main/java/org/polyfrost/hytils/handlers/lobby/sound/SilentLobby.java @@ -25,12 +25,85 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class SilentLobby { - @SubscribeEvent public void onSoundPlay(PlaySoundEvent event) { - if (HypixelUtils.INSTANCE.isHypixel() && !LocrawUtil.INSTANCE.isInGame() && HytilsConfig.silentLobby) { - if (!event.name.startsWith("gui.")) { + if (HypixelUtils.INSTANCE.isHypixel() && !LocrawUtil.INSTANCE.isInGame()) { + String sound = event.name; + if (HytilsConfig.silentLobby && !sound.startsWith("gui.")) { event.result = null; + } else { + /* + This code is taken from LobbySounds by Sk1er LLC under the GPL License: + https://github.com/Sk1erLLC/LobbySounds/blob/master/LICENSE + Only changes to adapt to this project have been made, as well as additions. + */ + if (sound.startsWith("step.") && HytilsConfig.lobbyDisableSteppingSounds) { + event.result = null; + } + + if (sound.startsWith("mob.slime") && HytilsConfig.lobbyDisableSlimeSounds) { + event.result = null; + } + + if (sound.startsWith("mob.enderdragon") && HytilsConfig.lobbyDisableDragonSounds) { + event.result = null; + } + + if ((sound.startsWith("mob.wither") || sound.startsWith("mob.skeleton")) && HytilsConfig.lobbyDisableWitherSounds) { + event.result = null; + } + + if (sound.equals("random.orb") && HytilsConfig.lobbyDisableExperienceOrbSounds) { + event.result = null; + } + + if (sound.equals("random.pop") && HytilsConfig.lobbyDisableItemPickupSounds) { + event.result = null; + } + + if (sound.equals("game.tnt.primed") && HytilsConfig.lobbyDisablePrimedTntSounds) { + event.result = null; + } + + if (sound.equals("random.explode") && HytilsConfig.lobbyDisableExplosionSounds) { + event.result = null; + } + + if (sound.equals("mob.chicken.plop") && HytilsConfig.lobbyDisableDeliveryManSounds) { + event.result = null; + } + + if ((sound.startsWith("note.") || sound.equals("random.click")) && HytilsConfig.lobbyDisableMysteryBoxSounds) { + event.result = null; + } + + if (sound.startsWith("fireworks") && HytilsConfig.lobbyDisableFireworkSounds) { + event.result = null; + } + + if (sound.equals("random.levelup") && HytilsConfig.lobbyDisableLevelupSounds) { + event.result = null; + } + + if (sound.startsWith("mob.bat") && HytilsConfig.lobbyDisableBatSounds) { + event.result = null; + } + + if (sound.equals("fire.fire") && HytilsConfig.lobbyDisableFireSounds) { + event.result = null; + } + + if (sound.startsWith("mob.endermen") && HytilsConfig.lobbyDisableEndermanSounds) { + event.result = null; + } + + if (sound.startsWith("random.bow") && HytilsConfig.lobbyDisableArrowSounds) { + event.result = null; + } + + if (sound.startsWith("random.door") && HytilsConfig.lobbyDisableDoorSounds) { + event.result = null; + } } } }