本文整理汇总了Java中org.bukkit.Material.values方法的典型用法代码示例。如果您正苦于以下问题:Java Material.values方法的具体用法?Java Material.values怎么用?Java Material.values使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.values方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: randomMusic
import org.bukkit.Material; //导入方法依赖的package包/类
public static Material randomMusic()
{
ArrayList<Material> records = new ArrayList<>();
for (Material material : Material.values())
if (material.isRecord())
records.add(material);
return records.get(RANDOM.nextInt(records.size()));
}
示例2: onCommand
import org.bukkit.Material; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (Rank.getRank(sender.getName()).getType().getLevel() < RankType.ELITE.getLevel()) {
Chat.player(sender, "&cYou don't have permission to do this.");
return true;
}
if (args.length != 1) {
Chat.player(sender, "&cUsage: /hat [item id or name]");
return true;
}
boolean isInt = true;
Material m = null;
try {
m = Material.getMaterial(Integer.parseInt(args[0]));
}
catch(Exception e) {
isInt = false;
m = Material.getMaterial(args[0].toUpperCase());
}
if (m == null) {
if (!isInt) {
for (Material c : Material.values())
if (c.name().toLowerCase().startsWith(args[0].toLowerCase()))
m = c;
}
}
if (m == null) {
Chat.player(sender, "&cUnknown item: " + args[0]);
return true;
}
Player p = Bukkit.getPlayerExact(sender.getName());
p.getInventory().setHelmet(new ItemStack(m));
Chat.player(sender, "&6Set helmet to &c" + m.name().replace("_", " ").toLowerCase());
return true;
}
示例3: createRandomItem
import org.bukkit.Material; //导入方法依赖的package包/类
public static ItemStack createRandomItem() {
Material[] materials = Material.values();
return new ItemStack(materials[RANDOM.nextInt(materials.length)]);
}