Class SpecificationFactory

java.lang.Object
com.pixelmonmod.api.SpecificationFactory

public class SpecificationFactory extends Object
The static factory for registering Requirements and getting instances of Specifications
  • Method Details

    • register

      public static <A, B, C extends Specification<A, B>> void register(Class<C> clazz, Requirement<A,B,?> requirement)
      Register a new Requirement for the given Specification
      Parameters:
      clazz - The type being registered under
      requirement - The requirement being registered
    • create

      @NotNull public static <A, B, C extends Specification<A, B>> @NotNull ParseAttempt<C> create(Class<? extends Specification<A,B>> clazz, String... specs)
      Creates a Specification instance from a string array for the given Specification
      Parameters:
      clazz - The type
      specs - The specs being parsed
      Returns:
      The pokemon spec created
    • requirements

      public static <A, B> ParseAttempt<List<Requirement<A,B,?>>> requirements(Class<? extends Specification<A,B>> specification, String spec)
      Gets the list of Requirements created from the given spec for the specified Specification
      Parameters:
      specification - The type
      spec - The spec being parsed
      Returns:
      The list of all requirements
    • empty

      public static <A, B, C extends Specification<A, B>> C empty()
      Gets the empty Specification
      Returns:
      The new spec
    • getRequirementNames

      public static String[] getRequirementNames(Class<? extends Specification<?,?>> clazz)
      Gets all requirement names in the given Specification
      Parameters:
      clazz - The type
      Returns:
      All requirement names registered under that type
    • fromNbt

      public static <A, B, C extends Specification<A, B>> ParseAttempt<C> fromNbt(Class<? extends Specification<A,B>> clazz, net.minecraft.nbt.CompoundTag nbt)
      Creates a Specification implementation from given item CompoundTag
      Type Parameters:
      A - The reforged type
      B - The minecraft type
      C - The implementation of the spec interface
      Parameters:
      clazz - The type
      nbt - The NBT data
      Returns:
      The specification implementation