2828import net .jadedmc .commandblockerpro .events .CommandBlockEvent ;
2929import net .jadedmc .commandblockerpro .rules .Rule ;
3030import net .jadedmc .commandblockerpro .utils .ChatUtils ;
31+ import org .bukkit .Sound ;
3132import org .bukkit .entity .Player ;
3233import org .bukkit .event .EventHandler ;
3334import org .bukkit .event .Listener ;
@@ -54,14 +55,14 @@ public PlayerCommandPreprocessListener(final CommandBlockerProPlugin plugin) {
5455 */
5556 @ EventHandler
5657 public void onCommandSend (PlayerCommandPreprocessEvent event ) {
57- Player player = event .getPlayer ();
58- String command = event .getMessage ().split (" " )[0 ];
58+ final Player player = event .getPlayer ();
59+ final String command = event .getMessage ().split (" " )[0 ];
5960
6061 // Loop through each rule configured, blocking the command if the rule catches it.
61- for (Rule rule : plugin .ruleManager ().rules ()) {
62+ for (final Rule rule : plugin .ruleManager ().getRules ()) {
6263 if (rule .shouldBlock (player , command )) {
6364 // Calls the CommandBlockEvent.
64- CommandBlockEvent commandBlockEvent = new CommandBlockEvent (player , command , rule );
65+ final CommandBlockEvent commandBlockEvent = new CommandBlockEvent (player , command , rule );
6566 plugin .getServer ().getPluginManager ().callEvent (commandBlockEvent );
6667
6768 // If the CommandBlockEvent is cancelled, allow the command to be processed.
@@ -82,6 +83,24 @@ public void onCommandSend(PlayerCommandPreprocessEvent event) {
8283 if (rule .hasBlockSound ()) {
8384 player .playSound (player .getLocation (), rule .getBlockSound (), rule .getBlockSoundVolume (), rule .getBlockSoundPitch ());
8485 }
86+ else if (plugin .settingsManager ().getConfig ().isSet ("blockSound.sound" )) {
87+ final Sound blockSound = Sound .valueOf (plugin .settingsManager ().getConfig ().getString ("blockSound.sound" ));
88+ float blockSoundPitch = 1.0f ;
89+ float blockSoundVolume = 1.0f ;
90+
91+ // Check for sound pitch.
92+ if (plugin .settingsManager ().getConfig ().isSet ("blockSound.pitch" )) {
93+ blockSoundPitch = (float ) plugin .settingsManager ().getConfig ().getDouble ("blockSound.pitch" );
94+ }
95+
96+ // Check for Sound volume.
97+ if (plugin .settingsManager ().getConfig ().isSet ("blockSound.volume" )) {
98+ blockSoundVolume = (float ) plugin .settingsManager ().getConfig ().getDouble ("blockSound.volume" );
99+ }
100+
101+ // Play the sound.
102+ player .playSound (player .getLocation (), blockSound , blockSoundVolume , blockSoundPitch );
103+ }
85104 }
86105 }
87106 }
0 commit comments