br.net.fabiozumbi12.RedProtect.Bukkit.Region Java Examples

The following examples show how to use br.net.fabiozumbi12.RedProtect.Bukkit.Region. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlagGui.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
public void open() {
    for (Player player : Bukkit.getServer().getOnlinePlayers()) {
        if (player.getOpenInventory().getTopInventory().equals(this.inv)) {
            Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
            if (r != null && r.equals(this.region) && !player.equals(this.player)) {
                RedProtect.get().lang.sendMessage(this.player, "cmdmanager.region.rpgui-other", new Replacer[]{new Replacer("{player}", player.getName())});
                return;
            }
        }
    }
    //Register Listener
    RedProtect.get().getServer().getPluginManager().registerEvents(this, RedProtect.get());

    this.inv = Bukkit.createInventory(player, this.size, this.name);
    inv.setContents(this.guiItems);
    player.openInventory(inv);
}
 
Example #2
Source File: BlockListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onVehicleBreak(VehicleDestroyEvent e) {
    RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is VehicleDestroyEvent event");

    if (!(e.getAttacker() instanceof Player)) {
        return;
    }
    Vehicle cart = e.getVehicle();
    Player p = (Player) e.getAttacker();
    Region r = RedProtect.get().rm.getTopRegion(cart.getLocation());

    if (r != null && !r.canMinecart(p)) {
        RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantbreak");
        e.setCancelled(true);
    }
}
 
Example #3
Source File: KillerProjectiles.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onDamagePlayer(ProjectileHitEvent event) {
    if (event.getHitEntity() instanceof Player) {

        Player player = (Player) event.getHitEntity();
        Projectile projectile = event.getEntity();
        Region r = RedProtect.get().rm.getTopRegion(projectile.getLocation());

        double damage;
        if (getConfig().getString("projectile-damage").endsWith("%")) {
            damage = (player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() / 100) * Double.valueOf(getConfig().getString("projectile-damage", "100%").replace("%", ""));
        } else {
            damage = getConfig().getInt("projectile-damage");
        }

        if (r != null && r.getFlagBool("killer-projectiles") && getConfig().getStringList("allowed-types").contains(projectile.getType().name())) {
            player.setHealth(damage);
        }
    }
}
 
Example #4
Source File: GlobalListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onHangingDamaged(HangingBreakByEntityEvent e) {
    Entity ent = e.getRemover();
    Location loc = e.getEntity().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(loc);
    if (r != null) {
        return;
    }

    if (ent instanceof Player) {
        Player p = (Player) ent;
        if (!bypassBuild(p, null, 0)) {
            e.setCancelled(true);
        }
    }
}
 
Example #5
Source File: GlobalListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onBucketFill(PlayerBucketFillEvent e) {
    Location l = e.getBlockClicked().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    if (r != null) {
        return;
    }

    if (!RedProtect.get().getUtil().canBuildNear(e.getPlayer(), l)) {
        e.setCancelled(true);
        return;
    }

    if (!bypassBuild(e.getPlayer(), null, 0)) {
        e.setCancelled(true);
    }
}
 
Example #6
Source File: RedProtectUtil.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
public boolean canBuildNear(Player p, Location loc) {
    if (RedProtect.get().config.configRoot().region_settings.deny_build_near <= 0) {
        return true;
    }
    int x = loc.getBlockX();
    int y = loc.getBlockY();
    int z = loc.getBlockZ();
    int radius = RedProtect.get().config.configRoot().region_settings.deny_build_near;

    for (int ix = x - radius; ix <= x + radius; ++ix) {
        for (int iy = y - radius; iy <= y + radius; ++iy) {
            for (int iz = z - radius; iz <= z + radius; ++iz) {
                Region reg = RedProtect.get().rm.getTopRegion(new Location(p.getWorld(), ix, iy, iz));
                if (reg != null && !reg.canBuild(p)) {
                    RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("blocklistener.cantbuild.nearrp").replace("{distance}", "" + radius));
                    return false;
                }
            }
        }
    }
    return true;
}
 
Example #7
Source File: GlobalListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
    RedProtect.get().logger.debug(LogLevel.DEFAULT, "GlobalListener - Is BlockBreakEvent event!");
    Block b = e.getBlock();
    Player p = e.getPlayer();
    Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
    if (r != null) {
        return;
    }

    if (!RedProtect.get().getUtil().canBuildNear(p, b.getLocation())) {
        e.setCancelled(true);
        return;
    }

    if (!bypassBuild(p, b, 2)) {
        e.setCancelled(true);
    }
}
 
