本文整理匯總了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;
}
示例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);
}
示例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;
}
}