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
static final boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable org.bukkit.Material
asBlock
(org.bukkit.Material type) Gets a block material corresponding to given item material, which might be the given material.static org.bukkit.Material
asItem
(org.bukkit.Material type) Deprecated.This just returns itself and has no usestatic @Nullable org.bukkit.inventory.ItemStack
asItemStack
(Object object) Convert an ItemType/Slot to ItemStack Will also accept an ItemStack that will return itselfstatic int
Gets damage/durability of an item, or 0 if it does not have damage.static int
getDamage
(org.bukkit.inventory.ItemStack itemStack) Gets damage/durability of an item, or 0 if it does not have damage.static int
getDamage
(org.bukkit.inventory.meta.ItemMeta itemMeta) Gets damage/durability of an itemmeta, or 0 if it does not have damage.static int
getMaxDamage
(ItemType itemType) Gets the max damage/durability of an itemstatic int
getMaxDamage
(org.bukkit.inventory.ItemStack itemStack) Gets the max damage/durability of an itemstatic org.bukkit.Material
getTreeSapling
(org.bukkit.TreeType treeType) static boolean
isAir
(org.bukkit.Material type) static boolean
isFence
(org.bukkit.block.Block block) Whether the block is a fence or a wall.static boolean
isGlass
(org.bukkit.Material material) static boolean
itemStacksEqual
(@Nullable org.bukkit.inventory.ItemStack itemStack1, @Nullable org.bukkit.inventory.ItemStack itemStack2) Tests whether two item stacks are of the same type, i.e.static void
Sets damage/durability of an item if possible.static void
setDamage
(org.bukkit.inventory.ItemStack itemStack, int damage) Sets damage/durability of an item if possible.static void
setHeadOwner
(ItemType skull, org.bukkit.OfflinePlayer player) Sets the owner of a player head.static void
setMaxDamage
(org.bukkit.inventory.ItemStack itemStack, int maxDamage) Set the max damage/durability of an item
-
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 -
REQUIRES_TEXTURE_LOOKUP
public static final boolean REQUIRES_TEXTURE_LOOKUP
-
-
Constructor Details
-
ItemUtils
public ItemUtils()
-
-
Method Details
-
getDamage
public static int getDamage(org.bukkit.inventory.ItemStack itemStack) Gets damage/durability of an item, or 0 if it does not have damage.- Parameters:
itemStack
- Item.- Returns:
- Damage.
-
getDamage
public static int getDamage(org.bukkit.inventory.meta.ItemMeta itemMeta) Gets damage/durability of an itemmeta, or 0 if it does not have damage.- Parameters:
itemMeta
- ItemMeta.- Returns:
- Damage.
-
getMaxDamage
public static int getMaxDamage(org.bukkit.inventory.ItemStack itemStack) 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
public static void setMaxDamage(org.bukkit.inventory.ItemStack itemStack, int maxDamage) Set the max damage/durability of an item- Parameters:
itemStack
- ItemStack to set max damagemaxDamage
- Amount of new max damage
-
setDamage
public static void setDamage(org.bukkit.inventory.ItemStack itemStack, int damage) 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.
-
getDamage
Gets damage/durability of an item, or 0 if it does not have damage.- Parameters:
itemType
- Item.- Returns:
- Damage.
-
getMaxDamage
Gets the max damage/durability of an itemNOTE: Will account for custom damageable items in MC 1.20.5+
- Parameters:
itemType
- Item to grab durability from- Returns:
- Max amount of damage this item can take
-
setDamage
Sets damage/durability of an item if possible.- Parameters:
itemType
- Item to modify.damage
- New damage. Note that on some Minecraft versions, this might be truncated to short.
-
setHeadOwner
Sets the owner of a player head.- Parameters:
skull
- player head item to modifyplayer
- owner of the head
-
asBlock
@Nullable public static @Nullable org.bukkit.Material asBlock(org.bukkit.Material type) Gets a block material corresponding to given item material, which might be the given material. If no block material is found, null is returned.- Parameters:
type
- Material.- Returns:
- Block version of material or null.
-
asItem
Deprecated.This just returns itself and has no useGets an item material corresponding to given block material, which might be the given material.- Parameters:
type
- Material.- Returns:
- Item version of material or null.
-
asItemStack
Convert an ItemType/Slot to ItemStack Will also accept an ItemStack that will return itself- Parameters:
object
- Object to convert- Returns:
- ItemStack from slot/itemtype
-
itemStacksEqual
public static boolean itemStacksEqual(@Nullable @Nullable org.bukkit.inventory.ItemStack itemStack1, @Nullable @Nullable org.bukkit.inventory.ItemStack itemStack2) Tests whether two item stacks are of the same type, i.e. it ignores the amounts.- Parameters:
itemStack1
-itemStack2
-- Returns:
- Whether the item stacks are of the same type
-
isAir
public static boolean isAir(org.bukkit.Material type) -
getTreeSapling
public static org.bukkit.Material getTreeSapling(org.bukkit.TreeType treeType) -
isFence
public static boolean isFence(org.bukkit.block.Block block) Whether the block is a fence or a wall.- Parameters:
block
- the block to check.- Returns:
- whether the block is a fence/wall.
-
isGlass
public static boolean isGlass(org.bukkit.Material material) - Parameters:
material
- The material to check- Returns:
- whether the material is a full glass block
-