diff options
author | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-10-11 15:10:56 -0400 |
---|---|---|
committer | Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> | 2023-10-11 16:16:34 -0400 |
commit | 4fbcf1b2a4790f3033e97c55cab344abdfaea8d2 (patch) | |
tree | b2bdbb1bc96655191a4b8de9df6b2e28c18ef376 /src/main/java/de/hysky/skyblocker/utils/ItemUtils.java | |
parent | e4a8417403e2e4b32c76199b951d49a6244e4881 (diff) | |
download | Skyblocker-4fbcf1b2a4790f3033e97c55cab344abdfaea8d2.tar.gz Skyblocker-4fbcf1b2a4790f3033e97c55cab344abdfaea8d2.tar.bz2 Skyblocker-4fbcf1b2a4790f3033e97c55cab344abdfaea8d2.zip |
Remove optionals
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/utils/ItemUtils.java')
-rw-r--r-- | src/main/java/de/hysky/skyblocker/utils/ItemUtils.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java index ea861a88..fa04acf8 100644 --- a/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java +++ b/src/main/java/de/hysky/skyblocker/utils/ItemUtils.java @@ -44,6 +44,7 @@ public class ItemUtils { /** * Gets the {@code ExtraAttributes} NBT tag from the item stack. + * * @param stack the item stack to get the {@code ExtraAttributes} NBT tag from * @return an optional containing the {@code ExtraAttributes} NBT tag of the item stack */ @@ -53,16 +54,18 @@ public class ItemUtils { /** * Gets the {@code ExtraAttributes} NBT tag from the item stack. + * * @param stack the item stack to get the {@code ExtraAttributes} NBT tag from * @return the {@code ExtraAttributes} NBT tag of the item stack, or null if the item stack is null or does not have an {@code ExtraAttributes} NBT tag */ @Nullable public static NbtCompound getExtraAttributes(@NotNull ItemStack stack) { - return getExtraAttributesOptional(stack).orElse(null); + return stack.getSubNbt(EXTRA_ATTRIBUTES); } /** * Gets the internal name of the item stack from the {@code ExtraAttributes} NBT tag. + * * @param stack the item stack to get the internal name from * @return an optional containing the internal name of the item stack */ @@ -72,15 +75,18 @@ public class ItemUtils { /** * Gets the internal name of the item stack from the {@code ExtraAttributes} NBT tag. + * * @param stack the item stack to get the internal name from * @return the internal name of the item stack, or an empty string if the item stack is null or does not have an internal name */ public static String getItemId(@NotNull ItemStack stack) { - return getItemIdOptional(stack).orElse(""); + NbtCompound extraAttributes = getExtraAttributes(stack); + return extraAttributes != null ? extraAttributes.getString(ID) : ""; } /** * Gets the UUID of the item stack from the {@code ExtraAttributes} NBT tag. + * * @param stack the item stack to get the UUID from * @return an optional containing the UUID of the item stack */ @@ -90,11 +96,13 @@ public class ItemUtils { /** * Gets the UUID of the item stack from the {@code ExtraAttributes} NBT tag. + * * @param stack the item stack to get the UUID from * @return the UUID of the item stack, or null if the item stack is null or does not have a UUID */ public static String getItemUuid(@NotNull ItemStack stack) { - return getItemUuidOptional(stack).orElse(""); + NbtCompound extraAttributes = getExtraAttributes(stack); + return extraAttributes != null ? extraAttributes.getString(UUID) : ""; } @Nullable |