Search in sources :

Example 1 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPCommands method handlePriority.

private static void handlePriority(Player p, int prior) {
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (RedProtect.get().ph.hasRegionPermLeader(p, "priority", r)) {
        if (r != null) {
            r.setPrior(prior);
            RPLang.sendMessage(p, RPLang.get("cmdmanager.region.priority.set").replace("{region}", r.getName()) + " " + prior);
            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " SET PRIORITY of region " + r.getName() + " to " + prior);
        } else {
            RPLang.sendMessage(p, "cmdmanager.region.todo.that");
        }
    }
}
Also used : Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region)

Example 2 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPCommands method HandleHelPage.

private static void HandleHelPage(CommandSender sender, int page) {
    sender.sendMessage(RPLang.get("_redprotect.prefix") + " " + RPLang.get("cmdmanager.available.cmds"));
    sender.sendMessage(RPLang.get("general.color") + "------------------------------------");
    sender.sendMessage(RPLang.get("cmdmanager.helpheader.alias"));
    if (sender instanceof Player) {
        Player player = (Player) sender;
        int i = 0;
        for (String key : RPLang.helpStrings()) {
            if (RedProtect.get().ph.hasGenPerm(player, key) || ((key.equals("pos1") || key.equals("pos1")) && RedProtect.get().ph.hasGenPerm(player, "redefine"))) {
                if (key.equalsIgnoreCase("flaggui")) {
                    continue;
                }
                i++;
                if (i > (page * 5) - 5 && i <= page * 5) {
                    player.sendMessage(RPLang.get("cmdmanager.help." + key).replace("{cmd}", getCmd(key)).replace("{alias}", getCmdAlias(key)));
                }
                if (i > page * 5) {
                    player.sendMessage(RPLang.get("general.color") + "------------------------------------");
                    player.sendMessage(RPLang.get("cmdmanager.page").replace("{page}", "" + (page + 1)));
                    break;
                }
            }
        }
    } else {
        sender.sendMessage(ChatColor.GOLD + "rp setconfig list " + ChatColor.DARK_AQUA + "- List all editable configs");
        sender.sendMessage(ChatColor.GOLD + "rp setconfig <Config-Section> <Value> " + ChatColor.DARK_AQUA + "- Set a config option");
        sender.sendMessage(ChatColor.GOLD + "rp info <region> <world> " + ChatColor.DARK_AQUA + "- Info about a region");
        sender.sendMessage(ChatColor.GOLD + "rp flag <regionName> <Flag> <Value> <World> " + ChatColor.DARK_AQUA + "- Set a flag on region");
        sender.sendMessage(ChatColor.GOLD + "rp flag info <region> <world> " + ChatColor.DARK_AQUA + "- Flag info for region");
        sender.sendMessage(ChatColor.GOLD + "rp teleport <playerName> <regionName> <World> " + ChatColor.DARK_AQUA + "- Teleport player to a region");
        sender.sendMessage(ChatColor.GOLD + "rp limit <playerName> " + ChatColor.DARK_AQUA + "- Area limit for player");
        sender.sendMessage(ChatColor.GOLD + "rp claimlimit <playerName> [world] " + ChatColor.DARK_AQUA + "- Claim limit for player");
        sender.sendMessage(ChatColor.GOLD + "rp list-all " + ChatColor.DARK_AQUA + "- List All regions");
        sender.sendMessage(ChatColor.GOLD + "rp list <player> [page] " + ChatColor.DARK_AQUA + "- List All regions from player");
        sender.sendMessage(ChatColor.GOLD + "rp ymlTomysql " + ChatColor.DARK_AQUA + "- Convert from Yml to Mysql");
        sender.sendMessage(ChatColor.GOLD + "rp mychunktorp " + ChatColor.DARK_AQUA + "- Convert from MyChunk to RedProtect");
        sender.sendMessage(ChatColor.GOLD + "rp single-to-files " + ChatColor.DARK_AQUA + "- Convert single world files to regions files");
        sender.sendMessage(ChatColor.GOLD + "rp files-to-single " + ChatColor.DARK_AQUA + "- Convert regions files to single world files");
        sender.sendMessage(ChatColor.GOLD + "rp gpTorp " + ChatColor.DARK_AQUA + "- Convert from GriefPrevention to RedProtect");
        sender.sendMessage(ChatColor.GOLD + "rp save-all " + ChatColor.DARK_AQUA + "- Save all regions to database");
        sender.sendMessage(ChatColor.GOLD + "rp load-all " + ChatColor.DARK_AQUA + "- Load all regions from database");
        sender.sendMessage(ChatColor.GOLD + "rp reload-config " + ChatColor.DARK_AQUA + "- Reload only the config");
        sender.sendMessage(ChatColor.GOLD + "rp reload " + ChatColor.DARK_AQUA + "- Reload the plugin");
    }
    sender.sendMessage(RPLang.get("general.color") + "------------------------------------");
    if (RedProtect.get().ph.hasPerm(sender, "admin")) {
        String jarversion = new java.io.File(RedProtect.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName();
        sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8&o- UChat full version: " + jarversion));
    }
}
Also used : Player(org.bukkit.entity.Player) ClanPlayer(net.sacredlabyrinth.phaed.simpleclans.ClanPlayer) OfflinePlayer(org.bukkit.OfflinePlayer) RedProtect(br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect)

Example 3 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPCommands method handletp.

private static void handletp(Player p, String rname, String wname, Player play) {
    World w = RedProtect.get().serv.getWorld(wname);
    if (w == null) {
        RPLang.sendMessage(p, "cmdmanager.region.invalidworld");
        return;
    }
    Region region = RedProtect.get().rm.getRegion(rname, w);
    if (region == null) {
        RPLang.sendMessage(p, RPLang.get("cmdmanager.region.doesntexist") + ": " + rname);
        return;
    }
    if (play == null) {
        if (!RedProtect.get().ph.hasRegionPermMember(p, "teleport", region)) {
            RPLang.sendMessage(p, "no.permission");
            return;
        }
    } else {
        if (!RedProtect.get().ph.hasPerm(p, "redprotect.teleport.other")) {
            RPLang.sendMessage(p, "no.permission");
            return;
        }
    }
    Location loc = null;
    if (region.getTPPoint() != null) {
        loc = region.getTPPoint();
        loc.setX(loc.getBlockX() + 0.500);
        loc.setZ(loc.getBlockZ() + 0.500);
    } else {
        int limit = w.getMaxHeight();
        if (w.getEnvironment().equals(Environment.NETHER)) {
            limit = 124;
        }
        for (int i = limit; i > 0; i--) {
            Material mat = w.getBlockAt(region.getCenterX(), i, region.getCenterZ()).getType();
            Material mat1 = w.getBlockAt(region.getCenterX(), i + 1, region.getCenterZ()).getType();
            Material mat2 = w.getBlockAt(region.getCenterX(), i + 2, region.getCenterZ()).getType();
            if (!mat.name().contains("LAVA") && !mat.equals(Material.AIR) && mat1.equals(Material.AIR) && mat2.equals(Material.AIR)) {
                loc = new Location(w, region.getCenterX() + 0.500, i + 1, region.getCenterZ() + 0.500);
                break;
            }
        }
    }
    if (loc != null) {
        if (play != null) {
            if (RedProtect.get().Ess) {
                RedProtect.get().pless.getUser(p).setLastLocation();
            }
            play.teleport(loc);
            RPLang.sendMessage(play, RPLang.get("cmdmanager.region.teleport") + " " + rname);
            RPLang.sendMessage(p, RPLang.get("cmdmanager.region.tpother") + " " + rname);
        } else {
            tpWait(p, loc, rname);
        }
    }
}
Also used : Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Material(org.bukkit.Material) World(org.bukkit.World) Location(org.bukkit.Location)

Example 4 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPCommands method handleDelete.

private static void handleDelete(Player p) {
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (RedProtect.get().ph.hasRegionPermLeader(p, "delete", r)) {
        if (r == null) {
            sendNotInRegionMessage(p);
            return;
        }
        int claims = RPConfig.getInt("region-settings.first-home.can-delete-after-claims");
        if (!r.canDelete() && (claims == -1 || RedProtect.get().rm.getPlayerRegions(p.getName(), p.getWorld()) < claims) && !p.hasPermission("redprotect.bypass")) {
            if (claims != -1) {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst-claims").replace("{claims}", "" + claims));
            } else {
                RPLang.sendMessage(p, RPLang.get("cmdmanager.region.cantdeletefirst"));
            }
            return;
        }
        DeleteRegionEvent event = new DeleteRegionEvent(r, p);
        Bukkit.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }
        String rname = r.getName();
        String w = r.getWorld();
        RedProtect.get().rm.remove(r, RedProtect.get().serv.getWorld(w));
        RPLang.sendMessage(p, RPLang.get("cmdmanager.region.deleted") + " " + rname);
        RedProtect.get().logger.addLog("(World " + w + ") Player " + p.getName() + " REMOVED region " + rname);
    } else {
        sendNoPermissionMessage(p);
    }
}
Also used : DeleteRegionEvent(br.net.fabiozumbi12.RedProtect.Bukkit.events.DeleteRegionEvent) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region)

