Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom sounds in actions & Fix for <1.21.3 #159

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.extendedclip.deluxemenus.utils.VersionHelper;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.scheduler.BukkitRunnable;
Expand Down Expand Up @@ -354,32 +353,16 @@ public void run() {
case BROADCAST_SOUND:
case BROADCAST_WORLD_SOUND:
case PLAY_SOUND:
final Sound sound;
String sound;
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;
}
sound = executable;
} 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;
}
sound = parts[0];

if (parts.length == 3) {
try {
Expand Down Expand Up @@ -415,6 +398,8 @@ public void run() {
}
}

sound = sound.toLowerCase().replace("_", ".");

switch (actionType) {
case BROADCAST_SOUND:
for (final Player broadcastTarget : Bukkit.getOnlinePlayers()) {
Expand Down