當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemMeta.setUnbreakable方法代碼示例

本文整理匯總了Java中org.bukkit.inventory.meta.ItemMeta.setUnbreakable方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemMeta.setUnbreakable方法的具體用法?Java ItemMeta.setUnbreakable怎麽用?Java ItemMeta.setUnbreakable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.inventory.meta.ItemMeta的用法示例。


在下文中一共展示了ItemMeta.setUnbreakable方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getWeapon

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public <T extends Weapon> ItemStack getWeapon(Class<T> weapon){
    T weaponInst = (T) weaponCache.computeIfAbsent(weapon, k->MiniWynnPlugin.getInjector().getInstance(weapon));
    weaponInst.getSpells().forEach(spell -> spellCache.put(spell.getPattern(), spell));
    weaponCache.putIfAbsent(weapon, weaponInst);
    ItemStack item = new ItemStack(
            weaponInst.getMaterial(),
            1,
            weaponInst.getDamage()
    );
    ItemMeta meta = item.getItemMeta();
    meta.setUnbreakable(true);
    meta.setDisplayName(weaponInst.getName());
    meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE);
    meta.setLore(weaponInst.getLore());
    item.setItemMeta(meta);
    return item;
}
 
開發者ID:mikroskeem,項目名稱:MiniWynn,代碼行數:19,代碼來源:SimpleItemFactory.java

示例2: onCommand

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
    if(!(sender instanceof Player)){
        sender.sendMessage("Only players can use this command.");
        return true;
    }
    if(args != null && args.length > 0){
        if(args[0].equalsIgnoreCase("toggle")){
            active = !active;
            for(Player p: Bukkit.getOnlinePlayers()){
                if(p.isOp()){
                    p.sendMessage(String.format("Ghost Block protection is now %s", active ? "active" : "disabled"));
                }
            }
            return true;
        }
        return false;
    }
    Player player = (Player)sender;
    ItemStack pic = new ItemStack(Material.DIAMOND_PICKAXE);
    ItemMeta meta = pic.getItemMeta();
    meta.setUnbreakable(true);
    meta.addEnchant(Enchantment.DIG_SPEED, 5, true);
    pic.setItemMeta(meta);
    player.getInventory().addItem(pic);
    player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 60000, 2, true, false), true);
    player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 60000, 1, true, false), true);
    return true;
}
 
開發者ID:RypoFalem,項目名稱:GhostBuster,代碼行數:30,代碼來源:GhostBusterPlugin.java

