9
0
mirror of https://github.com/WiIIiam278/HuskSync.git synced 2025-12-28 02:59:13 +00:00

Add additional cast checking to PDC tag fetching, cast via complex type (#118)

This commit is contained in:
William
2023-04-05 12:53:05 +01:00
committed by GitHub
parent e7e7995e4e
commit 7ed7d0a29e
2 changed files with 15 additions and 9 deletions

View File

@@ -37,8 +37,8 @@ public record BukkitPersistentTypeMapping<T, Z>(PersistentDataTagType type, Pers
}
public void setContainerValue(@NotNull PersistentDataContainerData container, @NotNull Player player, @NotNull NamespacedKey key) throws NullPointerException {
container.getTagValue(key.toString(), bukkitType.getPrimitiveType())
.ifPresent(value -> player.getPersistentDataContainer().set(key, bukkitType, (Z) value));
container.getTagValue(key.toString(), bukkitType.getComplexType())
.ifPresent(value -> player.getPersistentDataContainer().set(key, bukkitType, value));
}
public static Optional<BukkitPersistentTypeMapping<?, ?>> getMapping(@NotNull PersistentDataTagType type) {