Example #8
Source File: BlockListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent e) {
    RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is BlockBurnEvent event");

    Block b = e.getBlock();

    Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
    if (r != null && !r.canFire()) {
        e.setCancelled(true);
        return;
    }

    if (!cont.canWorldBreak(b)) {
        e.setCancelled(true);
    }
}
 
Example #9
Source File: BorderCommand.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender) {
        HandleHelpPage(sender, 1);
        return true;
    }

    Player player = (Player) sender;

    if (args.length == 0) {
        Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
        if (r != null) {
            RedProtect.get().getUtil().addBorder(player, r);
        } else {
            RedProtect.get().lang.sendMessage(player, "cmdmanager.region.todo.that");
        }
        return true;
    }

    RedProtect.get().lang.sendCommandHelp(sender, "border", true);
    return true;
}
 
Example #10
Source File: Compat19.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onConsume(PlayerItemConsumeEvent e) {
    if (e.getItem() == null) {
        return;
    }

    Player p = e.getPlayer();
    //deny potion
    if (p == null) {
        return;
    }

    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (r != null && e.getItem().getType().equals(Material.CHORUS_FRUIT) && !r.canTeleport(p)) {
        RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse");
        e.setCancelled(true);
    }
}
 
Example #11
Source File: GlobalListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPlayerFrostWalk(EntityBlockFormEvent e) {
    Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
    if (r != null) {
        return;
    }
    RedProtect.get().logger.debug(LogLevel.DEFAULT, "GlobalListener - EntityBlockFormEvent canceled? ");
    if (e.getEntity() instanceof Player) {
        Player p = (Player) e.getEntity();
        if (!RedProtect.get().config.globalFlagsRoot().worlds.get(p.getWorld().getName()).iceform_by.player && !p.hasPermission("redprotect.bypass.world")) {
            e.setCancelled(true);
        }
    } else if (!RedProtect.get().config.globalFlagsRoot().worlds.get(e.getEntity().getWorld().getName()).iceform_by.entity) {
        e.setCancelled(true);
    }
}
 
Example #12
Source File: WorldFlatFileRegionManager.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Map<Integer, Region> getGroupRegion(int x, int y, int z) {
    Map<Integer, Region> regionlist = new HashMap<>();
    for (Region r : regions.values()) {
        if (x <= r.getMaxMbrX() && x >= r.getMinMbrX() && y <= r.getMaxY() && y >= r.getMinY() && z <= r.getMaxMbrZ() && z >= r.getMinMbrZ()) {
            if (regionlist.containsKey(r.getPrior())) {
                Region reg1 = regionlist.get(r.getPrior());
                int Prior = r.getPrior();
                if (reg1.getArea() >= r.getArea()) {
                    r.setPrior(Prior + 1);
                } else {
                    reg1.setPrior(Prior + 1);
                }
            }
            regionlist.put(r.getPrior(), r);
        }
    }
    return regionlist;
}
 
Example #13
Source File: PlayerListener.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkMaxPlayer(Player p, Region r) {
    if (r.canBuild(p)) {
        return true;
    }
    int ttl = 0;
    for (Player onp : p.getWorld().getPlayers()) {
        if (onp == p) {
            continue;
        }
        Region reg = RedProtect.get().rm.getTopRegion(onp.getLocation());
        if (reg != null && reg == r) {
            ttl++;
        }
    }
    return ttl < r.getMaxPlayers();
}
 
Example #14
Source File: BlockListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockBreak(BlockBreakEvent e) {
    RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is BlockBreakEvent event!");

    Player p = e.getPlayer();
    Block b = e.getBlock();

    boolean antih = RedProtect.get().config.configRoot().region_settings.anti_hopper;
    Region r = RedProtect.get().rm.getTopRegion(b.getLocation());

    if (!RedProtect.get().ph.hasPerm(p, "redprotect.bypass")) {
        Block ib = b.getRelative(BlockFace.UP);
        if ((antih && !cont.canBreak(p, ib)) || !cont.canBreak(p, b)) {
            RedProtect.get().lang.sendMessage(p, "blocklistener.container.breakinside");
            e.setCancelled(true);
            return;
        }
    }

    if (r == null && canBreakList(p.getWorld(), b.getType().name())) {
        return;
    }

    if (r != null && (b.getType().name().equals("MOB_SPAWNER") || b.getType().name().equals("SPAWNER")) && r.canPlaceSpawner(p)) {
        return;
    }

    if (r != null && r.canBuild(p) && b.getType().name().endsWith("_SIGN")) {
        Sign s = (Sign) b.getState();
        if (s.getLine(0).equalsIgnoreCase("[flag]")) {
            RedProtect.get().config.removeSign(r.getID(), b.getLocation());
            return;
        }
    }

    if (r != null && !r.canBuild(p) && !r.canTree(b) && !r.canMining(b) && !r.canCrops(b) && !r.canBreak(b.getType())) {
        RedProtect.get().lang.sendMessage(p, "blocklistener.region.cantbuild");
        e.setCancelled(true);
    }
}
 
