diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/main/java/me/Danker/DankersSkyblockMod.java | 6 | ||||
-rw-r--r-- | src/main/java/me/Danker/commands/CustomMusicCommand.java | 38 | ||||
-rw-r--r-- | src/main/java/me/Danker/features/CustomMusic.java | 3 | ||||
-rw-r--r-- | src/main/java/me/Danker/handlers/ConfigHandler.java | 1 |
5 files changed, 43 insertions, 7 deletions
@@ -85,7 +85,7 @@ Discord Server: https://discord.gg/QsEkNQS - /reparty - Disbands and reparties all members in the party - /fairysouls - Check the fairysouls of a player - /lobbybank - Uses API to find the average bank total of the lobby, as well the three players with the highest total money in the bank (and purse). -- /dsmmusic <stop/reload> - Stops or reloads the custom music. +- /dsmmusic <stop/reload/volume> [dungeonboss] [#] - Stops or reloads the custom music. ## Keybinds - Open Maddox menu - M by default. diff --git a/src/main/java/me/Danker/DankersSkyblockMod.java b/src/main/java/me/Danker/DankersSkyblockMod.java index 4b453ea..84cd9cc 100644 --- a/src/main/java/me/Danker/DankersSkyblockMod.java +++ b/src/main/java/me/Danker/DankersSkyblockMod.java @@ -85,7 +85,7 @@ public class DankersSkyblockMod { public static String ANSWER_COLOUR; @EventHandler - public void init(FMLInitializationEvent event) { + public void init(FMLInitializationEvent event) throws UnsupportedAudioFileException, IOException, LineUnavailableException { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new ArachneESP()); MinecraftForge.EVENT_BUS.register(new ArrowTerminalSolver()); @@ -141,6 +141,7 @@ public class DankersSkyblockMod { ConfigHandler.reloadConfig(); GoldenEnchants.init(); TriviaSolver.init(); + CustomMusic.init(configDirectory); keyBindings[0] = new KeyBinding("Open Maddox Menu", Keyboard.KEY_M, "Danker's Skyblock Mod"); keyBindings[1] = new KeyBinding("Regular Ability", Keyboard.KEY_NUMPAD4, "Danker's Skyblock Mod"); @@ -152,7 +153,7 @@ public class DankersSkyblockMod { } @EventHandler - public void preInit(final FMLPreInitializationEvent event) throws UnsupportedAudioFileException, IOException, LineUnavailableException { + public void preInit(final FMLPreInitializationEvent event) { ClientCommandHandler.instance.registerCommand(new ArmourCommand()); ClientCommandHandler.instance.registerCommand(new BankCommand()); ClientCommandHandler.instance.registerCommand(new BlockSlayerCommand()); @@ -181,7 +182,6 @@ public class DankersSkyblockMod { ClientCommandHandler.instance.registerCommand(new ToggleCommand()); configDirectory = event.getModConfigurationDirectory().toString(); - CustomMusic.init(configDirectory); } @EventHandler diff --git a/src/main/java/me/Danker/commands/CustomMusicCommand.java b/src/main/java/me/Danker/commands/CustomMusicCommand.java index 0279ee8..8e389ac 100644 --- a/src/main/java/me/Danker/commands/CustomMusicCommand.java +++ b/src/main/java/me/Danker/commands/CustomMusicCommand.java @@ -2,6 +2,7 @@ package me.Danker.commands; import me.Danker.DankersSkyblockMod; import me.Danker.features.CustomMusic; +import me.Danker.handlers.ConfigHandler; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; @@ -9,6 +10,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; +import javax.sound.sampled.Clip; +import javax.sound.sampled.FloatControl; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.UnsupportedAudioFileException; import java.io.IOException; @@ -23,7 +26,7 @@ public class CustomMusicCommand extends CommandBase { @Override public String getCommandUsage(ICommandSender arg0) { - return "/" + getCommandName() + " <stop/reload>"; + return "/" + getCommandName() + " <stop/reload/volume> [dungeonboss] [#]"; } public static String usage(ICommandSender arg0) { @@ -38,7 +41,9 @@ public class CustomMusicCommand extends CommandBase { @Override public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { if (args.length == 1) { - return getListOfStringsMatchingLastWord(args, "stop", "reload"); + return getListOfStringsMatchingLastWord(args, "stop", "reload", "volume"); + } else if (args.length == 2) { + return getListOfStringsMatchingLastWord(args, "dungeonboss"); } return null; } @@ -66,6 +71,35 @@ public class CustomMusicCommand extends CommandBase { e.printStackTrace(); } break; + case "volume": + if (arg1.length < 3) { + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); + return; + } + + switch (arg1[1].toLowerCase()) { + case "dungeonboss": + try { + float volume = Float.parseFloat(arg1[2]); + + FloatControl bounds = (FloatControl) CustomMusic.dungeonboss.getControl(FloatControl.Type.MASTER_GAIN); + if (volume <= bounds.getMinimum() || volume >= bounds.getMaximum()) { + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Volume can only be set between " + bounds.getMinimum() + " and " + bounds.getMaximum() + ".")); + return; + } + + CustomMusic.dungeonbossDecibels = volume; + ConfigHandler.writeIntConfig("music", "DungeonBossDecibels", (int) volume); + CustomMusic.init(DankersSkyblockMod.configDirectory); + } catch (IOException | LineUnavailableException | UnsupportedAudioFileException e) { + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "An error occurred while trying to reload music.")); + e.printStackTrace(); + } + break; + default: + player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); + } + break; default: player.addChatMessage(new ChatComponentText(DankersSkyblockMod.ERROR_COLOUR + "Usage: " + getCommandUsage(arg0))); } diff --git a/src/main/java/me/Danker/features/CustomMusic.java b/src/main/java/me/Danker/features/CustomMusic.java index 3c411d8..ee0a2cc 100644 --- a/src/main/java/me/Danker/features/CustomMusic.java +++ b/src/main/java/me/Danker/features/CustomMusic.java @@ -25,6 +25,7 @@ public class CustomMusic { static boolean prevInDungeonBossRoom = false; static boolean inDungeonBossRoom = false; public static Clip dungeonboss; + public static float dungeonbossDecibels; @SubscribeEvent public void onWorldChange(WorldEvent.Load event) { @@ -98,7 +99,7 @@ public class CustomMusic { dungeonboss.open(ais); FloatControl volume = (FloatControl) dungeonboss.getControl(FloatControl.Type.MASTER_GAIN); - volume.setValue(-20F); + volume.setValue(dungeonbossDecibels); } } diff --git a/src/main/java/me/Danker/handlers/ConfigHandler.java b/src/main/java/me/Danker/handlers/ConfigHandler.java index 89eed6c..8a95ae5 100644 --- a/src/main/java/me/Danker/handlers/ConfigHandler.java +++ b/src/main/java/me/Danker/handlers/ConfigHandler.java @@ -274,6 +274,7 @@ public class ConfigHandler { ToggleCommand.hideTooltipsInExperimentAddonsToggled = initBoolean("toggles", "HideTooltipsInExperimentAddons", false); // Custom Music ToggleCommand.dungeonBossMusic = initBoolean("toggles", "DungeonBossMusic", false); + CustomMusic.dungeonbossDecibels = (float) initInt("music", "DungeonBossDecibels", -20); // API if (!hasKey("api", "APIKey")) writeStringConfig("api", "APIKey", ""); |