Class StateSerialization

java.lang.Object
net.glowstone.block.state.StateSerialization

public class StateSerialization extends Object
  • Constructor Details

    • StateSerialization

      public StateSerialization()
  • Method Details

    • parse

      public static BlockStateData parse(org.bukkit.Material material, String state) throws InvalidBlockStateException
      Reads a BlockStateData instance from a string.
      Parameters:
      material - the block type
      state - 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 - if type isn't a block type with a BlockStateReader, or state 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 given MaterialData and the given BlockStateData are valid for the given block type and describe the same state.
      Parameters:
      type - the block type, or null
      data - the block state that's a MaterialData, or null
      state - the block state that's a BlockStateData, or null
      Returns:
      true if all parameters are non-null, data is valid for type, and state is empty or matches data; false otherwise
      Throws:
      InvalidBlockStateException - if type is not null but isn't a block type with a BlockStateReader
    • parseData

      public static org.bukkit.material.MaterialData parseData(org.bukkit.Material type, BlockStateData state) throws InvalidBlockStateException
      Converts a BlockStateData instance to a MaterialData instance.
      Parameters:
      type - the block type, or null
      state - the block state, or null
      Returns:
      the block state as a MaterialData instance, or null if either parameter is null
      Throws:
      InvalidBlockStateException - if type is not null but isn't a block type with a BlockStateReader
    • getReader

      public static BlockStateReader<?> getReader(org.bukkit.Material material)
      Returns the BlockStateReader for a block type.
      Parameters:
      material - a material, or null
      Returns:
      the BlockStateReader for material, or null if material is null or not a block type that has a BlockStateReader
    • getColor

      public static org.bukkit.DyeColor getColor(String color)
      Returns the DyeColor with a given name (case-insensitive).
      Parameters:
      color - the name of a color, or null
      Returns:
      the DyeColor with that name, or null if color is null or no colors match