当前位置: 首页>>代码示例>>Java>>正文


Java Material.valueOf方法代码示例

本文整理汇总了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;
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:27,代码来源:SelectorLayout.java

示例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");
}
 
开发者ID:cadox8,项目名称:WC,代码行数:8,代码来源:RainTask.java

示例3: matches

import org.bukkit.Material; //导入方法依赖的package包/类
@Override
public boolean matches() {
    try {
        Material.valueOf(getEnteredArgument());
        return true;
    } catch (IllegalArgumentException e) {
        return false;
    }
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:10,代码来源:MaterialArgument.java

示例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;
}
 
开发者ID:Chazmondo,项目名称:DogTags,代码行数:29,代码来源:TagsCommand.java

示例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);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:9,代码来源:IconMaker.java

示例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;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:16,代码来源:ItemUtils.java

示例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()));
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:36,代码来源:SupplyDropManager.java

示例8: get

import org.bukkit.Material; //导入方法依赖的package包/类
public Material get() {
    try {
        return Material.valueOf(this.materialName);
    } catch (Exception exception) {
        return null;
    }
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:8,代码来源:WrappedMaterial.java

示例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]);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:5,代码来源:RapidToolsModule.java


注:本文中的org.bukkit.Material.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。