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);
}
}
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:
}
}
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);
}
}
}
}
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;
}
}
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;
}
}
Aggregations