use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.
the class RPMine18 method onAttemptInteractAS.
@EventHandler
public void onAttemptInteractAS(PlayerInteractAtEntityEvent e) {
if (e.isCancelled()) {
return;
}
Entity ent = e.getRightClicked();
Location l = ent.getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
Player p = e.getPlayer();
if (r == null) {
// global flags
if (ent instanceof ArmorStand) {
if (!RPConfig.getGlobalFlagBool(l.getWorld().getName() + ".build")) {
e.setCancelled(true);
return;
}
}
return;
}
if (ent instanceof ArmorStand) {
if (r != null && !r.canBuild(p)) {
RPLang.sendMessage(p, "playerlistener.region.cantedit");
e.setCancelled(true);
}
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.
the class RPMine19 method onPlayerTeleport.
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e) {
if (e.isCancelled()) {
return;
}
final Player p = e.getPlayer();
Location lfrom = e.getFrom();
Location lto = e.getTo();
if (e.getCause().equals(PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT)) {
final Region rfrom = RedProtect.get().rm.getTopRegion(lfrom);
final Region rto = RedProtect.get().rm.getTopRegion(lto);
if (rfrom != null && !rfrom.canTeleport(p)) {
RPLang.sendMessage(p, "playerlistener.region.cantuse");
e.setCancelled(true);
}
if (rto != null && !rto.canTeleport(p)) {
RPLang.sendMessage(p, "playerlistener.region.cantuse");
e.setCancelled(true);
}
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.
the class RPMine19 method onLingerPotion.
@EventHandler
public void onLingerPotion(LingeringPotionSplashEvent e) {
if (!(e.getEntity().getShooter() instanceof Player)) {
return;
}
Player p = (Player) e.getEntity().getShooter();
Entity ent = e.getEntity();
RedProtect.get().logger.debug("Is LingeringPotionSplashEvent event.");
Region r = RedProtect.get().rm.getTopRegion(ent.getLocation());
if (r != null && !r.allowEffects(p)) {
RPLang.sendMessage(p, "playerlistener.region.cantuse");
e.setCancelled(true);
return;
}
if (RPUtil.denyPotion(e.getEntity().getItem())) {
e.setCancelled(true);
if (e.getEntity().getShooter() instanceof Player) {
RPLang.sendMessage((Player) e.getEntity().getShooter(), RPLang.get("playerlistener.denypotion"));
}
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.
the class RPMine19 method onChangeBlock.
@EventHandler
public void onChangeBlock(EntityChangeBlockEvent e) {
if (e.isCancelled()) {
return;
}
if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
Block b = e.getBlock();
Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
if (r != null && !r.canBuild(p)) {
RPLang.sendMessage(p, "blocklistener.region.cantbreak");
e.setCancelled(true);
}
}
}
use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.
the class RPMine19 method onPlayerInteract.
@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
Player p = event.getPlayer();
Block b = event.getClickedBlock();
ItemStack itemInHand = event.getItem();
Location l = null;
if (b != null) {
l = b.getLocation();
RedProtect.get().logger.debug("RPPlayerListener - Is PlayerInteractEvent event. The block is " + b.getType().name());
} else {
l = p.getLocation();
}
if (RedProtect.get().tpWait.contains(p.getName())) {
RedProtect.get().tpWait.remove(p.getName());
RPLang.sendMessage(p, "cmdmanager.region.tpcancelled");
}
if (itemInHand != null && (event.getAction().name().equals("RIGHT_CLICK_BLOCK") || b == null)) {
Material hand = itemInHand.getType();
Region r = RedProtect.get().rm.getTopRegion(l);
if (r != null && hand.equals(Material.CHORUS_FRUIT) && !r.canTeleport(p)) {
RPLang.sendMessage(p, "playerlistener.region.cantuse");
event.setCancelled(true);
event.setUseItemInHand(Event.Result.DENY);
}
}
}
Aggregations