Class ObsidianMaterial

java.lang.Object
com.moyskleytech.obsidian.material.ObsidianMaterial
All Implemented Interfaces:
Comparable<ObsidianMaterial>
Direct Known Subclasses:
BookMaterial, BukkitMaterial, HeadMaterial, ItemsAdderMaterial, OraxenMaterial, PotionMaterial, SkriptMaterial, SlimefunMaterial, SpawnerMaterial, XMaterial

public abstract class ObsidianMaterial extends Object implements Comparable<ObsidianMaterial>
A future proof Material wrapper for bukkit servers allowing all BukkitMaterial without recompiling. Fallsback to XSeries.XMaterial on legacy versions.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static final ObsidianMaterial
    Add a custom material into the cache that could be later used with valueOf, should be called for all subclasses
    protected Object
     
    int
     
    boolean
     
    int
     
    boolean
    isSimilar(org.bukkit.inventory.ItemStack item)
    Compare this value with a ItemStack for similarities
    Make ObsidianMaterial act like a enum, return the key representing this unique instance
    static void
    registerAdapter(Class<? extends Adapter> clazz)
    Class for registering adapters for parsing
    static void
    Force all bukkit materials into the cache
    static final ObsidianMaterial
    Allow to remove a custom implementation of ObsidianMaterial from the cache
    abstract org.bukkit.inventory.ItemStack
    Object a ItemStack of the desired material
    abstract org.bukkit.Material
    Obtain the bukkit material associated with this material
     
    static final ObsidianMaterial
    valueOf(String materialString)
    Parse a material from a string, currently supports BookMaterial, HeadMaterial, BukkitMaterials, PotionMaterial, SpawnerMaterial and XMaterial, custom implementations use .add()
    static final ObsidianMaterial
    valueOf(org.bukkit.Material materialString)
    Wrap a Material into a ObsidianMaterial, same as wrap(org.bukkit.Material)
    Return the full list of known material, might be incomplete as Materials are only cached when used
    static final ObsidianMaterial
    wrap(com.cryptomorin.xseries.XMaterial mat)
    Wrap a XMaterial into a ObsidianMaterial
    static final ObsidianMaterial
    wrap(org.bukkit.Material mat)
    Wrap a bukkit Material into a ObsidianMaterial

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ObsidianMaterial

      public ObsidianMaterial()
  • Method Details

    • registerAdapter

      public static void registerAdapter(Class<? extends Adapter> clazz)
      Class for registering adapters for parsing
      Parameters:
      clazz - The class of the adapter, will auto call the parameterless constructor
    • remove

      public static final ObsidianMaterial remove(String s)
      Allow to remove a custom implementation of ObsidianMaterial from the cache
      Parameters:
      s - The key to remove
      Returns:
      the removed value or null
    • wrap

      public static final ObsidianMaterial wrap(org.bukkit.Material mat)
      Wrap a bukkit Material into a ObsidianMaterial
      Parameters:
      mat - the bukkit Material to wrap
      Returns:
      Returns a bukkit Material representing the value, instanceOf BukkitMaterial
    • wrap

      public static final ObsidianMaterial wrap(com.cryptomorin.xseries.XMaterial mat)
      Wrap a XMaterial into a ObsidianMaterial
      Parameters:
      mat - the XMaterial object
      Returns:
      a ObsidianMaterial representing the object could be instance of BukkitMaterial or XMaterial
    • add

      public static final ObsidianMaterial add(ObsidianMaterial im)
      Add a custom material into the cache that could be later used with valueOf, should be called for all subclasses
      Parameters:
      im - The new material to register
      Returns:
      The registered material
    • valueOf

      public static final ObsidianMaterial valueOf(org.bukkit.Material materialString)
      Wrap a Material into a ObsidianMaterial, same as wrap(org.bukkit.Material)
      Parameters:
      materialString - The material to represents
      Returns:
      The ObsidianMaterial associated with it
    • valueOf

      public static final ObsidianMaterial valueOf(String materialString)
      Parse a material from a string, currently supports BookMaterial, HeadMaterial, BukkitMaterials, PotionMaterial, SpawnerMaterial and XMaterial, custom implementations use .add()
      Parameters:
      materialString - the string to parse
      Returns:
      Corresponding material of null if nothing match
    • values

      public static List<ObsidianMaterial> values()
      Return the full list of known material, might be incomplete as Materials are only cached when used
      Returns:
      All the materials in the cache
    • registerAllBukkitMaterials

      public static void registerAllBukkitMaterials()
      Force all bukkit materials into the cache
    • name

      public String name()
      Make ObsidianMaterial act like a enum, return the key representing this unique instance
      Returns:
      the unique key of the material
    • isSimilar

      public boolean isSimilar(org.bukkit.inventory.ItemStack item)
      Compare this value with a ItemStack for similarities
      Parameters:
      item - The item to compare
      Returns:
      If the itemstack is similar
    • toMaterial

      public abstract org.bukkit.Material toMaterial()
      Obtain the bukkit material associated with this material
      Returns:
      the enum value associated
    • toItem

      public abstract org.bukkit.inventory.ItemStack toItem()
      Object a ItemStack of the desired material
      Returns:
      new ItemStack
    • clone

      protected Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(ObsidianMaterial arg0)
      Specified by:
      compareTo in interface Comparable<ObsidianMaterial>