From ad9b1573c259b5489d3d667ec2100798f3573e86 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sun, 23 Jan 2022 21:52:17 +0300 Subject: [PATCH 1/3] 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 From d9f19aaf9c7c058d0f20103540a5fbeda472e4bd Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sun, 23 Jan 2022 22:56:21 +0300 Subject: [PATCH 2/3] Added item lookup system support to all GUI items (except mask materials) --- .../com/willfp/reforges/gui/ReforgeGUI.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/gui/ReforgeGUI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/gui/ReforgeGUI.kt index 8df57f8..cf54a5e 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/gui/ReforgeGUI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/gui/ReforgeGUI.kt @@ -7,6 +7,7 @@ import com.willfp.eco.core.gui.menu.Menu import com.willfp.eco.core.gui.slot.FillerMask import com.willfp.eco.core.gui.slot.MaskMaterials import com.willfp.eco.core.gui.slot.Slot +import com.willfp.eco.core.items.Items import com.willfp.eco.core.items.builder.ItemStackBuilder import com.willfp.eco.util.NumberUtils import com.willfp.reforges.ReforgesPlugin @@ -114,12 +115,9 @@ object ReforgeGUI { .mapNotNull { Material.getMaterial(it.uppercase()) } .toTypedArray() - val allowMaterial = - Material.getMaterial(plugin.configYml.getString("gui.show-allowed.allow-material", false).uppercase())!! - val denyMaterial = - Material.getMaterial(plugin.configYml.getString("gui.show-allowed.deny-material", false).uppercase())!! - val closeMaterial = - Material.getMaterial(plugin.configYml.getString("gui.close.material", false).toUpperCase())!! + val allowItem = Items.lookup(plugin.configYml.getString("gui.show-allowed.allow-material")).item + val denyItem = Items.lookup(plugin.configYml.getString("gui.show-allowed.deny-material")).item + val closeItem = Items.lookup(plugin.configYml.getString("gui.close.material")).item menu = Menu.builder(plugin.configYml.getInt("gui.rows")).apply { setTitle(plugin.langYml.getFormattedString("menu.title")) @@ -136,9 +134,11 @@ object ReforgeGUI { ).status if (status == ReforgeStatus.ALLOW || status == ReforgeStatus.ALLOW_STONE) { - previous.type = allowMaterial + previous.type = allowItem.type + previous.itemMeta = allowItem.itemMeta } else { - previous.type = denyMaterial + previous.type = denyItem.type + previous.itemMeta = denyItem.itemMeta } } }.build() @@ -172,7 +172,7 @@ object ReforgeGUI { plugin.configYml.getInt("gui.close.location.row"), plugin.configYml.getInt("gui.close.location.column"), Slot.builder( - ItemStackBuilder(closeMaterial) + ItemStackBuilder(closeItem) .setDisplayName(plugin.langYml.getFormattedString("menu.close")) .build() ).onLeftClick { event, _, _ -> From 04f7a746b8fd41493ae5eeb5d527559a89cb0d58 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Tue, 25 Jan 2022 20:26:15 +0300 Subject: [PATCH 3/3] Fixed open command broken from previous commit --- .../src/main/kotlin/com/willfp/reforges/commands/CommandOpen.kt | 1 + 1 file changed, 1 insertion(+) 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 f43dc24..e196719 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 @@ -29,6 +29,7 @@ class CommandOpen( plugin.configYml.getDouble("gui.open-sound.pitch").toFloat() ) } + menu.open(player) } override fun tabComplete(sender: CommandSender, args: List): List {