use of br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onBlockForm.
@EventHandler
public void onBlockForm(BlockFormEvent event) {
RedProtect.get().logger.debug("RPBlockListener - Is Blockform event!");
if (event.isCancelled()) {
return;
}
BlockState b = event.getNewState();
if (b == null) {
return;
}
RedProtect.get().logger.debug("Is Blockform event: " + b.getType().name());
if (b.getType().equals(Material.SNOW) || b.getType().equals(Material.ICE)) {
Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
if (r != null && !r.canIceForm()) {
event.setCancelled(true);
}
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.listeners.RPBlockListener in project RedProtect by FabioZumbi12.
the class RPBlockListener method onFlow.
@EventHandler
public void onFlow(BlockFromToEvent e) {
RedProtect.get().logger.debug("RPBlockListener - Is BlockFromToEvent event");
if (e.isCancelled()) {
return;
}
Block bto = e.getToBlock();
Block bfrom = e.getBlock();
RedProtect.get().logger.debug("RPBlockListener - Is BlockFromToEvent event is to " + bto.getType().name() + " from " + bfrom.getType().name());
Region rto = RedProtect.get().rm.getTopRegion(bto.getLocation());
Region rfrom = RedProtect.get().rm.getTopRegion(bfrom.getLocation());
if (rto != null && bfrom.isLiquid() && !rto.canFlow()) {
e.setCancelled(true);
return;
}
if (rfrom != null && bfrom.isLiquid() && !rfrom.canFlow()) {
e.setCancelled(true);
return;
}
if (rto != null && !bto.isEmpty() && !rto.FlowDamage()) {
e.setCancelled(true);
return;
}
// deny blocks spread in/out regions
if (rfrom != null && rto != null && rfrom != rto && !rfrom.sameLeaders(rto)) {
e.setCancelled(true);
return;
}
if (rfrom == null && rto != null) {
e.setCancelled(true);
}
}
Aggregations