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


Java Potion.apply方法代码示例

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


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

示例1: setMainPotionEffect

import org.bukkit.potion.Potion; //导入方法依赖的package包/类
public ItemBuilder setMainPotionEffect(PotionType type, boolean extendedDurability, int level, boolean splash) {
    if (! (meta instanceof PotionMeta))
        return this;

    Potion potion = Potion.fromItemStack(stack);
    potion.setType(type);

    if (! type.isInstant())
        potion.setHasExtendedDuration(extendedDurability);

    potion.setLevel(level);
    potion.setSplash(splash);

    potion.apply(stack);

    return this;
}
 
开发者ID:shawlaf,项目名称:Banmanager,代码行数:18,代码来源:ItemBuilder.java

示例2: LuckyPotion

import org.bukkit.potion.Potion; //导入方法依赖的package包/类
public void LuckyPotion(BlockBreakEvent event){
    Location loc = event.getBlock().getLocation();
    World world = loc.getWorld();
    ItemStack energyPotion = new ItemStack(Material.POTION, 1);
    PotionMeta energyPotionMeta = (PotionMeta) energyPotion.getItemMeta();
    energyPotionMeta.setDisplayName("§6Lucky Potion");
    List<String> lore = new ArrayList<String>();
    lore.add("§6"+ LuckyBlocksMainController.instance.language.getString("POTION_DURATION"));
    energyPotionMeta.setLore(lore);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.ABSORPTION, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HEAL, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20*60, 1), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 20*60, 3), true);
    energyPotionMeta.addCustomEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 20*60, 3), true);
    energyPotion.setItemMeta(energyPotionMeta);
    Potion po = new Potion((byte) 8258);
    po.apply(energyPotion);
    world.dropItemNaturally(loc,energyPotion);
}
 
开发者ID:josegrobles,项目名称:LuckyBlocksBukkit,代码行数:23,代码来源:LuckyBlocksActionController.java

示例3: use

import org.bukkit.potion.Potion; //导入方法依赖的package包/类
public boolean use(Fight fight, Character attacking, Character defending, ItemStack weapon) {
    Player attackingPlayer = attacking.getPlayer().getPlayer();
    Player defendingPlayer = defending.getPlayer().getPlayer();
    if (weapon.getType().isEdible() || weapon.getType() == Material.POTION) {
        switch (weapon.getType()) {
            case GOLDEN_APPLE:
                attackingPlayer.getInventory().removeItem(weapon);
                defending.setHealth(Math.min(defending.getHealth() + 10, defending.getMaxHealth()));
                defendingPlayer.setHealth(defending.getHealth());
                fight.sendMessage(ChatColor.YELLOW + (attacking.isNameHidden() ? ChatColor.MAGIC + attacking.getName() + ChatColor.RESET : attacking.getName()) + ChatColor.YELLOW + " fed " + (defending.isNameHidden() ? ChatColor.MAGIC + defending.getName() + ChatColor.RESET : defending.getName()) + ChatColor.YELLOW + " a golden carrot, healing 5 HP.");
                return true;
            case POTION:
                if (weapon.hasItemMeta()) {
                    if (weapon.getItemMeta().hasDisplayName()) {
                        if (weapon.getItemMeta().getDisplayName().equalsIgnoreCase("Masheek")) {
                            attackingPlayer.getInventory().removeItem(weapon);
                            defending.setMana(Math.min(defending.getMana() + 5, defending.getMaxMana()));
                            fight.sendMessage(ChatColor.YELLOW + (attacking.isNameHidden() ? ChatColor.MAGIC + attacking.getName() + ChatColor.RESET : attacking.getName()) + ChatColor.YELLOW + " used a bottle of Masheek on " + (defending.isNameHidden() ? ChatColor.MAGIC + defending.getName() + ChatColor.RESET : defending.getName()) + ChatColor.YELLOW + ", replenishing 5 mana.");
                            return true;
                        }
                    }
                }
                attackingPlayer.getInventory().removeItem(weapon);
                Potion potion = Potion.fromItemStack(weapon);
                potion.apply(defendingPlayer);
                fight.sendMessage(ChatColor.YELLOW + (attacking.isNameHidden() ? ChatColor.MAGIC + attacking.getName() + ChatColor.RESET : attacking.getName()) + ChatColor.YELLOW + " used a potion on " + (defending.isNameHidden() ? ChatColor.MAGIC + defending.getName() + ChatColor.RESET : defending.getName()));
                return true;
            default:
                fight.sendMessage(ChatColor.YELLOW + (attacking.isNameHidden() ? ChatColor.MAGIC + attacking.getName() + ChatColor.RESET : attacking.getName()) + ChatColor.YELLOW + " fed something to " + (defending.isNameHidden() ? ChatColor.MAGIC + defending.getName() + ChatColor.RESET : defending.getName()) + ChatColor.YELLOW + " but it had no effect.");
                return true;
        }
    } else {
        fight.sendMessage(ChatColor.YELLOW + (attacking.isNameHidden() ? ChatColor.MAGIC + attacking.getName() + ChatColor.RESET : attacking.getName()) + ChatColor.YELLOW + " attempted to use a " + weapon.getType().toString().toLowerCase().replace('_', ' ') + " on " + (defending.isNameHidden() ? ChatColor.MAGIC + defending.getName() + ChatColor.RESET : defending.getName()) + ChatColor.YELLOW + " but it didn't seem to do anything.");
        return true;
    }
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:37,代码来源:ItemSkill.java


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