本文整理匯總了Java中org.bukkit.Material.matchMaterial方法的典型用法代碼示例。如果您正苦於以下問題:Java Material.matchMaterial方法的具體用法?Java Material.matchMaterial怎麽用?Java Material.matchMaterial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.Material
的用法示例。
在下文中一共展示了Material.matchMaterial方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parse
import org.bukkit.Material; //導入方法依賴的package包/類
public static MaterialPattern parse(String text) {
String[] pieces = text.split(":");
Material material = Material.matchMaterial(pieces[0]);
if(material == null) {
throw new IllegalArgumentException("Could not find material '" + pieces[0] + "'.");
}
if(pieces.length > 1) {
try {
return new MaterialPattern(material, Byte.parseByte(pieces[1]));
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid damage value: " + pieces[1], e);
}
} else {
return new MaterialPattern(material);
}
}
示例2: parseMaterial
import org.bukkit.Material; //導入方法依賴的package包/類
public static Material parseMaterial(Node node, String text) throws InvalidXMLException {
Material material = Material.matchMaterial(text);
if(material == null) {
throw new InvalidXMLException("Unknown material '" + text + "'", node);
}
return material;
}
示例3: parseInternal
import org.bukkit.Material; //導入方法依賴的package包/類
@Override
protected Material parseInternal(Node node, String text) throws FormatException, InvalidXMLException {
Material material = NMSHacks.materialByKey(text);
if(material != null) return material;
material = Material.matchMaterial(text);
if(material != null) return material;
throw new InvalidXMLException("Unknown material '" + text + "'", node);
}
示例4: strToStack
import org.bukkit.Material; //導入方法依賴的package包/類
/**
* Format a given formatted string into
* a object {@link ItemStack}
*
* @param string Formatted string
*
* @return Stack
*/
public static ItemStack strToStack(String string)
{
String[] data = string.split(", ");
return new ItemStack(Material.matchMaterial(data[0]), Integer.parseInt(data[1]), Short.parseShort(data[2]));
}