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


Java ItemMeta.addEnchant方法代碼示例

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


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

示例1: createClassButton

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
private ItemStack createClassButton(MatchPlayer viewer, PlayerClass cls) {
    ItemStack item = cls.getIcon().toItemStack(1);
    ItemMeta meta = item.getItemMeta();
    meta.addItemFlags(ItemFlag.values());

    meta.setDisplayName((cls.canUse(viewer.getBukkit()) ? ChatColor.GREEN : ChatColor.RED) + cls.getName());
    if(getMatch().getMatchModule(ClassMatchModule.class).selectedClass(viewer.getDocument()).equals(cls)) {
        meta.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
    }

    List<String> lore = Lists.newArrayList();
    if(cls.getLongDescription() != null) {
        ChatUtils.wordWrap(ChatColor.GOLD + cls.getLongDescription(), LORE_WIDTH_PIXELS, lore);
    } else if(cls.getDescription() != null) {
        lore.add(ChatColor.GOLD + cls.getDescription());
    }

    if(!cls.canUse(viewer.getBukkit())) {
        lore.add(ChatColor.RED + PGMTranslations.t("class.picker.restricted", viewer));
    }

    meta.setLore(lore);
    item.setItemMeta(meta);

    return item;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:27,代碼來源:PickerMatchModule.java

示例2: formButton

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static ItemStack formButton(Faction faction, Resource resource) {
    ItemStack icon = resource.getIcon();
    ItemMeta meta = icon.getItemMeta();
    SaturationLevel level = faction.isResourceSaturated(resource);
    if (level == SaturationLevel.SURPLUS) {
        meta.addEnchant(Enchantment.LUCK, 1, true);
        meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    }
    meta.setDisplayName(level.getColor() + resource.getName());
    ArrayList<String> lore = new ArrayList<>();
    lore.add(ProgressBar.getBar((double) faction.getSaturatedResources().get(resource)));
    lore.add(level.getColor().toString() + faction.getSaturatedResources().get(resource) + "%");
    String population = String.valueOf(faction.getPopulation());
    String units = String.valueOf(faction.getDemand(resource));
    lore.add(FMessage.POPULATION_REQUIRED.getMessage(population, units, resource.getName()));
    lore.add(FMessage.POPULATION_GRANTING1.getMessage());
    lore.add(FMessage.POPULATION_GRANTING2.getMessage(String.valueOf(faction.getConsumableResources().get(resource)), resource.getName()));
    meta.setLore(lore);
    icon.setItemMeta(meta);
    return icon;
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:22,代碼來源:DemandMenu.java

示例3: addCategoriesToInventory

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
private void addCategoriesToInventory(Inventory inventory, Player player) {
	for (MerchantCategory category : this.categories) {
		if (category.getMaterial() == null) {
			Main.getInstance()
					.getServer()
					.getConsoleSender()
					.sendMessage(
							ChatWriter
									.pluginMessage(ChatColor.RED
											+ "Careful: Not supported material in shop category '"
											+ category.getName() + "'"));
		} else if ((player == null)
				|| (player.hasPermission(category.getPermission()))) {
			ItemStack is = new ItemStack(category.getMaterial(), 1);
			ItemMeta im = is.getItemMeta();

			if ((this.currentCategory != null)
					&& (this.currentCategory.equals(category))) {
				im.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
			}

			im.setDisplayName(category.getName());
			im.setLore(category.getLores());
			is.setItemMeta(im);

			inventory.addItem(new ItemStack[] { is });
		}
	}
}
 
開發者ID:Ldcr993519867,項目名稱:BedwarsXP,代碼行數:30,代碼來源:XPItemShop.java

示例4: processMeta

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public void processMeta(Player player, ItemMeta meta) {
    if (displayName != null)
        meta.setDisplayName(displayName.resolve(player, placeholders));
    meta.setLore(lore.stream().map(m -> m.resolve(player, placeholders)).collect(Collectors.toList()));
    meta.addItemFlags(flags.toArray(new ItemFlag[0]));
    for (Map.Entry<Enchantment, PlaceholderValue<Integer>> ench : enchantments.entrySet())
        meta.addEnchant(ench.getKey(), ench.getValue().resolve(player), true);
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:9,代碼來源:CustomItem.java

示例5: execute

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String[] args) throws CommandException {
    if (!(sender instanceof Player)) {
        throw new CommandException("Only players can use this command!");
    }
    Player player = (Player) sender;

    ItemStack goditem = new ItemStack(Material.DIAMOND_SWORD);
    ItemMeta goditemMeta = goditem.getItemMeta();
    goditemMeta.setDisplayName(ChatColor.BLUE + "GOD ITEM!");
    goditemMeta.addEnchant(Enchantment.DAMAGE_ALL, 1000, true);
    goditemMeta.addEnchant(Enchantment.DURABILITY, 1000, true);
    goditem.setItemMeta(goditemMeta);
    if (args.length == 0) {
        player.getInventory().addItem(goditem);
        player.sendMessage(ChatColor.AQUA + "Receiving item...");
        return true;
    }
    if (args.length == 1) {
        boolean x = false;
        for (Player p : Bukkit.getOnlinePlayers()) {
            if (p.getName().equals(args[0])) {
                x = true;
                break;
            }
        }
        if (!x) {
            player.sendMessage(ChatColor.RED + "Could not find the specified player.");
            return true;
        }
        Player target = Bukkit.getPlayer(args[0]);
        target.getInventory().addItem(goditem);
        target.sendMessage(ChatColor.AQUA + "Receiving item...");
        return true;
    }
    player.sendMessage(ChatColor.RED + "/givegoditem [player]");
    return true;
}
 
開發者ID:Warvale,項目名稱:Locked,代碼行數:39,代碼來源:GiveGodItem.java

示例6: initialize

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
@Override
public void initialize() {
    ItemMeta im;
    grapple = new ItemStack(Material.FISHING_ROD);
    im = grapple.getItemMeta();
    im.addEnchant(Enchantment.DURABILITY, 5, true);
    im.setDisplayName(ChatColor.GOLD + "Grappling Hook");
    im.setLore(Arrays.asList(new String[] { ChatColor.YELLOW + "It's adventure time!", "", ChatColor.GREEN + "Right-click to shoot a hook.", ChatColor.GREEN + "Right-click again to grapple!" }));
    im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
    im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    im.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
    grapple.setItemMeta(im);
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:14,代碼來源:GrappleManager.java

示例7: setScraps

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static void setScraps(Player player, int amount) throws SQLException {
    UUID uuid = player.getUniqueId();
    PreparedStatement stmt = plugin.getDb().getConnection().prepareStatement("UPDATE scraps_eco SET amount = " + amount + " WHERE uuid = '" + uuid.toString() + "'");
    stmt.executeUpdate();

    ItemStack item = new ItemStack(Material.SULPHUR, 1);
    ItemMeta meta = item.getItemMeta();
    meta.setDisplayName(ChatColor.GREEN.toString() + getScraps(player) + (getScraps(player) == 1 ? " Scrap" : " Scraps"));
    meta.addEnchant(Enchantment.LUCK, 1, true);
    meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
    item.setItemMeta(meta);
    player.getInventory().setItem(8, item);
}
 
開發者ID:Warvale,項目名稱:Locked,代碼行數:14,代碼來源:ScrapsUtil.java

示例8: init

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static void init() {
    ItemMeta im = forbidden.getItemMeta();
    im.setDisplayName(" ");
    forbidden.setItemMeta(im);
    im = arrow.getItemMeta();
    im.setDisplayName("§a箭");
    arrow.setItemMeta(im);
    im = bow.getItemMeta();
    im.spigot().setUnbreakable(true);
    im.addEnchant(Enchantment.ARROW_INFINITE, 1, false);
    bow.setItemMeta(im);

}
 
開發者ID:Soldier233,項目名稱:ArchersBattle,代碼行數:14,代碼來源:ItemManager.java

示例9: 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

示例10: addEnchantments

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static void addEnchantments(ItemMeta meta, Map<Enchantment, Integer> enchantments) {
    for(Map.Entry<Enchantment, Integer> enchantment : enchantments.entrySet()) {
        if(meta.getEnchantLevel(enchantment.getKey()) < enchantment.getValue()) {
            meta.addEnchant(enchantment.getKey(), enchantment.getValue(), true);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:8,代碼來源:ItemUtils.java

示例11: getItem

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemStack getItem(Material m, String name, int amount, Enchantment e, int enchLevel,
		boolean showEnchantments) {
	ItemStack i = new ItemStack(m, amount);
	ItemMeta im = i.getItemMeta();
	im.addEnchant(e, enchLevel, true);
	if (!showEnchantments) {
		im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
	}
	im.setDisplayName(name);
	i.setItemMeta(im);
	return i;
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:13,代碼來源:Item.java

示例12: getWreckingBall

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemStack getWreckingBall() {
	ItemStack i = new ItemStack(Material.FIREBALL);
        ItemMeta m = i.getItemMeta();
        m.setDisplayName(WRECKINGBALL_NAME);
        m.setLore(Utils.getInstance().getLore(ChatColor.RED + "Misbruik wordt bestraft! \n Absoluut NIET delen met spelers."));
        m.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
        m.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        i.setItemMeta(m);
        return i;
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:11,代碼來源:WreckingBallModule.java

示例13: SimpleWand

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public SimpleWand() {
	baseItem = new ItemStack(Material.STICK, 1);
	ItemMeta meta = baseItem.getItemMeta();
	meta.setDisplayName(displayName + "none");
	meta.setLore(Arrays.asList(new String[]{"Right click to cast", "'/bind <spell>' to bind"}));
	meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
	meta.addEnchant(Enchantment.MENDING, 1, true);
	baseItem.setItemMeta(meta);
}
 
開發者ID:mcardy,項目名稱:MystiCraft,代碼行數:10,代碼來源:SimpleWand.java

示例14: addGlow

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public static void addGlow(ItemMeta meta) {
    meta.addEnchant(new EnchantGlow() , 1, true);
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:4,代碼來源:EnchantGlow.java

示例15: addEnchant

import org.bukkit.inventory.meta.ItemMeta; //導入方法依賴的package包/類
public ItemMaker addEnchant(Enchantment ench, int level, boolean ignoreLevelRestriction) {
    ItemMeta itemMeta = this.itemStack.getItemMeta();
    itemMeta.addEnchant(ench, level, ignoreLevelRestriction);
    this.itemStack.setItemMeta(itemMeta);
    return this;
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:7,代碼來源:ItemMaker.java


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