Package ch.njol.skript.bukkitutil
Class ItemUtils
java.lang.Object
ch.njol.skript.bukkitutil.ItemUtils
Miscellaneous static utility methods related to items.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
static final boolean
static final boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddItemToList
(ItemStack toAdd, Iterable<ItemStack> to) Add an ItemStack to a List/Inventory
This will break up the ItemStack if it's too largeaddListToList
(Iterable<ItemStack> from, Iterable<ItemStack> to) Add a List/Inventory to another List/Inventorystatic ItemStack
clampedStack
(ItemStack itemStack) Return an ItemStack with a stack size no higher than 99
Minecraft will not serialize an ItemStack with a size > 99static int
Gets damage/durability of an item, or 0 if it does not have damage.static int
Gets damage/durability of an itemmeta, or 0 if it does not have damage.static int
getMaxDamage
(ItemStack itemStack) Gets the max damage/durability of an itemstatic int
getMaxStackSize
(ItemStack itemStack) Get the max stack size of an ItemStackstatic void
removeItemFromList
(ItemStack toRemove, Iterable<ItemStack> from) Remove an ItemStack from a list of ItemStacks or an Inventorystatic void
Sets damage/durability of an item if possible.static void
setHeadOwner
(ItemStack skull, OfflinePlayer player) Sets the owner of a player head.static void
setMaxDamage
(ItemStack itemStack, int maxDamage) Set the max damage/durability of an itemstatic void
setMaxStackSize
(ItemStack itemStack, int maxStackSize) Set the max stack size of an ItemStack
-
Field Details
-
HAS_MAX_DAMAGE
public static final boolean HAS_MAX_DAMAGE -
HAS_RESET
public static final boolean HAS_RESET -
CAN_CREATE_PLAYER_PROFILE
public static final boolean CAN_CREATE_PLAYER_PROFILE
-
-
Constructor Details
-
ItemUtils
public ItemUtils()
-
-
Method Details
-
clampedStack
Return an ItemStack with a stack size no higher than 99
Minecraft will not serialize an ItemStack with a size > 99- Parameters:
itemStack
- ItemStack to check- Returns:
- ItemStack with size not greater than 99
-
getDamage
Gets damage/durability of an item, or 0 if it does not have damage.- Parameters:
itemStack
- Item.- Returns:
- Damage.
-
getDamage
Gets damage/durability of an itemmeta, or 0 if it does not have damage.- Parameters:
itemMeta
- ItemMeta.- Returns:
- Damage.
-
getMaxDamage
Gets the max damage/durability of an itemNOTE: Will account for custom damageable items in MC 1.20.5+
- Parameters:
itemStack
- Item to grab durability from- Returns:
- Max amount of damage this item can take
-
setMaxDamage
Set the max damage/durability of an item- Parameters:
itemStack
- ItemStack to set max damagemaxDamage
- Amount of new max damage
-
setDamage
Sets damage/durability of an item if possible.- Parameters:
itemStack
- Item to modify.damage
- New damage. Note that on some Minecraft versions, this might be truncated to short.
-
getMaxStackSize
Get the max stack size of an ItemStack- Parameters:
itemStack
- ItemStack to check- Returns:
- Max stack size of ItemStack
-
setMaxStackSize
Set the max stack size of an ItemStack- Parameters:
itemStack
- ItemStack to change max stack sizemaxStackSize
- Max stack size clamped between 1 and 99
-
setHeadOwner
Sets the owner of a player head.- Parameters:
skull
- player head item to modifyplayer
- owner of the head
-
removeItemFromList
Remove an ItemStack from a list of ItemStacks or an Inventory- Parameters:
toRemove
- ItemStack to removefrom
- List/Inventory to remove from
-
addItemToList
Add an ItemStack to a List/Inventory
This will break up the ItemStack if it's too large- Parameters:
toAdd
- ItemStack to addto
- List/Inventory to add to- Returns:
- List of ItemStacks that didn't fit (only when adding to an Inventory)
-
addListToList
Add a List/Inventory to another List/Inventory- Parameters:
from
- List/Inventory to addto
- List/Inventory to add to- Returns:
- List of ItemStacks that didn't fit (only when adding to an Inventory)
-