本文整理汇总了Java中org.bukkit.Material.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java Material.valueOf方法的具体用法?Java Material.valueOf怎么用?Java Material.valueOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.valueOf方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectorItem
import org.bukkit.Material; //导入方法依赖的package包/类
public static ItemStack getSelectorItem() {
if(selectorItem != null) return selectorItem;
YAMLConfig config = ConfigOptions.instance.getConfig();
String name = config.getString("petSelector.item.name", "&aPets");
String material = config.getString("petSelector.item.material", Material.BONE.name());
int materialData = config.getInt("petSelector.item.materialData", 0);
List<String> lore = config.config().getStringList("petSelector.item.lore");
if (lore == null) {
lore = new ArrayList<String>();
}
ItemStack i = new ItemStack(Material.valueOf(material), 1, (short) materialData);
ItemMeta meta = i.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
ArrayList<String> loreList = new ArrayList<String>();
if (lore.size() > 0) {
for (String s : lore) {
loreList.add(ChatColor.translateAlternateColorCodes('&', s));
}
}
if (!loreList.isEmpty()) {
meta.setLore(loreList);
}
i.setItemMeta(meta);
selectorItem = i;
return i;
}
示例2: RainTask
import org.bukkit.Material; //导入方法依赖的package包/类
public RainTask(String name){
rains.getStringList(name).forEach(s -> locs.add(Utils.stringToLocation(s)));
rain = WCSurvival.RainType.valueOf(rains.getString(name + ".type").toUpperCase());
material = rains.contains(name + ".mat") ? Material.valueOf(rains.getString(name + ".mat").toUpperCase()) : Material.AIR;
levels = rains.contains(name + ".levels") ? rains.getInt(name + ".levels") : 0;
time = rains.getInt(name + ".time");
}
示例3: matches
import org.bukkit.Material; //导入方法依赖的package包/类
@Override
public boolean matches() {
try {
Material.valueOf(getEnteredArgument());
return true;
} catch (IllegalArgumentException e) {
return false;
}
}
示例4: getRemoveItem
import org.bukkit.Material; //导入方法依赖的package包/类
private ItemStack getRemoveItem(Player p){
ConfigManager.load();
FileConfiguration config = ConfigManager.get();
Material mat = config.getString("gui.gui-item.item") != null ?
Material.valueOf(config.getString("gui.gui-item.item")) : Material.PAPER;
ItemStack is = new ItemStack(mat);
is.setDurability(Short.valueOf(ConfigManager.getInt("gui.gui-item.data")+""));
ItemMeta im = is.getItemMeta();
ArrayList<String> lore = new ArrayList<>();
String title = ColorUtil.translate(ConfigManager.getString("gui.gui-item.name"));
String id = StorageHandler.getPlayerTag(p) != null ? StorageHandler.getPlayerTag(p) : "No";
title = title.replace("%id%", WordUtils.capitalizeFully(id.toLowerCase()));
im.setDisplayName(title);
for(String l : config.getStringList("gui.gui-item.lore")){
lore.add(ColorUtil.translate(l));
}
im.setLore(lore);
is.setItemMeta(im);
return is;
}
示例5: IconMaker
import org.bukkit.Material; //导入方法依赖的package包/类
public IconMaker(String type) {
try {
Material m = Material.valueOf(type);
this.item = new ItemStack(m);
} catch (IllegalArgumentException | NullPointerException e) {
this.item = new ItemStack(Material.STONE);
}
}
示例6: nbtToItemStack
import org.bukkit.Material; //导入方法依赖的package包/类
public static ItemStack nbtToItemStack(NbtCompound nbt) {
ItemStack item = new ItemStack(Material.valueOf(nbt.getString("material")));
if (!ItemUtils.isEmpty(item)) {
item.setAmount(nbt.getInteger("amount"));
item.setDurability(nbt.getShort("data"));
if (nbt.containsKey("tag")) {
item = toBukkitItemStack(item);
NbtFactory.setItemTag(item, nbt.getCompound("tag"));
}
}
return item;
}
示例7: loadSupplyData
import org.bukkit.Material; //导入方法依赖的package包/类
public void loadSupplyData() {
file = new PluginFile(main, "supplyDrops", FileType.YAML);
YamlConfiguration config = file.returnYaml();
// Supply content
// If no content for supply drops is set in config, set a default one to
// avoid a NPE.
if (config.getConfigurationSection("supply-drops.items") == null) {
main.getLogger().info("No Supplydrop content found. Setting defaults.");
String path = "supply-drops.items.0";
config.set(path + ".material", "STONE");
config.set(path + ".chance", 75);
config.set(path + ".amount", 32);
file.save(config);
}
for (String key : config.getConfigurationSection("supply-drops.items").getKeys(false)) {
Material itemMaterial = Material
.valueOf(config.getString("supply-drops.items." + key + ".material").toUpperCase());
int itemChance = config.getInt("supply-drops.items." + key + ".chance");
int itemAmount = config.getInt("supply-drops.items." + key + ".amount");
supplyContent.add(new SupplyDropContent(itemMaterial, itemChance, itemAmount));
}
// Supply drops
for (String s : config.getStringList("supply-drops.objects")) {
Location loc = StringUtilities.stringToLocation(s);
loc.getBlock().setType(Material.CHEST);
Chest chest = (Chest) loc.getBlock().getState();
supplyDrops.add(new SupplyDropObject(loc, chest, chest.getInventory()));
}
}
示例8: get
import org.bukkit.Material; //导入方法依赖的package包/类
public Material get() {
try {
return Material.valueOf(this.materialName);
} catch (Exception exception) {
return null;
}
}
示例9: getMaterial
import org.bukkit.Material; //导入方法依赖的package包/类
public Material getMaterial(Material material)
{
return Material.valueOf(((ConfigurationBuilder.ToolMaterial) this.moduleConfiguration.get("material")).name().toUpperCase() + "_" + material.name().split("_")[1]);
}