Search in sources :

Example 6 with Snowman

use of org.bukkit.entity.Snowman in project acidisland by tastybento.

the class IslandGuard1_9 method onLingeringPotionDamage.

@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) {
    if (!IslandGuard.inWorld(e.getEntity().getLocation())) {
        return;
    }
    if (e.getEntity() == null || e.getEntity().getUniqueId() == null) {
        return;
    }
    if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
        UUID attacker = thrownPotions.get(e.getDamager().getEntityId());
        // Self damage
        if (attacker.equals(e.getEntity().getUniqueId())) {
            return;
        }
        Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
        boolean inNether = false;
        if (e.getEntity().getWorld().equals(ASkyBlock.getNetherWorld())) {
            inNether = true;
        }
        // Monsters being hurt
        if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
            // Normal island check
            if (island != null && island.getMembers().contains(attacker)) {
                // Members always allowed
                return;
            }
            if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) {
                return;
            }
            // Not allowed
            e.setCancelled(true);
            return;
        }
        // Mobs being hurt
        if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman || e.getEntity() instanceof Villager) {
            if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker))) {
                return;
            }
            e.setCancelled(true);
            return;
        }
        // Establish whether PVP is allowed or not.
        boolean pvp = false;
        if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) {
            pvp = true;
        }
        // Players being hurt PvP
        if (e.getEntity() instanceof Player) {
            if (pvp) {
            } else {
                e.setCancelled(true);
            }
        }
    }
}
Also used : Player(org.bukkit.entity.Player) Animals(org.bukkit.entity.Animals) Squid(org.bukkit.entity.Squid) Monster(org.bukkit.entity.Monster) Villager(org.bukkit.entity.Villager) Snowman(org.bukkit.entity.Snowman) IronGolem(org.bukkit.entity.IronGolem) UUID(java.util.UUID) Slime(org.bukkit.entity.Slime) Island(com.wasteofplastic.acidisland.Island) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Animals (org.bukkit.entity.Animals)6 IronGolem (org.bukkit.entity.IronGolem)6 Monster (org.bukkit.entity.Monster)6 Player (org.bukkit.entity.Player)6 Slime (org.bukkit.entity.Slime)6 Snowman (org.bukkit.entity.Snowman)6 Squid (org.bukkit.entity.Squid)6 Villager (org.bukkit.entity.Villager)6 EventHandler (org.bukkit.event.EventHandler)6 Projectile (org.bukkit.entity.Projectile)4 Island (com.wasteofplastic.acidisland.Island)3 Island (com.wasteofplastic.askyblock.Island)3 UUID (java.util.UUID)2 Creeper (org.bukkit.entity.Creeper)2 ItemFrame (org.bukkit.entity.ItemFrame)2 LivingEntity (org.bukkit.entity.LivingEntity)2 ItemStack (org.bukkit.inventory.ItemStack)2