Package net.glowstone.block.state
Class StateSerialization
java.lang.Object
net.glowstone.block.state.StateSerialization
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.DyeColorReturns theDyeColorwith a given name (case-insensitive).static BlockStateReader<?>getReader(org.bukkit.Material material) Returns theBlockStateReaderfor a block type.static booleanmatches(org.bukkit.Material type, org.bukkit.material.MaterialData data, BlockStateData state) Returns whether the givenMaterialDataand the givenBlockStateDataare valid for the given block type and describe the same state.static BlockStateDataReads aBlockStateDatainstance from a string.static org.bukkit.material.MaterialDataparseData(org.bukkit.Material type, BlockStateData state) Converts aBlockStateDatainstance to aMaterialDatainstance.
-
Constructor Details
-
StateSerialization
public StateSerialization()
-
-
Method Details
-
parse
public static BlockStateData parse(org.bukkit.Material material, String state) throws InvalidBlockStateException Reads aBlockStateDatainstance from a string.- Parameters:
material- the block typestate- the state as a string, or null- Returns:
- the default state if
stateis null, empty or "*" after stripping leading and trailing whitespace; otherwise, a state parsed from the string. - Throws:
InvalidBlockStateException- iftypeisn't a block type with aBlockStateReader, orstateis 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 givenMaterialDataand the givenBlockStateDataare 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,
datais valid fortype, andstateis empty or matchesdata; false otherwise - Throws:
InvalidBlockStateException- iftypeis 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 aBlockStateDatainstance to aMaterialDatainstance.- Parameters:
type- the block type, or nullstate- the block state, or null- Returns:
- the block state as a
MaterialDatainstance, or null if either parameter is null - Throws:
InvalidBlockStateException- iftypeis not null but isn't a block type with aBlockStateReader
-
getReader
Returns theBlockStateReaderfor a block type.- Parameters:
material- a material, or null- Returns:
- the
BlockStateReaderformaterial, or null ifmaterialis null or not a block type that has aBlockStateReader
-
getColor
Returns theDyeColorwith a given name (case-insensitive).- Parameters:
color- the name of a color, or null- Returns:
- the
DyeColorwith that name, or null ifcoloris null or no colors match
-