public class StateSerialization extends Object
Constructor and Description |
---|
StateSerialization() |
Modifier and Type | Method and Description |
---|---|
static org.bukkit.DyeColor |
getColor(String color)
Returns the
DyeColor with a given name (case-insensitive). |
static BlockStateReader<?> |
getReader(org.bukkit.Material material)
Returns the
BlockStateReader for a block type. |
static boolean |
matches(org.bukkit.Material type,
org.bukkit.material.MaterialData data,
BlockStateData state)
Returns whether the given
MaterialData and the given BlockStateData are valid
for the given block type and describe the same state. |
static BlockStateData |
parse(org.bukkit.Material material,
String state)
Reads a
BlockStateData instance from a string. |
static org.bukkit.material.MaterialData |
parseData(org.bukkit.Material type,
BlockStateData state)
Converts a
BlockStateData instance to a MaterialData instance. |
public static BlockStateData parse(org.bukkit.Material material, String state) throws InvalidBlockStateException
BlockStateData
instance from a string.material
- the block typestate
- the state as a string, or nullstate
is null, empty or "*" after stripping leading and
trailing whitespace; otherwise, a state parsed from the string.InvalidBlockStateException
- if type
isn't a block type with a
BlockStateReader
, or state
is an invalid block-state stringpublic static boolean matches(org.bukkit.Material type, org.bukkit.material.MaterialData data, BlockStateData state) throws InvalidBlockStateException
MaterialData
and the given BlockStateData
are valid
for the given block type and describe the same state.type
- the block type, or nulldata
- the block state that's a MaterialData
, or nullstate
- the block state that's a BlockStateData
, or nulldata
is valid for type
, and
state
is empty or matches data
; false otherwiseInvalidBlockStateException
- if type
is not null but isn't a block type with a
BlockStateReader
public static org.bukkit.material.MaterialData parseData(org.bukkit.Material type, BlockStateData state) throws InvalidBlockStateException
BlockStateData
instance to a MaterialData
instance.type
- the block type, or nullstate
- the block state, or nullMaterialData
instance, or null if either parameter is
nullInvalidBlockStateException
- if type
is not null but isn't a block type with a
BlockStateReader
public static BlockStateReader<?> getReader(org.bukkit.Material material)
BlockStateReader
for a block type.material
- a material, or nullBlockStateReader
for material
, or null if material
is
null or not a block type that has a BlockStateReader
public static org.bukkit.DyeColor getColor(String color)
DyeColor
with a given name (case-insensitive).color
- the name of a color, or nullDyeColor
with that name, or null if color
is null or no colors
matchCopyright © 2021. All rights reserved.