org.bukkit.inventory.meta.PotionMeta#addCustomEffect ( )源码实例Demo

下面列出了org.bukkit.inventory.meta.PotionMeta#addCustomEffect ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: UhcCore   文件: ChildrenLeftUnattended.java
private void giveTeamReward(Player player){
    Wolf wolf = (Wolf) player.getWorld().spawnEntity(player.getLocation(), EntityType.WOLF);
    wolf.setTamed(true);
    wolf.setOwner(player);
    wolf.setAdult();

    ItemStack potion = new ItemStack(Material.POTION);
    PotionMeta meta = (PotionMeta) potion.getItemMeta();
    meta.setMainEffect(PotionEffectType.SPEED);
    PotionEffect potionEffect = new PotionEffect(PotionEffectType.SPEED, 8*60*20, 0);
    meta.addCustomEffect(potionEffect, true);

    meta.setDisplayName(ChatColor.WHITE + "Potion of Swiftness");

    potion.setItemMeta(meta);

    player.getWorld().dropItem(player.getLocation(), potion);
}
 
源代码2 项目: UhcCore   文件: JsonItemUtils.java
private static ItemMeta parseCustomPotionEffects(ItemMeta meta, JsonArray jsonArray) throws ParseException{
    if (meta instanceof PotionMeta){
        PotionMeta potionMeta = (PotionMeta) meta;

        for (JsonElement jsonElement : jsonArray){
            JsonObject effect = jsonElement.getAsJsonObject();
            potionMeta.addCustomEffect(parsePotionEffect(effect), true);
        }

        return potionMeta;
    }else{
        return VersionUtils.getVersionUtils().applySuspiciousStewEffects(meta, jsonArray);
    }
}
 
源代码3 项目: CS-CoreLib   文件: CustomPotion.java
@Deprecated
public CustomPotion(String name, int durability, String[] lore, PotionEffect effect) {
	super(Material.POTION, name, (ReflectionUtils.getVersion().startsWith("v1_8_")) ? durability: 0, lore);
	PotionMeta meta = (PotionMeta) getItemMeta();
	if (ReflectionUtils.getVersion().startsWith("v1_8_")) meta.setMainEffect(PotionEffectType.SATURATION);
	else meta.setMainEffect(effect.getType());
	meta.addCustomEffect(effect, true);
	setItemMeta(meta);
}
 
源代码4 项目: CS-CoreLib   文件: CustomPotion.java
public CustomPotion(String name, PotionType type, PotionEffect effect, String... lore) {
	super(Material.POTION, name, lore);
	PotionMeta meta = (PotionMeta) getItemMeta();
	meta.setBasePotionData(new PotionData(type));
	meta.addCustomEffect(effect, true);
	setItemMeta(meta);
}
 
源代码5 项目: CS-CoreLib   文件: CustomPotion.java
public CustomPotion(String name, Color color, PotionEffect effect, String... lore) {
	super(Material.POTION, name, lore);
	PotionMeta meta = (PotionMeta) getItemMeta();
	meta.setColor(color);
	meta.addCustomEffect(effect, true);
	setItemMeta(meta);
}
 
源代码6 项目: BedwarsRel   文件: ItemStackParser.java
@SuppressWarnings("unchecked")
private void parsePotionEffects() {
  PotionMeta customPotionMeta = (PotionMeta) this.finalStack.getItemMeta();
  for (Object potionEffect : (List<Object>) this.linkedSection.get("effects")) {
    LinkedHashMap<String, Object> potionEffectSection =
        (LinkedHashMap<String, Object>) potionEffect;

    if (!potionEffectSection.containsKey("type")) {
      continue;
    }

    PotionEffectType potionEffectType = null;
    int duration = 1;
    int amplifier = 0;

    potionEffectType =
        PotionEffectType.getByName(potionEffectSection.get("type").toString().toUpperCase());

    if (potionEffectSection.containsKey("duration")) {
      duration = Integer.parseInt(potionEffectSection.get("duration").toString()) * 20;
    }

    if (potionEffectSection.containsKey("amplifier")) {
      amplifier = Integer.parseInt(potionEffectSection.get("amplifier").toString()) - 1;
    }

    if (potionEffectType == null) {
      continue;
    }

    customPotionMeta.addCustomEffect(new PotionEffect(potionEffectType, duration, amplifier),
        true);
  }

  this.finalStack.setItemMeta(customPotionMeta);
}