Example 5 with Region

use of br.net.fabiozumbi12.RedProtect.Sponge.Region in project RedProtect by FabioZumbi12.

the class RPCommands method handleAddAdmin.

private static void handleAddAdmin(Player p, String sVictim) {
    Region r = RedProtect.get().rm.getTopRegion(p.getLocation());
    if (RedProtect.get().ph.hasRegionPermAdmin(p, "addadmin", r)) {
        if (r == null) {
            sendNotInRegionMessage(p);
            return;
        }
        Player pVictim = RedProtect.get().serv.getPlayer(sVictim);
        String VictimUUID = RPUtil.PlayerToUUID(sVictim);
        if (RPUtil.UUIDtoPlayer(VictimUUID) == null) {
            RPLang.sendMessage(p, RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", sVictim));
            return;
        }
        if (r.isLeader(VictimUUID)) {
            RPLang.sendMessage(p, ChatColor.RED + sVictim + " " + RPLang.get("cmdmanager.region.leader.already"));
            return;
        }
        if (!r.isAdmin(VictimUUID)) {
            r.addAdmin(VictimUUID);
            RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + p.getName() + " ADDED ADMIN " + RPUtil.UUIDtoPlayer(VictimUUID) + " to region " + r.getName());
            RPLang.sendMessage(p, RPLang.get("general.color") + sVictim + " " + RPLang.get("cmdmanager.region.admin.added") + " " + r.getName());
            if (pVictim != null && pVictim.isOnline() && !pVictim.equals(p)) {
                RPLang.sendMessage(pVictim, RPLang.get("cmdmanager.region.admin.youadded").replace("{region}", r.getName()) + " " + p.getName());
            }
        } else {
            RPLang.sendMessage(p, ChatColor.RED + sVictim + " " + RPLang.get("cmdmanager.region.admin.already"));
        }
    } else {
        sendNoPermissionMessage(p);
    }
}
Also used : Player(org.bukkit.entity.Player) ClanPlayer(net.sacredlabyrinth.phaed.simpleclans.ClanPlayer) OfflinePlayer(org.bukkit.OfflinePlayer) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region)

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