use of org.bukkit.potion.PotionEffect in project EliteMobs by MagmaGuy.
the class MovementSpeed method applyPowers.
@Override
public void applyPowers(Entity entity) {
entity.setMetadata(powerMetadata, new FixedMetadataValue(plugin, true));
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2));
MinorPowerPowerStance minorPowerPowerStance = new MinorPowerPowerStance();
minorPowerPowerStance.itemEffect(entity);
}
use of org.bukkit.potion.PotionEffect in project Essentials by drtshock.
the class Commandheal method healPlayer.
private void healPlayer(final User user) throws PlayerExemptException, QuietAbortException {
final Player player = user.getBase();
if (player.getHealth() == 0) {
throw new PlayerExemptException(tl("healDead"));
}
final double amount = player.getMaxHealth() - player.getHealth();
final EntityRegainHealthEvent erhe = new EntityRegainHealthEvent(player, amount, RegainReason.CUSTOM);
ess.getServer().getPluginManager().callEvent(erhe);
if (erhe.isCancelled()) {
throw new QuietAbortException();
}
double newAmount = player.getHealth() + erhe.getAmount();
if (newAmount > player.getMaxHealth()) {
newAmount = player.getMaxHealth();
}
player.setHealth(newAmount);
player.setFoodLevel(20);
player.setFireTicks(0);
user.sendMessage(tl("heal"));
for (PotionEffect effect : player.getActivePotionEffects()) {
player.removePotionEffect(effect.getType());
}
}
use of org.bukkit.potion.PotionEffect in project InfernalMobs by NyaaCat.
the class AbilityPotions method onPlayerAttack.
@Override
public void onPlayerAttack(LivingEntity mobEntity, Mob mob, Player attacker, boolean isDirectAttack, EntityDamageByEntityEvent ev) {
if (Helper.possibility(0.3))
return;
Vector velocity = attacker.getEyeLocation().toVector().subtract(mobEntity.getEyeLocation().toVector());
velocity.multiply(1D / 15D);
velocity.add(new Vector(0, 0.2, 0));
ThrownPotion t = mobEntity.launchProjectile(ThrownPotion.class, velocity);
ItemStack item = new ItemStack(Material.SPLASH_POTION);
PotionMeta pm = (PotionMeta) item.getItemMeta();
PotionEffect effect = Helper.randomItem(POTION_EFFECTS);
pm.addCustomEffect(effect, false);
pm.setColor(effect.getColor());
item.setItemMeta(pm);
t.setItem(item);
}
use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.
the class EntityMyPet method onLivingUpdate.
public void onLivingUpdate() {
if (hasRider) {
if (this.passenger == null || !(this.passenger instanceof EntityPlayer)) {
hasRider = false;
// climb height -> halfslab
this.W = 0.5F;
Location playerLoc = getOwner().getPlayer().getLocation();
Location petLoc = getBukkitEntity().getLocation();
petLoc.setYaw(playerLoc.getYaw());
petLoc.setPitch(playerLoc.getPitch());
getOwner().getPlayer().teleport(petLoc);
}
} else {
if (this.passenger != null) {
if (this.passenger instanceof EntityPlayer) {
if (getOwner().equals(this.passenger)) {
hasRider = true;
// climb height -> 1 block
this.W = 1.0F;
petTargetSelector.finish();
petPathfinderSelector.finish();
} else {
// just the owner can ride a pet
this.passenger.mount(null);
}
} else {
this.passenger.mount(null);
}
}
}
if (sitPathfinder.isSitting() && sitCounter-- <= 0) {
MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getHeadHeight() + 1, 0), "spell", 0F, 0F, 0F, 1F, 3, 32);
sitCounter = 30;
}
Player p = myPet.getOwner().getPlayer();
if (p != null && p.isOnline() && !p.isDead()) {
if (p.isSneaking() != isSneaking()) {
this.setSneaking(!isSneaking());
}
if (Configuration.Misc.INVISIBLE_LIKE_OWNER) {
if (!isInvisible && p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
isInvisible = true;
getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
} else if (isInvisible && !p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
getBukkitEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
isInvisible = false;
}
}
if (!this.isInvisible() && getOwner().getDonationRank() != DonateCheck.DonationRank.None && donatorParticleCounter-- <= 0) {
donatorParticleCounter = 20 + getRandom().nextInt(10);
MyPetApi.getPlatformHelper().playParticleEffect(this.getBukkitEntity().getLocation().add(0, 1, 0), "VILLAGER_HAPPY", 0.4F, 0.4F, 0.4F, 0.4F, 5, 10);
}
}
}
use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.
the class EntityMyPet method onLivingUpdate.
public void onLivingUpdate() {
if (hasRider) {
if (this.passenger == null || !(this.passenger instanceof EntityPlayer)) {
hasRider = false;
// climb height -> halfslab
this.S = 0.5F;
Location playerLoc = getOwner().getPlayer().getLocation();
Location petLoc = getBukkitEntity().getLocation();
petLoc.setYaw(playerLoc.getYaw());
petLoc.setPitch(playerLoc.getPitch());
getOwner().getPlayer().teleport(petLoc);
}
} else {
if (this.passenger != null) {
if (this.passenger instanceof EntityPlayer) {
if (getOwner().equals(this.passenger)) {
hasRider = true;
// climb height -> 1 block
this.S = 1.0F;
petTargetSelector.finish();
petPathfinderSelector.finish();
} else {
// just the owner can ride a pet
this.passenger.mount(null);
}
} else {
this.passenger.mount(null);
}
}
}
if (sitPathfinder.isSitting() && sitCounter-- <= 0) {
MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getHeadHeight() + 1, 0), "BARRIER", 0F, 0F, 0F, 5F, 1, 32);
sitCounter = 60;
}
Player p = myPet.getOwner().getPlayer();
if (p != null && p.isOnline() && !p.isDead()) {
if (p.isSneaking() != isSneaking()) {
this.setSneaking(!isSneaking());
}
if (Configuration.Misc.INVISIBLE_LIKE_OWNER) {
if (!isInvisible && p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
isInvisible = true;
getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
} else if (isInvisible && !p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
getBukkitEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
isInvisible = false;
}
}
if (!this.isInvisible() && getOwner().getDonationRank() != DonateCheck.DonationRank.None && donatorParticleCounter-- <= 0) {
donatorParticleCounter = 20 + getRandom().nextInt(10);
MyPetApi.getPlatformHelper().playParticleEffect(this.getBukkitEntity().getLocation().add(0, 1, 0), "VILLAGER_HAPPY", 0.4F, 0.4F, 0.4F, 0.4F, 5, 10);
}
}
}
Aggregations