use of org.bukkit.entity.EnderCrystal in project RedProtect by FabioZumbi12.
the class RPGlobalListener method onEntityDamageEntity.
@EventHandler
public void onEntityDamageEntity(EntityDamageByEntityEvent e) {
if (e.isCancelled()) {
return;
}
Entity e1 = e.getEntity();
Entity e2 = e.getDamager();
Location loc = e1.getLocation();
Region r1 = RedProtect.get().rm.getTopRegion(loc);
if (r1 != null) {
return;
}
if (e2 instanceof Creeper || e2.getType().equals(EntityType.PRIMED_TNT) || e2.getType().equals(EntityType.MINECART_TNT)) {
if (e1 instanceof Player) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".explosion-entity-damage")) {
e.setCancelled(true);
return;
}
}
if (e1 instanceof Animals || e1 instanceof Villager || e1 instanceof Golem) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".explosion-entity-damage")) {
e.setCancelled(true);
return;
}
}
if (e1 instanceof Monster) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".explosion-entity-damage")) {
e.setCancelled(true);
return;
}
}
}
if (e2 instanceof Player) {
Player p = (Player) e2;
if (e.getCause().equals(DamageCause.LIGHTNING) || e.getCause().equals(DamageCause.BLOCK_EXPLOSION) || e.getCause().equals(DamageCause.ENTITY_EXPLOSION)) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".entity-block-damage")) {
e.setCancelled(true);
return;
}
}
if ((e1 instanceof Minecart || e1 instanceof Boat) && !RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".use-minecart") && !p.hasPermission("redprotect.bypass.world")) {
e.setCancelled(true);
return;
}
if (e1 instanceof Player) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".pvp") && !p.hasPermission("redprotect.bypass.world")) {
e.setCancelled(true);
return;
}
}
if (e1 instanceof Animals || e1 instanceof Villager || e1 instanceof Golem) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".player-hurt-passives") && !p.hasPermission("redprotect.bypass.world")) {
e.setCancelled(true);
return;
}
}
if (e1 instanceof Monster) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".player-hurt-monsters") && !p.hasPermission("redprotect.bypass.world")) {
e.setCancelled(true);
return;
}
}
if (e1 instanceof Hanging || e1 instanceof EnderCrystal || e1 instanceof ArmorStand) {
if (!RPConfig.getGlobalFlagList(p.getWorld().getName() + ".if-build-false.break-blocks").contains(e1.getType().name()) && !bypassBuild(p, null, 0)) {
e.setCancelled(true);
return;
}
}
}
if (e2 instanceof Projectile) {
Projectile proj = (Projectile) e2;
if (proj.getShooter() instanceof Player) {
Player p = (Player) proj.getShooter();
if (e1 instanceof Player) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".pvp") && !p.hasPermission("redprotect.bypass.world")) {
e.setCancelled(true);
return;
}
}
if (e1 instanceof Animals || e1 instanceof Villager || e1 instanceof Golem) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".player-hurt-passives") && !p.hasPermission("redprotect.bypass.world")) {
e.setCancelled(true);
return;
}
}
if (e1 instanceof Monster) {
if (!RPConfig.getGlobalFlagBool(loc.getWorld().getName() + ".player-hurt-monsters") && !p.hasPermission("redprotect.bypass.world")) {
e.setCancelled(true);
return;
}
}
if (e1 instanceof Hanging || e1 instanceof EnderCrystal || e1 instanceof ArmorStand) {
if (!RPConfig.getGlobalFlagList(p.getWorld().getName() + ".if-build-false.break-blocks").contains(e1.getType().name()) && !bypassBuild(p, null, 0)) {
e.setCancelled(true);
}
}
}
}
}
use of org.bukkit.entity.EnderCrystal in project askyblock by tastybento.
the class IslandGuard1_9 method EndCrystalDamage.
/**
* Handle end crystal damage by visitors
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void EndCrystalDamage(EntityDamageByEntityEvent e) {
if (e.getEntity() == null || !IslandGuard.inWorld(e.getEntity())) {
return;
}
if (!(e.getEntity() instanceof EnderCrystal)) {
return;
}
Player p = null;
if (e.getDamager() instanceof Player) {
p = (Player) e.getDamager();
} else if (e.getDamager() instanceof Projectile) {
// Get the shooter
Projectile projectile = (Projectile) e.getDamager();
ProjectileSource shooter = projectile.getShooter();
if (shooter instanceof Player) {
p = (Player) shooter;
}
}
if (p != null) {
if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
// Check if on island
if (plugin.getGrid().playerIsOnIsland(p)) {
return;
}
// Check island
Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
return;
}
if (island != null && island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) {
return;
}
Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected);
e.setCancelled(true);
}
}
use of org.bukkit.entity.EnderCrystal in project acidisland by tastybento.
the class IslandGuard1_9 method EndCrystalDamage.
/**
* Handle end crystal damage by visitors
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void EndCrystalDamage(final EntityDamageByEntityEvent e) {
if (e.getEntity() == null || !IslandGuard.inWorld(e.getEntity())) {
return;
}
if (!(e.getEntity() instanceof EnderCrystal)) {
return;
}
Player p = null;
if (e.getDamager() instanceof Player) {
p = (Player) e.getDamager();
} else if (e.getDamager() instanceof Projectile) {
// Get the shooter
Projectile projectile = (Projectile) e.getDamager();
ProjectileSource shooter = projectile.getShooter();
if (shooter instanceof Player) {
p = (Player) shooter;
}
}
if (p != null) {
if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
// Check if on island
if (plugin.getGrid().playerIsOnIsland(p)) {
return;
}
// Check island
Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
return;
}
if (island != null && island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) {
return;
}
Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected);
e.setCancelled(true);
}
}
use of org.bukkit.entity.EnderCrystal in project RedProtect by FabioZumbi12.
the class RPPlayerListener method onEntityDamageByEntityEvent.
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent e) {
Player p = null;
RedProtect.get().logger.debug("RPLayerListener: Is EntityDamageByEntityEvent event");
if (e.getDamager() instanceof Player) {
p = (Player) e.getDamager();
} else if (e.getDamager() instanceof Projectile) {
Projectile proj = (Projectile) e.getDamager();
if (proj.getShooter() instanceof Player) {
p = (Player) proj.getShooter();
}
}
if (p != null) {
RedProtect.get().logger.debug("Player: " + p.getName());
} else {
RedProtect.get().logger.debug("Player: is null");
return;
}
RedProtect.get().logger.debug("Damager: " + e.getDamager().getType().name());
// check killaura or freekill
if (RPConfig.getBool("server-protection.check-killaura-freekill.enable")) {
startCheckRate(p.getName());
}
Location l = e.getEntity().getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
if (r == null) {
return;
}
if (RedProtect.get().tpWait.contains(p.getName())) {
RedProtect.get().tpWait.remove(p.getName());
RPLang.sendMessage(p, "cmdmanager.region.tpcancelled");
}
if (e.getEntity() instanceof Player && !p.equals(e.getEntity()) && r.flagExists("pvp") && !r.canPVP((Player) e.getEntity(), p)) {
RPLang.sendMessage(p, "entitylistener.region.cantpvp");
e.setCancelled(true);
}
if ((e.getEntity() instanceof Hanging || e.getEntity() instanceof EnderCrystal) && !r.canBuild(p) && !r.canBreak(e.getEntityType())) {
RPLang.sendMessage(p, "playerlistener.region.cantremove");
e.setCancelled(true);
}
if ((e.getEntity() instanceof Boat || e.getEntity() instanceof Minecart) && !r.canMinecart(p)) {
RPLang.sendMessage(p, "blocklistener.region.cantbreak");
e.setCancelled(true);
}
}
use of org.bukkit.entity.EnderCrystal in project Glowstone by GlowstoneMC.
the class ItemEndCrystal method rightClickBlock.
@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) {
if (target == null || (target.getType() != Material.BEDROCK && target.getType() != Material.OBSIDIAN)) {
return;
}
Location location = target.getRelative(BlockFace.UP).getLocation();
// Spawn the crystal in the center of the block
location.add(0.5, 0, 0.5);
EnderCrystal crystal = player.getWorld().spawn(location, EnderCrystal.class);
// "Defaults to false when placing by hand [..]
// http://minecraft.gamepedia.com/End_Crystal#Data_values
crystal.setShowingBottom(false);
super.rightClickBlock(player, target, face, holding, clickedLoc, hand);
}
Aggregations