当前位置: 首页>>代码示例>>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;未经允许,请勿转载。