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
A future proof Material wrapper for bukkit servers allowing all
BukkitMaterial without recompiling. Fallsback to XSeries.XMaterial on legacy
versions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final ObsidianMaterialadd(ObsidianMaterial im) Add a custom material into the cache that could be later used with valueOf, should be called for all subclassesprotected Objectclone()intcompareTo(ObsidianMaterial arg0) booleaninthashCode()booleanisSimilar(org.bukkit.inventory.ItemStack item) Compare this value with a ItemStack for similaritiesname()Make ObsidianMaterial act like a enum, return the key representing this unique instancestatic voidregisterAdapter(Class<? extends Adapter> clazz) Class for registering adapters for parsingstatic voidForce all bukkit materials into the cachestatic final ObsidianMaterialAllow to remove a custom implementation of ObsidianMaterial from the cacheabstract org.bukkit.inventory.ItemStacktoItem()Object a ItemStack of the desired materialabstract org.bukkit.MaterialObtain the bukkit material associated with this materialtoString()static final ObsidianMaterialParse a material from a string, currently supports BookMaterial, HeadMaterial, BukkitMaterials, PotionMaterial, SpawnerMaterial and XMaterial, custom implementations use .add()static final ObsidianMaterialvalueOf(org.bukkit.Material materialString) Wrap a Material into a ObsidianMaterial, same as wrap(org.bukkit.Material)static List<ObsidianMaterial>values()Return the full list of known material, might be incomplete as Materials are only cached when usedstatic final ObsidianMaterialwrap(com.cryptomorin.xseries.XMaterial mat) Wrap a XMaterial into a ObsidianMaterialstatic final ObsidianMaterialwrap(org.bukkit.Material mat) Wrap a bukkit Material into a ObsidianMaterial
-
Constructor Details
-
ObsidianMaterial
public ObsidianMaterial()
-
-
Method Details
-
registerAdapter
Class for registering adapters for parsing- Parameters:
clazz- The class of the adapter, will auto call the parameterless constructor
-
remove
Allow to remove a custom implementation of ObsidianMaterial from the cache- Parameters:
s- The key to remove- Returns:
- the removed value or null
-
wrap
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
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
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
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
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
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
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
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<ObsidianMaterial>
-