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