From 72759b74427e6b96a915d363cabb1a5e23b654f9 Mon Sep 17 00:00:00 2001 From: XiaoMoMi Date: Sun, 5 Jan 2025 16:27:09 +0800 Subject: [PATCH] Update PlayerActionManager.java --- .../bukkit/action/PlayerActionManager.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/plugin/src/main/java/net/momirealms/customcrops/bukkit/action/PlayerActionManager.java b/plugin/src/main/java/net/momirealms/customcrops/bukkit/action/PlayerActionManager.java index 4f89214..cc02b92 100644 --- a/plugin/src/main/java/net/momirealms/customcrops/bukkit/action/PlayerActionManager.java +++ b/plugin/src/main/java/net/momirealms/customcrops/bukkit/action/PlayerActionManager.java @@ -368,15 +368,18 @@ public class PlayerActionManager extends AbstractActionManager { private void registerSoundAction() { registerAction((args, chance) -> { if (args instanceof Section section) { - Sound sound = Sound.sound( - Key.key(section.getString("key")), - Sound.Source.valueOf(section.getString("source", "PLAYER").toUpperCase(Locale.ENGLISH)), - section.getDouble("volume", 1.0).floatValue(), - section.getDouble("pitch", 1.0).floatValue() - ); + MathValue volume = MathValue.auto(section.get("volume")); + MathValue pitch = MathValue.auto(section.get("pitch")); + Key key = Key.key(section.getString("key")); + Sound.Source source = Sound.Source.valueOf(section.getString("source", "PLAYER").toUpperCase(Locale.ENGLISH)); return context -> { - if (context.holder() == null) return; if (Math.random() > chance.evaluate(context)) return; + Sound sound = Sound.sound( + key, + source, + (float) volume.evaluate(context), + (float) pitch.evaluate(context) + ); Audience audience = plugin.getSenderFactory().getAudience(context.holder()); AdventureHelper.playSound(audience, sound); };