use of br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener in project RedProtect by FabioZumbi12.
the class RPPlayerListener method onPlayerFrostWalk.
@EventHandler(priority = EventPriority.LOW)
public void onPlayerFrostWalk(EntityBlockFormEvent e) {
if (!(e.getEntity() instanceof Player)) {
return;
}
RedProtect.get().logger.debug("RPPlayerListener - EntityBlockFormEvent canceled? " + e.isCancelled());
Player p = (Player) e.getEntity();
Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
if (r != null && e.getNewState().getType().name().contains("FROSTED_ICE") && !r.canIceForm(p)) {
e.setCancelled(true);
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.listeners.RPPlayerListener in project RedProtect by FabioZumbi12.
the class RPPlayerListener method onHangingDamaged.
@EventHandler
public void onHangingDamaged(HangingBreakByEntityEvent e) {
if (e.isCancelled()) {
return;
}
RedProtect.get().logger.debug("Is RPPlayerListener - HangingBreakByEntityEvent event");
Entity ent = e.getRemover();
Location loc = e.getEntity().getLocation();
Region r = RedProtect.get().rm.getTopRegion(loc);
if (ent instanceof Player) {
Player player = (Player) ent;
if (r != null && !r.canBuild(player) && !r.canBreak(e.getEntity().getType())) {
RPLang.sendMessage(player, "blocklistener.region.cantbuild");
e.setCancelled(true);
}
}
if (ent instanceof Monster) {
if (r != null && !r.canMobLoot()) {
e.setCancelled(true);
}
}
}
Aggregations