use of org.bukkit.entity.Projectile in project acidisland by tastybento.
the class PlayerEvents method onVisitorGetDamage.
/**
* Prevents visitors from getting damage if invinciblevisitors option is set to TRUE
* @param e - event
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onVisitorGetDamage(EntityDamageByEntityEvent e) {
if (!Settings.invincibleVisitors || !Settings.visitorDamagePrevention.contains(e.getCause()) || !(e.getEntity() instanceof Player) || !e.getCause().equals(DamageCause.ENTITY_ATTACK)) {
return;
}
Player p = (Player) e.getEntity();
if (!IslandGuard.inWorld(p) || plugin.getGrid().locationIsOnIsland(p, p.getLocation()))
return;
// Find out who the attacker is
Player attacker = null;
if (e.getDamager() instanceof Player) {
attacker = (Player) e.getDamager();
}
if (e.getDamager() instanceof Projectile) {
Projectile projectile = (Projectile) e.getDamager();
if (projectile.getShooter() instanceof Player) {
attacker = (Player) projectile.getShooter();
}
}
// If we cannot work out who is the attacker then just prevent the damage and return
if (attacker == null) {
e.setCancelled(true);
return;
}
// Check if at spawn
if (plugin.getGrid().isAtSpawn(e.getEntity().getLocation())) {
// Check if PVP is allowed at spawn or not
if ((e.getEntity().getWorld().getEnvironment().equals(Environment.NORMAL) && plugin.getGrid().getIslandAt(e.getEntity().getLocation()).getIgsFlag(SettingsFlag.PVP)) || (e.getEntity().getWorld().getEnvironment().equals(Environment.NETHER) && plugin.getGrid().getIslandAt(e.getEntity().getLocation()).getIgsFlag(SettingsFlag.NETHER_PVP))) {
// Damage allowed
return;
}
// PVP is not allowed
attacker.sendMessage(ChatColor.RED + plugin.myLocale(attacker.getUniqueId()).visitorsProtected);
e.setCancelled(true);
} else {
// Not at spawn, protect visitor
attacker.sendMessage(ChatColor.RED + plugin.myLocale(attacker.getUniqueId()).visitorsProtected);
e.setCancelled(true);
}
}
use of org.bukkit.entity.Projectile in project Denizen-For-Bukkit by DenizenScript.
the class ShootCommand method arrowDamage.
@EventHandler
public void arrowDamage(EntityDamageByEntityEvent event) {
// Get the damager
Entity arrow = event.getDamager();
// First, quickly confirm it's a projectile (relevant at all)
if (!(arrow instanceof Projectile)) {
return;
}
// Second, more slowly check if we shot it
if (!arrows.containsKey(arrow.getUniqueId())) {
return;
}
// Replace its entry with the hit entity.
arrows.remove(arrow.getUniqueId());
arrows.put(arrow.getUniqueId(), new dEntity(event.getEntity()));
}
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);
}
}
}
Aggregations