use of br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onLightning.
@EventHandler
public void onLightning(LightningStrikeEvent e) {
RedProtect.get().logger.debug("RPBlockListener - Is LightningStrikeEvent event");
Location l = e.getLightning().getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
if (r != null && !r.canFire()) {
e.setCancelled(true);
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onBlockGrow.
@EventHandler
public void onBlockGrow(BlockGrowEvent event) {
RedProtect.get().logger.debug("RPBlockListener - Is BlockGrowEvent event: " + event.getNewState().getType().name());
if (event.isCancelled()) {
return;
}
Region r = RedProtect.get().rm.getTopRegion(event.getBlock().getLocation());
if (r != null && !r.canGrow()) {
event.setCancelled(true);
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onLeafDecay.
@EventHandler
public void onLeafDecay(LeavesDecayEvent e) {
RedProtect.get().logger.debug("RPBlockListener - Is LeavesDecayEvent event");
if (e.isCancelled()) {
return;
}
Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
if (r != null && !r.leavesDecay()) {
e.setCancelled(true);
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onStructureGrow.
@EventHandler
public void onStructureGrow(StructureGrowEvent e) {
RedProtect.get().logger.debug("RPBlockListener - Is StructureGrowEvent event");
if (!RPConfig.getBool("deny-structure-bypass-regions")) {
return;
}
Region rfrom = RedProtect.get().rm.getTopRegion(e.getLocation());
for (BlockState bstt : e.getBlocks()) {
Region rto = RedProtect.get().rm.getTopRegion(bstt.getLocation());
Block bloc = bstt.getLocation().getBlock();
// deny blocks spread in/out regions
if (rfrom != null && rto != null && rfrom != rto && !rfrom.sameLeaders(rto)) {
bstt.setType(bloc.getType());
}
if (rfrom == null && rto != null) {
bstt.setType(bloc.getType());
}
if (rfrom != null && rto == null) {
bstt.setType(bloc.getType());
}
bstt.update();
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onPistonRetract.
@SuppressWarnings("deprecation")
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e) {
RedProtect.get().logger.debug("RPBlockListener - Is BlockPistonRetractEvent event");
if (RPConfig.getBool("performance.disable-PistonEvent-handler")) {
return;
}
// delay piston
if (RPConfig.getBool("performance.piston.use-piston-restricter")) {
if (pistonRetractDelay.contains(e.getBlock().getLocation().toString())) {
e.setCancelled(true);
return;
} else {
delayRetractPiston(e.getBlock().getLocation().toString());
}
}
World w = e.getBlock().getWorld();
Boolean antih = RPConfig.getBool("region-settings.anti-hopper");
Block piston = e.getBlock();
if (!Bukkit.getBukkitVersion().startsWith("1.8.") && !Bukkit.getBukkitVersion().startsWith("1.9.")) {
Block b = e.getRetractLocation().getBlock();
RedProtect.get().logger.debug("BlockPistonRetractEvent not 1.8 event - Block: " + b.getType().name());
Region pr = RedProtect.get().rm.getTopRegion(piston.getLocation());
Region br = RedProtect.get().rm.getTopRegion(b.getLocation());
if (pr == null && br != null || (pr != null && br != null && pr != br && !pr.sameLeaders(br))) {
e.setCancelled(true);
return;
}
if (antih) {
int x = b.getX();
int y = b.getY();
int z = b.getZ();
Block ib = w.getBlockAt(x, y + 1, z);
if (!cont.canWorldBreak(ib) || !cont.canWorldBreak(b)) {
e.setCancelled(true);
}
}
} else {
List<Block> blocks = e.getBlocks();
Region pr = RedProtect.get().rm.getTopRegion(piston.getLocation());
for (Block b : blocks) {
RedProtect.get().logger.debug("BlockPistonRetractEvent 1.8 event - Block: " + b.getType().name());
Region br = RedProtect.get().rm.getTopRegion(b.getLocation());
if (pr == null && br != null || (pr != null && br != null && pr != br && !pr.sameLeaders(br))) {
e.setCancelled(true);
return;
}
if (antih) {
int x = b.getX();
int y = b.getY();
int z = b.getZ();
Block ib = w.getBlockAt(x, y + 1, z);
if (!cont.canWorldBreak(ib) || !cont.canWorldBreak(b)) {
e.setCancelled(true);
return;
}
}
}
}
}
Aggregations