Search in sources :

Example 91 with LivingEntity

use of org.bukkit.entity.LivingEntity in project modules-extra by CubeEngine.

the class ListenerPlayerEntity method onPlayerInteractEntityEvent.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event) {
    if (!(event.getRightClicked() instanceof LivingEntity)) {
        return;
    }
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    ActionPlayerEntity action;
    if (player.getItemInHand().getType() == COAL && entity instanceof PoweredMinecart) {
        action = this.newAction(UseFurnaceMinecart.class, entity.getWorld());
    } else if (player.getItemInHand().getType() == INK_SACK && entity instanceof Sheep || entity instanceof Wolf) {
        action = this.newAction(EntityDye.class, entity.getWorld());
        if (action != null) {
            ((EntityDye) action).setColor(((Dye) player.getItemInHand().getData()).getColor());
        }
    } else if (player.getItemInHand().getType().equals(BOWL) && entity instanceof MushroomCow) {
        action = this.newAction(EntityFillSoup.class, entity.getWorld());
    } else {
        return;
    }
    if (action != null) {
        action.setEntity(entity);
        action.setPlayer(player);
        action.setLocation(entity.getLocation());
        this.logAction(action);
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) Entity(org.spongepowered.api.entity.Entity) Dye(org.bukkit.material.Dye) Player(org.spongepowered.api.entity.player.Player) MushroomCow(org.bukkit.entity.MushroomCow) PoweredMinecart(org.bukkit.entity.minecart.PoweredMinecart) Sheep(org.bukkit.entity.Sheep) Wolf(org.bukkit.entity.Wolf) EventHandler(org.bukkit.event.EventHandler)

Example 92 with LivingEntity

use of org.bukkit.entity.LivingEntity in project modules-extra by CubeEngine.

the class ListenerEntitySpawn method onCreatureSpawn.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    LivingEntity entity = event.getEntity();
    World world = entity.getWorld();
    switch(event.getSpawnReason()) {
        case NATURAL:
        case JOCKEY:
        case CHUNK_GEN:
        case VILLAGE_DEFENSE:
        case VILLAGE_INVASION:
            SpawnNatural naturalSpawn = this.newAction(SpawnNatural.class, world);
            if (naturalSpawn != null) {
                naturalSpawn.setLocation(entity.getLocation());
                naturalSpawn.setEntity(entity);
                this.logAction(naturalSpawn);
            }
            return;
        case SPAWNER:
            SpawnSpawner spawnerSpawn = this.newAction(SpawnSpawner.class, world);
            if (spawnerSpawn != null) {
                spawnerSpawn.setLocation(entity.getLocation());
                spawnerSpawn.setEntity(entity);
                this.logAction(spawnerSpawn);
            }
            return;
        case EGG:
        case BUILD_SNOWMAN:
        case BUILD_IRONGOLEM:
        case BUILD_WITHER:
        case BREEDING:
            SpawnOther otherSpawn = this.newAction(SpawnOther.class, world);
            if (otherSpawn != null) {
                otherSpawn.setLocation(entity.getLocation());
                otherSpawn.setEntity(entity);
                this.logAction(otherSpawn);
            }
            return;
        case SPAWNER_EGG:
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) World(org.bukkit.World) EventHandler(org.bukkit.event.EventHandler)

Example 93 with LivingEntity

use of org.bukkit.entity.LivingEntity in project Village_Defense by Plajer.

the class ArenaEvents method onDieEntity.

@EventHandler
public void onDieEntity(EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof LivingEntity && e.getDamager() instanceof Wolf && e.getEntity() instanceof Zombie) {
        // trick to get non player killer of zombie
        if (!e.getEntity().hasMetadata("VillageEntity"))
            return;
        if (e.getDamage() >= ((LivingEntity) e.getEntity()).getHealth()) {
            Arena arena = ArenaRegistry.getArena(e.getEntity().getMetadata("PlayingArena").get(0).asString());
            Player player = (Player) ((Wolf) e.getDamager()).getOwner();
            if (player == null)
                return;
            if (ArenaRegistry.getArena(player) != null) {
                arena.addStat(player, "kills");
                arena.addExperience(player, 2);
            }
        }
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) Zombie(org.bukkit.entity.Zombie) Wolf(org.bukkit.entity.Wolf) EventHandler(org.bukkit.event.EventHandler)

Example 94 with LivingEntity

use of org.bukkit.entity.LivingEntity in project Village_Defense by Plajer.

the class GolemBuster method damageEntity.

@Override
public boolean damageEntity(DamageSource damagesource, float f) {
    if (damagesource != null && damagesource.getEntity() != null && damagesource.getEntity().getBukkitEntity().getType() == EntityType.IRON_GOLEM) {
        this.die();
        this.die();
        org.bukkit.inventory.ItemStack[] itemStack = new org.bukkit.inventory.ItemStack[] { new org.bukkit.inventory.ItemStack(org.bukkit.Material.ROTTEN_FLESH) };
        Bukkit.getServer().getPluginManager().callEvent(new EntityDeathEvent((LivingEntity) this.getBukkitEntity(), Arrays.asList(itemStack), expToDrop));
        IronGolem golem = (IronGolem) damagesource.getEntity().getBukkitEntity();
        // golem.getWorld().createExplosion(golem.getLocation(), 4);
        org.bukkit.entity.Entity primed = golem.getWorld().spawnEntity(golem.getLocation(), EntityType.PRIMED_TNT);
        return true;
    } else {
        super.damageEntity(damagesource, f);
        return false;
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EntityDeathEvent(org.bukkit.event.entity.EntityDeathEvent) IronGolem(org.bukkit.entity.IronGolem) EntityIronGolem(net.minecraft.server.v1_12_R1.EntityIronGolem)

Example 95 with LivingEntity

use of org.bukkit.entity.LivingEntity in project Village_Defense by Plajer.

the class PlayerBuster method damageEntity.

@Override
public boolean damageEntity(DamageSource damagesource, float f) {
    if (damagesource != null && damagesource.getEntity() != null && damagesource.getEntity().getBukkitEntity().getType() == EntityType.PLAYER) {
        ItemStack[] itemStack = new ItemStack[] { new ItemStack(Material.ROTTEN_FLESH) };
        Bukkit.getServer().getPluginManager().callEvent(new EntityDeathEvent((LivingEntity) this.getBukkitEntity(), Arrays.asList(itemStack), expToDrop));
        Player player = (Player) damagesource.getEntity().getBukkitEntity();
        getBukkitEntity().getWorld().spawnEntity(getBukkitEntity().getLocation(), EntityType.PRIMED_TNT);
        this.die();
        return true;
    } else {
        super.damageEntity(damagesource, f);
        return false;
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) PathfinderGoalLookAtPlayer(net.minecraft.server.v1_12_R1.PathfinderGoalLookAtPlayer) EntityDeathEvent(org.bukkit.event.entity.EntityDeathEvent) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)322 Entity (org.bukkit.entity.Entity)169 Player (org.bukkit.entity.Player)121 Location (org.bukkit.Location)71 EventHandler (org.bukkit.event.EventHandler)63 Vector (org.bukkit.util.Vector)60 ItemStack (org.bukkit.inventory.ItemStack)47 ArrayList (java.util.ArrayList)41 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)37 PotionEffect (org.bukkit.potion.PotionEffect)34 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)30 Block (org.bukkit.block.Block)24 Mage (com.elmakers.mine.bukkit.api.magic.Mage)22 Projectile (org.bukkit.entity.Projectile)20 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)18 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)17 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)16 Target (com.elmakers.mine.bukkit.utility.Target)15 World (org.bukkit.World)14 Creature (org.bukkit.entity.Creature)14