fix: Fix Sound.valueOf compatibility for 1.21.1

- Added null checks in SoundAction.execute()
- Added fallback for Sound enum compatibility
- Fixed IncompatibleClassChangeError on PlayerJoinEvent
- Added SpaceLegacy ready config (spacelegacy-config.yml)
This commit is contained in:
loki5512344 2026-02-24 14:17:44 +01:00
parent 6e99cf9390
commit 0a5acdecb0
2 changed files with 354 additions and 3 deletions

View file

@ -16,9 +16,14 @@ public class SoundAction implements Action {
Sound parsedSound;
try {
parsedSound = Sound.valueOf(parts[0].toUpperCase());
String soundName = parts[0].toUpperCase().trim();
parsedSound = Sound.valueOf(soundName);
} catch (IllegalArgumentException e) {
parsedSound = Sound.ENTITY_EXPERIENCE_ORB_PICKUP;
try {
parsedSound = Sound.ENTITY_EXPERIENCE_ORB_PICKUP;
} catch (NoSuchFieldError ex) {
parsedSound = Sound.valueOf("ENTITY_EXPERIENCE_ORB_PICKUP");
}
}
this.sound = parsedSound;
@ -28,7 +33,9 @@ public class SoundAction implements Action {
@Override
public void execute(Player player) {
player.playSound(player.getLocation(), sound, volume, pitch);
if (player != null && sound != null) {
player.playSound(player.getLocation(), sound, volume, pitch);
}
}
@Override