本文整理汇总了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]));
}