Package com.cryptomorin.xseries
Class XBlock
- java.lang.Object
-
- com.cryptomorin.xseries.XBlock
-
public final class XBlock extends Object
XBlock - MaterialData/BlockData Support
BlockState (Old): https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/BlockState.html BlockData (New): https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/BlockData.html MaterialData (Old): https://hub.spigotmc.org/javadocs/spigot/org/bukkit/material/MaterialData.htmlAll the parameters are non-null except the ones marked as nullable. This class doesn't and shouldn't support materials that are
Material.isLegacy().- Version:
- 2.2.0
- Author:
- Crypto Morin
- See Also:
Block,BlockState,MaterialData,XMaterial
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXBlock.BlockMaterialAn enum with cached legacy materials which can be used when comparing blocks with blocks and blocks with items.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static intaddCakeSlices(org.bukkit.block.Block block, int slices)static intgetAge(org.bukkit.block.Block block)static org.bukkit.DyeColorgetColor(org.bukkit.block.Block block)Wool and Dye.static org.bukkit.block.BlockFacegetDirection(org.bukkit.block.Block block)static intgetFluidLevel(org.bukkit.block.Block block)static org.bukkit.block.BlockFacegetRotation(org.bukkit.block.Block block)static XMaterialgetType(org.bukkit.block.Block block)Deprecated.Not stable, useisType(Block, XMaterial)orisSimilar(Block, XMaterial)instead.static booleanisAir(org.bukkit.Material material)static booleanisBeetroot(org.bukkit.Material material)static booleanisCake(org.bukkit.Material material)static booleanisCarrot(org.bukkit.Material material)static booleanisContainer(org.bukkit.block.Block block)Checks if the block is a container.static booleanisCrop(XMaterial material)Any material that can be planted which is fromCROPSstatic booleanisDangerous(XMaterial material)Any material that can damage players, usually by interacting with the block.static booleanisLava(org.bukkit.Material material)static booleanisLit(org.bukkit.block.Block block)static booleanisMelon(org.bukkit.Material material)static booleanisNetherWart(org.bukkit.Material material)static booleanisOneOf(org.bukkit.block.Block block, Collection<String> blocks)static booleanisOpen(org.bukkit.block.Block block)static booleanisPotato(org.bukkit.Material material)static booleanisPowered(org.bukkit.block.Block block)static booleanisSimilar(org.bukkit.block.Block block, XMaterial material)Same asisType(Block, XMaterial)except it also does a simpleXMaterial.matchXMaterial(Material)comparison with the given block and material.static booleanisSugarCane(org.bukkit.Material material)static booleanisType(org.bukkit.block.Block block, XMaterial material)Universal Methodstatic booleanisWater(org.bukkit.Material material)static booleanisWaterStationary(org.bukkit.block.Block block)static booleanisWheat(org.bukkit.Material material)static voidsetAge(org.bukkit.block.Block block, int age)static voidsetCakeSlices(org.bukkit.block.Block block, int amount)static booleansetColor(org.bukkit.block.Block block, org.bukkit.DyeColor color)Sets the type of any block that can be colored.static booleansetDirection(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing)static voidsetEnderPearlOnFrame(org.bukkit.block.Block endPortalFrame, boolean eye)static booleansetFluidLevel(org.bukkit.block.Block block, int level)Can be used on cauldrons as well.static voidsetLit(org.bukkit.block.Block block, boolean lit)Can be furnaces or redstone lamps.static voidsetOpened(org.bukkit.block.Block block, boolean opened)static voidsetPowered(org.bukkit.block.Block block, boolean powered)static voidsetRotation(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing)static booleansetType(org.bukkit.block.Block block, XMaterial material)
-
-
-
Field Detail
-
CAKE_SLICES
public static final byte CAKE_SLICES
- See Also:
- Constant Field Values
-
-
Method Detail
-
isLit
public static boolean isLit(org.bukkit.block.Block block)
-
isContainer
public static boolean isContainer(@Nullable org.bukkit.block.Block block)
Checks if the block is a container. Containers are chests, hoppers, enderchests and everything that has an inventory.- Parameters:
block- the block to check.- Returns:
- true if the block is a container, otherwise false.
-
setLit
public static void setLit(org.bukkit.block.Block block, boolean lit)Can be furnaces or redstone lamps.- Parameters:
block- the block to change.lit- if it should be lit or not.
-
isCrop
public static boolean isCrop(XMaterial material)
Any material that can be planted which is fromCROPS- Parameters:
material- the material to check.- Returns:
- true if this material is a crop, otherwise false.
-
isDangerous
public static boolean isDangerous(XMaterial material)
Any material that can damage players, usually by interacting with the block.- Parameters:
material- the material to check.- Returns:
- true if this material is dangerous, otherwise false.
-
getColor
public static org.bukkit.DyeColor getColor(org.bukkit.block.Block block)
Wool and Dye. But Dye is not a block itself.
-
isCake
public static boolean isCake(@Nullable org.bukkit.Material material)
-
isWheat
public static boolean isWheat(@Nullable org.bukkit.Material material)
-
isSugarCane
public static boolean isSugarCane(@Nullable org.bukkit.Material material)
-
isBeetroot
public static boolean isBeetroot(@Nullable org.bukkit.Material material)
-
isNetherWart
public static boolean isNetherWart(@Nullable org.bukkit.Material material)
-
isCarrot
public static boolean isCarrot(@Nullable org.bukkit.Material material)
-
isMelon
public static boolean isMelon(@Nullable org.bukkit.Material material)
-
isPotato
public static boolean isPotato(@Nullable org.bukkit.Material material)
-
getDirection
public static org.bukkit.block.BlockFace getDirection(org.bukkit.block.Block block)
-
setDirection
public static boolean setDirection(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing)
-
setType
public static boolean setType(@Nonnull org.bukkit.block.Block block, @Nullable XMaterial material)
-
getAge
public static int getAge(org.bukkit.block.Block block)
-
setAge
public static void setAge(org.bukkit.block.Block block, int age)
-
setColor
public static boolean setColor(org.bukkit.block.Block block, org.bukkit.DyeColor color)Sets the type of any block that can be colored.- Parameters:
block- the block to color.color- the color to use.- Returns:
- true if the block can be colored, otherwise false.
-
setFluidLevel
public static boolean setFluidLevel(org.bukkit.block.Block block, int level)Can be used on cauldrons as well.- Parameters:
block- the block to set the fluid level of.level- the level of fluid.- Returns:
- true if this block can have a fluid level, otherwise false.
-
getFluidLevel
public static int getFluidLevel(org.bukkit.block.Block block)
-
isWaterStationary
public static boolean isWaterStationary(org.bukkit.block.Block block)
-
isWater
public static boolean isWater(org.bukkit.Material material)
-
isLava
public static boolean isLava(org.bukkit.Material material)
-
isOneOf
public static boolean isOneOf(org.bukkit.block.Block block, Collection<String> blocks)
-
setCakeSlices
public static void setCakeSlices(org.bukkit.block.Block block, int amount)
-
addCakeSlices
public static int addCakeSlices(org.bukkit.block.Block block, int slices)
-
setEnderPearlOnFrame
public static void setEnderPearlOnFrame(org.bukkit.block.Block endPortalFrame, boolean eye)
-
getType
@Deprecated public static XMaterial getType(org.bukkit.block.Block block)
Deprecated.Not stable, useisType(Block, XMaterial)orisSimilar(Block, XMaterial)instead. If you want to save a block material somewhere, you need to useXMaterial.matchXMaterial(Material)- Parameters:
block- the block to get its XMaterial type.- Returns:
- the XMaterial of the block.
-
isSimilar
public static boolean isSimilar(org.bukkit.block.Block block, XMaterial material)Same asisType(Block, XMaterial)except it also does a simpleXMaterial.matchXMaterial(Material)comparison with the given block and material.- Parameters:
block- the block to compare.material- the material to compare with.- Returns:
- true if block type is similar to the given material.
- Since:
- 1.3.0
- See Also:
isType(Block, XMaterial)
-
isType
public static boolean isType(org.bukkit.block.Block block, XMaterial material)Universal MethodCheck if the block type matches the specified XMaterial. Note that this method assumes that you've already tried doing
XMaterial.matchXMaterial(Material)usingBlock.getType()and compared it with the other XMaterial. If not, useisSimilar(Block, XMaterial)- Parameters:
block- the block to check.material- the XMaterial similar to this block type.- Returns:
- true if the raw block type matches with the material.
- See Also:
isSimilar(Block, XMaterial)
-
isAir
public static boolean isAir(@Nullable org.bukkit.Material material)
-
isPowered
public static boolean isPowered(org.bukkit.block.Block block)
-
setPowered
public static void setPowered(org.bukkit.block.Block block, boolean powered)
-
isOpen
public static boolean isOpen(org.bukkit.block.Block block)
-
setOpened
public static void setOpened(org.bukkit.block.Block block, boolean opened)
-
getRotation
public static org.bukkit.block.BlockFace getRotation(org.bukkit.block.Block block)
-
setRotation
public static void setRotation(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing)
-
-