Example #15
Source File: WorldFlatFileRegionManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Set<Region> getLeaderRegions(String pname) {
    SortedSet<Region> regionsp = new TreeSet<>(Comparator.comparing(Region::getName));
    for (Region r : regions.values()) {
        if (r.isLeader(pname)) {
            regionsp.add(r);
        }
    }
    return regionsp;
}
 
Example #16
Source File: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public static void handleRename(Player p, String newName) {
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (RedProtect.get().ph.hasRegionPermLeader(p, "rename", r)) {
        if (r == null) {
            RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that");
            return;
        }

        //filter name
        newName = RedProtect.get().getUtil().fixRegionName(p, newName);
        if (newName == null) return;

        RenameRegionEvent event = new RenameRegionEvent(r, newName, r.getName(), p);
        Bukkit.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }

        String oldname = event.getOldName();
        newName = event.getNewName();

        Region newRegion = RedProtect.get().rm.renameRegion(newName, r);
        RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("cmdmanager.region.rename.newname") + " " + newRegion.getName());
        RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " RENAMED region " + oldname + " to " + newRegion.getName());
    } else {
        RedProtect.get().lang.sendMessage(p, "no.permission");
    }
}
 
Example #17
Source File: RegionManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public Set<Region> getAllRegions() {
    Set<Region> regions = new HashSet<>();
    for (World w : RedProtect.get().getServer().getWorlds()) {
        WorldRegionManager rm = this.regionManagers.get(w.getName());
        regions.addAll(rm.getAllRegions());
    }
    return regions;
}
 
Example #18
Source File: WorldFlatFileRegionManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Set<Region> getRegions(int x, int y, int z) {
    Set<Region> regionl = new HashSet<>();
    regions.values().forEach(r -> {
        if (x <= r.getMaxMbrX() &&
                x >= r.getMinMbrX() &&
                y <= r.getMaxY() &&
                y >= r.getMinY() &&
                z <= r.getMaxMbrZ() &&
                z >= r.getMinMbrZ()) {
            regionl.add(r);
        }
    });
    return regionl;
}
 
Example #19
Source File: AddLeaderCommand.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length == 3 && (sender instanceof ConsoleCommandSender || RedProtect.get().ph.hasPerm(sender, "redprotect.command.admin.addleader"))) {
        World w = RedProtect.get().getServer().getWorld(args[2]);
        if (w == null) {
            RedProtect.get().lang.sendMessage(sender, RedProtect.get().lang.get("cmdmanager.region.invalidworld"));
            return true;
        }
        Region r = RedProtect.get().rm.getRegion(args[1], w.getName());
        if (r == null) {
            RedProtect.get().lang.sendMessage(sender, RedProtect.get().lang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
            return true;
        }
        handleAddLeader(sender, args[0], r);
        return true;
    } else if (sender instanceof Player) {
        Player player = (Player) sender;

        if (args.length == 1) {
            handleAddLeader(player, args[0], null);
            return true;
        }
    }

    RedProtect.get().lang.sendCommandHelp(sender, "addleader", true);
    return true;
}
 
Example #20
Source File: BlockListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onFallBlockPlace(EntitySpawnEvent e) {
    if (e.getEntityType().equals(EntityType.FALLING_BLOCK)) {
        Region r = RedProtect.get().rm.getTopRegion(e.getLocation());
        if (r != null && !r.allowGravity()) {
            e.getEntity().remove();
        }
    }
}
 
Example #21
Source File: RemoveMemberCommand.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
    if (sender instanceof Player) {
        Region r = RedProtect.get().rm.getTopRegion(((Player) sender).getLocation());
        if (r != null && args.length == 1) {
            if (args[0].isEmpty())
                return r.getMembers().stream().map(PlayerRegion::getPlayerName).collect(Collectors.toList());
            else
                return r.getMembers().stream().filter(p -> p.getPlayerName().toLowerCase().startsWith(args[0].toLowerCase())).map(PlayerRegion::getPlayerName).collect(Collectors.toList());
        }
    }
    return new ArrayList<>();
}
 
