use of br.net.fabiozumbi12.RedProtect.Bukkit.Region in project RedProtect by FabioZumbi12.
the class RPPlayerListener method PlayerTrownPotion.
@EventHandler
public void PlayerTrownPotion(PotionSplashEvent e) {
if (!(e.getPotion().getShooter() instanceof Player)) {
return;
}
Player p = (Player) e.getPotion().getShooter();
Entity ent = e.getEntity();
RedProtect.get().logger.debug("Is PotionSplashEvent event.");
Region r = RedProtect.get().rm.getTopRegion(ent.getLocation());
if (r != null && !r.usePotions(p)) {
RPLang.sendMessage(p, "playerlistener.region.cantuse");
e.setCancelled(true);
return;
}
// deny potion
if (RPUtil.denyPotion(e.getPotion().getItem(), p)) {
e.setCancelled(true);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.Region in project RedProtect by FabioZumbi12.
the class RPPlayerListener method onBucketUse.
@EventHandler
public void onBucketUse(PlayerBucketEmptyEvent e) {
if (e.isCancelled()) {
return;
}
Player p = e.getPlayer();
Location l = e.getBlockClicked().getLocation();
Region r = RedProtect.get().rm.getTopRegion(l);
if (r != null && !r.canBuild(p) && (p.getItemInHand().getType().name().contains("BUCKET"))) {
e.setCancelled(true);
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.Region in project RedProtect by FabioZumbi12.
the class RPPlayerListener method onPlayerCommand.
@EventHandler
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
Player p = e.getPlayer();
if (RedProtect.get().tpWait.contains(p.getName())) {
RedProtect.get().tpWait.remove(p.getName());
RPLang.sendMessage(p, "cmdmanager.region.tpcancelled");
}
String msg = e.getMessage();
String cmd = msg.split(" ")[0];
String cmds = cmd.toLowerCase().replace("/", "");
if (RPConfig.getStringList("server-protection.deny-commands-on-worlds." + p.getWorld().getName()).contains(msg.split(" ")[0].replace("/", "")) && !p.hasPermission("redprotect.bypass")) {
RPLang.sendMessage(p, "playerlistener.command-notallowed");
e.setCancelled(true);
return;
}
if (RPConfig.hasGlobalKey(p.getWorld().getName() + ".command-ranges." + cmd.toLowerCase().replace("/", "")) && !cmds.equals(".")) {
double min = RPConfig.getGlobalFlagDouble(p.getWorld().getName() + ".command-ranges." + cmds + ".min-range");
double max = RPConfig.getGlobalFlagDouble(p.getWorld().getName() + ".command-ranges." + cmds + ".max-range");
String mesg = RPConfig.getGlobalFlagString(p.getWorld().getName() + ".command-ranges." + cmds + ".message");
double py = p.getLocation().getY();
if (py < min || py > max) {
if (mesg != null && !mesg.equals("")) {
RPLang.sendMessage(p, mesg);
}
e.setCancelled(true);
return;
}
}
if (cmd.equalsIgnoreCase("/back") || cmd.equalsIgnoreCase("/home")) {
PlayerCmd.put(p.getName(), msg);
}
Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
if (r != null) {
if ((cmd.equalsIgnoreCase("/petc") || cmd.equalsIgnoreCase("/petcall")) && RedProtect.get().MyPet && !r.canPet(p)) {
RPLang.sendMessage(p, "playerlistener.region.cantpet");
e.setCancelled(true);
return;
}
if (!r.AllowCommands(p, msg)) {
if (cmd.equalsIgnoreCase("/rp") || cmd.equalsIgnoreCase("/redprotect")) {
return;
}
RPLang.sendMessage(p, "playerlistener.region.cantcommand");
e.setCancelled(true);
return;
}
if (!r.DenyCommands(p, msg)) {
for (String alias : RedProtect.get().getCommand("RedProtect").getAliases()) {
if (cmd.equalsIgnoreCase("/" + alias)) {
return;
}
}
RPLang.sendMessage(p, "playerlistener.region.cantcommand");
e.setCancelled(true);
return;
}
if (cmd.equalsIgnoreCase("/sethome") && !r.AllowHome(p)) {
RPLang.sendMessage(p, "playerlistener.region.canthome");
e.setCancelled(true);
return;
}
// Pvp check
if (cmd.equalsIgnoreCase("/pvp") && RedProtect.get().PvPm) {
if (r.isPvPArena() && !PvPlayer.get(p).hasPvPEnabled() && !r.canBuild(p)) {
RPLang.sendMessage(p, "playerlistener.region.pvpenabled");
RedProtect.get().serv.dispatchCommand(RedProtect.get().serv.getConsoleSender(), RPConfig.getString("flags-configuration.pvparena-nopvp-kick-cmd").replace("{player}", p.getName()));
return;
}
}
if (RedProtect.get().Mc && !r.getFlagBool("allow-magiccarpet") && (!r.isAdmin(p) && !r.isLeader(p))) {
if (cmd.equalsIgnoreCase("/magiccarpet")) {
e.setCancelled(true);
RPLang.sendMessage(p, "playerlistener.region.cantmc");
} else {
for (String cmda : MagicCarpet.getPlugin(MagicCarpet.class).getCommand("MagicCarpet").getAliases()) {
if (cmd.equalsIgnoreCase("/" + cmda)) {
e.setCancelled(true);
RPLang.sendMessage(p, "playerlistener.region.cantmc");
}
}
}
}
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.Region in project RedProtect by FabioZumbi12.
the class RPPlayerListener method PlayerTrownEgg.
@EventHandler
public void PlayerTrownEgg(PlayerEggThrowEvent e) {
Location l = e.getEgg().getLocation();
Player p = e.getPlayer();
Region r = RedProtect.get().rm.getTopRegion(l);
if (r != null && !r.canBuild(p)) {
e.setHatching(false);
RPLang.sendMessage(p, "playerlistener.region.canthatch");
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.Region in project RedProtect by FabioZumbi12.
the class RPPlayerListener method onHunger.
@EventHandler
public void onHunger(FoodLevelChangeEvent e) {
if (!(e.getEntity() instanceof Player)) {
return;
}
Player p = (Player) e.getEntity();
Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
if (r != null && !r.canHunger()) {
e.setCancelled(true);
}
}
Aggregations