Package net.glowstone.block.state
Class StateSerialization
java.lang.Object
net.glowstone.block.state.StateSerialization
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.DyeColor
Returns theDyeColor
with a given name (case-insensitive).static BlockStateReader<?>
getReader
(org.bukkit.Material material) Returns theBlockStateReader
for a block type.static boolean
matches
(org.bukkit.Material type, org.bukkit.material.MaterialData data, BlockStateData state) Returns whether the givenMaterialData
and the givenBlockStateData
are valid for the given block type and describe the same state.static BlockStateData
Reads aBlockStateData
instance from a string.static org.bukkit.material.MaterialData
parseData
(org.bukkit.Material type, BlockStateData state) Converts aBlockStateData
instance to aMaterialData
instance.
-
Constructor Details
-
StateSerialization
public StateSerialization()
-
-
Method Details
-
parse
public static BlockStateData parse(org.bukkit.Material material, String state) throws InvalidBlockStateException Reads aBlockStateData
instance from a string.- Parameters:
material
- the block typestate
- the state as a string, or null- Returns:
- the default state if
state
is null, empty or "*" after stripping leading and trailing whitespace; otherwise, a state parsed from the string. - Throws:
InvalidBlockStateException
- iftype
isn't a block type with aBlockStateReader
, orstate
is an invalid block-state string
-
matches
public static boolean matches(org.bukkit.Material type, org.bukkit.material.MaterialData data, BlockStateData state) throws InvalidBlockStateException Returns whether the givenMaterialData
and the givenBlockStateData
are valid for the given block type and describe the same state.- Parameters:
type
- the block type, or nulldata
- the block state that's aMaterialData
, or nullstate
- the block state that's aBlockStateData
, or null- Returns:
- true if all parameters are non-null,
data
is valid fortype
, andstate
is empty or matchesdata
; false otherwise - Throws:
InvalidBlockStateException
- iftype
is not null but isn't a block type with aBlockStateReader
-
parseData
public static org.bukkit.material.MaterialData parseData(org.bukkit.Material type, BlockStateData state) throws InvalidBlockStateException Converts aBlockStateData
instance to aMaterialData
instance.- Parameters:
type
- the block type, or nullstate
- the block state, or null- Returns:
- the block state as a
MaterialData
instance, or null if either parameter is null - Throws:
InvalidBlockStateException
- iftype
is not null but isn't a block type with aBlockStateReader
-
getReader
Returns theBlockStateReader
for a block type.- Parameters:
material
- a material, or null- Returns:
- the
BlockStateReader
formaterial
, or null ifmaterial
is null or not a block type that has aBlockStateReader
-
getColor
Returns theDyeColor
with a given name (case-insensitive).- Parameters:
color
- the name of a color, or null- Returns:
- the
DyeColor
with that name, or null ifcolor
is null or no colors match
-