Example #22
Source File: RemoveAdminCommand.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
    if (sender instanceof Player) {
        Region r = RedProtect.get().rm.getTopRegion(((Player) sender).getLocation());
        if (r != null && args.length == 1) {
            if (args[0].isEmpty())
                return r.getAdmins().stream().map(PlayerRegion::getPlayerName).collect(Collectors.toList());
            else
                return r.getAdmins().stream().filter(p -> p.getPlayerName().toLowerCase().startsWith(args[0].toLowerCase())).map(PlayerRegion::getPlayerName).collect(Collectors.toList());
        }
    }
    return new ArrayList<>();
}
 
Example #23
Source File: RemoveLeaderCommand.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
    if (sender instanceof Player) {
        Region r = RedProtect.get().rm.getTopRegion(((Player) sender).getLocation());
        if (r != null && args.length == 1) {
            if (args[0].isEmpty())
                return r.getLeaders().stream().map(PlayerRegion::getPlayerName).collect(Collectors.toList());
            else
                return r.getLeaders().stream().filter(p -> p.getPlayerName().toLowerCase().startsWith(args[0].toLowerCase())).map(PlayerRegion::getPlayerName).collect(Collectors.toList());
        }
    }
    return new ArrayList<>();
}
 
Example #24
Source File: WorldFlatFileRegionManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Set<Region> getMemberRegions(String uuid) {
    SortedSet<Region> regionsp = new TreeSet<>(Comparator.comparing(Region::getName));
    for (Region r : regions.values()) {
        if (r.isLeader(uuid) || r.isAdmin(uuid) || r.isMember(uuid)) {
            regionsp.add(r);
        }
    }
    return regionsp;
}
 
Example #25
Source File: Pos1Command.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender) {
        HandleHelpPage(sender, 1);
        return true;
    }

    Player player = (Player) sender;

    String claimmode = RedProtect.get().config.getWorldClaimType(player.getWorld().getName());
    if (!claimmode.equalsIgnoreCase("WAND") && !claimmode.equalsIgnoreCase("BOTH") && !RedProtect.get().ph.hasCommandPerm(player, "redefine")) {
        return true;
    }

    if (args.length == 0) {
        Location pl = player.getLocation();
        RedProtect.get().firstLocationSelections.put(player, pl);
        player.sendMessage(RedProtect.get().lang.get("playerlistener.wand1") + RedProtect.get().lang.get("general.color") + " (" + ChatColor.GOLD + pl.getBlockX() + RedProtect.get().lang.get("general.color") + ", " + ChatColor.GOLD + pl.getBlockY() + RedProtect.get().lang.get("general.color") + ", " + ChatColor.GOLD + pl.getBlockZ() + RedProtect.get().lang.get("general.color") + ").");

        //show preview border
        if (RedProtect.get().firstLocationSelections.containsKey(player) && RedProtect.get().secondLocationSelections.containsKey(player)) {
            Location loc1 = RedProtect.get().firstLocationSelections.get(player);
            Location loc2 = RedProtect.get().secondLocationSelections.get(player);
            if (RedProtect.get().hooks.worldEdit && RedProtect.get().config.configRoot().hooks.useWECUI) {
                WEHook.setSelectionRP(player, loc1, loc2);
            }

            if (loc1.getWorld().equals(loc2.getWorld()) && loc1.distanceSquared(loc2) > RedProtect.get().config.configRoot().region_settings.max_scan) {
                double dist = loc1.distanceSquared(loc2);
                RedProtect.get().lang.sendMessage(player, String.format(RedProtect.get().lang.get("regionbuilder.selection.maxdefine"), RedProtect.get().config.configRoot().region_settings.max_scan, (int) dist));
            } else {
                RedProtect.get().getUtil().addBorder(player, new Region("", loc1, loc2, player.getWorld().getName()));
            }
        }
        return true;
    }

    RedProtect.get().lang.sendCommandHelp(sender, "pos1", true);
    return true;
}
 
Example #26
Source File: WorldFlatFileRegionManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Set<Region> getRegionsNear(int px, int pz, int radius) {
    SortedSet<Region> ret = new TreeSet<>(Comparator.comparing(Region::getName));

    for (Region r : regions.values()) {
        RedProtect.get().logger.debug(LogLevel.DEFAULT, "Radius: " + radius);
        RedProtect.get().logger.debug(LogLevel.DEFAULT, "X radius: " + Math.abs(r.getCenterX() - px) + " - Z radius: " + Math.abs(r.getCenterZ() - pz));
        if (Math.abs(r.getCenterX() - px) <= radius && Math.abs(r.getCenterZ() - pz) <= radius) {
            ret.add(r);
        }
    }
    return ret;
}
 