示例3: CustomPanelTexture

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public CustomPanelTexture(int texture) {
	setTexture(texture);
	ItemStack textureItem = new ItemStack(Material.DIAMOND_HOE);
	textureItem.setDurability((short) texture);
	ItemMeta am = textureItem.getItemMeta();
	am.setUnbreakable(true);
	am.setDisplayName("&rPanel".replace('&', '�'));
	am.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
	am.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
	textureItem.setItemMeta(am);
	
	setTextureItem(textureItem);
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:14,代碼來源:CustomPanelTexture.java

示例4: CustomItemTexture

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public CustomItemTexture(int texture) {
	item = new ItemStack(Material.DIAMOND_SWORD);
	item.setDurability((short) 2);
   	ItemMeta im = item.getItemMeta();
   	im.setUnbreakable(true);
   	item.setItemMeta(im);
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:8,代碼來源:CustomItemTexture.java

示例5: Magazine

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public Magazine(ConfigurationSection config) {
	this.name = config.getName();
	
	this.tag = ChatColor.BLACK + "Magazine: "
			+ Integer.toHexString(this.getName().hashCode() + this.getName().length());
	
	this.example = config.getItemStack("example");
	if (this.example == null) {
		throw new IllegalArgumentException("No inventory representation (section example) provided for this bullet, it cannot be instanced");
	} else {
		if (this.example.hasItemMeta()) {
			if (this.example.getItemMeta().hasLore()) {
				this.exampleLore = this.example.getItemMeta().getLore();
			}
			ItemMeta meta = this.example.getItemMeta();
			meta.setUnbreakable(true);
			this.example.setItemMeta(meta);
		}
	}
	
	if (config.contains("bullets")) {
		ConfigurationSection bullets = config.getConfigurationSection("bullets");
		for (String bulletName : bullets.getKeys(false)) {
			if (AddGun.getPlugin().getAmmo().getBullet(bulletName) == null) {
				AddGun.getPlugin().warning("Could not find bullet " + bulletName + " for magazine " + this.name);
			} else {
				this.allowedBullets.add(bulletName);
				this.allowsRounds.put(bulletName, bullets.getInt(bulletName, 1));
			}
		}
	}
	
	if (allowedBullets.isEmpty()) {
		throw new IllegalArgumentException("No bullets defined for this magazine? We cannot proceed");
	}
	
	Map<String, Object> magazineData = new HashMap<String, Object>();
	
	magazineData.put("rounds", Integer.valueOf(0));
	
	this.example = updateMagazineData(this.example, magazineData);

}
 
開發者ID:ProgrammerDan,項目名稱:AddGun,代碼行數:44,代碼來源:Magazine.java

示例6: addWep

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public void addWep(ItemStack item) {
	if (this.type.equalsIgnoreCase("side")) {
		SuperiorCraft.wm2.inv.addItem(item);
	}
	else {
		if (type.equalsIgnoreCase("assault")) {
			for (int i = 1; i < 9; i++) {
				if (SuperiorCraft.wm1.inv.getItem(i) == null) {
					SuperiorCraft.wm1.inv.setItem(i, item);
					return;
				}
			}
		}
		else if (type.equalsIgnoreCase("sniper")) {
			for (int i = 1; i < 9; i++) {
				if (SuperiorCraft.wm1.inv.getItem(i + 9) == null) {
					item.setDurability((short) 2);
		        	ItemMeta im = item.getItemMeta();
		        	im.setUnbreakable(true);
		        	item.setItemMeta(im);
					SuperiorCraft.wm1.inv.setItem(i + 9, item);
					return;
				}
			}
		}
		else if (type.equalsIgnoreCase("shotgun")) {
			for (int i = 1; i < 9; i++) {
				if (SuperiorCraft.wm1.inv.getItem(i + 9 * 2) == null) {
					SuperiorCraft.wm1.inv.setItem(i + 9 * 2, item);
					return;
				}
			}
		}
		else if (type.equalsIgnoreCase("special")) {
			for (int i = 1; i < 9; i++) {
				if (SuperiorCraft.wm1.inv.getItem(i + 9 * 3) == null) {
					SuperiorCraft.wm1.inv.setItem(i + 9 * 3, item);
					return;
				}
			}
		}
		else {
			SuperiorCraft.wm1.inv.addItem(item);
		}
	}
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:47,代碼來源:LongRangeWeapon.java

示例7: setUnbreakable

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static void setUnbreakable(ItemStack stack){
	
	ItemMeta meta = stack.getItemMeta();
	meta.setUnbreakable(true);
	stack.setItemMeta(meta);
	
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:8,代碼來源:Unbreakable.java

示例8: itemStackCreation

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static boolean itemStackCreation(Material mat, int amount, List lore, String name, short durability, boolean unbreakable, int elevel, boolean unsafe, Enchantment[] enchantments, UUID player){

		Player p = Bukkit.getServer().getPlayer(player);

		try{

			ItemStack i = new ItemStack(mat, amount);
			i.setDurability(durability);
			ItemMeta m = i.getItemMeta();
			m.setDisplayName(name);

			if(lore != null){

				m.setLore(lore);

			}

			m.setLocalizedName(name);
			m.setUnbreakable(unbreakable);

			if(enchantments == null){

				i.setItemMeta(m);

				p.getInventory().addItem(i);

				return true;

			} else {

				for(int j = 0; j < enchantments.length; j++){

					m.addEnchant(enchantments[j], elevel, unsafe);

				}

			}

			i.setItemMeta(m);

			p.getInventory().addItem(i);

			return true;

		} catch (NullPointerException e){

			e.printStackTrace();

			return false;

		}

	}
 
開發者ID:RedNyanCat,項目名稱:UselessAPI,代碼行數:54,代碼來源:Api.java


注:本文中的org.bukkit.inventory.meta.ItemMeta.setUnbreakable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。