mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-23 16:41:35 +01:00
Impl ItemMeta#getOrDefault
This commit is contained in:
parent
4741c932a0
commit
c8fbf47bd9
@ -95,9 +95,14 @@ public class ItemMeta {
|
||||
return customModelData;
|
||||
}
|
||||
|
||||
@Contract("_, null -> null; _, !null -> !null")
|
||||
public <T> T getOrDefault(@NotNull ItemTag<T> tag, @Nullable T defaultValue) {
|
||||
return tag.read(toNBT());
|
||||
var nbt = toNBT();
|
||||
var key = tag.getKey();
|
||||
if (nbt.containsKey(key)) {
|
||||
return tag.read(toNBT());
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public <T> @Nullable T get(@NotNull ItemTag<T> tag) {
|
||||
|
Loading…
Reference in New Issue
Block a user