org.bukkit.entity.Golem Java Examples

The following examples show how to use org.bukkit.entity.Golem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 7 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onItemFrameDamage(final EntityDamageByEntityEvent e) {
    // Check world
    if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) {
        return;
    }
    if (e.getDamager() instanceof Projectile) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Projectile damage to itemframe");
        // Find out who fired the arrow
        Projectile p = (Projectile) e.getDamager();
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Shooter is " + p.getShooter().toString());
        if (p.getShooter() instanceof Skeleton || p.getShooter() instanceof Golem) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Shooter is mob");
            if (!Settings.allowMobDamageToItemFrames) {
                if (DEBUG)
                    plugin.getLogger().info("DEBUG: Damage not allowed, cancelling");
                e.setCancelled(true);
            }
        }
    }
}
 
Example #2
Source File: LimitLogic.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
public CreatureType getCreatureType(EntityType entityType) {
    if (Monster.class.isAssignableFrom(entityType.getEntityClass())
            || WaterMob.class.isAssignableFrom(entityType.getEntityClass())
            || Slime.class.isAssignableFrom(entityType.getEntityClass())
            || Ghast.class.isAssignableFrom(entityType.getEntityClass())
            ) {
        return CreatureType.MONSTER;
    } else if (Animals.class.isAssignableFrom(entityType.getEntityClass())) {
        return CreatureType.ANIMAL;
    } else if (Villager.class.isAssignableFrom(entityType.getEntityClass())) {
        return CreatureType.VILLAGER;
    } else if (Golem.class.isAssignableFrom(entityType.getEntityClass())) {
        return CreatureType.GOLEM;
    }
    return CreatureType.UNKNOWN;
}
 
Example #3
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onItemFrameDamage(final HangingBreakByEntityEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("DEBUG: Hanging break by entity event");
        plugin.getLogger().info("DEBUG: cause = " + e.getCause());
        plugin.getLogger().info("DEBUG: entity = " + e.getEntity());
        plugin.getLogger().info("DEBUG: remover = " + e.getRemover());
    }
    // Check world
    if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) {
        return;
    }
    if (e.getRemover() instanceof Skeleton || e.getRemover() instanceof Golem) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: Remover is mob");
        if (!Settings.allowMobDamageToItemFrames) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Damage not allowed, cancelling");
            e.setCancelled(true);
        }
    }
}
 
Example #4
Source File: LimitLogic.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public CreatureType getCreatureType(LivingEntity creature) {
    if (creature instanceof Monster
            || creature instanceof WaterMob
            || creature instanceof Slime
            || creature instanceof Ghast) {
        return CreatureType.MONSTER;
    } else if (creature instanceof Animals) {
        return CreatureType.ANIMAL;
    } else if (creature instanceof Villager) {
        return CreatureType.VILLAGER;
    } else if (creature instanceof Golem) {
        return CreatureType.GOLEM;
    }
    return CreatureType.UNKNOWN;
}