1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00
This commit is contained in:
TheBusyBiscuit 2020-06-13 01:02:39 +02:00
commit 62ffb59ba2
2 changed files with 13 additions and 2 deletions

View File

@ -45,6 +45,9 @@ public class CustomItemDataService implements PersistentDataService, Keyed {
}
public Optional<String> getItemData(ItemStack item) {
if (item == null || !item.hasItemMeta()) {
return Optional.empty();
}
return getItemData(item.getItemMeta());
}

View File

@ -26,8 +26,12 @@ public final class ItemStackWrapper extends ItemStack {
public ItemStackWrapper(ItemStack item) {
super(item.getType());
meta = item.getItemMeta();
hasItemMeta = item.hasItemMeta();
if (hasItemMeta) {
meta = item.getItemMeta();
} else {
meta = null;
}
}
@Override
@ -41,8 +45,12 @@ public final class ItemStackWrapper extends ItemStack {
// Since this class is immutable, we can simply let the super class create one copy
// and then store that instead of creating a clone everytime.
// This will significantly speed up any loop comparisons if used correctly.
if (meta == null) {
throw new UnsupportedOperationException("#hasItemMeta() must be checked prior to this call");
} else {
return meta;
}
}
@Override
public int getAmount() {