Search in sources :

Example 86 with Projectile

use of org.bukkit.entity.Projectile in project Glowstone by GlowstoneMC.

the class GlowPlayer method damage.

@Override
public void damage(double amount, Entity source, @NotNull DamageCause cause) {
    boolean pvpAllowed = server.isPvpEnabled() && world.getPVP();
    if (!pvpAllowed) {
        if (source instanceof Player) {
            return;
        }
        if (cause == DamageCause.PROJECTILE && source instanceof Projectile) {
            Projectile projectile = (Projectile) source;
            if (projectile.getShooter() instanceof Player) {
                return;
            }
        }
    }
    super.damage(amount, source, cause);
}
Also used : Player(org.bukkit.entity.Player) GlowOfflinePlayer(net.glowstone.GlowOfflinePlayer) Projectile(org.bukkit.entity.Projectile)

Aggregations

Projectile (org.bukkit.entity.Projectile)86 EventHandler (org.bukkit.event.EventHandler)55 Player (org.bukkit.entity.Player)44 Entity (org.bukkit.entity.Entity)37 LivingEntity (org.bukkit.entity.LivingEntity)28 ProjectileSource (org.bukkit.projectiles.ProjectileSource)18 EntityDamageByEntityEvent (org.bukkit.event.entity.EntityDamageByEntityEvent)13 Location (org.bukkit.Location)9 Animals (org.bukkit.entity.Animals)9 Monster (org.bukkit.entity.Monster)9 Vector (org.bukkit.util.Vector)9 Villager (org.bukkit.entity.Villager)8 ItemStack (org.bukkit.inventory.ItemStack)8 Hanging (org.bukkit.entity.Hanging)7 EntityDamageEvent (org.bukkit.event.entity.EntityDamageEvent)7 PotionEffect (org.bukkit.potion.PotionEffect)7 Block (org.bukkit.block.Block)6 Arrow (org.bukkit.entity.Arrow)6 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)4 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)4