use of org.bukkit.entity.Projectile in project Jobs by GamingMesh.
the class JobsPaymentListener method onEntityDeath.
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
// Entity that died must be living
if (!(event.getEntity() instanceof LivingEntity))
return;
LivingEntity lVictim = (LivingEntity) event.getEntity();
// mob spawner, no payment or experience
if (lVictim.hasMetadata(mobSpawnerMetadata)) {
lVictim.removeMetadata(mobSpawnerMetadata, plugin);
return;
}
// make sure plugin is enabled
if (!plugin.isEnabled())
return;
if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event.getEntity().getLastDamageCause();
org.bukkit.entity.Player pDamager = null;
if (e.getDamager() instanceof org.bukkit.entity.Player) {
pDamager = (org.bukkit.entity.Player) e.getDamager();
} else if (e.getDamager() instanceof Projectile && ((Projectile) e.getDamager()).getShooter() instanceof org.bukkit.entity.Player) {
pDamager = (org.bukkit.entity.Player) ((Projectile) e.getDamager()).getShooter();
} else if (e.getDamager() instanceof Tameable) {
Tameable t = (Tameable) e.getDamager();
if (t.isTamed() && t.getOwner() instanceof org.bukkit.entity.Player) {
pDamager = (org.bukkit.entity.Player) t.getOwner();
}
}
if (pDamager != null) {
// check if in creative
if (pDamager.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
return;
if (!Jobs.getPermissionHandler().hasWorldPermission(pDamager, pDamager.getLocation().getWorld().getName()))
return;
// restricted area multiplier
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(pDamager);
// pay
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(pDamager);
Jobs.action(jDamager, new EntityActionInfo(lVictim.getType(), ActionType.KILL), multiplier);
}
}
}
use of org.bukkit.entity.Projectile in project EliteMobs by MagmaGuy.
the class AttackBlinding method attackBlinding.
@EventHandler
public void attackBlinding(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity damagee = event.getEntity();
if (damager.hasMetadata(powerMetadata)) {
if (damagee instanceof Player) {
Player player = (Player) damagee;
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 5, 3));
}
} else if (damager instanceof Projectile && damagee instanceof Player) {
if (ProjectileMetadataDetector.projectileMetadataDetector((Projectile) damager, powerMetadata)) {
Player player = (Player) damagee;
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 5, 3));
}
}
}
use of org.bukkit.entity.Projectile in project EliteMobs by MagmaGuy.
the class AttackPoison method onHit.
@EventHandler
public void onHit(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity damagee = event.getEntity();
if (damager.hasMetadata(powerMetadata) && damagee instanceof LivingEntity) {
((LivingEntity) damagee).addPotionEffect(new PotionEffect(PotionEffectType.POISON, 50, 1));
}
if (damager instanceof Projectile) {
if (ProjectileMetadataDetector.projectileMetadataDetector((Projectile) damager, powerMetadata)) {
((LivingEntity) damagee).addPotionEffect(new PotionEffect(PotionEffectType.POISON, 50, 1));
}
}
}
use of org.bukkit.entity.Projectile in project EliteMobs by MagmaGuy.
the class AttackFreeze method attackFreeze.
@EventHandler
public void attackFreeze(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity damagee = event.getEntity();
Block block = damagee.getLocation().getBlock();
Material originalMaterial = block.getType();
if (!originalMaterial.equals(Material.AIR)) {
return;
}
if (damagee.hasMetadata(MetadataHandler.FROZEN_COOLDOWN)) {
return;
}
//if a block spawned by the plugin is already in place, skip effect
if (block.hasMetadata("TemporaryBlock")) {
return;
}
if (damager.hasMetadata(powerMetadata)) {
processID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
int counter = 0;
@Override
public void run() {
iceEffectApplier(counter, damagee, block);
counter++;
}
}, 1, 1);
}
if (damager instanceof Projectile) {
if (ProjectileMetadataDetector.projectileMetadataDetector((Projectile) damager, powerMetadata)) {
processID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
int counter = 0;
@Override
public void run() {
iceEffectApplier(counter, damagee, block);
counter++;
}
}, 1, 1);
}
}
}
use of org.bukkit.entity.Projectile in project EliteMobs by MagmaGuy.
the class AttackFire method attackFire.
@EventHandler
public void attackFire(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity damagee = event.getEntity();
if (damager.hasMetadata(powerMetadata)) {
damagee.setFireTicks(40);
}
if (damager instanceof Projectile) {
if (ProjectileMetadataDetector.projectileMetadataDetector((Projectile) damager, powerMetadata)) {
damagee.setFireTicks(40);
}
}
}
Aggregations