use of br.net.fabiozumbi12.RedProtect.Bukkit.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);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.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);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.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);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.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);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.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);
}
}
}
}
}
Aggregations