Search in sources :

Example 16 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPGlobalListener method onBucketFill.

@EventHandler
public void onBucketFill(PlayerBucketFillEvent e) {
    if (e.isCancelled()) {
        return;
    }
    Location l = e.getBlockClicked().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    if (r != null) {
        return;
    }
    if (!RPUtil.canBuildNear(e.getPlayer(), l)) {
        e.setCancelled(true);
        return;
    }
    if (!bypassBuild(e.getPlayer(), null, 0)) {
        e.setCancelled(true);
    }
}
Also used : Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 17 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPGlobalListener method onPlayerInteract.

@EventHandler
public void onPlayerInteract(PlayerInteractEntityEvent e) {
    if (e.isCancelled()) {
        return;
    }
    Player p = e.getPlayer();
    Entity ent = e.getRightClicked();
    Location l = ent.getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    if (r != null) {
        return;
    }
    if (ent instanceof ItemFrame || ent instanceof Painting) {
        if (!bypassBuild(p, null, 0)) {
            e.setCancelled(true);
            return;
        }
    }
    if (ent instanceof Minecart || ent instanceof Boat) {
        if (!RPConfig.getGlobalFlagBool(l.getWorld().getName() + ".use-minecart") && !p.hasPermission("redprotect.bypass.world")) {
            e.setCancelled(true);
            return;
        }
    }
    if (!RPConfig.getGlobalFlagBool(l.getWorld().getName() + ".interact") && !p.hasPermission("redprotect.bypass.world") && (!(ent instanceof Player))) {
        if (RPConfig.getGlobalFlagList(p.getWorld().getName() + ".if-interact-false.allow-entities").contains(ent.getType().name())) {
            return;
        }
        e.setCancelled(true);
    }
}
Also used : Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) Minecart(org.bukkit.entity.Minecart) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) ItemFrame(org.bukkit.entity.ItemFrame) Location(org.bukkit.Location) Painting(org.bukkit.entity.Painting) Boat(org.bukkit.entity.Boat) EventHandler(org.bukkit.event.EventHandler)

Example 18 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPGlobalListener method onBlockBurn.

@EventHandler
public void onBlockBurn(BlockBurnEvent e) {
    if (e.isCancelled()) {
        return;
    }
    Block b = e.getBlock();
    Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
    if (r != null) {
        return;
    }
    if (!RPConfig.getGlobalFlagBool(b.getWorld().getName() + ".fire-block-damage")) {
        e.setCancelled(true);
    }
}
Also used : Block(org.bukkit.block.Block) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 19 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPGlobalListener method onBlockBreak.

@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
    RedProtect.get().logger.debug("RPGlobalListener - Is BlockBreakEvent event! Cancelled? " + e.isCancelled());
    if (e.isCancelled()) {
        return;
    }
    Block b = e.getBlock();
    Player p = e.getPlayer();
    Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
    if (r != null) {
        return;
    }
    if (!RPUtil.canBuildNear(p, b.getLocation())) {
        e.setCancelled(true);
        return;
    }
    if (!bypassBuild(p, b, 2)) {
        e.setCancelled(true);
    }
}
Also used : Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 20 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region 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)

Aggregations

Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)113 EventHandler (org.bukkit.event.EventHandler)92 Player (org.bukkit.entity.Player)69 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)47 Listener (org.spongepowered.api.event.Listener)46 Location (org.bukkit.Location)43 World (org.spongepowered.api.world.World)30 Block (org.bukkit.block.Block)26 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)20 PvPlayer (me.NoChance.PvPManager.PvPlayer)20 Entity (org.bukkit.entity.Entity)20 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)19 Entity (org.spongepowered.api.entity.Entity)19 LivingEntity (org.bukkit.entity.LivingEntity)16 Player (org.spongepowered.api.entity.living.player.Player)16 World (org.bukkit.World)10 Monster (org.bukkit.entity.Monster)10 Material (org.bukkit.Material)9 ClanPlayer (net.sacredlabyrinth.phaed.simpleclans.ClanPlayer)8 OfflinePlayer (org.bukkit.OfflinePlayer)8