当前位置: 首页>>代码示例>>Java>>正文


Java Material.POTION属性代码示例

本文整理汇总了Java中org.bukkit.Material.POTION属性的典型用法代码示例。如果您正苦于以下问题:Java Material.POTION属性的具体用法?Java Material.POTION怎么用?Java Material.POTION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.POTION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInteract

@EventHandler(priority = EventPriority.HIGHEST)
public void onInteract(PlayerInteractEvent event) {
    Action action = event.getAction();
    ItemStack item = event.getItem();

    if (item == null) {
        return;
    }

    if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
        Player player = event.getPlayer();
        InventoryData data = InventoryData.getData(player);
        // check if we are consuming an item.
        if (item.getType().isEdible() || item.getType() == Material.POTION) {
            // update data.
            data.setConsumeTime(System.currentTimeMillis());
        }
    }

}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:20,代码来源:InventoryListener.java

示例2: onItemConsume

@EventHandler
public void onItemConsume(PlayerItemConsumeEvent e){
    Player p = e.getPlayer();
    ItemStack item = e.getItem();
    Material type = item != null ? item.getType() : Material.AIR;
    int thirst = p.getLevel();

    if (type == Material.POTION && item.getDurability() == 0 && p.getInventory().getItemInMainHand().isSimilar(item)){
        p.getInventory().getItemInMainHand().setType(Material.AIR);

        for (ItemStack i : p.getInventory().getContents()){
            if (i.getType() == Material.GLASS_BOTTLE){
                i.setType(Material.AIR);
            }
        }

        p.setLevel(0);
        if (thirst + 256 >= 1000){
            p.setLevel(1000);
            return;
        }
        p.setLevel(thirst + 256);
        p.sendMessage(p.getLevel() + " // " + thirst + 256);
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:25,代码来源:Thirst.java

示例3: howMuchSpaceForItemAsync

@Override
public int howMuchSpaceForItemAsync(WrappedDirection insertDirection, ItemStack insertion) {
	if (!cachedChunk.isLoaded()) {
		return 0;
	}
	if (isInvLocked(cachedBrewingStand)) {
		return 0;
	}
	if (insertion.getType() == Material.POTION || insertion.getType() == Material.SPLASH_POTION || insertion.getType() == Material.LINGERING_POTION) {
		if (cachedInv.getItem(0) != null && cachedInv.getItem(1) != null && cachedInv.getItem(2) != null) {
			return 0;
		} else {
			return 1;
		}
	} else if (insertDirection.isSide() && insertion.getType() == Material.BLAZE_POWDER) {
		return howManyItemsFit(insertion, cachedInv.getFuel());
	} else if (isBrewingIngredient(insertion)) {
		return howManyItemsFit(insertion, cachedInv.getIngredient());
	} else {
		return 0;
	}
}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:22,代码来源:BrewingStandContainer.java

示例4: getSwamplandWater

/**
 *l.add("��2��Ȼ���Խ��,����...");
	l.add("��e���������....");
 * @return ����ˮ
 */
public static ItemStack getSwamplandWater(){
	ItemStack sw=new ItemStack(Material.POTION);
	PotionMeta im = (PotionMeta) sw.getItemMeta();
	im.setColor(Color.fromRGB(50, 69, 107));
	im.setDisplayName("��8��l����ˮ");
	List<String> l=new LinkedList<String>();
	l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(2, 15)+"%");
	l.add("��2��l"+rs.getLoreTabel("SickKind")+": ��c��l"+rs.defSick.split(";")[(int)Utils.random(0, rs.defSick.split(";").length)]);
	l.add("��2��l"+rs.getLoreTabel("Sickness")+": ��c��l"+Utils.random(30, 50)+"%");
	l.add("");
	l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
	l.add("");
	l.add("��2��Ȼ���Խ��,����...");
	l.add("��e���������....");
	im.setLore(l);
	sw.setItemMeta(im);
	return sw;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:23,代码来源:Items.java

示例5: init

@Override
public boolean init(Expression<?>[] expr, int i, Kleenean kleenean, @NotNull SkriptParser.ParseResult parseResult) {
	switch (parseResult.mark) {
		case 0:
			material = Material.POTION;
			break;
		case 1:
			material = Material.SPLASH_POTION;
			break;
		case 2:
			material = Material.LINGERING_POTION;
			break;
		case 3:
			material = Material.TIPPED_ARROW;
			break;
		default:
			material = Material.POTION;
			break;
	}
	potionEffects = (Expression<PotionEffect>) expr[0];
	return true;
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:22,代码来源:ExprCustomPotionItem.java

示例6: getFreshWater

/**
 * l.add("��2����ֱ������");
 * @return ��ˮ
 */
public static ItemStack getFreshWater(){
	ItemStack sw=new ItemStack(Material.POTION);
	PotionMeta im = (PotionMeta) sw.getItemMeta();
	im.setColor(Color.fromRGB(36, 165, 229));
	im.setDisplayName("��3��l��ˮ");
	List<String> l=new LinkedList<String>();
	l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(10, 25)+"%");
	l.add("");
	l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
	l.add("");
	l.add("��2����ֱ������");
	im.setLore(l);
	sw.setItemMeta(im);
	return sw;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:19,代码来源:Items.java

示例7: getSeaWater

/**
 * l.add("��2��ˮ,����...");
	l.add("��4�������ܽ��,��l���м�������!");
	l.add("��b��Ҫ�þ�ˮװ�����������������!");
 * @return ��ˮ
 */
public static ItemStack getSeaWater(){
	ItemStack sw=new ItemStack(Material.POTION);
	PotionMeta im = (PotionMeta) sw.getItemMeta();
	im.setColor(Color.fromRGB(15, 103, 219));
	im.setDisplayName("��1��l��ˮ");
	List<String> l=new LinkedList<String>();
	l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l-"+Utils.random(2, 20)+"%");
	l.add("��2��l"+rs.getLoreTabel("SickKind")+": ��c��l"+rs.defSick.split(";")[(int)Utils.random(0, rs.defSick.split(";").length)]);
	l.add("��2��l"+rs.getLoreTabel("Sickness")+": ��c��l"+Utils.random(20, 30)+"%");
	l.add("");
	l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
	l.add("");
	l.add("��2��ˮ,����...");
	l.add("��4�������ܽ��,��l���м�������!");
	l.add("��b��Ҫ�þ�ˮװ�����������������!");
	im.setLore(l);
	sw.setItemMeta(im);
	return sw;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:25,代码来源:Items.java

示例8: getRainwater

/**
	l.add("��2��ˮ�����˵���DZȽϸɾ���");
	l.add("��b���ǻ����н�С���ʵò�");
 * @return ��ˮ
 */
public static ItemStack getRainwater(){
	ItemStack sw=new ItemStack(Material.POTION);
	PotionMeta im = (PotionMeta) sw.getItemMeta();
	im.setColor(Color.fromRGB(36, 165, 229));
	im.setDisplayName("��b��l��ˮ");
	List<String> l=new LinkedList<String>();
	l.add("��a��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(5, 25)+"%");
	l.add("��2��l"+rs.getLoreTabel("SickKind")+": ��c��l"+rs.defSick.split(";")[(int)Utils.random(0, rs.defSick.split(";").length)]);
	l.add("��2��l"+rs.getLoreTabel("Sickness")+": ��c��l"+Utils.random(2, 10)+"%");
	l.add("");
	l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
	l.add("");
	l.add("��2��ˮ�����˵���DZȽϸɾ���");
	l.add("��b���ǻ����н�С���ʵò�");
	im.setLore(l);
	sw.setItemMeta(im);
	return sw;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:23,代码来源:Items.java

示例9: getLakeWater

/**
 * l.add("��2��ˮ,�����ճɿ�ˮ");
	l.add("��4��lֱ�Ӻ��м�������!");
	l.add("��b��Ҫ�á�e��l��ˮװ�á�b���������������!");
 * @return��ˮ
 */
public static ItemStack getLakeWater(){
	ItemStack sw=new ItemStack(Material.POTION);
	PotionMeta im = (PotionMeta) sw.getItemMeta();
	im.setColor(Color.fromRGB(36, 165, 229));
	im.setDisplayName("��2��l��ˮ");
	List<String> l=new LinkedList<String>();
	l.add("��2��l"+rs.getLoreTabel("Thirst")+": ��b��l"+Utils.random(5, 20)+"%");
	l.add("��2��l"+rs.getLoreTabel("SickKind")+": ��c��l"+rs.defSick.split(";")[(int)Utils.random(0, rs.defSick.split(";").length)]);
	l.add("��2��l"+rs.getLoreTabel("Sickness")+": ��c��l"+Utils.random(5, 15)+"%");
	l.add("");
	l.add("��7��l"+rs.getLoreTabel("Weight")+": 1");
	l.add("");
	l.add("��4��lֱ�Ӻ��м�������!");
	l.add("��b��Ҫ�á�e��l��ˮװ�á�b���������������!");
	im.setLore(l);
	sw.setItemMeta(im);
	return sw;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:24,代码来源:Items.java

示例10: getTradingItem

private VillagerTrade getTradingItem(MerchantCategory category,
		ItemStack stack, Game game, Player player) {
	for (VillagerTrade trade : category.getOffers()) {
		if ((trade.getItem1().getType() != Material.AIR)
				|| (trade.getRewardItem().getType() != Material.AIR)) {
			ItemStack iStack = toItemStack(trade, player, game);
			if ((iStack.getType() == Material.ENDER_CHEST)
					&& (stack.getType() == Material.ENDER_CHEST))
				return trade;
			if (((iStack.getType() == Material.POTION) || ((Main
					.getInstance().getCurrentVersion().startsWith("v1_9")) && ((iStack
					.getType().equals(Material.valueOf("TIPPED_ARROW")))
					|| (iStack.getType().equals(Material
							.valueOf("LINGERING_POTION"))) || (iStack
						.getType()
					.equals(Material.valueOf("SPLASH_POTION"))))))
					&& (((PotionMeta) iStack.getItemMeta())
							.getCustomEffects().equals(((PotionMeta) stack
							.getItemMeta()).getCustomEffects()))) {
				return trade;
			}
			if (iStack.equals(stack)) {
				return trade;
			}
		}
	}
	return null;
}
 
开发者ID:Ldcr993519867,项目名称:BedwarsXP,代码行数:28,代码来源:XPItemShop.java

示例11: testValidity

private boolean testValidity(ItemStack[] contents) {
    for (ItemStack stack : contents) {
        if (stack != null && stack.getType() == Material.POTION && stack.getDurability() != 0) {
            Potion potion = Potion.fromItemStack(stack);

            // Just to be safe, null check this.
            if (potion == null)
                continue;

            PotionType type = potion.getType();

            // Mundane potions etc, can return a null type
            if (type == null)
                continue;

            // is 33s poison, allow
            if (type == PotionType.POISON && !potion.hasExtendedDuration() && potion.getLevel() == 1) {
                continue;
            }

            if (potion.getLevel() > getMaxLevel(type)) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:27,代码来源:PotionLimitListener.java

示例12: onInteract

@EventHandler
public void onInteract(PlayerInteractEvent e){
    Player p = e.getPlayer();
    Weapon weapon;

    if (e.getItem() == null || e.getHand() != EquipmentSlot.HAND) return;

    if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK){
        if (e.getItem().getType() == Material.POTION) return;
        if (e.getItem() == null || Weapon.getWeaponByItemStack(e.getItem()) == null || !Weapon.isWeapon(e.getItem())) return;
        weapon = Weapon.getWeaponByItemStack(e.getItem());

        if (weapon != null) e.setCancelled(true);
        if (weapon == null) return;

        weapon.shoot(p);
        return;
    }

    if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK){
        if (e.getItem() == null || Weapon.getWeaponByItemStack(e.getItem()) == null || !Weapon.isWeapon(e.getItem())) return;
        weapon = Weapon.getWeaponByItemStack(e.getItem());

        if (weapon != null) e.setCancelled(true);
        if (weapon == null) return;

        if (weapon.getId() == 0) return;

        weapon.watch(p);
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:31,代码来源:Weapons.java

示例13: parseItem

public ItemStack parseItem(Element el, Material type, short damage) throws InvalidXMLException {
    int amount = XMLUtils.parseNumber(el.getAttribute("amount"), Integer.class, 1);

    // If the item is a potion with non-zero damage, and there is
    // no modern potion ID, decode the legacy damage value.
    final Potion legacyPotion;
    if(type == Material.POTION && damage > 0 && el.getAttribute("potion") == null) {
        try {
            legacyPotion = Potion.fromDamage(damage);
        } catch(IllegalArgumentException e) {
            throw new InvalidXMLException("Invalid legacy potion damage value " + damage + ": " + e.getMessage(), el, e);
        }

        // If the legacy splash bit is set, convert to a splash potion
        if(legacyPotion.isSplash()) {
            type = Material.SPLASH_POTION;
            legacyPotion.setSplash(false);
        }

        // Potions always have damage 0
        damage = 0;
    } else {
        legacyPotion = null;
    }

    ItemStack itemStack = new ItemStack(type, amount, damage);
    if(itemStack.getType() != type) {
        throw new InvalidXMLException("Invalid item/block", el);
    }

    final ItemMeta meta = itemStack.getItemMeta();
    if(meta != null) { // This happens if the item is "air"
        parseItemMeta(el, meta);

        // If we decoded a legacy potion, apply it now, but only if there are no custom effects.
        // This emulates the old behavior of custom effects overriding default effects.
        if(legacyPotion != null) {
            final PotionMeta potionMeta = (PotionMeta) meta;
            if(!potionMeta.hasCustomEffects()) {
                potionMeta.setBasePotionData(new PotionData(legacyPotion.getType(),
                                                            legacyPotion.hasExtendedDuration(),
                                                            legacyPotion.getLevel() == 2));
            }
        }

        itemStack.setItemMeta(meta);
    }

    return itemStack;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:50,代码来源:GlobalItemParser.java

示例14: potionItem

@Test
public void potionItem() throws Exception {
    final ItemStack item = new ItemStack(Material.POTION);
    final PotionMeta meta = (PotionMeta) item.getItemMeta();
    meta.setPotionBrew(Bukkit.potionRegistry().get(Bukkit.key("healing")));
    item.setItemMeta(meta);

}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:PotionClassificationTest.java

示例15: anvilStuff

@SuppressWarnings("deprecation")
@EventHandler
public void anvilStuff(PlayerInteractEvent e){
	if(e.getClickedBlock() == null)return;
	if(e.getClickedBlock().getType().equals(Material.ANVIL)){
		e.setCancelled(true);
		Player p = e.getPlayer();
		String uuid = p.getUniqueId().toString();
		long tokens = getTokens(uuid);
		if(p.getItemInHand().getType() == Material.AIR ||
				p.getItemInHand().getType() == Material.GOLDEN_APPLE ||
				p.getItemInHand().getType() == Material.ARROW ||
				p.getItemInHand().getType() == Material.POTION){
			
			p.sendMessage(tag + ChatColor.RED + "You can\'t repair that!");
		}else{
			if(tokens < 1){
				p.sendMessage(tag + ChatColor.RED + "You need at least 1 token to repair things!!");
			}else{
				if(p.getItemInHand().getDurability() > 0){
					p.getItemInHand().setDurability((short) 0);
					setTokens(uuid, getTokens(uuid)-1);
					p.sendMessage(tag + ChatColor.BLUE + "Your item has been repaired");
				}else{
					p.sendMessage(tag + ChatColor.RED + "This item isn\'t broken");
				}
			}
		}
	}
}
 
开发者ID:OverloadedCore,项目名称:kaosEssentials,代码行数:30,代码来源:Core.java


注:本文中的org.bukkit.Material.POTION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。