diff --git a/src/main/java/com/extendedclip/deluxemenus/action/ActionType.java b/src/main/java/com/extendedclip/deluxemenus/action/ActionType.java index f843315..0196647 100644 --- a/src/main/java/com/extendedclip/deluxemenus/action/ActionType.java +++ b/src/main/java/com/extendedclip/deluxemenus/action/ActionType.java @@ -32,8 +32,11 @@ public enum ActionType { CLOSE("[close]", "Close the viewers open menu", "- '[close]"), REFRESH("[refresh]", "Refresh items in the current menu view", "- '[refresh]"), BROADCAST_SOUND("[broadcastsound]", "Broadcast a sound to the server", "- '[broadcastsound]"), + BROADCAST_RAW_SOUND("[broadcastrawsound]", "Broadcast a RAW sound to the server", "- '[broadcastrawsound]"), BROADCAST_WORLD_SOUND("[broadcastsoundworld]", "Broadcast a sound to the player's world", "- '[broadcastsoundworld]"), + BROADCAST_WORLD_RAW_SOUND("[broadcastrawsoundworld]", "Broadcast a RAW sound to the player's world", "- '[broadcastrawsoundworld]"), PLAY_SOUND("[sound]", "Play a sound for a the specific player", "- '[sound]"), + PLAY_RAW_SOUND("[rawsound]", "Play a RAW sound for a the specific player", "- '[rawsound]"), TAKE_MONEY("[takemoney]", "Take money from a player (requires Vault)", "- '[takemoney] "), GIVE_MONEY("[givemoney]", "Give money to a player (requires Vault)", "- '[givemoney] "), TAKE_EXP("[takeexp]", "Take exp points/levels from a player", "- '[takeexp] L'"), diff --git a/src/main/java/com/extendedclip/deluxemenus/action/ClickActionTask.java b/src/main/java/com/extendedclip/deluxemenus/action/ClickActionTask.java index 2fa55ec..020bbb8 100644 --- a/src/main/java/com/extendedclip/deluxemenus/action/ClickActionTask.java +++ b/src/main/java/com/extendedclip/deluxemenus/action/ClickActionTask.java @@ -352,33 +352,45 @@ public void run() { break; case BROADCAST_SOUND: + case BROADCAST_RAW_SOUND: case BROADCAST_WORLD_SOUND: + case BROADCAST_WORLD_RAW_SOUND: + case PLAY_RAW_SOUND: case PLAY_SOUND: - final Sound sound; + boolean isRaw = isRaw(actionType); + + Sound sound = null; + String soundName = executable; float volume = 1; float pitch = 1; if (!executable.contains(" ")) { - try { - sound = Sound.valueOf(executable.toUpperCase()); - } catch (final IllegalArgumentException exception) { - DeluxeMenus.printStacktrace( - "Sound name given for sound action: " + executable + ", is not a valid sound!", - exception - ); - break; + if (!isRaw) { + try { + sound = Sound.valueOf(executable.toUpperCase()); + } catch (final IllegalArgumentException exception) { + DeluxeMenus.printStacktrace( + "Sound name given for sound action: " + executable + ", is not a valid sound!", + exception + ); + break; + } } } else { String[] parts = executable.split(" ", 3); - try { - sound = Sound.valueOf(parts[0].toUpperCase()); - } catch (final IllegalArgumentException exception) { - DeluxeMenus.printStacktrace( - "Sound name given for sound action: " + parts[0] + ", is not a valid sound!", - exception - ); - break; + if (!isRaw) { + try { + sound = Sound.valueOf(parts[0].toUpperCase()); + } catch (final IllegalArgumentException exception) { + DeluxeMenus.printStacktrace( + "Sound name given for sound action: " + parts[0] + ", is not a valid sound!", + exception + ); + break; + } + } else { + soundName = parts[0]; } if (parts.length == 3) { @@ -416,6 +428,21 @@ public void run() { } switch (actionType) { + case BROADCAST_WORLD_RAW_SOUND: + for (final Player broadcastTarget : player.getWorld().getPlayers()) { + broadcastTarget.playSound(broadcastTarget.getLocation(), soundName, volume, pitch); + } + break; + + case BROADCAST_RAW_SOUND: + for (final Player broadcastTarget : Bukkit.getOnlinePlayers()) { + broadcastTarget.playSound(broadcastTarget.getLocation(), soundName, volume, pitch); + } + break; + + case PLAY_RAW_SOUND: + player.playSound(player.getLocation(), soundName, volume, pitch); + break; case BROADCAST_SOUND: for (final Player broadcastTarget : Bukkit.getOnlinePlayers()) { broadcastTarget.playSound(broadcastTarget.getLocation(), sound, volume, pitch); @@ -438,4 +465,9 @@ public void run() { break; } } + + private boolean isRaw(ActionType actionType) { + return actionType == ActionType.PLAY_RAW_SOUND || actionType == ActionType.BROADCAST_RAW_SOUND || actionType == ActionType.BROADCAST_WORLD_RAW_SOUND; + } + } \ No newline at end of file