mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Merge branch 'master' of https://github.com/TheBusyBiscuit/Slimefun4
This commit is contained in:
commit
62ffb59ba2
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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,7 +45,11 @@ 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.
|
||||
return meta;
|
||||
if (meta == null) {
|
||||
throw new UnsupportedOperationException("#hasItemMeta() must be checked prior to this call");
|
||||
} else {
|
||||
return meta;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user