mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix reading custom jukebox songs (#4757)
* Read sound event objects properly in jukebox song * Add debug log for unexpected sound event type
This commit is contained in:
parent
1efb633723
commit
63a3da7c56
1 changed files with 11 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
|||
package org.geysermc.geyser.level;
|
||||
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.RegistryEntry;
|
||||
|
||||
|
@ -33,7 +34,16 @@ public record JukeboxSong(String soundEvent, String description) {
|
|||
|
||||
public static JukeboxSong read(RegistryEntry entry) {
|
||||
NbtMap data = entry.getData();
|
||||
String soundEvent = data.getString("sound_event");
|
||||
Object soundEventObject = data.get("sound_event");
|
||||
String soundEvent;
|
||||
if (soundEventObject instanceof NbtMap map) {
|
||||
soundEvent = map.getString("sound_id");
|
||||
} else if (soundEventObject instanceof String string) {
|
||||
soundEvent = string;
|
||||
} else {
|
||||
soundEvent = "";
|
||||
GeyserImpl.getInstance().getLogger().debug("Sound event for " + entry.getId() + " was of an unexpected type! Expected string or NBT map, got " + soundEventObject);
|
||||
}
|
||||
String description = MessageTranslator.deserializeDescription(data);
|
||||
return new JukeboxSong(soundEvent, description);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue