Class ItemStackWrapper
java.lang.Object
org.bukkit.inventory.ItemStack
io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper
- All Implemented Interfaces:
Cloneable
,ConfigurationSerializable
,Translatable
This
Please be very careful when using this.
ItemStack
, which is not intended for actual usage, caches its ItemMeta
.
This significantly speeds up any ItemStack
comparisons a lot.
You cannot invoke equals(Object)
, hashCode()
or any of its setter on an
ItemStackWrapper
.Please be very careful when using this.
- Author:
- TheBusyBiscuit, md5sha256
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addUnsafeEnchantment
(Enchantment ench, int level) clone()
boolean
static ItemStackWrapper
Creates anItemStackWrapper
of anItemStack
.int
int
hashCode()
boolean
void
setAmount
(int amount) boolean
setItemMeta
(ItemMeta itemMeta) void
static ItemStackWrapper
Creates anItemStackWrapper
of anItemStack
.static ItemStackWrapper[]
This creates anItemStackWrapper
array from a givenItemStack
array.static List<ItemStackWrapper>
Methods inherited from class org.bukkit.inventory.ItemStack
addEnchantment, addEnchantments, addUnsafeEnchantments, containsEnchantment, deserialize, getData, getDurability, getEnchantmentLevel, getEnchantments, getMaxStackSize, getTranslationKey, getType, isSimilar, removeEnchantment, removeEnchantments, serialize, setData, setDurability, toString
-
Method Details
-
hasItemMeta
public boolean hasItemMeta()- Overrides:
hasItemMeta
in classItemStack
-
getItemMeta
- Overrides:
getItemMeta
in classItemStack
-
getAmount
public int getAmount() -
equals
-
hashCode
public int hashCode() -
clone
-
setType
-
setAmount
public void setAmount(int amount) -
setItemMeta
- Overrides:
setItemMeta
in classItemStack
-
addUnsafeEnchantment
- Overrides:
addUnsafeEnchantment
in classItemStack
-
forceWrap
Creates anItemStackWrapper
of anItemStack
. This method will not check if the passedItemStack
has already been wrapped- Parameters:
itemStack
- TheItemStack
to wrap- Returns:
- Returns an
ItemStackWrapper
of the passedItemStack
- See Also:
-
wrap
Creates anItemStackWrapper
of anItemStack
. This method will return the the casted reference of the passedItemStack
if it is already anItemStackWrapper
- Parameters:
itemStack
- TheItemStack
to wrap- Returns:
- Returns an
ItemStackWrapper
of the passedItemStack
- See Also:
-
wrapArray
This creates anItemStackWrapper
array from a givenItemStack
array.- Parameters:
items
- The array ofItemStacks
to transform- Returns:
- An
ItemStackWrapper
array
-
wrapList
- Parameters:
items
- TheList
ofItemStacks
to transform- Returns:
- An
ItemStackWrapper
array
-