Example #27
Source File: CommandHandlers.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public static void handleAddAdmin(CommandSender src, String sVictim, Region r) {
    if (src instanceof Player) {
        Player p = (Player) src;
        r = RedProtect.get().rm.getTopRegion(p.getLocation());
        if (r == null) {
            RedProtect.get().lang.sendMessage(p, "cmdmanager.region.todo.that");
            return;
        }
    }

    if (RedProtect.get().ph.hasRegionPermAdmin(src, "addadmin", r)) {
        Player pVictim = RedProtect.get().getServer().getPlayer(sVictim);

        if (RedProtect.get().getUtil().PlayerToUUID(sVictim) == null) {
            RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("cmdmanager.noplayer.thisname").replace("{player}", sVictim));
            return;
        }

        if (r.isLeader(sVictim)) {
            RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.leader.already"));
            return;
        }

        if (!r.isAdmin(sVictim)) {
            r.addAdmin(sVictim);
            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + src.getName() + " ADDED ADMIN " + sVictim + " to region " + r.getName());
            RedProtect.get().lang.sendMessage(src, RedProtect.get().lang.get("general.color") + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.added") + " " + r.getName());
            if (pVictim != null && pVictim.isOnline() && !pVictim.equals(src)) {
                RedProtect.get().lang.sendMessage(pVictim, RedProtect.get().lang.get("cmdmanager.region.admin.youadded").replace("{region}", r.getName()) + " " + src.getName());
            }
        } else {
            RedProtect.get().lang.sendMessage(src, ChatColor.RED + sVictim + " " + RedProtect.get().lang.get("cmdmanager.region.admin.already"));
        }
    } else if (src instanceof Player) {
        RedProtect.get().lang.sendMessage(src, "no.permission");
    }
}
 
Example #28
Source File: PermissionHandler.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
private boolean regionPermMember(Player p, String s, Region poly) {
    String adminperm = "redprotect.command.admin." + s;
    String userperm = "redprotect.command." + s;
    if (poly == null) {
        return this.hasPerm(p, adminperm) || this.hasPerm(p, userperm);
    }
    return this.hasPerm(p, adminperm) || (this.hasPerm(p, userperm) && (poly.isLeader(p) || poly.isAdmin(p) || poly.isMember(p)));
}
 
Example #29
Source File: ValueCommand.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender) {
        HandleHelpPage(sender, 1);
        return true;
    }

    Player player = (Player) sender;

    if (args.length == 0) {
        Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
        if (r != null) {
            if (RedProtect.get().ph.hasRegionPermLeader(player, "value", r)) {
                if (r.getArea() <= RedProtect.get().config.ecoRoot().max_area_toget_value) {
                    r.setValue(EconomyManager.getRegionValue(r));
                    RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.value.is").replace("{value}", EconomyManager.getFormatted(r.getValue()) + " " + RedProtect.get().config.ecoRoot().economy_name));

                    RedProtect.get().logger.debug(LogLevel.DEFAULT, "Region Value: " + r.getValue());
                    return true;
                } else {
                    RedProtect.get().lang.sendMessage(player, RedProtect.get().lang.get("cmdmanager.value.areabig").replace("{maxarea}", String.valueOf(RedProtect.get().config.ecoRoot().max_area_toget_value)));
                    return true;
                }
            } else {
                RedProtect.get().lang.sendMessage(player, "playerlistener.region.cantuse");
                return true;
            }
        } else {
            RedProtect.get().lang.sendMessage(player, "cmdmanager.region.todo.that");
            return true;
        }
    }

    RedProtect.get().lang.sendCommandHelp(sender, "value", true);
    return true;
}
 
Example #30
Source File: InfernalMobsHook.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onInfernalSpawn(InfernalSpawnEvent event) {
    Region r = RedProtect.get().rm.getTopRegion(event.getEntity().getLocation());
    if (r != null) {
        if (r.isLeader(RedProtect.get().config.configRoot().region_settings.default_leader)) {
            if (!RedProtect.get().config.configRoot().hooks.infernal_mobs.allow_server_regions)
                event.setCancelled(true);
        } else if (!RedProtect.get().config.configRoot().hooks.infernal_mobs.allow_player_regions) {
            event.setCancelled(true);
        }
    }
}