|
8 | 8 | import com.craftmend.openaudiomc.spigot.services.server.enums.ServerVersion;
|
9 | 9 | import de.tr7zw.changeme.nbtapi.NBT;
|
10 | 10 | import de.tr7zw.changeme.nbtapi.NBTItem;
|
| 11 | +import de.tr7zw.changeme.nbtapi.NbtApiException; |
11 | 12 | import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBT;
|
12 | 13 | import org.bukkit.Bukkit;
|
13 | 14 | import org.bukkit.ChatColor;
|
@@ -83,13 +84,21 @@ public static ItemStack getSkull(String source, int radius) {
|
83 | 84 | .setString("Value", textureValue);
|
84 | 85 | });
|
85 | 86 |
|
86 |
| - NBT.modifyComponents(skull, nbt -> { |
87 |
| - ReadWriteNBT profileNbt = nbt.getOrCreateCompound("minecraft:profile"); |
88 |
| - profileNbt.setUUID("id", speakerUUID); |
89 |
| - ReadWriteNBT propertiesNbt = profileNbt.getCompoundList("properties").addCompound(); |
90 |
| - propertiesNbt.setString("name", "textures"); |
91 |
| - propertiesNbt.setString("value", textureValue); |
92 |
| - }); |
| 87 | + try { |
| 88 | + NBT.modifyComponents(skull, nbt -> { |
| 89 | + ReadWriteNBT profileNbt = nbt.getOrCreateCompound("minecraft:profile"); |
| 90 | + profileNbt.setUUID("id", speakerUUID); |
| 91 | + ReadWriteNBT propertiesNbt = profileNbt.getCompoundList("properties").addCompound(); |
| 92 | + propertiesNbt.setString("name", "textures"); |
| 93 | + propertiesNbt.setString("value", textureValue); |
| 94 | + }); |
| 95 | + } catch (NbtApiException e) { |
| 96 | + if (e.getMessage().contains("only works for")) { |
| 97 | + OpenAudioLogger.info("Failed to use modern speaker NBT, this server version does not support it."); |
| 98 | + } else { |
| 99 | + e.printStackTrace(); |
| 100 | + } |
| 101 | + } |
93 | 102 |
|
94 | 103 | SkullMeta sm = (SkullMeta) skull.getItemMeta();
|
95 | 104 | if (sm != null) {
|
|
0 commit comments