org.bukkit.potion.PotionEffectType#POISON源码实例Demo

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

源代码1 项目: MineTinker   文件: Poisonous.java
public PotionEffect getPotionEffect(@Nullable Event event, @Nullable Entity entity, @NotNull Player player, @NotNull ItemStack tool) {
	int level = modManager.getModLevel(tool, this);
	int duration = (int) (this.duration * Math.pow(this.durationMultiplier, (level - 1)));
	int amplifier = this.effectAmplifier * (level - 1);
	if (entity == null) {
		ChatWriter.logModifier(player, event, this, tool,
				"Duration(" + duration + ")",
				"Amplifier(" + amplifier + ")");
	} else {
		ChatWriter.logModifier(player, event, this, tool,
				"Duration(" + duration + ")",
				"Amplifier(" + amplifier + ")",
				"Entity(" + entity.getType().toString() + ")");
	}

	return new PotionEffect(PotionEffectType.POISON, duration, amplifier, false, false);
}
 
源代码2 项目: ProjectAres   文件: PotionDamageResolver.java
@Override
public @Nullable PotionInfo resolveDamage(EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
    // If potion is already resolved (i.e. as a splash potion), leave it alone
    if(damager instanceof PotionInfo ||
       damager instanceof ProjectileInfo && ((ProjectileInfo) damager).getProjectile() instanceof PotionInfo) {
        return null;
    }

    final PotionEffectType effect;
    switch(damageType) {
        case POISON: effect = PotionEffectType.POISON; break;
        case WITHER: effect = PotionEffectType.WITHER; break;
        case MAGIC: effect = PotionEffectType.HARM; break;
        default: return null;
    }

    return new GenericPotionInfo(effect);
}
 
源代码3 项目: Skript   文件: EffPoison.java
@Override
protected void execute(final Event e) {
	for (final LivingEntity le : entites.getArray(e)) {
		if (!cure) {
			Timespan dur;
			int d = (int) (duration != null && (dur = duration.getSingle(e)) != null ? 
					(dur.getTicks_i() >= Integer.MAX_VALUE ? Integer.MAX_VALUE : dur.getTicks_i()) : DEFAULT_DURATION);
			if (le.hasPotionEffect(PotionEffectType.POISON)) {
				for (final PotionEffect pe : le.getActivePotionEffects()) {
					if (pe.getType() != PotionEffectType.POISON)
						continue;
					d += pe.getDuration();
				}
			}
			le.addPotionEffect(new PotionEffect(PotionEffectType.POISON, d, 0), true);
		} else {
			le.removePotionEffect(PotionEffectType.POISON);
		}
	}
}
 
源代码4 项目: PGM   文件: PotionDamageResolver.java
@Override
public @Nullable PotionInfo resolveDamage(
    EntityDamageEvent.DamageCause damageType, Entity victim, @Nullable PhysicalInfo damager) {
  PotionEffectType effect;
  switch (damageType) {
    case POISON:
      effect = PotionEffectType.POISON;
      break;
    case WITHER:
      effect = PotionEffectType.WITHER;
      break;
    case MAGIC:
      effect = null;
      break;
    default:
      return null;
  }

  // If potion is already resolved (i.e. as a splash potion), leave it alone
  if (damager instanceof PotionInfo
      || damager instanceof ProjectileInfo
          && ((ProjectileInfo) damager).getProjectile() instanceof PotionInfo) {
    return null;
  }

  return new GenericPotionInfo(effect);
}
 
源代码5 项目: MineTinker   文件: Poisonous.java
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
	if (!dropPoisonedMeat) {
		return;
	}

	LivingEntity mob = event.getEntity();
	Player player = mob.getKiller();

	if (player == null) {
		return;
	}

	if (Lists.WORLDS.contains(player.getWorld().getName())) {
		return;
	}

	boolean isPoisoned = false;

	for (PotionEffect potionEffect : mob.getActivePotionEffects()) {
		if (potionEffect.getType() == PotionEffectType.POISON) {
			isPoisoned = true;
			break;
		}
	}

	if (!isPoisoned) {
		return;
	}

	int numberOfMeat = 0;
	int numberOfPotatoes = 0;

	Iterator<ItemStack> iterator = event.getDrops().iterator();

	while (iterator.hasNext()) {
		ItemStack drop = iterator.next();
		if (isMeat(drop)) {
			iterator.remove();
			numberOfMeat++;
		} else if (drop.getType() == Material.POTATO) {
			iterator.remove();
			numberOfPotatoes++;
		}
	}

	ChatWriter.logModifier(player, event, this, player.getInventory().getItemInMainHand(),
			"Entity(" + event.getEntity().getType().toString() + ")");

	if (numberOfMeat > 0) event.getDrops().add(new ItemStack(Material.ROTTEN_FLESH, numberOfMeat));
	if (numberOfPotatoes > 0) event.getDrops().add(new ItemStack(Material.POISONOUS_POTATO, numberOfPotatoes));
}