From ad9b1573c259b5489d3d667ec2100798f3573e86 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sun, 23 Jan 2022 21:52:17 +0300 Subject: [PATCH] Added enabled: true/false option to every sound in the config --- .../reforges/util/ReforgeHandler.java | 51 +++++++++++-------- .../willfp/reforges/commands/CommandOpen.kt | 15 +++--- .../reforges/commands/CommandReforge.kt | 14 ++--- .../core-plugin/src/main/resources/config.yml | 4 ++ 4 files changed, 50 insertions(+), 34 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/reforges/reforges/util/ReforgeHandler.java b/eco-core/core-plugin/src/main/java/com/willfp/reforges/reforges/util/ReforgeHandler.java index 2d9363d..0a220e0 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/reforges/reforges/util/ReforgeHandler.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/reforges/reforges/util/ReforgeHandler.java @@ -76,12 +76,14 @@ public class ReforgeHandler extends PluginDependent { if (!EconomyManager.hasAmount(player, cost)) { player.sendMessage(this.getPlugin().getLangYml().getMessage("insufficient-money")); - player.playSound( - player.getLocation(), - Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.insufficient-money-sound.id").toUpperCase()), - 1f, - (float) this.getPlugin().getConfigYml().getDouble("gui.insufficient-money-sound.pitch") - ); + if (this.getPlugin().getConfigYml().getBool("gui.insufficient-money-sound.enabled")) { + player.playSound( + player.getLocation(), + Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.insufficient-money-sound.id").toUpperCase()), + 1f, + (float) this.getPlugin().getConfigYml().getDouble("gui.insufficient-money-sound.pitch") + ); + } return; } @@ -92,13 +94,14 @@ public class ReforgeHandler extends PluginDependent { xpCost *= Math.pow(this.getPlugin().getConfigYml().getDouble("reforge.cost-exponent"), reforges); if (player.getLevel() < xpCost) { player.sendMessage(this.getPlugin().getLangYml().getMessage("insufficient-xp")); - - player.playSound( - player.getLocation(), - Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.insufficient-money-sound.id").toUpperCase()), - 1f, - (float) this.getPlugin().getConfigYml().getDouble("gui.insufficient-money-sound.pitch") - ); + if (this.getPlugin().getConfigYml().getBool("gui.insufficient-money-sound.enabled")) { + player.playSound( + player.getLocation(), + Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.insufficient-money-sound.id").toUpperCase()), + 1f, + (float) this.getPlugin().getConfigYml().getDouble("gui.insufficient-money-sound.pitch") + ); + } return; } @@ -120,19 +123,25 @@ public class ReforgeHandler extends PluginDependent { stone.setItemMeta(null); stone.setAmount(0); + if (this.getPlugin().getConfigYml().getBool("gui.stone-sound.enabled")) { + player.playSound( + player.getLocation(), + Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.stone-sound.id").toUpperCase()), + 1f, + (float) this.getPlugin().getConfigYml().getDouble("gui.stone-sound.pitch") + ); + } + + } + + if (this.getPlugin().getConfigYml().getBool("gui.sound.enabled")) { player.playSound( player.getLocation(), - Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.stone-sound.id").toUpperCase()), + Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.sound.id").toUpperCase()), 1f, - (float) this.getPlugin().getConfigYml().getDouble("gui.stone-sound.pitch") + (float) this.getPlugin().getConfigYml().getDouble("gui.sound.pitch") ); } - player.playSound( - player.getLocation(), - Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.sound.id").toUpperCase()), - 1f, - (float) this.getPlugin().getConfigYml().getDouble("gui.sound.pitch") - ); } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandOpen.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandOpen.kt index e42661d..f43dc24 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandOpen.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandOpen.kt @@ -21,13 +21,14 @@ class CommandOpen( sender.sendMessage(plugin.langYml.getMessage("invalid-player")) return } - player.playSound( - player.location, - Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()), - 1f, - plugin.configYml.getDouble("gui.open-sound.pitch").toFloat() - ) - menu.open(player) + if (plugin.configYml.getBool("gui.open-sound.enabled")) { + player.playSound( + player.location, + Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()), + 1f, + plugin.configYml.getDouble("gui.open-sound.pitch").toFloat() + ) + } } override fun tabComplete(sender: CommandSender, args: List): List { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforge.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforge.kt index 902a523..59fee3b 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforge.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforge.kt @@ -12,12 +12,14 @@ class CommandReforge( ) : PluginCommand(plugin, "reforge", "reforges.command.reforge", true) { override fun onExecute(player: CommandSender, args: List) { player as Player - player.playSound( - player.location, - Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()), - 1f, - plugin.configYml.getDouble("gui.open-sound.pitch").toFloat() - ) + if (plugin.configYml.getBool("gui.open-sound.enabled")) { + player.playSound( + player.location, + Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()), + 1f, + plugin.configYml.getDouble("gui.open-sound.pitch").toFloat() + ) + } menu.open(player) } } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index e759454..b3ff2aa 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -105,18 +105,22 @@ gui: - '&7You cannot reforge this item!' sound: + enabled: true id: BLOCK_ANVIL_USE pitch: 1 open-sound: + enabled: true id: BLOCK_ANVIL_PLACE pitch: 0.8 stone-sound: + enabled: true id: ENTITY_ENDER_DRAGON_HURT pitch: 0.5 insufficient-money-sound: + enabled: true id: ENTITY_VILLAGER_NO pitch: 0.8