public interface MaterialAndData
This will probably need an overhaul for 1.8, but I'm hoping that using this class everywhere as an intermediate for the concept of "material type" will allow for a relatively easy transition. We'll see.
In the meantime, this class primary uses String-based "keys" to identify a material. This is not necessarily meant to be a friendly or printable name, though the class is capable of generating a semi-friendly name, which will be the key lowercased and with underscores replaced with spaces. It will also attempt to create a nice name for the variant, such as "blue wool". There is no DB for this, it is all based on the internal Bukkit Material and MaterialData enumerations.
Some examples of keys: wool diamond_block monster_egg wool:15 (for black wool)
This class may also handle special "brushes", and is extended in the MagicPlugin as MaterialBrush. In this case there may be other non-material keys such as clone, copy, schematic:lantern, map, etc.
When used as a storage mechanism for Block or Material data, this class will store the following bits of information:
If persisted to a ConfigurationSection, this will currently only store the base Material and data, extra metadata will not be saved.
| Modifier and Type | Method and Description |
|---|---|
org.bukkit.inventory.ItemStack |
applyToItem(org.bukkit.inventory.ItemStack stack) |
org.bukkit.inventory.ItemStack |
applyToItem(org.bukkit.inventory.ItemStack stack,
ItemUpdatedCallback callback) |
String |
getBaseName() |
Byte |
getBlockData() |
String |
getCommandLine() |
Short |
getData() |
org.bukkit.inventory.ItemStack |
getItemStack(int amount) |
org.bukkit.inventory.ItemStack |
getItemStack(int amount,
ItemUpdatedCallback callback) |
String |
getKey() |
org.bukkit.Material |
getMaterial() |
String |
getModernBlockData() |
String |
getName() |
String |
getName(Messages messages) |
Map<String,Object> |
getTags() |
boolean |
is(org.bukkit.block.Block block) |
boolean |
isDifferent(org.bukkit.block.Block block) |
boolean |
isDifferent(org.bukkit.inventory.ItemStack itemStack) |
boolean |
isDifferent(org.bukkit.Material material) |
boolean |
isValid() |
void |
modify(org.bukkit.block.Block block) |
void |
modify(org.bukkit.block.Block block,
boolean applyPhysics) |
void |
modify(org.bukkit.block.Block block,
ModifyType modifyType) |
void |
setCommandLine(String commandLine) |
void |
setCustomName(String customName) |
void |
setData(Short data) |
void |
setMaterial(org.bukkit.Material material) |
void |
setMaterial(org.bukkit.Material material,
short data) |
void |
setRawData(Object data) |
void |
updateFrom(org.bukkit.block.Block block) |
void |
updateFrom(MaterialAndData other) |
void updateFrom(MaterialAndData other)
void updateFrom(org.bukkit.block.Block block)
void setMaterial(org.bukkit.Material material,
short data)
void setMaterial(org.bukkit.Material material)
void modify(org.bukkit.block.Block block)
void modify(org.bukkit.block.Block block,
boolean applyPhysics)
void modify(org.bukkit.block.Block block,
ModifyType modifyType)
void setData(Short data)
@Nullable org.bukkit.Material getMaterial()
String getKey()
String getName()
boolean is(org.bukkit.block.Block block)
boolean isDifferent(org.bukkit.block.Block block)
boolean isDifferent(org.bukkit.Material material)
boolean isDifferent(org.bukkit.inventory.ItemStack itemStack)
@Nullable org.bukkit.inventory.ItemStack getItemStack(int amount)
@Nullable org.bukkit.inventory.ItemStack getItemStack(int amount, ItemUpdatedCallback callback)
boolean isValid()
void setCommandLine(String commandLine)
void setCustomName(String customName)
void setRawData(Object data)
org.bukkit.inventory.ItemStack applyToItem(org.bukkit.inventory.ItemStack stack)
org.bukkit.inventory.ItemStack applyToItem(org.bukkit.inventory.ItemStack stack,
ItemUpdatedCallback callback)
Copyright © 2021 elMakers. All rights reserved.