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