mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-27 02:21:38 +01:00
Deprecate old tag getters in ItemMeta
This commit is contained in:
parent
354b4e3bc3
commit
418fc8b4be
@ -15,6 +15,7 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ItemMeta implements TagReader, Writeable {
|
||||
|
||||
@ -111,16 +112,6 @@ public class ItemMeta implements TagReader, Writeable {
|
||||
return Collections.unmodifiableSet(canPlaceOn);
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
public <T> T getOrDefault(@NotNull Tag<T> tag, @Nullable T defaultValue) {
|
||||
var key = tag.getKey();
|
||||
if (nbt.containsKey(key)) {
|
||||
return tag.read(toNBT());
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> @Nullable T getTag(@NotNull Tag<T> tag) {
|
||||
return tag.read(nbt);
|
||||
@ -131,10 +122,6 @@ public class ItemMeta implements TagReader, Writeable {
|
||||
return nbt.containsKey(tag.getKey());
|
||||
}
|
||||
|
||||
public <T> @Nullable T get(@NotNull Tag<T> tag) {
|
||||
return getTag(tag);
|
||||
}
|
||||
|
||||
public @NotNull NBTCompound toNBT() {
|
||||
return nbt.deepClone();
|
||||
}
|
||||
@ -175,4 +162,26 @@ public class ItemMeta implements TagReader, Writeable {
|
||||
writer.write(cachedBuffer);
|
||||
this.cachedBuffer.resetReaderIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getTag(Tag)} with {@link Tag#defaultValue(Supplier)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract(pure = true)
|
||||
public <T> T getOrDefault(@NotNull Tag<T> tag, @Nullable T defaultValue) {
|
||||
var key = tag.getKey();
|
||||
if (nbt.containsKey(key)) {
|
||||
return tag.read(toNBT());
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getTag(Tag)}
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> @Nullable T get(@NotNull Tag<T> tag) {
|
||||
return getTag(tag);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user