當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。