Search in sources :

Example 31 with Region

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);
    }
}
Also used : Entity(org.bukkit.entity.Entity) MyPetBukkitEntity(de.Keyle.MyPet.api.entity.MyPetBukkitEntity) Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 32 with Region

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);
    }
}
Also used : Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 33 with Region

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");
                    }
                }
            }
        }
    }
}
Also used : Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Example 34 with Region

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");
    }
}
Also used : Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 35 with Region

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);
    }
}
Also used : Player(org.bukkit.entity.Player) PvPlayer(me.NoChance.PvPManager.PvPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)113 EventHandler (org.bukkit.event.EventHandler)92 Player (org.bukkit.entity.Player)69 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)47 Listener (org.spongepowered.api.event.Listener)46 Location (org.bukkit.Location)43 World (org.spongepowered.api.world.World)30 Block (org.bukkit.block.Block)26 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)20 PvPlayer (me.NoChance.PvPManager.PvPlayer)20 Entity (org.bukkit.entity.Entity)20 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)19 Entity (org.spongepowered.api.entity.Entity)19 LivingEntity (org.bukkit.entity.LivingEntity)16 Player (org.spongepowered.api.entity.living.player.Player)16 World (org.bukkit.World)10 Monster (org.bukkit.entity.Monster)10 Material (org.bukkit.Material)9 ClanPlayer (net.sacredlabyrinth.phaed.simpleclans.ClanPlayer)8 OfflinePlayer (org.bukkit.OfflinePlayer)8