Search in sources :

Example 1 with EnderCrystal

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);
                }
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) Creeper(org.bukkit.entity.Creeper) Minecart(org.bukkit.entity.Minecart) EnderCrystal(org.bukkit.entity.EnderCrystal) Projectile(org.bukkit.entity.Projectile) Golem(org.bukkit.entity.Golem) Animals(org.bukkit.entity.Animals) ArmorStand(org.bukkit.entity.ArmorStand) Hanging(org.bukkit.entity.Hanging) Monster(org.bukkit.entity.Monster) Villager(org.bukkit.entity.Villager) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) Boat(org.bukkit.entity.Boat) EventHandler(org.bukkit.event.EventHandler)

Example 2 with EnderCrystal

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);
    }
}
Also used : Player(org.bukkit.entity.Player) EnderCrystal(org.bukkit.entity.EnderCrystal) ProjectileSource(org.bukkit.projectiles.ProjectileSource) Island(com.wasteofplastic.askyblock.Island) Projectile(org.bukkit.entity.Projectile) EventHandler(org.bukkit.event.EventHandler)

Example 3 with EnderCrystal

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);
    }
}
Also used : Player(org.bukkit.entity.Player) EnderCrystal(org.bukkit.entity.EnderCrystal) ProjectileSource(org.bukkit.projectiles.ProjectileSource) Island(com.wasteofplastic.acidisland.Island) Projectile(org.bukkit.entity.Projectile) EventHandler(org.bukkit.event.EventHandler)

Example 4 with EnderCrystal

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);
    }
}
Also used : Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Hanging(org.bukkit.entity.Hanging) Minecart(org.bukkit.entity.Minecart) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EnderCrystal(org.bukkit.entity.EnderCrystal) Projectile(org.bukkit.entity.Projectile) Location(org.bukkit.Location) Boat(org.bukkit.entity.Boat) EventHandler(org.bukkit.event.EventHandler)

Example 5 with EnderCrystal

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);
}
Also used : EnderCrystal(org.bukkit.entity.EnderCrystal) Location(org.bukkit.Location)

Aggregations

EnderCrystal (org.bukkit.entity.EnderCrystal)5 Player (org.bukkit.entity.Player)4 Projectile (org.bukkit.entity.Projectile)4 EventHandler (org.bukkit.event.EventHandler)4 Location (org.bukkit.Location)3 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)2 Boat (org.bukkit.entity.Boat)2 Hanging (org.bukkit.entity.Hanging)2 Minecart (org.bukkit.entity.Minecart)2 ProjectileSource (org.bukkit.projectiles.ProjectileSource)2 Island (com.wasteofplastic.acidisland.Island)1 Island (com.wasteofplastic.askyblock.Island)1 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)1 PvPlayer (me.NoChance.PvPManager.PvPlayer)1 Animals (org.bukkit.entity.Animals)1 ArmorStand (org.bukkit.entity.ArmorStand)1 Creeper (org.bukkit.entity.Creeper)1 Entity (org.bukkit.entity.Entity)1 Golem (org.bukkit.entity.Golem)1 LivingEntity (org.bukkit.entity.LivingEntity)1