Deprecate old tag getters in ItemMeta

This commit is contained in:
TheMode 2021-05-17 17:50:05 +02:00
parent 354b4e3bc3
commit 418fc8b4be

View File

@ -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);
}
}