use of br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect 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));
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect in project RedProtect by FabioZumbi12.
the class RPCommands method onCommand.
public boolean onCommand(CommandSender sender, Command command, String commandLabel, final String[] args) {
if (args.length == 0) {
sender.sendMessage(RPLang.get("general.color") + "---------------- " + RedProtect.get().pdf.getFullName() + " ----------------");
sender.sendMessage(RPLang.get("general.color") + "Developed by " + ChatColor.GOLD + RedProtect.get().pdf.getAuthors() + RPLang.get("general.color") + ".");
sender.sendMessage(RPLang.get("general.color") + "For more information about the commands, type [" + ChatColor.GOLD + "/rp " + getCmd("help") + RPLang.get("general.color") + "].");
sender.sendMessage(RPLang.get("general.color") + "For a tutorial, type [" + ChatColor.GOLD + "/rp " + getCmd("tutorial") + RPLang.get("general.color") + "].");
sender.sendMessage(RPLang.get("general.color") + "---------------------------------------------------");
return true;
}
if (args.length == 2) {
if (args[0].equalsIgnoreCase("test-uuid")) {
try {
String name = MojangUUIDs.getUUID(args[1]);
RedProtect.get().logger.warning("Leader from: " + args[1]);
RedProtect.get().logger.warning("UUID To name: " + name);
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
}
if (!(sender instanceof Player)) {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("clear-kicks")) {
RedProtect.get().denyEnter.clear();
RedProtect.get().logger.sucess("All region kicks was clear");
return true;
}
if (args[0].equalsIgnoreCase("single-to-files")) {
RedProtect.get().logger.sucess("[" + RPUtil.SingleToFiles() + "]" + " regions converted to your own files with success");
return true;
}
if (args[0].equalsIgnoreCase("files-to-single")) {
RedProtect.get().logger.sucess("[" + RPUtil.FilesToSingle() + "]" + " regions converted to unified world file with success");
return true;
}
if (args[0].equalsIgnoreCase("ymlToMysql")) {
try {
if (!RPUtil.ymlToMysql()) {
RedProtect.get().logger.severe("ERROR: Check if your 'file-type' configuration is set to 'yml' before convert from YML to Mysql.");
return true;
} else {
RedProtect.get().getConfig().set("file-type", "mysql");
RedProtect.get().saveConfig();
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
RedProtect.get().logger.sucess("RedProtect reloaded with Mysql as database! Ready to use!");
return true;
}
} catch (Exception e) {
e.printStackTrace();
return true;
}
}
if (args[0].equalsIgnoreCase("mysqlToYml")) {
try {
if (!RPUtil.mysqlToYml()) {
RedProtect.get().logger.severe("ERROR: Check if your 'file-type' configuration is set to 'mysql' before convert from MYSQL to Yml.");
return true;
} else {
RedProtect.get().getConfig().set("file-type", "yml");
RedProtect.get().saveConfig();
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
RedProtect.get().logger.sucess("RedProtect reloaded with Yml as database! Ready to use!");
return true;
}
} catch (Exception e) {
e.printStackTrace();
return true;
}
}
if (args[0].equalsIgnoreCase("gpTorp")) {
if (!RedProtect.get().GP) {
RedProtect.get().logger.sucess("The plugin GriefPrevention is not installed or is disabled");
return true;
}
if (RPUtil.convertFromGP() == 0) {
RedProtect.get().logger.severe("No region converted from GriefPrevention.");
return true;
} else {
RedProtect.get().rm.saveAll();
RedProtect.get().logger.info(ChatColor.AQUA + "[" + RPUtil.convertFromGP() + "] regions converted from GriefPrevention with success");
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
return true;
}
}
if (checkCmd(args[0], "update")) {
if (RedProtect.get().Update) {
RedProtect.get().logger.info(ChatColor.AQUA + "Starting download update...");
new Updater(RedProtect.get(), 87463, RedProtect.get().JarFile, Updater.UpdateType.NO_VERSION_CHECK, true);
RedProtect.get().logger.sucess("Download completed! Restart your server to use the new version.");
return true;
} else {
RedProtect.get().logger.info(ChatColor.AQUA + "No updates to download!");
return true;
}
}
if (args[0].equalsIgnoreCase("list-all")) {
int total = 0;
for (Region r : RedProtect.get().rm.getAllRegions()) {
RedProtect.get().logger.info(ChatColor.GREEN + "[" + total + "]" + "Region: " + r.getName() + ChatColor.RESET + " | " + ChatColor.AQUA + "World: " + r.getWorld() + ChatColor.RESET);
total++;
}
RedProtect.get().logger.sucess(total + " regions for " + Bukkit.getWorlds().size() + " worlds.");
return true;
}
if (args[0].equalsIgnoreCase("mychunktorp")) {
if (handleMyChunk()) {
RedProtect.get().rm.saveAll();
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
RedProtect.get().logger.sucess("...converting MyChunk database");
RedProtect.get().logger.sucess("http://dev.bukkit.org/bukkit-plugins/mychunk/");
return true;
} else {
RedProtect.get().logger.sucess("The plugin MyChunk is not installed or no regions found");
return true;
}
}
if (args[0].equalsIgnoreCase("save-all")) {
RedProtect.get().logger.SaveLogs();
RedProtect.get().logger.sucess(RedProtect.get().rm.saveAll() + " regions saved with success!");
return true;
}
if (args[0].equalsIgnoreCase("load-all")) {
RedProtect.get().rm.clearDB();
try {
RedProtect.get().rm.loadAll();
} catch (Exception e) {
RedProtect.get().logger.severe("Error on load all regions from database files:");
e.printStackTrace();
}
RedProtect.get().logger.sucess(RedProtect.get().rm.getAllRegions().size() + " regions has been loaded from database files!");
return true;
}
if (checkCmd(args[0], "reload")) {
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
RedProtect.get().logger.sucess("RedProtect Plus reloaded!");
return true;
}
if (args[0].equalsIgnoreCase("reload-config")) {
RPConfig.init();
RPLang.init();
RedProtect.get().logger.sucess("RedProtect Plus configs reloaded!");
return true;
}
}
if (args.length == 2) {
// rp removeall <player>
if (checkCmd(args[0], "removeall")) {
int removed = RedProtect.get().rm.removeAll(args[1]);
if (removed <= 0) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.noneremoved"));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.removed").replace("{regions}", removed + "").replace("{player}", args[1]));
}
return true;
}
// rp regenall <player>
if (checkCmd(args[0], "regenall")) {
int regen = RedProtect.get().rm.regenAll(args[1]);
if (regen <= 0) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.noneregenerated"));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.regenerated").replace("{regions}", regen + "").replace("{player}", args[1]));
}
return true;
}
// rp regen stop
if (checkCmd(args[0], "regenall") && args[1].equalsIgnoreCase("stop")) {
if (!RedProtect.get().WE) {
return true;
}
RPUtil.stopRegen = true;
RPLang.sendMessage(sender, "&aRegen will stop now. To continue reload the plugin!");
return true;
}
// rp list <player>
if (checkCmd(args[0], "list")) {
getRegionforList(sender, RPUtil.PlayerToUUID(args[1]), 1);
return true;
}
if (args[0].equalsIgnoreCase("setconfig") && args[1].equalsIgnoreCase("list")) {
sender.sendMessage(ChatColor.AQUA + "=========== Config Sections: ===========");
for (String section : RedProtect.get().getConfig().getValues(false).keySet()) {
if (section.contains("debug-messages") || section.contains("file-type") || section.contains("language")) {
sender.sendMessage(ChatColor.GOLD + section + " : " + ChatColor.GREEN + RedProtect.get().getConfig().get(section).toString());
}
}
sender.sendMessage(ChatColor.AQUA + "====================================");
return true;
}
// rp clamilimit player
if (checkCmd(args[0], "claimlimit")) {
Player offp = RedProtect.get().serv.getOfflinePlayer(args[1]).getPlayer();
if (offp == null) {
sender.sendMessage(RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
return true;
}
int limit = RedProtect.get().ph.getPlayerClaimLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.claim.unlimited")) {
sender.sendMessage(RPLang.get("cmdmanager.nolimit"));
return true;
}
int currentUsed = RedProtect.get().rm.getRegions(RPUtil.PlayerToUUID(offp.getName()), offp.getWorld()).size();
ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
sender.sendMessage(RPLang.get("cmdmanager.yourclaims") + color + currentUsed + RPLang.get("general.color") + "/" + color + limit + RPLang.get("general.color"));
return true;
}
if (checkCmd(args[0], "limit")) {
Player offp = RedProtect.get().serv.getOfflinePlayer(args[1]).getPlayer();
if (offp == null) {
sender.sendMessage(RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
return true;
}
int limit = RedProtect.get().ph.getPlayerBlockLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.blocks.unlimited")) {
sender.sendMessage(RPLang.get("cmdmanager.nolimit"));
return true;
}
int currentUsed = RedProtect.get().rm.getTotalRegionSize(RPUtil.PlayerToUUID(offp.getName()), offp.getWorld().getName());
ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
sender.sendMessage(RPLang.get("cmdmanager.yourarea") + color + currentUsed + RPLang.get("general.color") + "/" + color + limit + RPLang.get("general.color"));
return true;
}
}
if (args.length == 3) {
// rp regen <region> <world>
if (checkCmd(args[0], "regen")) {
if (!RedProtect.get().WE) {
return true;
}
World w = RedProtect.get().serv.getWorld(args[2]);
if (w == null) {
sender.sendMessage(RPLang.get("cmdmanager.region.invalidworld"));
return true;
}
Region r = RedProtect.get().rm.getRegion(args[1], w);
if (r == null) {
sender.sendMessage(RPLang.get("correct.usage") + " " + ChatColor.YELLOW + "Invalid region: " + args[1]);
return true;
}
if (RedProtect.get().AWE && RPConfig.getBool("hooks.asyncworldedit.use-for-regen")) {
AWEListener.regenRegion(r, Bukkit.getWorld(r.getWorld()), r.getMaxLocation(), r.getMinLocation(), 0, sender, false);
} else {
WEListener.regenRegion(r, Bukkit.getWorld(r.getWorld()), r.getMaxLocation(), r.getMinLocation(), 0, sender, false);
}
return true;
}
// rp undo <region> <world>
if (args[0].equalsIgnoreCase("undo")) {
if (!RedProtect.get().WE) {
return true;
}
World w = RedProtect.get().serv.getWorld(args[2]);
if (w == null) {
sender.sendMessage(RPLang.get("cmdmanager.region.invalidworld"));
return true;
}
Region r = RedProtect.get().rm.getRegion(args[1], w);
if (r == null) {
sender.sendMessage(RPLang.get("correct.usage") + " " + ChatColor.YELLOW + "Invalid region: " + args[1]);
return true;
}
if (RedProtect.get().AWE && RPConfig.getBool("hooks.asyncworldedit.use-for-regen")) {
if (AWEListener.undo(r.getID())) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.sucess").replace("{region}", r.getName()));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.none").replace("{region}", r.getName()));
}
} else {
if (WEListener.undo(r.getID())) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.sucess").replace("{region}", r.getName()));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.none").replace("{region}", r.getName()));
}
}
return true;
}
// rp list <player> [page]
if (checkCmd(args[0], "list")) {
try {
int Page = Integer.parseInt(args[2]);
getRegionforList(sender, RPUtil.PlayerToUUID(args[1]), Page);
return true;
} catch (NumberFormatException e) {
RPLang.sendMessage(sender, "cmdmanager.region.listpage.error");
return true;
}
}
// rp clamilimit player world
if (checkCmd(args[0], "claimlimit")) {
Player offp = RedProtect.get().serv.getOfflinePlayer(args[1]).getPlayer();
World w = RedProtect.get().serv.getWorld(args[2]);
if (offp == null) {
sender.sendMessage(RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
return true;
}
int limit = RedProtect.get().ph.getPlayerClaimLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.claim.unlimited")) {
sender.sendMessage(RPLang.get("cmdmanager.nolimit"));
return true;
}
if (w == null) {
sender.sendMessage(RPLang.get("cmdmanager.region.invalidworld"));
return true;
}
int currentUsed = RedProtect.get().rm.getRegions(RPUtil.PlayerToUUID(offp.getName()), w).size();
ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
sender.sendMessage(RPLang.get("cmdmanager.yourclaims") + color + currentUsed + RPLang.get("general.color") + "/" + color + limit + RPLang.get("general.color"));
return true;
}
if (args[0].equalsIgnoreCase("setconfig")) {
if (args[1].equals("debug-messages") || args[1].equals("file-type") || args[1].equals("language")) {
Object from = RedProtect.get().getConfig().get(args[1]);
if (args[2].equals("true") || args[2].equals("false")) {
RedProtect.get().getConfig().set(args[1], Boolean.parseBoolean(args[2]));
} else {
try {
int value = Integer.parseInt(args[2]);
RedProtect.get().getConfig().set(args[1], value);
} catch (NumberFormatException ex) {
RedProtect.get().getConfig().set(args[1], args[2]);
}
}
sender.sendMessage(RPLang.get("cmdmanager.configset") + " " + from.toString() + " > " + args[2]);
RPConfig.save();
return true;
} else {
sender.sendMessage(RPLang.get("cmdmanager.confignotset") + " " + args[1]);
return true;
}
}
// rp info <region> <world>
if (checkCmd(args[0], "info")) {
if (Bukkit.getWorld(args[2]) != null) {
Region r = RedProtect.get().rm.getRegion(args[1], Bukkit.getWorld(args[2]));
if (r != null) {
sender.sendMessage(RPLang.get("general.color") + "-----------------------------------------");
sender.sendMessage(r.info());
sender.sendMessage(RPLang.get("general.color") + "-----------------------------------------");
} else {
sender.sendMessage(RPLang.get("correct.usage") + " " + ChatColor.YELLOW + "Invalid region: " + args[1]);
}
} else {
sender.sendMessage(RPLang.get("correct.usage") + " " + ChatColor.YELLOW + "Invalid World: " + args[2]);
}
return true;
}
}
if (args.length == 4) {
// rp kick <player> [region] [world]
if (checkCmd(args[0], "kick")) {
Region r = RedProtect.get().rm.getRegion(args[2], args[3]);
if (r == null) {
sender.sendMessage("No regions by name " + args[2] + " or by world " + args[3]);
return true;
}
Player visit = Bukkit.getPlayer(args[1]);
if (visit == null) {
sender.sendMessage("No online players with name " + args[1]);
return true;
}
if (r.canBuild(visit)) {
sender.sendMessage("You cant kick members of a region");
return true;
}
Region rv = RedProtect.get().rm.getTopRegion(visit.getLocation());
if (rv == null || !rv.getID().equals(r.getID())) {
sender.sendMessage("This player is not on this region");
return true;
}
RPUtil.DenyEnterPlayer(visit.getWorld(), visit.getLocation(), visit.getLocation(), visit, r, true);
String sec = String.valueOf(RPConfig.getInt("region-settings.delay-after-kick-region"));
if (RedProtect.get().denyEnterRegion(r.getID(), visit.getName())) {
RPUtil.DenyEnterPlayer(visit.getWorld(), visit.getLocation(), visit.getLocation(), visit, r, true);
sender.sendMessage("The player " + visit.getName() + " has been kicked from " + r.getName() + " by " + sec + " seconds.");
} else {
sender.sendMessage("This player is already kicked from this region by " + sec);
}
return true;
}
if (checkCmd(args[0], "teleport")) {
// rp teleport <player> <region> <world>
Player play = RedProtect.get().serv.getPlayer(args[1]);
if (play != null) {
World w = RedProtect.get().serv.getWorld(args[3]);
if (w == null) {
sender.sendMessage(RPLang.get("cmdmanager.region.invalidworld"));
return true;
}
Region region = RedProtect.get().rm.getRegion(args[2], w);
if (region == null) {
sender.sendMessage(RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return true;
}
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 (RedProtect.get().Ess) {
RedProtect.get().pless.getUser(play).setLastLocation();
}
play.teleport(loc);
RPLang.sendMessage(play, RPLang.get("cmdmanager.region.teleport") + " " + args[2]);
sender.sendMessage(ChatColor.AQUA + "Player " + play.getName() + " teleported to " + args[2]);
return true;
} else {
sender.sendMessage(RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
HandleHelPage(sender, 1);
return true;
}
}
// rp flag info <region> <world>
if (checkCmd(args[0], "flag") && checkCmd(args[1], "info")) {
if (Bukkit.getWorld(args[3]) != null) {
Region r = RedProtect.get().rm.getRegion(args[2], Bukkit.getWorld(args[3]));
if (r != null) {
sender.sendMessage(RPLang.get("general.color") + "------------[" + RPLang.get("cmdmanager.region.flag.values") + "]------------");
sender.sendMessage(r.getFlagInfo());
sender.sendMessage(RPLang.get("general.color") + "------------------------------------");
} else {
sender.sendMessage(RPLang.get("correct.usage") + " " + ChatColor.YELLOW + "Invalid region: " + args[2]);
}
} else {
sender.sendMessage(RPLang.get("correct.usage") + " " + ChatColor.YELLOW + "Invalid World: " + args[3]);
}
return true;
}
}
if (args.length == 5) {
/*/rp flag <regionName> <flag> <value> <world>*/
if (checkCmd(args[0], "flag")) {
World w = RedProtect.get().serv.getWorld(args[4]);
if (w == null) {
sender.sendMessage(RPLang.get("correct.usage") + ChatColor.YELLOW + " rp " + getCmd("flag") + " <regionName> <flag> <value> <world>");
return true;
}
Region r = RedProtect.get().rm.getRegion(args[1], w);
if (r != null && (RPConfig.getDefFlags().contains(args[2]) || RPConfig.AdminFlags.contains(args[2]))) {
Object objflag = RPUtil.parseObject(args[3]);
r.setFlag(args[2], objflag);
sender.sendMessage(RPLang.get("cmdmanager.region.flag.set").replace("{flag}", "'" + args[2] + "'") + " " + r.getFlagString(args[2]));
RedProtect.get().logger.addLog("Console changed flag " + args[2] + " to " + r.getFlagString(args[2]));
return true;
}
}
}
HandleHelPage(sender, 1);
return true;
}
// commands as player
final Player player = (Player) sender;
if (args.length == 1) {
String claimmode = RPConfig.getWorldClaimType(player.getWorld().getName());
if (claimmode.equalsIgnoreCase("WAND") || claimmode.equalsIgnoreCase("BOTH") || RedProtect.get().ph.hasGenPerm(player, "redefine")) {
// rp pos1
if (checkCmd(args[0], "pos1")) {
Location pl = player.getLocation();
RedProtect.get().firstLocationSelections.put(player, pl);
player.sendMessage(RPLang.get("playerlistener.wand1") + RPLang.get("general.color") + " (" + ChatColor.GOLD + pl.getBlockX() + RPLang.get("general.color") + ", " + ChatColor.GOLD + pl.getBlockY() + RPLang.get("general.color") + ", " + ChatColor.GOLD + pl.getBlockZ() + RPLang.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 (loc1.getWorld().equals(loc2.getWorld()) && loc1.distanceSquared(loc2) > RPConfig.getInt("region-settings.define-max-distance")) {
Double dist = loc1.distanceSquared(loc2);
RPLang.sendMessage(player, String.format(RPLang.get("regionbuilder.selection.maxdefine"), RPConfig.getInt("region-settings.define-max-distance"), dist.intValue()));
} else {
RPUtil.addBorder(player, RPUtil.get4Points(loc1, loc2, player.getLocation().getBlockY()));
}
}
return true;
} else // rp pos2
if (checkCmd(args[0], "pos2")) {
Location pl = player.getLocation();
RedProtect.get().secondLocationSelections.put(player, pl);
player.sendMessage(RPLang.get("playerlistener.wand2") + RPLang.get("general.color") + " (" + ChatColor.GOLD + pl.getBlockX() + RPLang.get("general.color") + ", " + ChatColor.GOLD + pl.getBlockY() + RPLang.get("general.color") + ", " + ChatColor.GOLD + pl.getBlockZ() + RPLang.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 (loc1.getWorld().equals(loc2.getWorld()) && loc1.distanceSquared(loc2) > RPConfig.getInt("region-settings.define-max-distance") && !RedProtect.get().ph.hasPerm(player, "redprotect.bypass.define-max-distance")) {
Double dist = loc1.distanceSquared(loc2);
RPLang.sendMessage(player, String.format(RPLang.get("regionbuilder.selection.maxdefine"), RPConfig.getInt("region-settings.define-max-distance"), dist.intValue()));
} else {
RPUtil.addBorder(player, RPUtil.get4Points(loc1, loc2, player.getLocation().getBlockY()));
}
}
return true;
}
}
// rp list-areas
if (checkCmd(args[0], "list-areas") && player.hasPermission("redprotect.list-areas")) {
sender.sendMessage(RPLang.get("general.color") + "-------------------------------------------------");
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.created.area-list"));
sender.sendMessage("-----");
for (World w : Bukkit.getWorlds()) {
Set<Region> wregions = new HashSet<>();
for (Region r : RedProtect.get().rm.getRegionsByWorld(w)) {
SimpleDateFormat dateformat = new SimpleDateFormat(RPConfig.getString("region-settings.date-format"));
Date now = null;
try {
now = dateformat.parse(RPUtil.DateNow());
} catch (ParseException e1) {
RedProtect.get().logger.severe("The 'date-format' don't match with date 'now'!!");
}
Date regiondate = null;
try {
regiondate = dateformat.parse(r.getDate());
} catch (ParseException e) {
RedProtect.get().logger.severe("The 'date-format' don't match with region date!!");
e.printStackTrace();
}
Long days = TimeUnit.DAYS.convert(now.getTime() - regiondate.getTime(), TimeUnit.MILLISECONDS);
for (String play : RPConfig.getStringList("purge.ignore-regions-from-players")) {
if (r.isLeader(RPUtil.PlayerToUUID(play)) || r.isAdmin(RPUtil.PlayerToUUID(play))) {
}
}
if (!r.isLeader(RPConfig.getString("region-settings.default-leader")) && days > RPConfig.getInt("purge.remove-oldest") && r.getArea() >= RPConfig.getInt("purge.regen.max-area-regen")) {
wregions.add(r);
}
}
if (wregions.size() == 0) {
continue;
}
Iterator<Region> it = wregions.iterator();
String colorChar = ChatColor.translateAlternateColorCodes('&', RPConfig.getString("region-settings.world-colors." + w.getName(), "&a"));
if (RPConfig.getBool("region-settings.region-list.hover-and-click-teleport") && RedProtect.get().ph.hasRegionPermAdmin(sender, "teleport", null)) {
boolean first = true;
FancyMessage fancy = new FancyMessage();
while (it.hasNext()) {
Region r = it.next();
String rname = RPLang.get("general.color") + ", " + ChatColor.GRAY + r.getName() + "(" + r.getArea() + ")";
if (first) {
rname = rname.substring(3);
first = false;
}
if (!it.hasNext()) {
rname = rname + RPLang.get("general.color") + ".";
}
fancy.text(rname).color(ChatColor.DARK_GRAY).tooltip(RPLang.get("cmdmanager.list.hover").replace("{region}", r.getName())).command("/rp " + getCmd("teleport") + " " + r.getName() + " " + r.getWorld()).then(" ");
}
sender.sendMessage(RPLang.get("general.color") + RPLang.get("region.world").replace(":", "") + " " + colorChar + w.getName() + "[" + wregions.size() + "]" + ChatColor.RESET + ": ");
fancy.send(sender);
sender.sendMessage("-----");
} else {
String worldregions = "";
while (it.hasNext()) {
Region r = it.next();
worldregions = worldregions + RPLang.get("general.color") + ", " + ChatColor.GRAY + r.getName() + "(" + r.getArea() + ")";
}
sender.sendMessage(RPLang.get("general.color") + RPLang.get("region.world").replace(":", "") + " " + colorChar + w.getName() + "[" + wregions.size() + "]" + ChatColor.RESET + ": ");
sender.sendMessage(worldregions.substring(3) + RPLang.get("general.color") + ".");
sender.sendMessage("-----");
}
}
return true;
}
// rp start
if (checkCmd(args[0], "start") && player.hasPermission("redprotect.start")) {
if (!RPConfig.isAllowedWorld(player)) {
RPLang.sendMessage(player, "regionbuilder.region.worldnotallowed");
return true;
}
RedProtect.get().confiemStart.add(player.getName());
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.confirm").replace("{cmd}", RPLang.get("cmdmanager.translation.confirm.alias")));
Bukkit.getScheduler().runTaskLater(RedProtect.get(), () -> RedProtect.get().confiemStart.remove(player.getName()), 600);
return true;
}
// rp confirm
if (checkCmd(args[0], "confirm") && player.hasPermission("redprotect.start") && RedProtect.get().version <= 1122) {
if (!RedProtect.get().confiemStart.contains(player.getName())) {
player.sendMessage(RPLang.get("cmdmanager.region.noconfirm").replace("{cmd}", RPLang.get("cmdmanager.translation.start")));
return true;
}
try {
RPSchematics.pasteSchematic(player);
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
// rp regen
if (checkCmd(args[0], "regen") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return true;
}
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.doesexists");
return true;
}
if (RedProtect.get().AWE && RPConfig.getBool("hooks.asyncworldedit.use-for-regen")) {
AWEListener.regenRegion(r, Bukkit.getWorld(r.getWorld()), r.getMaxLocation(), r.getMinLocation(), 0, sender, false);
} else {
WEListener.regenRegion(r, Bukkit.getWorld(r.getWorld()), r.getMaxLocation(), r.getMinLocation(), 0, sender, false);
}
return true;
}
// rp undo
if (args[0].equalsIgnoreCase("undo") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return true;
}
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.doesexists");
return true;
}
if (RedProtect.get().AWE && RPConfig.getBool("hooks.asyncworldedit.use-for-regen")) {
if (AWEListener.undo(r.getID())) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.sucess").replace("{region}", r.getName()));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.none").replace("{region}", r.getName()));
}
} else {
if (WEListener.undo(r.getID())) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.sucess").replace("{region}", r.getName()));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.none").replace("{region}", r.getName()));
}
}
return true;
}
if (checkCmd(args[0], "update") && player.hasPermission("redprotect.update")) {
if (RedProtect.get().Update) {
RPLang.sendMessage(player, ChatColor.AQUA + "Starting download update...");
new Updater(RedProtect.get(), 87463, RedProtect.get().JarFile, Updater.UpdateType.NO_VERSION_CHECK, true);
RPLang.sendMessage(player, ChatColor.AQUA + "Update downloaded! Will take effect on next server reboot.");
return true;
} else {
RPLang.sendMessage(player, ChatColor.AQUA + "No updates to download!");
return true;
}
}
if (checkCmd(args[0], "laccept")) {
if (RedProtect.get().alWait.containsKey(player)) {
// info = region+world+pname
String info = RedProtect.get().alWait.get(player);
Player lsender = Bukkit.getPlayer(info.split("@")[2]);
Region r = RedProtect.get().rm.getRegion(info.split("@")[0], info.split("@")[1]);
String VictimUUID = player.getName();
if (RedProtect.get().OnlineMode) {
VictimUUID = player.getUniqueId().toString();
}
if (r != null) {
if (RedProtect.get().ph.getPlayerClaimLimit(player) == (RedProtect.get().rm.getRegions(VictimUUID, r.getWorld()).size() + 1)) {
RPLang.sendMessage(player, "regionbuilder.claim.limit");
return true;
}
r.addLeader(VictimUUID);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.leader.youadded").replace("{region}", r.getName()) + " " + lsender.getName());
if (lsender != null && lsender.isOnline()) {
RPLang.sendMessage(lsender, RPLang.get("cmdmanager.region.leader.accepted").replace("{region}", r.getName()).replace("{player}", player.getName()));
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.doesexists");
}
RedProtect.get().alWait.remove(player);
return true;
} else {
RPLang.sendMessage(player, "cmdmanager.norequests");
return true;
}
}
if (checkCmd(args[0], "ldeny")) {
if (RedProtect.get().alWait.containsKey(player)) {
// info = region+world+pname
String info = RedProtect.get().alWait.get(player);
Player lsender = Bukkit.getPlayer(info.split("@")[2]);
Region r = RedProtect.get().rm.getRegion(info.split("@")[0], info.split("@")[1]);
if (r != null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.leader.youdenied").replace("{region}", r.getName()).replace("{player}", lsender.getName()));
if (lsender != null && lsender.isOnline()) {
RPLang.sendMessage(lsender, RPLang.get("cmdmanager.region.leader.denied").replace("{region}", r.getName()).replace("{player}", player.getName()));
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.doesexists");
}
RedProtect.get().alWait.remove(player);
return true;
} else {
RPLang.sendMessage(player, "cmdmanager.norequests");
return true;
}
}
if (checkCmd(args[0], "settp") && RedProtect.get().ph.hasGenPerm(player, "settp")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
if (RedProtect.get().ph.hasRegionPermLeader(player, "settp", r)) {
r.setTPPoint(player.getLocation());
RPLang.sendMessage(player, "cmdmanager.region.settp.ok");
return true;
} else {
RPLang.sendMessage(player, "playerlistener.region.cantuse");
return true;
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
}
if (checkCmd(args[0], "deltp") && RedProtect.get().ph.hasGenPerm(player, "deltp")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
if (RedProtect.get().ph.hasRegionPermLeader(player, "deltp", r)) {
r.setTPPoint(null);
RPLang.sendMessage(player, "cmdmanager.region.settp.removed");
return true;
} else {
RPLang.sendMessage(player, "playerlistener.region.cantuse");
return true;
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
}
if (checkCmd(args[0], "border") && RedProtect.get().ph.hasGenPerm(player, "border")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
RPUtil.addBorder(player, r.get4Points(player.getLocation().getBlockY()));
return true;
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
}
if (checkCmd(args[0], "cancelbuy") && player.hasPermission("redprotect.eco.cancelbuy")) {
if (!RedProtect.get().Vault) {
return true;
}
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
if (r.isLeader(RPUtil.PlayerToUUID(player.getName()))) {
if (r.isForSale()) {
r.removeFlag("for-sale");
r.setWelcome("");
if (r.leaderSize() == 0) {
if (RPConfig.getEcoBool("rename-region")) {
RedProtect.get().rm.renameRegion(RPUtil.nameGen(player.getName(), r.getWorld()), r);
}
r.addLeader(RPUtil.PlayerToUUID(player.getName()));
} else {
if (RPConfig.getEcoBool("rename-region")) {
RedProtect.get().rm.renameRegion(RPUtil.nameGen(RPUtil.UUIDtoPlayer(r.getLeaders().get(0)), r.getWorld()), r);
}
}
RPLang.sendMessage(player, "economy.region.cancelbuy");
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " cancelled buy stat of region " + r.getName());
return true;
} else {
RPLang.sendMessage(player, "economy.region.buy.notforsale");
return true;
}
} else {
RPLang.sendMessage(player, "economy.region.sell.own");
return true;
}
}
if (checkCmd(args[0], "value") && RedProtect.get().ph.hasGenPerm(player, "value")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
if (RedProtect.get().ph.hasRegionPermLeader(player, "value", r)) {
if (r.getArea() < RPConfig.getEcoInt("max-area-toget-value")) {
r.setValue(RPEconomy.getRegionValue(r));
RPLang.sendMessage(player, RPLang.get("cmdmanager.value.is").replace("{value}", RPEconomy.getFormatted(r.getValue()) + " " + RPConfig.getEcoString("economy-name")));
RedProtect.get().logger.debug("Region Value: " + r.getValue());
return true;
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.value.areabig").replace("{maxarea}", RPConfig.getEcoInt("max-area-toget-value").toString()));
return true;
}
} else {
RPLang.sendMessage(player, "playerlistener.region.cantuse");
return true;
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
}
if (args[0].equalsIgnoreCase("save-all")) {
if (player.hasPermission("redprotect.admin.save-all")) {
RedProtect.get().logger.SaveLogs();
RPLang.sendMessage(player, ChatColor.GREEN + "" + RedProtect.get().rm.saveAll() + " regions saved with success!");
return true;
}
}
if (args[0].equalsIgnoreCase("load-all")) {
if (player.hasPermission("redprotect.admin.load-all")) {
RedProtect.get().rm.clearDB();
try {
RedProtect.get().rm.loadAll();
} catch (Exception e) {
RPLang.sendMessage(player, "Error on load all regions from database files:");
e.printStackTrace();
}
RPLang.sendMessage(player, ChatColor.GREEN + "" + RedProtect.get().rm.getAllRegions().size() + " regions has been loaded from database files!");
return true;
}
}
if (checkCmd(args[0], "define")) {
if (!RedProtect.get().ph.hasGenPerm(player, "define")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
String serverName = RPConfig.getString("region-settings.default-leader");
String name = RPUtil.nameGen(serverName, player.getWorld().getName());
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, serverName, new ArrayList<>(), true);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " DEFINED region " + r2.getName());
}
return true;
}
// rp claim
if (checkCmd(args[0], "claim")) {
if ((!claimmode.equalsIgnoreCase("WAND") && !claimmode.equalsIgnoreCase("BOTH")) && !player.hasPermission("redprotect.admin.claim")) {
RPLang.sendMessage(player, "blocklistener.region.blockmode");
return true;
}
String name = RPUtil.nameGen(player.getName(), player.getWorld().getName());
String leader = player.getUniqueId().toString();
if (!RedProtect.get().OnlineMode) {
leader = player.getName().toLowerCase();
}
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, leader, new ArrayList<>(), false);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " CLAIMED region " + r2.getName());
}
return true;
}
if (args[0].equalsIgnoreCase("mychunkconvert") && player.isOp()) {
if (handleMyChunk()) {
RPLang.sendMessage(player, ChatColor.GREEN + "...converting" + ChatColor.AQUA + " MyChunk " + ChatColor.GREEN + "database!");
RPLang.sendMessage(player, ChatColor.GOLD + "See all the process on console!");
return true;
} else {
RPLang.sendMessage(player, ChatColor.RED + "The plugin MyChunk is not installed or no regions found");
return true;
}
}
if (checkCmd(args[0], "reload") && player.hasPermission("redprotect.admin.reload")) {
RedProtect.get().getServer().getPluginManager().disablePlugin(RedProtect.get());
RedProtect.get().getServer().getPluginManager().enablePlugin(RedProtect.get());
RPLang.sendMessage(player, "cmdmanager.reloaded");
return true;
}
if (args[0].equalsIgnoreCase("reload-config") && player.hasPermission("redprotect.admin.reload")) {
RPConfig.init();
RPLang.init();
RPLang.sendMessage(player, "cmdmanager.reloaded");
return true;
}
if (checkCmd(args[0], "wand") && player.hasPermission("redprotect.magicwand")) {
Inventory inv = player.getInventory();
Material mat = Material.getMaterial(RPConfig.getString("wands.adminWandID"));
ItemStack item = new ItemStack(mat);
if (!inv.contains(mat) && inv.firstEmpty() != -1) {
inv.addItem(item);
RPLang.sendMessage(player, RPLang.get("cmdmanager.wand.given").replace("{item}", item.getType().name()));
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.wand.nospace").replace("{item}", item.getType().name()));
}
return true;
}
if (checkCmd(args[0], "help")) {
HandleHelPage(sender, 1);
return true;
}
if (checkCmd(args[0], "tutorial")) {
RPLang.sendMessage(player, "cmdmanager.tutorial");
RPLang.sendMessage(player, "cmdmanager.tutorial1");
RPLang.sendMessage(player, "cmdmanager.tutorial2");
RPLang.sendMessage(player, "cmdmanager.tutorial3");
RPLang.sendMessage(player, "cmdmanager.tutorial4");
RPLang.sendMessage(player, "cmdmanager.tutorial5");
RPLang.sendMessage(player, "cmdmanager.tutorial6");
return true;
}
if (checkCmd(args[0], "near")) {
if (RedProtect.get().ph.hasPerm(player, "redprotect.near")) {
Set<Region> regions = RedProtect.get().rm.getRegionsNear(player, 60, player.getWorld());
if (regions.size() == 0) {
RPLang.sendMessage(player, "cmdmanager.noregions.nearby");
} else {
Iterator<Region> i = regions.iterator();
RPLang.sendMessage(player, RPLang.get("general.color") + "------------------------------------");
RPLang.sendMessage(player, RPLang.get("cmdmanager.regionwith40"));
RPLang.sendMessage(player, RPLang.get("general.color") + "------------------------------------");
while (i.hasNext()) {
Region r = i.next();
player.sendMessage(RPLang.get("cmdmanager.region.name") + r.getName() + RPLang.get("general.color") + ChatColor.translateAlternateColorCodes('&', " | Center (&6X,Z" + RPLang.get("general.color") + "): &6") + r.getCenterX() + ", " + r.getCenterZ());
}
RPLang.sendMessage(player, RPLang.get("general.color") + "------------------------------------");
}
} else {
RPLang.sendMessage(player, "no.permission");
}
return true;
}
if (checkCmd(args[0], "flag")) {
if (RedProtect.get().ph.hasGenPerm(player, "flaggui")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
if (RedProtect.get().ph.hasRegionPermAdmin(player, "flaggui", r)) {
RPGui gui = new RPGui(RPUtil.getTitleName(r), player, r, RedProtect.get(), false, RPConfig.getGuiMaxSlot());
gui.open();
return true;
} else {
sendNoPermissionMessage(player);
return true;
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
}
}
}
if (args.length == 2) {
// rp removeall <player>
if (checkCmd(args[0], "removeall") && sender.hasPermission("redprotect.removeall")) {
if (!RedProtect.get().WE) {
return true;
}
int removed = RedProtect.get().rm.removeAll(args[1]);
if (removed <= 0) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.noneremoved"));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.removed").replace("{regions}", removed + "").replace("{player}", args[1]));
}
return true;
}
// rp regenall <player>
if (checkCmd(args[0], "regenall") && sender.hasPermission("redprotect.regenall")) {
if (!RedProtect.get().WE) {
return true;
}
int regen = RedProtect.get().rm.regenAll(args[1]);
if (regen <= 0) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.noneregenerated"));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.regenerated").replace("{regions}", regen + "").replace("{player}", args[1]));
}
return true;
}
// rp regen stop
if (args[0].equalsIgnoreCase("regen") && args[1].equalsIgnoreCase("stop") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return true;
}
RPUtil.stopRegen = true;
RPLang.sendMessage(player, "&aRegen will stop now. To continue reload the plugin!");
return true;
}
if (checkCmd(args[0], "flag") && args[1].equalsIgnoreCase("gui-edit")) {
if (player.hasPermission("redprotect.gui.edit")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
RPGui gui = new RPGui(RPLang.get("gui.editflag"), player, r, RedProtect.get(), true, RPConfig.getGuiMaxSlot());
gui.open();
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
}
return true;
}
}
if (checkCmd(args[0], "help")) {
try {
int page = Integer.parseInt(args[1]);
HandleHelPage(sender, page);
} catch (NumberFormatException e) {
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + ChatColor.DARK_AQUA + "/rp " + getCmd("help") + "[page]");
}
return true;
}
if (checkCmd(args[0], "define")) {
if (!RedProtect.get().ph.hasGenPerm(player, "define")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
String serverName = RPConfig.getString("region-settings.default-leader");
String name = args[1].replace("/", "|");
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, serverName, new ArrayList<>(), true);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " DEFINED region " + r2.getName());
}
return true;
}
// rp claim [nameOfRegion]
if (checkCmd(args[0], "claim")) {
String claimmode = RPConfig.getWorldClaimType(player.getWorld().getName());
if ((!claimmode.equalsIgnoreCase("WAND") && !claimmode.equalsIgnoreCase("BOTH")) && !player.hasPermission("redprotect.admin.claim")) {
RPLang.sendMessage(player, "blocklistener.region.blockmode");
return true;
}
String name = args[1].replace("/", "|");
String leader = player.getUniqueId().toString();
if (!RedProtect.get().OnlineMode) {
leader = player.getName().toLowerCase();
}
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, leader, new ArrayList<>(), false);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " CLAIMED region " + r2.getName());
}
return true;
}
if (checkCmd(args[0], "redefine")) {
Region oldRect = RedProtect.get().rm.getRegion(args[1], player.getWorld());
if (oldRect == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
return true;
}
if (!RedProtect.get().ph.hasRegionPermLeader(player, "redefine", oldRect)) {
RPLang.sendMessage(player, "no.permission");
return true;
}
RedefineRegionBuilder rb = new RedefineRegionBuilder(player, oldRect, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player));
if (rb.ready()) {
Region r2 = rb.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.redefined") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " REDEFINED region " + r2.getName());
}
return true;
}
if (args[0].equalsIgnoreCase("setconfig") && args[1].equalsIgnoreCase("list")) {
if (!player.hasPermission("redprotect.admin.setconfig")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
RPLang.sendMessage(player, ChatColor.AQUA + "=========== Config Sections: ===========");
for (String section : RedProtect.get().getConfig().getValues(false).keySet()) {
if (section.equals("debug-messages") || section.equals("file-type") || section.equals("language")) {
RPLang.sendMessage(player, ChatColor.GOLD + section + " : " + ChatColor.GREEN + RedProtect.get().getConfig().get(section).toString());
}
}
RPLang.sendMessage(player, ChatColor.AQUA + "====================================");
return true;
}
}
if (args.length == 3) {
// rp regen <region> <world>
if (args[0].equalsIgnoreCase("regen") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return true;
}
World w = RedProtect.get().serv.getWorld(args[2]);
if (w == null) {
sender.sendMessage(RPLang.get("cmdmanager.region.invalidworld"));
return true;
}
Region r = RedProtect.get().rm.getRegion(args[1], w);
if (r == null) {
sender.sendMessage(RPLang.get("correct.usage") + " " + ChatColor.YELLOW + "Invalid region: " + args[1]);
return true;
}
if (RedProtect.get().AWE && RPConfig.getBool("hooks.asyncworldedit.use-for-regen")) {
AWEListener.regenRegion(r, Bukkit.getWorld(r.getWorld()), r.getMaxLocation(), r.getMinLocation(), 0, sender, false);
} else {
WEListener.regenRegion(r, Bukkit.getWorld(r.getWorld()), r.getMaxLocation(), r.getMinLocation(), 0, sender, false);
}
return true;
}
// rp undo <region> <world>
if (args[0].equalsIgnoreCase("undo") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return true;
}
World w = RedProtect.get().serv.getWorld(args[2]);
if (w == null) {
sender.sendMessage(RPLang.get("cmdmanager.region.invalidworld"));
return true;
}
Region r = RedProtect.get().rm.getRegion(args[1], w);
if (r == null) {
sender.sendMessage(RPLang.get("correct.usage") + " " + ChatColor.YELLOW + "Invalid region: " + args[1]);
return true;
}
if (RedProtect.get().AWE && RPConfig.getBool("hooks.asyncworldedit.use-for-regen")) {
if (AWEListener.undo(r.getID())) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.sucess").replace("{region}", r.getName()));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.none").replace("{region}", r.getName()));
}
} else {
if (WEListener.undo(r.getID())) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.sucess").replace("{region}", r.getName()));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.none").replace("{region}", r.getName()));
}
}
return true;
}
if (checkCmd(args[0], "flag") && args[1].equalsIgnoreCase("gui-edit")) {
if (player.hasPermission("redprotect.gui.edit")) {
int MaxSlot = 0;
try {
MaxSlot = 9 * Integer.parseInt(args[2]);
if (MaxSlot > 54 || MaxSlot < RPConfig.getGuiMaxSlot()) {
RPLang.sendMessage(player, "gui.edit.invalid-lines");
return true;
}
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.invalid.number");
return true;
}
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
RPGui gui = new RPGui(RPLang.get("gui.editflag"), player, r, RedProtect.get(), true, MaxSlot);
gui.open();
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
}
return true;
}
}
// rp claim [regionName] [leader]
if (checkCmd(args[0], "claim")) {
String claimmode = RPConfig.getWorldClaimType(player.getWorld().getName());
if ((!claimmode.equalsIgnoreCase("WAND") && !claimmode.equalsIgnoreCase("BOTH")) && !player.hasPermission("redprotect.admin.claim")) {
RPLang.sendMessage(player, "blocklistener.region.blockmode");
return true;
}
String name = args[1].replace("/", "|");
String leader = player.getUniqueId().toString();
List<String> addedAdmins = new ArrayList<>();
addedAdmins.add(RPUtil.PlayerToUUID(args[2]));
if (!RedProtect.get().OnlineMode) {
leader = player.getName().toLowerCase();
}
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, leader, addedAdmins, false);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " CLAIMED region " + r2.getName());
}
return true;
}
// rp copyflag from to
if (checkCmd(args[0], "copyflag")) {
if (!RedProtect.get().ph.hasGenPerm(player, "copyflag")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
World w = player.getWorld();
Region from = RedProtect.get().rm.getRegion(args[1], w);
Region to = RedProtect.get().rm.getRegion(args[2], w);
if (from == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
return true;
}
if (to == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return true;
}
for (String key : from.flags.keySet()) {
to.setFlag(key, from.flags.get(key));
}
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.flag.copied") + args[1] + " > " + args[2]);
RedProtect.get().logger.addLog("Player " + player.getName() + " Copied FLAGS from " + args[1] + " to " + args[2]);
return true;
}
if (args[0].equalsIgnoreCase("setconfig")) {
if (!player.hasPermission("redprotect.admin.setconfig")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
if (RedProtect.get().getConfig().contains(args[1])) {
Object from = RedProtect.get().getConfig().get(args[1]);
if (args[2].equals("true") || args[2].equals("false")) {
RedProtect.get().getConfig().set(args[1], Boolean.parseBoolean(args[2]));
} else {
try {
int value = Integer.parseInt(args[2]);
RedProtect.get().getConfig().set(args[1], value);
} catch (NumberFormatException ex) {
RedProtect.get().getConfig().set(args[1], args[2]);
}
}
RPLang.sendMessage(player, RPLang.get("cmdmanager.configset") + " " + from.toString() + " > " + args[2]);
RPConfig.save();
return true;
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.confignotset") + " " + args[1]);
return true;
}
}
}
if (args.length == 4 || args.length == 5) {
// rp createportal <newRegionName> <regionTo> <world>
if (checkCmd(args[0], "createportal")) {
if (!RedProtect.get().ph.hasGenPerm(player, "createportal")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
World w = RedProtect.get().serv.getWorld(args[3]);
if (w == null) {
sender.sendMessage(RPLang.get("cmdmanager.region.invalidworld"));
return true;
}
Region r = RedProtect.get().rm.getRegion(args[2], w);
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
return true;
}
String serverName = RPConfig.getString("region-settings.default-leader");
String name = args[1].replace("/", "|");
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, serverName, new ArrayList<>(), true);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, String.format(RPLang.get("cmdmanager.region.portalcreated"), name, r.getName(), w.getName()));
RPLang.sendMessage(player, "cmdmanager.region.portalhint");
r2.setFlag("server-enter-command", "rp tp {player} " + r.getName() + " " + w.getName());
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " CREATED A PORTAL " + r2.getName() + " to " + r.getName() + " world " + w.getName());
}
return true;
}
}
// rp kick <player> [region] [world]
if (checkCmd(args[0], "kick")) {
if (args.length == 2 || args.length == 4) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
if (args.length == 4) {
r = RedProtect.get().rm.getRegion(args[2], args[3]);
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
}
if (!RedProtect.get().ph.hasRegionPermMember(player, "kick", r)) {
RPLang.sendMessage(player, "no.permission");
return true;
}
Player visit = Bukkit.getPlayer(args[1]);
if (visit == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
return true;
}
if (r.canBuild(visit)) {
RPLang.sendMessage(player, "cmdmanager.cantkick.member");
return true;
}
Region rv = RedProtect.get().rm.getTopRegion(visit.getLocation());
if (rv == null || rv != null && !rv.getID().equals(r.getID())) {
RPLang.sendMessage(player, "cmdmanager.noplayer.thisregion");
return true;
}
if (RedProtect.get().SC && SCHook.inWar(r, player, visit)) {
RPLang.sendMessage(player, "cmdmanager.cantkick.war");
return true;
}
String sec = String.valueOf(RPConfig.getInt("region-settings.delay-after-kick-region"));
if (RedProtect.get().denyEnterRegion(r.getID(), visit.getName())) {
RPUtil.DenyEnterPlayer(visit.getWorld(), visit.getLocation(), visit.getLocation(), visit, r, true);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.kicked").replace("{player}", args[1]).replace("{region}", r.getName()).replace("{time}", sec));
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.already.cantenter").replace("{time}", sec));
}
return true;
}
}
// rp expand-vert [region] [world]
if (checkCmd(args[0], "expand-vert")) {
if (!RedProtect.get().ph.hasGenPerm(player, "expandvert")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
Region r = null;
// rp expand-vert
switch(args.length) {
case 1:
r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
break;
// rp expand-vert [region]
case 2:
r = RedProtect.get().rm.getRegion(args[1], player.getWorld());
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
return true;
}
break;
// rp expand-vert [region] [world]
case 3:
if (Bukkit.getWorld(args[2]) == null) {
RPLang.sendMessage(player, "cmdmanager.region.invalidworld");
return true;
}
r = RedProtect.get().rm.getRegion(args[1], Bukkit.getWorld(args[2]));
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
return true;
}
break;
default:
RPLang.sendMessage(player, "cmdmanager.help.expandvert");
return true;
}
r.setMaxY(player.getWorld().getMaxHeight());
r.setMinY(0);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.expandvert.success").replace("{region}", r.getName()).replace("{miny}", String.valueOf(r.getMinY())).replace("{maxy}", String.valueOf(r.getMaxY())));
return true;
}
// rp setmaxy <size> [region] [world]
if (checkCmd(args[0], "setmaxy")) {
if (!RedProtect.get().ph.hasGenPerm(player, "setmaxy")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
Region r = null;
// rp setmaxy <size>
switch(args.length) {
case 2:
r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
break;
// rp setmaxy <size> [region]
case 3:
r = RedProtect.get().rm.getRegion(args[2], player.getWorld());
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return true;
}
break;
// rp setmaxy <size> [region] [world]
case 4:
if (Bukkit.getWorld(args[3]) == null) {
RPLang.sendMessage(player, "cmdmanager.region.invalidworld");
return true;
}
r = RedProtect.get().rm.getRegion(args[2], Bukkit.getWorld(args[3]));
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return true;
}
break;
default:
RPLang.sendMessage(player, "cmdmanager.help.setmaxy");
return true;
}
String from = String.valueOf(r.getMaxY());
try {
int size = Integer.parseInt(args[1]);
if ((size - r.getMinY()) <= 1) {
RPLang.sendMessage(player, "cmdmanager.region.ysiszesmatch");
return true;
}
r.setMaxY(size);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.setmaxy.success").replace("{region}", r.getName()).replace("{fromsize}", from).replace("{size}", String.valueOf(size)));
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SETMAXY of region " + r.getName() + " to " + args[1]);
return true;
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.invalid.number");
return true;
}
}
// rp setmaxy <size> [region] [world]
if (checkCmd(args[0], "setminy")) {
if (!RedProtect.get().ph.hasGenPerm(player, "setminy")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
Region r = null;
// rp setmaxy <size>
switch(args.length) {
case 2:
r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
break;
// rp setmaxy <size> [region]
case 3:
r = RedProtect.get().rm.getRegion(args[2], player.getWorld());
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return true;
}
break;
// rp setmaxy <size> [region] [world]
case 4:
if (Bukkit.getWorld(args[3]) == null) {
RPLang.sendMessage(player, "cmdmanager.region.invalidworld");
return true;
}
r = RedProtect.get().rm.getRegion(args[2], Bukkit.getWorld(args[3]));
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return true;
}
break;
default:
RPLang.sendMessage(player, "cmdmanager.help.setminy");
return true;
}
String from = String.valueOf(r.getMinY());
try {
int size = Integer.parseInt(args[1]);
if ((r.getMaxY() - size) <= 1) {
RPLang.sendMessage(player, "cmdmanager.region.ysiszesmatch");
return true;
}
r.setMinY(size);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.setminy.success").replace("{region}", r.getName()).replace("{fromsize}", from).replace("{size}", String.valueOf(size)));
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SETMINY of region " + r.getName() + " to " + args[1]);
return true;
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.invalid.number");
return true;
}
}
if (checkCmd(args[0], "buy") && player.hasPermission("redprotect.eco.buy")) {
if (!RedProtect.get().Vault) {
return true;
}
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
if (!r.isForSale()) {
RPLang.sendMessage(player, "economy.region.buy.notforsale");
return true;
}
if (args.length == 1) {
buyHandler(player, r.getValue(), r);
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " BUY region " + r.getName() + " for " + r.getValue());
return true;
}
}
if (checkCmd(args[0], "sell") && player.hasPermission("redprotect.eco.sell")) {
if (!RedProtect.get().Vault) {
return true;
}
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
if (r.isForSale()) {
RPLang.sendMessage(player, "economy.region.sell.already");
return true;
}
if (args.length == 1) {
r.setValue(RPEconomy.getRegionValue(r));
if (r.isLeader(player)) {
sellHandler(r, player, RPUtil.PlayerToUUID(player.getName()), r.getValue());
} else {
sellHandler(r, player, r.getLeaders().get(0), r.getValue());
}
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SELL region " + r.getName() + " for " + r.getValue());
return true;
}
if (args.length == 2) {
// rp sell <value/player>
try {
long value = Long.valueOf(args[1]);
if (player.hasPermission("redprotect.eco.setvalue")) {
r.setValue(value);
if (r.isLeader(player)) {
sellHandler(r, player, RPUtil.PlayerToUUID(player.getName()), r.getValue());
} else {
sellHandler(r, player, r.getLeaders().get(0), r.getValue());
}
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SELL region " + r.getName() + " for " + r.getValue());
return true;
}
} catch (NumberFormatException e) {
if (player.hasPermission("redprotect.eco.others")) {
r.setValue(RPEconomy.getRegionValue(r));
sellHandler(r, player, RPUtil.PlayerToUUID(args[1]), r.getValue());
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SELL region " + r.getName() + " in name of player " + args[1] + " for " + r.getValue());
return true;
}
}
}
if (args.length == 3) {
// rp sell player value
try {
long value = Long.valueOf(args[2]);
if (player.hasPermission("redprotect.eco.setvalue")) {
r.setValue(value);
sellHandler(r, player, RPUtil.PlayerToUUID(args[1]), value);
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SELL region " + r.getName() + " in name of player " + args[1] + " for " + value);
return true;
}
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.eco.notdouble");
return true;
}
}
}
if (checkCmd(args[0], "teleport")) {
if (args.length == 1) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.help.teleport").replace("{cmd}", getCmd("teleport")).replace("{alias}", getCmdAlias("teleport")));
return true;
}
if (args.length == 2) {
handletp(player, args[1], player.getWorld().getName(), null);
return true;
}
if (args.length == 3) {
handletp(player, args[1], args[2], null);
return true;
}
if (args.length == 4) {
// /rp teleport <player> <region> <world>
Player play = RedProtect.get().serv.getPlayer(args[1]);
if (play != null) {
handletp(player, args[2], args[3], play);
return true;
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
RPLang.sendMessage(player, RPLang.get("cmdmanager.help.teleport").replace("{cmd}", getCmd("teleport")).replace("{alias}", getCmdAlias("teleport")));
return true;
}
}
}
if (checkCmd(args[0], "limit")) {
if (!RedProtect.get().ph.hasGenPerm(player, "limit")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
if (args.length == 1) {
int limit = RedProtect.get().ph.getPlayerBlockLimit(player);
if (limit < 0 || RedProtect.get().ph.hasPerm(player, "redprotect.limit.blocks.unlimited")) {
RPLang.sendMessage(player, "cmdmanager.nolimit");
return true;
}
String uuid = player.getUniqueId().toString();
if (!RedProtect.get().OnlineMode) {
uuid = player.getName().toLowerCase();
}
int currentUsed = RedProtect.get().rm.getTotalRegionSize(uuid, player.getWorld().getName());
ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
RPLang.sendMessage(player, RPLang.get("cmdmanager.yourarea") + color + currentUsed + RPLang.get("general.color") + "/" + color + limit + RPLang.get("general.color"));
return true;
}
if (!RedProtect.get().ph.hasPerm(player, "redprotect.other.limit")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
if (args.length == 2) {
Player offp = RedProtect.get().serv.getOfflinePlayer(args[1]).getPlayer();
if (offp == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
return true;
}
int limit = RedProtect.get().ph.getPlayerBlockLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.blocks.unlimited")) {
RPLang.sendMessage(player, "cmdmanager.nolimit");
return true;
}
int currentUsed = RedProtect.get().rm.getTotalRegionSize(RPUtil.PlayerToUUID(offp.getName()), offp.getWorld().getName());
ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
RPLang.sendMessage(player, RPLang.get("cmdmanager.yourarea") + color + currentUsed + RPLang.get("general.color") + "/" + color + limit + RPLang.get("general.color"));
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.limit"));
return true;
}
if (checkCmd(args[0], "claimlimit")) {
if (!RedProtect.get().ph.hasGenPerm(player, "claimlimit")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
if (args.length == 1) {
int limit = RedProtect.get().ph.getPlayerClaimLimit(player);
if (limit < 0 || RedProtect.get().ph.hasPerm(player, "redprotect.claimunlimited")) {
RPLang.sendMessage(player, "cmdmanager.nolimit");
return true;
}
int currentUsed = RedProtect.get().rm.getRegions(RPUtil.PlayerToUUID(player.getName()), player.getWorld()).size();
ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
RPLang.sendMessage(player, RPLang.get("cmdmanager.yourclaims") + color + currentUsed + RPLang.get("general.color") + "/" + color + limit + RPLang.get("general.color"));
return true;
}
if (!RedProtect.get().ph.hasPerm(player, "redprotect.other.claimlimit")) {
RPLang.sendMessage(player, "no.permission");
return true;
}
if (args.length == 2) {
Player offp = RedProtect.get().serv.getOfflinePlayer(args[1]).getPlayer();
if (offp == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
return true;
}
int limit = RedProtect.get().ph.getPlayerClaimLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.claim.unlimited")) {
RPLang.sendMessage(player, "cmdmanager.nolimit");
return true;
}
int currentUsed = RedProtect.get().rm.getRegions(RPUtil.PlayerToUUID(offp.getName()), offp.getWorld()).size();
ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
RPLang.sendMessage(player, RPLang.get("cmdmanager.yourclaims") + color + currentUsed + RPLang.get("general.color") + "/" + color + limit + RPLang.get("general.color"));
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.claimlimit"));
return true;
}
if (checkCmd(args[0], "welcome")) {
if (args.length >= 2) {
String wMessage = "";
if (args[1].equals("off")) {
handleWelcome(player, wMessage);
return true;
} else {
for (int i = 1; i < args.length; i++) {
wMessage = wMessage + args[i] + " ";
}
handleWelcome(player, wMessage);
return true;
}
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.welcome"));
return true;
}
if (checkCmd(args[0], "priority")) {
int prior = 0;
if (args.length == 2) {
try {
prior = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.notnumber");
return true;
}
handlePriority(player, prior);
return true;
}
if (args.length == 3) {
try {
prior = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.notnumber");
return true;
}
handlePrioritySingle(player, prior, args[1]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.priority"));
return true;
}
if (checkCmd(args[0], "delete")) {
// rp del [region] [world]
if (args.length == 1) {
handleDelete(player);
return true;
}
if (args.length == 2) {
handleDeleteName(player, args[1], "");
return true;
}
if (args.length == 3) {
handleDeleteName(player, args[1], args[2]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.delete"));
return true;
}
if (checkCmd(args[0], "info")) {
// rp info [region] [world]
if (args.length == 1) {
handleInfoTop(player);
return true;
}
if (args.length == 2) {
handleInfo(player, args[1], "");
return true;
}
if (args.length == 3) {
handleInfo(player, args[1], args[2]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.info"));
return true;
}
if (checkCmd(args[0], "addmember")) {
if (args.length == 2) {
handleAddMember(player, args[1]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.addmember"));
return true;
}
if (checkCmd(args[0], "addadmin")) {
if (args.length == 2) {
handleAddAdmin(player, args[1]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.addadmin"));
return true;
}
if (checkCmd(args[0], "addleader")) {
if (args.length == 2) {
handleAddLeader(player, args[1]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.addleader"));
return true;
}
if (checkCmd(args[0], "removemember")) {
if (args.length == 2) {
handleRemoveMember(player, args[1]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.removemember"));
return true;
}
if (checkCmd(args[0], "removeadmin")) {
if (args.length == 2) {
handleRemoveAdmin(player, args[1]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.removeadmin"));
return true;
}
if (checkCmd(args[0], "removeleader")) {
if (args.length == 2) {
handleRemoveLeader(player, args[1]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.removeleader"));
return true;
}
if (checkCmd(args[0], "rename")) {
if (args.length == 2) {
handleRename(player, args[1]);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.rename"));
return true;
}
if (checkCmd(args[0], "flag")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return true;
}
if (args.length == 2) {
if (RPConfig.getBool("flags-configuration.change-flag-delay.enable")) {
if (RPConfig.getStringList("flags-configuration.change-flag-delay.flags").contains(args[1])) {
if (!RedProtect.get().changeWait.contains(r.getName() + args[1])) {
RPUtil.startFlagChanger(r.getName(), args[1], player);
handleFlag(player, args[1], "", r);
return true;
} else {
RPLang.sendMessage(player, RPLang.get("gui.needwait.tochange").replace("{seconds}", RPConfig.getString("flags-configuration.change-flag-delay.seconds")));
return true;
}
}
}
handleFlag(player, args[1], "", r);
return true;
}
if (args.length >= 3) {
String text = "";
for (int i = 2; i < args.length; i++) {
text = text + " " + args[i];
}
if (RPConfig.getBool("flags-configuration.change-flag-delay.enable")) {
if (RPConfig.getStringList("flags-configuration.change-flag-delay.flags").contains(args[1])) {
if (!RedProtect.get().changeWait.contains(r.getName() + args[1])) {
RPUtil.startFlagChanger(r.getName(), args[1], player);
handleFlag(player, args[1], text.substring(1), r);
return true;
} else {
RPLang.sendMessage(player, RPLang.get("gui.needwait.tochange").replace("{seconds}", RPConfig.getString("flags-configuration.change-flag-delay.seconds")));
return true;
}
}
}
handleFlag(player, args[1], text.substring(1), r);
return true;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.flag"));
return true;
}
if (checkCmd(args[0], "list")) {
// rp list
if (args.length == 1) {
handleList(player, RPUtil.PlayerToUUID(player.getName()), 1);
return true;
}
// rp list [player]
if (args.length == 2) {
handleList(player, RPUtil.PlayerToUUID(args[1]), 1);
return true;
}
// rp list [player] [page]
if (args.length == 3) {
try {
int Page = Integer.parseInt(args[2]);
handleList(player, RPUtil.PlayerToUUID(args[1]), Page);
return true;
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.listpage.error");
return true;
}
}
}
RPLang.sendMessage(player, RPLang.get("correct.command") + " " + ChatColor.DARK_AQUA + "/rp " + getCmd("help"));
return true;
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect in project RedProtect by FabioZumbi12.
the class RedProtect method onEnable.
public void onEnable() {
try {
plugin = this;
BossBar = checkBM();
MyChunk = checkMyChunk();
MyPet = checkMyPet();
McMMo = checkMcMMo();
Mc = checkMc();
Vault = checkVault();
SkillAPI = checkSkillAPI();
PvPm = checkPvPm();
Ess = checkEss();
GP = checkGP();
Dyn = checkDyn();
WE = checkWe();
AWE = checkAWe();
SC = checkSP();
Fac = checkFac();
PLib = checkPLib();
PlaceHolderAPI = checkPHAPI();
JarFile = this.getFile();
initVars();
RPConfig.init();
RPLang.init();
rm.loadAll();
OnlineMode = serv.getOnlineMode();
serv.getPluginManager().registerEvents(new RPGlobalListener(), this);
serv.getPluginManager().registerEvents(new RPBlockListener(), this);
serv.getPluginManager().registerEvents(new RPPlayerListener(), this);
serv.getPluginManager().registerEvents(new RPEntityListener(), this);
serv.getPluginManager().registerEvents(new RPWorldListener(), this);
serv.getPluginManager().registerEvents(new RPAddProtection(), this);
version = getBukkitVersion();
logger.debug("Version String: " + version);
if (version >= 180) {
serv.getPluginManager().registerEvents(new RPMine18(), this);
}
if (version >= 190) {
serv.getPluginManager().registerEvents(new RPMine19(), this);
}
getCommand("RedProtect").setExecutor(new RPCommands());
if (Vault) {
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
logger.warning("Vault found, but for some reason cant be used with RedProtect.");
Vault = false;
} else {
econ = rsp.getProvider();
logger.info("Vault found. Hooked.");
}
}
if (PLib) {
logger.info("ProtocolLib found. Hidding Gui Flag item stats.");
}
if (PvPm) {
logger.info("PvPManager found. Hooked.");
}
if (Ess) {
pless = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
logger.info("Essentials found. Hooked.");
}
if (WE) {
logger.info("WorldEdit found. Hooked.");
}
if (AWE) {
logger.info("AsyncWorldEdit found. Hooked.");
}
if (BossBar) {
logger.info("BossbarAPI found. Hooked.");
}
if (MyPet) {
serv.getPluginManager().registerEvents(new MPListener(), this);
logger.info("MyPet found. Hooked.");
}
if (McMMo) {
serv.getPluginManager().registerEvents(new McMMoListener(), this);
logger.info("McMMo found. Hooked.");
}
if (SkillAPI) {
serv.getPluginManager().registerEvents(new SkillAPIListener(), this);
logger.info("SkillAPI found. Hooked.");
}
if (MyChunk) {
logger.sucess("MyChunk found. Ready to convert!");
logger.warning("Use '/rp mychunkconvert' to start MyChunk conversion (This may cause lag during conversion)");
}
if (Mc) {
logger.info("MagicCarpet found. Hooked.");
}
if (SC) {
clanManager = SimpleClans.getInstance().getClanManager();
logger.info("SimpleClans found. Hooked.");
}
if (Dyn && RPConfig.getBool("hooks.dynmap.enable")) {
logger.info("Dynmap found. Hooked.");
logger.info("Loading dynmap markers...");
dynmap = new RPDynmap((DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap"));
logger.info("Dynmap markers loaded!");
}
if (PlaceHolderAPI) {
new RPPlaceHoldersAPI(this).hook();
logger.info("PlaceHolderAPI found. Hooked and registered some chat placeholders.");
}
if (Fac) {
serv.getPluginManager().registerEvents(new RPFactions(), this);
logger.info("Factions found. Hooked.");
}
if (!RPConfig.getString("file-type").equalsIgnoreCase("mysql")) {
RPUtil.ReadAllDB(rm.getAllRegions());
} else {
logger.info("Theres " + rm.getTotalRegionsNum() + " regions on (" + RPConfig.getString("file-type") + ") database!");
}
logger.info("Loading API...");
this.rpAPI = new RedProtectAPI();
logger.info("API Loaded!");
logger.clear("&4 _ _ _ &c _ _ _ _ _ _ _ _ _ __");
logger.clear("&4|_| |_ | \\ &c|_| |_| | | | |_ | | /");
logger.clear("&4| \\ |_ |_/ &c| | \\ |_| | |_ |_ | /");
logger.clear("&a¯ " + pdf.getFullName() + " enabled");
logger.clear("");
if (RPConfig.getBool("update-check.enable")) {
logger.info("Checking for update...");
if (CheckUpdate()) {
logger.sucess("Update available! Use /rp update to download.");
} else {
logger.info("No update available.");
}
}
if (RPConfig.getString("file-type").equals("yml")) {
AutoSaveHandler();
}
} catch (Exception e) {
e.printStackTrace();
if (!RPConfig.getString("file-type").equalsIgnoreCase("mysql")) {
logger.severe("Error enabling RedProtect, plugin will shut down.");
this.disable();
}
}
}
use of br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect 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.RedProtect in project RedProtect by FabioZumbi12.
the class RPCommands method process.
@SuppressWarnings("deprecation")
public CommandResult process(CommandSource sender, String arguments) throws CommandException {
CommandResult cmdr = CommandResult.success();
String[] args = arguments.split(" ");
if (!(sender instanceof Player)) {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("single-to-files")) {
RedProtect.get().logger.sucess("[" + RPUtil.SingleToFiles() + "]" + " regions converted to your own files with success");
return cmdr;
}
if (args[0].equalsIgnoreCase("files-to-single")) {
RedProtect.get().logger.sucess("[" + RPUtil.FilesToSingle() + "]" + " regions converted to unified world file with success");
return cmdr;
}
if (args[0].equalsIgnoreCase("fileToMysql")) {
try {
if (!RPUtil.fileToMysql()) {
RedProtect.get().logger.severe("ERROR: Check if your 'file-type' configuration is set to 'file' before convert from FILE to Mysql.");
return cmdr;
} else {
RedProtect.get().cfgs.setConfig("file-type", "mysql");
RedProtect.get().cfgs.save();
RedProtect.get().reload();
RedProtect.get().logger.sucess("Redprotect reloaded with Mysql as database! Ready to use!");
return cmdr;
}
} catch (Exception e) {
e.printStackTrace();
return cmdr;
}
}
if (args[0].equalsIgnoreCase("mysqlToFile")) {
try {
if (!RPUtil.mysqlToFile()) {
RedProtect.get().logger.severe("ERROR: Check if your 'file-type' configuration is set to 'mysql' before convert from MYSQL to File.");
return cmdr;
} else {
RedProtect.get().cfgs.setConfig("file-type", "file");
RedProtect.get().cfgs.save();
RedProtect.get().reload();
RedProtect.get().logger.sucess("Redprotect reloaded with File as database! Ready to use!");
return cmdr;
}
} catch (Exception e) {
e.printStackTrace();
return cmdr;
}
}
if (args[0].isEmpty()) {
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "---------------- " + RedProtect.get().container.getName() + " ----------------"));
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "Developed by &eFabioZumbi12" + RPLang.get("general.color") + "."));
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "For more information about the commands, type [&e/rp ?" + RPLang.get("general.color") + "]."));
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "For a tutorial, type [&e/rp tutorial" + RPLang.get("general.color") + "]."));
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "---------------------------------------------------"));
return cmdr;
}
if (args[0].equalsIgnoreCase("list-all")) {
int total = 0;
for (Region r : RedProtect.get().rm.getAllRegions()) {
RedProtect.get().logger.info("&a[" + total + "]" + "Region: " + r.getName() + "&r | &3World: " + r.getWorld() + "&r");
total++;
}
RedProtect.get().logger.sucess(total + " regions for " + Sponge.getServer().getWorlds().size() + " worlds.");
return cmdr;
}
if (args[0].equalsIgnoreCase("save-all")) {
RedProtect.get().rm.saveAll();
RedProtect.get().logger.SaveLogs();
RedProtect.get().logger.sucess(RedProtect.get().rm.getAllRegions().size() + " regions saved with success!");
return cmdr;
}
if (args[0].equalsIgnoreCase("load-all")) {
RedProtect.get().rm.clearDB();
try {
RedProtect.get().rm.loadAll();
} catch (Exception e) {
RedProtect.get().logger.severe("Error on load all regions from database files:");
e.printStackTrace();
}
RedProtect.get().logger.sucess(RedProtect.get().rm.getAllRegions().size() + " regions has been loaded from database files!");
return cmdr;
}
if (checkCmd(args[0], "reload")) {
for (Player p : RedProtect.get().game.getServer().getOnlinePlayers()) {
RedProtect.get().getPVHelper().closeInventory(p);
}
RedProtect.get().reload();
RedProtect.get().logger.sucess("Redprotect reloaded with success!");
return cmdr;
}
if (args[0].equalsIgnoreCase("reload-config")) {
RedProtect.get().cfgs = new RPConfig();
RPLang.init();
RedProtect.get().logger.sucess("Redprotect Plus configs reloaded!");
return cmdr;
}
}
if (args.length == 2) {
// rp removeall <player>
if (checkCmd(args[0], "removeall")) {
int removed = RedProtect.get().rm.removeAll(args[1]);
if (removed <= 0) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.noneremoved"));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.removed").replace("{regions}", removed + "").replace("{player}", args[1]));
}
return cmdr;
}
// rp regenall <player>
if (checkCmd(args[0], "regenall")) {
int regen = RedProtect.get().rm.regenAll(args[1]);
if (regen <= 0) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.noneregenerated"));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.regenerated").replace("{regions}", regen + "").replace("{player}", args[1]));
}
return cmdr;
}
// rp regen stop
if (checkCmd(args[0], "regen") && args[1].equalsIgnoreCase("stop")) {
if (!RedProtect.get().WE) {
return cmdr;
}
RPUtil.stopRegen = true;
RPLang.sendMessage(sender, "&aRegen will stop now. To continue reload the plugin!");
return cmdr;
}
// rp list <player>
if (checkCmd(args[0], "list")) {
getRegionforList(sender, RPUtil.PlayerToUUID(args[1]), 1);
return cmdr;
}
// rp clamilimit player
if (checkCmd(args[0], "claimlimit")) {
User offp = RPUtil.getUser(args[1]);
if (offp == null) {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1])));
return cmdr;
}
int limit = RedProtect.get().ph.getPlayerClaimLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.claim.unlimited")) {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.nolimit")));
return cmdr;
}
int currentUsed = RedProtect.get().rm.getRegions(RPUtil.PlayerToUUID(offp.getName())).size();
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.yourclaims") + currentUsed + RPLang.get("general.color") + "/&e" + limit + RPLang.get("general.color")));
return cmdr;
}
// rp limit player
if (checkCmd(args[0], "limit")) {
User offp = RPUtil.getUser(args[1]);
if (offp == null) {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1])));
return cmdr;
}
int limit = RedProtect.get().ph.getPlayerBlockLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.blocks.unlimited")) {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.nolimit")));
return cmdr;
}
int currentUsed = RedProtect.get().rm.getTotalRegionSize(RPUtil.PlayerToUUID(offp.getName()), offp.getPlayer().isPresent() ? offp.getPlayer().get().getWorld().getName() : null);
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.yourarea") + currentUsed + RPLang.get("general.color") + "/&e" + limit + RPLang.get("general.color")));
return cmdr;
}
}
if (args.length == 3) {
// rp clamilimit player world
if (checkCmd(args[0], "claimlimit")) {
User offp = RPUtil.getUser(args[1]);
World w = null;
if (RedProtect.get().serv.getWorld(args[2]).isPresent()) {
w = RedProtect.get().serv.getWorld(args[2]).get();
}
if (offp == null) {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1])));
return cmdr;
}
int limit = RedProtect.get().ph.getPlayerClaimLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.claim.unlimited")) {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.nolimit")));
return cmdr;
}
if (w == null) {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.region.invalidworld")));
return cmdr;
}
int currentUsed = RedProtect.get().rm.getRegions(RPUtil.PlayerToUUID(offp.getName()), w).size();
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.yourclaims") + currentUsed + RPLang.get("general.color") + "/&e" + limit + RPLang.get("general.color")));
return cmdr;
}
if (args[0].equalsIgnoreCase("setconfig")) {
if (args[1].contains("debug-messages") || args[1].contains("file-type")) {
Object from = RedProtect.get().cfgs.getObject(args[1]);
if (args[2].equals("true") || args[2].equals("false")) {
RedProtect.get().cfgs.setConfig(args[1], Boolean.parseBoolean(args[2]));
} else {
try {
int value = Integer.parseInt(args[2]);
RedProtect.get().cfgs.setConfig(args[1], value);
} catch (NumberFormatException ex) {
RedProtect.get().cfgs.setConfig(args[1], args[2]);
}
}
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.configset") + " " + from + " > " + args[2]));
RedProtect.get().cfgs.save();
return cmdr;
} else {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.confignotset") + " " + args[1]));
return cmdr;
}
}
// rp info <region> <world>
if (checkCmd(args[0], "info")) {
if (Sponge.getServer().getWorld(args[2]).isPresent()) {
Region r = RedProtect.get().rm.getRegion(args[1], Sponge.getServer().getWorld(args[2]).get());
if (r != null) {
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "-----------------------------------------"));
sender.sendMessage(r.info());
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "-----------------------------------------"));
} else {
sender.sendMessage(RPUtil.toText(RPLang.get("correct.usage") + "&eInvalid region: " + args[1]));
}
} else {
sender.sendMessage(RPUtil.toText(RPLang.get("correct.usage") + " " + "&eInvalid World: " + args[2]));
}
return cmdr;
}
}
if (args.length == 4) {
if (checkCmd(args[0], "teleport")) {
// rp tp <player> <region> <world>
Player play = null;
if (RedProtect.get().serv.getPlayer(args[1]).isPresent()) {
play = RedProtect.get().serv.getPlayer(args[1]).get();
}
if (play != null) {
World w = null;
if (RedProtect.get().serv.getWorld(args[3]).isPresent()) {
w = RedProtect.get().serv.getWorld(args[3]).get();
}
if (w == null) {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.region.invalidworld")));
return cmdr;
}
Region region = RedProtect.get().rm.getRegion(args[2], w);
if (region == null) {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]));
return cmdr;
}
Location<World> loc = null;
if (region.getTPPoint() != null) {
loc = new Location<>(w, region.getTPPoint().getBlockX() + 0.500, region.getTPPoint().getBlockY(), region.getTPPoint().getBlockZ() + 0.500);
} else {
int limit = 256;
if (w.getDimension().equals(DimensionTypes.NETHER)) {
limit = 124;
}
for (int i = limit; i > 0; i--) {
BlockType mat = new Location<>(w, region.getCenterX(), i, region.getCenterZ()).getBlockType();
BlockType mat1 = new Location<>(w, region.getCenterX(), i + 1, region.getCenterZ()).getBlockType();
BlockType mat2 = new Location<>(w, region.getCenterX(), i + 2, region.getCenterZ()).getBlockType();
if (!mat.equals(BlockTypes.LAVA) && !mat.equals(BlockTypes.AIR) && mat1.equals(BlockTypes.AIR) && mat2.equals(BlockTypes.AIR)) {
loc = new Location<>(w, region.getCenterX() + 0.500, i + 1, region.getCenterZ() + 0.500);
break;
}
}
}
play.setLocation(loc);
RPLang.sendMessage(play, RPLang.get("cmdmanager.region.tp") + " " + args[2]);
sender.sendMessage(RPUtil.toText("&3Player teleported to " + args[2]));
return cmdr;
} else {
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1])));
HandleHelPage(sender, 1);
return cmdr;
}
}
// rp flag info <region> <world>
if (checkCmd(args[0], "flag") && checkCmd(args[1], "info")) {
if (Sponge.getServer().getWorld(args[3]).isPresent()) {
Region r = RedProtect.get().rm.getRegion(args[2], Sponge.getServer().getWorld(args[3]).get());
if (r != null) {
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "------------[" + RPLang.get("cmdmanager.region.flag.values") + "]------------"));
sender.sendMessage(r.getFlagInfo());
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "------------------------------------"));
} else {
sender.sendMessage(RPUtil.toText(RPLang.get("correct.usage") + "&eInvalid region: " + args[2]));
}
} else {
sender.sendMessage(RPUtil.toText(RPLang.get("correct.usage") + "&eInvalid World: " + args[3]));
}
return cmdr;
}
}
if (args.length == 5) {
/*/rp flag <regionName> <flag> <value> <world>*/
if (checkCmd(args[0], "flag")) {
World w = null;
if (RedProtect.get().serv.getWorld(args[4]).isPresent()) {
w = RedProtect.get().serv.getWorld(args[4]).get();
}
if (w == null) {
sender.sendMessage(RPUtil.toText(RPLang.get("correct.usage") + "&e rp flag <regionName> <flag> <value> <world>"));
return cmdr;
}
Region r = RedProtect.get().rm.getRegion(args[1], w);
if (r != null && (RedProtect.get().cfgs.getDefFlags().contains(args[2]) || RedProtect.get().cfgs.AdminFlags.contains(args[2]))) {
Object objflag = RPUtil.parseObject(args[3]);
r.setFlag(args[2], objflag);
sender.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.region.flag.set").replace("{flag}", "'" + args[2] + "'") + " " + r.getFlagString(args[2])));
RedProtect.get().logger.addLog("Console changed flag " + args[2] + " to " + r.getFlagString(args[2]));
return cmdr;
}
}
}
HandleHelPage(sender, 1);
return cmdr;
}
// commands as player
final Player player = (Player) sender;
if (args.length == 1) {
// rp regen
if (checkCmd(args[0], "regen") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return cmdr;
}
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.doesexists");
return cmdr;
}
WEListener.regenRegion(r, Sponge.getServer().getWorld(r.getWorld()).get(), r.getMaxLocation(), r.getMinLocation(), 0, sender, false);
return cmdr;
}
// rp undo
if (args[0].equalsIgnoreCase("undo") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return cmdr;
}
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.doesexists");
return cmdr;
}
if (WEListener.undo(r.getID())) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.sucess").replace("{region}", r.getName()));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.none").replace("{region}", r.getName()));
}
return cmdr;
}
String claimmode = RedProtect.get().cfgs.getWorldClaimType(player.getWorld().getName());
if (claimmode.equalsIgnoreCase("WAND") || claimmode.equalsIgnoreCase("BOTH") || RedProtect.get().ph.hasGenPerm(player, "redefine")) {
// rp pos1
if (checkCmd(args[0], "pos1")) {
Location<World> pl = player.getLocation();
RedProtect.get().firstLocationSelections.put(player, pl);
player.sendMessage(RPUtil.toText(RPLang.get("playerlistener.wand1") + RPLang.get("general.color") + " (&6" + pl.getBlockX() + RPLang.get("general.color") + ", &6" + pl.getBlockY() + RPLang.get("general.color") + ", &6" + pl.getBlockZ() + RPLang.get("general.color") + ")."));
// show preview border
if (RedProtect.get().firstLocationSelections.containsKey(player) && RedProtect.get().secondLocationSelections.containsKey(player)) {
Location<World> loc1 = RedProtect.get().firstLocationSelections.get(player);
Location<World> loc2 = RedProtect.get().secondLocationSelections.get(player);
if (loc1.getPosition().distanceSquared(loc2.getPosition()) > RedProtect.get().cfgs.getInt("region-settings.define-max-distance") && !player.hasPermission("redprotect.bypass.define-max-distance")) {
Double dist = loc1.getPosition().distanceSquared(loc2.getPosition());
RPLang.sendMessage(player, String.format(RPLang.get("regionbuilder.selection.maxdefine"), RedProtect.get().cfgs.getInt("region-settings.define-max-distance"), dist.intValue()));
} else {
RPUtil.addBorder(player, RPUtil.get4Points(loc1, loc2, player.getLocation().getBlockY()));
}
}
return cmdr;
} else // rp pos2
if (checkCmd(args[0], "pos2")) {
Location<World> pl = player.getLocation();
RedProtect.get().secondLocationSelections.put(player, pl);
player.sendMessage(RPUtil.toText(RPLang.get("playerlistener.wand2") + RPLang.get("general.color") + " (&6" + pl.getBlockX() + RPLang.get("general.color") + ", &6" + pl.getBlockY() + RPLang.get("general.color") + ", &6" + pl.getBlockZ() + RPLang.get("general.color") + ")."));
// show preview border
if (RedProtect.get().firstLocationSelections.containsKey(player) && RedProtect.get().secondLocationSelections.containsKey(player)) {
Location<World> loc1 = RedProtect.get().firstLocationSelections.get(player);
Location<World> loc2 = RedProtect.get().secondLocationSelections.get(player);
if (loc1.getPosition().distanceSquared(loc2.getPosition()) > RedProtect.get().cfgs.getInt("region-settings.define-max-distance") && !RedProtect.get().ph.hasPerm(player, "redprotect.bypass.define-max-distance")) {
Double dist = loc1.getPosition().distanceSquared(loc2.getPosition());
RPLang.sendMessage(player, String.format(RPLang.get("regionbuilder.selection.maxdefine"), RedProtect.get().cfgs.getInt("region-settings.define-max-distance"), dist.intValue()));
} else {
RPUtil.addBorder(player, RPUtil.get4Points(loc1, loc2, player.getLocation().getBlockY()));
}
}
return cmdr;
}
}
if (args[0].isEmpty()) {
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "---------------- " + RedProtect.get().container.getName() + " ----------------"));
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "Developed by &eFabioZumbi12" + RPLang.get("general.color") + "."));
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "For more information about the commands, type [&e/rp ?" + RPLang.get("general.color") + "]."));
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "For a tutorial, type [&e/rp tutorial" + RPLang.get("general.color") + "]."));
sender.sendMessage(RPUtil.toText(RPLang.get("general.color") + "---------------------------------------------------"));
return cmdr;
}
if (checkCmd(args[0], "laccept")) {
if (RedProtect.get().alWait.containsKey(player)) {
// info = region+world+pname
String info = RedProtect.get().alWait.get(player);
Player lsender = Sponge.getServer().getPlayer(info.split("@")[2]).get();
Region r = RedProtect.get().rm.getRegion(info.split("@")[0], info.split("@")[1]);
String VictimUUID = player.getName();
if (RedProtect.get().OnlineMode) {
VictimUUID = player.getUniqueId().toString();
}
if (r != null) {
if (RedProtect.get().ph.getPlayerClaimLimit(player) == (RedProtect.get().rm.getRegions(VictimUUID, r.getWorld()).size() + 1)) {
RPLang.sendMessage(player, "regionbuilder.claim.limit");
return cmdr;
}
r.addLeader(VictimUUID);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.leader.youadded").replace("{region}", r.getName()) + " " + lsender.getName());
if (lsender != null && lsender.isOnline()) {
RPLang.sendMessage(lsender, RPLang.get("cmdmanager.region.leader.accepted").replace("{region}", r.getName()).replace("{player}", player.getName()));
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.doesexists");
}
RedProtect.get().alWait.remove(player);
return cmdr;
} else {
RPLang.sendMessage(player, "cmdmanager.norequests");
return cmdr;
}
}
if (checkCmd(args[0], "ldeny")) {
if (RedProtect.get().alWait.containsKey(player)) {
// info = region+world+pname
String info = RedProtect.get().alWait.get(player);
Player lsender = Sponge.getServer().getPlayer(info.split("@")[2]).get();
Region r = RedProtect.get().rm.getRegion(info.split("@")[0], info.split("@")[1]);
if (r != null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.leader.youdenied").replace("{region}", r.getName()).replace("{player}", lsender.getName()));
if (lsender != null && lsender.isOnline()) {
RPLang.sendMessage(lsender, RPLang.get("cmdmanager.region.leader.denied").replace("{region}", r.getName()).replace("{player}", player.getName()));
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.doesexists");
}
RedProtect.get().alWait.remove(player);
return cmdr;
} else {
RPLang.sendMessage(player, "cmdmanager.norequests");
return cmdr;
}
}
if (checkCmd(args[0], "settp") && RedProtect.get().ph.hasGenPerm(player, "settp")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
if (RedProtect.get().ph.hasRegionPermLeader(player, "settp", r)) {
r.setTPPoint(player.getLocation());
RPLang.sendMessage(player, "cmdmanager.region.settp.ok");
return cmdr;
} else {
RPLang.sendMessage(player, "playerlistener.region.cantuse");
return cmdr;
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
}
if (checkCmd(args[0], "deltp") && RedProtect.get().ph.hasGenPerm(player, "settp")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
if (RedProtect.get().ph.hasRegionPermLeader(player, "settp", r)) {
r.setTPPoint(null);
RPLang.sendMessage(player, "cmdmanager.region.settp.removed");
return cmdr;
} else {
RPLang.sendMessage(player, "playerlistener.region.cantuse");
return cmdr;
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
}
if (checkCmd(args[0], "border") && RedProtect.get().ph.hasGenPerm(player, "border")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
RPUtil.addBorder(player, r.get4Points(player.getLocation().getBlockY()));
return cmdr;
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
}
if (checkCmd(args[0], "cancelbuy") && RedProtect.get().ph.hasGenPerm(player, "redprotect.eco.cancelbuy")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
if (r.isLeader(RPUtil.PlayerToUUID(player.getName()))) {
if (r.isForSale()) {
r.setFlag("for-sale", false);
r.setWelcome("");
if (r.leaderSize() == 0) {
if (RedProtect.get().cfgs.getEcoBool("rename-region")) {
RedProtect.get().rm.renameRegion(RPUtil.nameGen(player.getName(), r.getWorld()), r);
}
r.addLeader(RPUtil.PlayerToUUID(player.getName()));
} else {
if (RedProtect.get().cfgs.getEcoBool("rename-region")) {
RedProtect.get().rm.renameRegion(RPUtil.nameGen(RPUtil.UUIDtoPlayer(r.getLeaders().get(0)), r.getWorld()), r);
}
}
RPLang.sendMessage(player, "economy.region.cancelbuy");
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " cancelled buy stat of region " + r.getName());
return cmdr;
} else {
RPLang.sendMessage(player, "economy.region.buy.notforsale");
return cmdr;
}
} else {
RPLang.sendMessage(player, "economy.region.sell.own");
return cmdr;
}
}
if (checkCmd(args[0], "value") && RedProtect.get().ph.hasGenPerm(player, "value")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
if (RedProtect.get().ph.hasRegionPermLeader(player, "value", r)) {
if (r.getArea() < RedProtect.get().cfgs.getEcoInt("max-area-toget-value")) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.value.is").replace("{value}", RPEconomy.getFormatted(RPEconomy.getRegionValue(r)) + " " + RedProtect.get().cfgs.getEcoString("economy-name")));
RedProtect.get().logger.debug("player", "Region Value: " + RPEconomy.getRegionValue(r));
return cmdr;
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.value.areabig").replace("{maxarea}", RedProtect.get().cfgs.getEcoInt("max-area-toget-value").toString()));
return cmdr;
}
} else {
RPLang.sendMessage(player, "playerlistener.region.cantuse");
return cmdr;
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
}
if (args[0].equalsIgnoreCase("save-all")) {
if (RedProtect.get().ph.hasGenPerm(player, "save-all")) {
RedProtect.get().rm.saveAll();
RedProtect.get().logger.SaveLogs();
RPLang.sendMessage(player, "&a" + RedProtect.get().rm.getAllRegions().size() + " regions saved with success!");
return cmdr;
}
}
if (args[0].equalsIgnoreCase("load-all")) {
if (RedProtect.get().ph.hasGenPerm(player, "load-all")) {
RedProtect.get().rm.clearDB();
try {
RedProtect.get().rm.loadAll();
} catch (Exception e) {
RPLang.sendMessage(player, "Error on load all regions from database files:");
e.printStackTrace();
}
RPLang.sendMessage(player, "&a" + RedProtect.get().rm.getAllRegions().size() + " regions has been loaded from database files!");
return cmdr;
}
}
if (checkCmd(args[0], "define")) {
if (!RedProtect.get().ph.hasGenPerm(player, "define")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
String serverName = RedProtect.get().cfgs.getString("region-settings.default-leader");
String name = RPUtil.nameGen(serverName, player.getWorld().getName());
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, serverName, new LinkedList<>(), true);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " DEFINED region " + r2.getName());
}
return cmdr;
}
// rp claim
if (checkCmd(args[0], "claim")) {
if ((!claimmode.equalsIgnoreCase("WAND") && !claimmode.equalsIgnoreCase("BOTH")) && !RedProtect.get().ph.hasGenPerm(player, "claim")) {
RPLang.sendMessage(player, "blocklistener.region.blockmode");
return cmdr;
}
String name = RPUtil.nameGen(player.getName(), player.getWorld().getName());
String leader = player.getUniqueId().toString();
if (!RedProtect.get().OnlineMode) {
leader = player.getName().toLowerCase();
}
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, leader, new LinkedList<>(), false);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " CLAIMED region " + r2.getName());
}
return cmdr;
}
if (checkCmd(args[0], "reload") && RedProtect.get().ph.hasGenPerm(player, "reload")) {
for (Player p : RedProtect.get().game.getServer().getOnlinePlayers()) {
RedProtect.get().getPVHelper().closeInventory(p);
}
RedProtect.get().reload();
RPLang.sendMessage(player, "cmdmanager.reloaded");
return cmdr;
}
if (checkCmd(args[0], "wand") && player.hasPermission("redprotect.magicwand")) {
Inventory inv = player.getInventory();
ItemType mat = (ItemType) RPUtil.getRegistryFor(ItemType.class, RedProtect.get().cfgs.getString("wands.adminWandID"));
ItemStack item = ItemStack.of(mat, 1);
item.offer(Keys.ITEM_ENCHANTMENTS, new ArrayList<>());
Iterable<Slot> slotIter = player.getInventory().slots();
for (Slot slot : slotIter) {
if (slot.peek().isPresent()) {
ItemStack stack = slot.peek().get();
if (stack.getItem().equals(mat)) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.wand.nospace").replace("{item}", mat.getName()));
return cmdr;
}
}
}
if (inv.query(Inventory.class).offer(item).getType().equals(Type.SUCCESS)) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.wand.given").replace("{item}", mat.getName()));
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.wand.nospace").replace("{item}", mat.getName()));
}
return cmdr;
}
if (checkCmd(args[0], "help")) {
HandleHelPage(sender, 1);
return cmdr;
}
if (checkCmd(args[0], "tutorial")) {
RPLang.sendMessage(player, "cmdmanager.tutorial");
RPLang.sendMessage(player, "cmdmanager.tutorial1");
RPLang.sendMessage(player, "cmdmanager.tutorial2");
RPLang.sendMessage(player, "cmdmanager.tutorial3");
RPLang.sendMessage(player, "cmdmanager.tutorial4");
RPLang.sendMessage(player, "cmdmanager.tutorial5");
return cmdr;
}
if (checkCmd(args[0], "near")) {
if (RedProtect.get().ph.hasUserPerm(player, "redprotect.near")) {
Set<Region> regions = RedProtect.get().rm.getRegionsNear(player, 60, player.getWorld());
if (regions.size() == 0) {
RPLang.sendMessage(player, "cmdmanager.noregions.nearby");
} else {
Iterator<Region> i = regions.iterator();
player.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.regionwith40")));
player.sendMessage(RPUtil.toText(RPLang.get("general.color") + "------------------------------------"));
while (i.hasNext()) {
Region r = i.next();
player.sendMessage(RPUtil.toText(RPLang.get("cmdmanager.region.name") + r.getName() + RPLang.get("general.color") + " | " + RPLang.get("region.center") + " (&6X,Z" + RPLang.get("general.color") + "): &6" + r.getCenterX() + ", " + r.getCenterZ()));
}
player.sendMessage(RPUtil.toText(RPLang.get("general.color") + "------------------------------------"));
}
} else {
RPLang.sendMessage(player, "no.permission");
}
return cmdr;
}
if (checkCmd(args[0], "flag")) {
if (RedProtect.get().ph.hasUserPerm(player, "flaggui")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r != null) {
if (r.isLeader(player) || r.isAdmin(player) || RedProtect.get().ph.hasAdminFlagPerm(player, "redprotect.admin.flaggui")) {
RPGui gui = new RPGui(r.getName(), player, r, RedProtect.get().cfgs.getGuiMaxSlot());
gui.open();
return cmdr;
} else {
sendNoPermissionMessage(player);
return cmdr;
}
} else {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
}
}
// rp renew-rent
if (checkCmd(args[0], "renew-rent") && RedProtect.get().ph.hasGenPerm(player, "redprotect.rent.renew-rent")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.doesexists");
return cmdr;
}
String puuid = RPUtil.PlayerToUUID(player.getName());
if (!r.isRentFor(puuid)) {
RPLang.sendMessage(player, "cmdmanager.rent.younotrented");
return cmdr;
}
if (RPUtil.getNowMillis() != r.getRentDateMillis(puuid) && !RedProtect.get().cfgs.getBool("region-settings.rent.renew-anytime")) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.rent.cantrenewanytime").replace("{renew}", r.getRentDateFormated(puuid)));
return cmdr;
}
UniqueAccount acc = RedProtect.get().econ.getOrCreateAccount(player.getUniqueId()).get();
if (acc.getBalance(RedProtect.get().econ.getDefaultCurrency()).doubleValue() >= r.getRentValue(puuid)) {
Calendar cal = Calendar.getInstance();
String[] opts = RedProtect.get().cfgs.getString("region-settings.rent.command-renew-adds").split(":");
if (opts[1].equalsIgnoreCase("MONTH")) {
cal.add(Calendar.MONTH, Integer.valueOf(opts[0]));
} else if (opts[1].equalsIgnoreCase("DAY")) {
cal.add(Calendar.DAY_OF_MONTH, Integer.valueOf(opts[0]));
}
acc.withdraw(RedProtect.get().econ.getDefaultCurrency(), BigDecimal.valueOf(r.getRentValue(puuid)), RedProtect.get().getPVHelper().getCause(player));
r.setRent(puuid, cal.getTimeInMillis());
RPLang.sendMessage(player, RPLang.get("cmdmanager.rent.renewsuccess").replace("{region}", r.getName()).replace("{value}", RPEconomy.getFormatted(r.getRentValue(puuid))));
} else {
RPLang.sendMessage(player, "cmdmanager.rent.renewfail");
}
return cmdr;
}
}
if (args.length == 2) {
// rp removeall <player>
if (checkCmd(args[0], "removeall") && sender.hasPermission("redprotect.removeall")) {
if (!RedProtect.get().WE) {
return cmdr;
}
int removed = RedProtect.get().rm.removeAll(args[1]);
if (removed <= 0) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.noneremoved"));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.removed").replace("{regions}", removed + "").replace("{player}", args[1]));
}
return cmdr;
}
// rp regenall <player>
if (checkCmd(args[0], "regenall") && sender.hasPermission("redprotect.regenall")) {
if (!RedProtect.get().WE) {
return cmdr;
}
int regen = RedProtect.get().rm.regenAll(args[1]);
if (regen <= 0) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.noneregenerated"));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.regenerated").replace("{regions}", regen + "").replace("{player}", args[1]));
}
return cmdr;
}
// rp regen stop
if (checkCmd(args[0], "regen") && args[1].equalsIgnoreCase("stop") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return cmdr;
}
RPUtil.stopRegen = true;
RPLang.sendMessage(player, "&aRegen will stop now. To continue reload the plugin!");
return cmdr;
}
if (checkCmd(args[0], "help")) {
try {
int page = Integer.parseInt(args[1]);
HandleHelPage(sender, page);
} catch (NumberFormatException e) {
RPLang.sendMessage(player, RPLang.get("correct.usage") + "&e/rp ? [page]");
}
return cmdr;
}
// rp define [nameOfRegion]
if (checkCmd(args[0], "define")) {
if (!RedProtect.get().ph.hasGenPerm(player, "define")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
String serverName = RedProtect.get().cfgs.getString("region-settings.default-leader");
String name = args[1].replace("/", "|");
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, serverName, new LinkedList<>(), true);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " DEFINED region " + r2.getName());
}
return cmdr;
}
// rp claim [nameOfRegion]
if (checkCmd(args[0], "claim")) {
String claimmode = RedProtect.get().cfgs.getWorldClaimType(player.getWorld().getName());
if ((!claimmode.equalsIgnoreCase("WAND") && !claimmode.equalsIgnoreCase("BOTH")) && !player.hasPermission("redprotect.admin.claim")) {
RPLang.sendMessage(player, "blocklistener.region.blockmode");
return cmdr;
}
String name = args[1].replace("/", "|");
String leader = player.getUniqueId().toString();
if (!RedProtect.get().OnlineMode) {
leader = player.getName().toLowerCase();
}
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, leader, new LinkedList<>(), false);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " CLAIMED region " + r2.getName());
}
return cmdr;
}
if (checkCmd(args[0], "redefine")) {
Region oldRect = RedProtect.get().rm.getRegion(args[1], player.getWorld());
if (oldRect == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
return cmdr;
}
if (!RedProtect.get().ph.hasRegionPermLeader(player, "redefine", oldRect)) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
RedefineRegionBuilder rb = new RedefineRegionBuilder(player, oldRect, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player));
if (rb.ready()) {
Region r2 = rb.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.redefined") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " REDEFINED region " + r2.getName());
}
return cmdr;
}
// rp del-rent <player>
if (checkCmd(args[0], "del-rent") && RedProtect.get().ph.hasUserPerm(player, "del-rent")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
if (!r.isLeader(player) && !RedProtect.get().ph.hasGenPerm(player, "redprotect.rent.others")) {
sendNoPermissionMessage(player);
return cmdr;
}
if (r.isRentFor(RPUtil.PlayerToUUID(args[1]))) {
r.removeRent(RPUtil.PlayerToUUID(args[1]));
RPLang.sendMessage(player, RPLang.get("cmdmanager.rent.playerremoved").replace("{region}", r.getName()));
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.rent.noplayerrented"));
}
return cmdr;
}
}
if (args.length == 3) {
// rp regen <region> <world>
if (checkCmd(args[0], "regen") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return cmdr;
}
World w = RedProtect.get().serv.getWorld(args[2]).get();
if (w == null) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.invalidworld"));
return cmdr;
}
Region r = RedProtect.get().rm.getRegion(args[1], w);
if (r == null) {
RPLang.sendMessage(sender, RPLang.get("correct.usage") + " &eInvalid region: " + args[1]);
return cmdr;
}
WEListener.regenRegion(r, Sponge.getServer().getWorld(r.getWorld()).get(), r.getMaxLocation(), r.getMinLocation(), 0, sender, false);
return cmdr;
}
// rp undo <region> <world>
if (args[0].equalsIgnoreCase("undo") && player.hasPermission("redprotect.regen")) {
if (!RedProtect.get().WE) {
return cmdr;
}
World w = RedProtect.get().serv.getWorld(args[2]).get();
if (w == null) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.region.invalidworld"));
return cmdr;
}
Region r = RedProtect.get().rm.getRegion(args[1], w);
if (r == null) {
RPLang.sendMessage(sender, RPLang.get("correct.usage") + " &eInvalid region: " + args[1]);
return cmdr;
}
if (WEListener.undo(r.getID())) {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.sucess").replace("{region}", r.getName()));
} else {
RPLang.sendMessage(sender, RPLang.get("cmdmanager.regen.undo.none").replace("{region}", r.getName()));
}
return cmdr;
}
// rp edit-rent <player> <valor/date>
if (checkCmd(args[0], "edit-rent") && RedProtect.get().ph.hasUserPerm(player, "edit-rent")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
if (!r.isLeader(player) && !RedProtect.get().ph.hasUserPerm(player, "rent.others")) {
sendNoPermissionMessage(player);
return cmdr;
}
if (!r.isRentFor(RPUtil.PlayerToUUID(args[1]))) {
RPLang.sendMessage(player, "cmdmanager.rent.playernotrented");
return cmdr;
}
try {
int value = Integer.valueOf(args[2]);
r.setRent(RPUtil.PlayerToUUID(args[1]), value);
RPLang.sendMessage(player, RPLang.get("cmdmanager.rent.renteditok").replace("{player}", args[1]).replace("{value}", args[2]));
return cmdr;
} catch (NumberFormatException ex) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(RedProtect.get().cfgs.getString("region-settings.date-format"));
try {
cal.setTime(sdf.parse(args[2]));
r.setRent(RPUtil.PlayerToUUID(args[1]), cal.getTimeInMillis());
RPLang.sendMessage(player, RPLang.get("cmdmanager.rent.renteditok").replace("{player}", args[1]).replace("{value}", args[2]));
return cmdr;
} catch (ParseException ignored) {
}
}
}
// rp claim [regionName] [leader]
if (checkCmd(args[0], "claim")) {
String claimmode = RedProtect.get().cfgs.getWorldClaimType(player.getWorld().getName());
if ((!claimmode.equalsIgnoreCase("WAND") && !claimmode.equalsIgnoreCase("BOTH")) && !player.hasPermission("redprotect.admin.claim")) {
RPLang.sendMessage(player, "blocklistener.region.blockmode");
return cmdr;
}
String name = args[1].replace("/", "|");
String leader = player.getUniqueId().toString();
List<String> addedAdmins = new ArrayList<>();
addedAdmins.add(RPUtil.PlayerToUUID(args[2]));
if (!RedProtect.get().OnlineMode) {
leader = player.getName().toLowerCase();
}
RegionBuilder rb2 = new DefineRegionBuilder(player, RedProtect.get().firstLocationSelections.get(player), RedProtect.get().secondLocationSelections.get(player), name, leader, addedAdmins, false);
if (rb2.ready()) {
Region r2 = rb2.build();
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.created") + " " + r2.getName() + ".");
RedProtect.get().rm.add(r2, player.getWorld());
RedProtect.get().firstLocationSelections.remove(player);
RedProtect.get().secondLocationSelections.remove(player);
RedProtect.get().logger.addLog("(World " + r2.getWorld() + ") Player " + player.getName() + " CLAIMED region " + r2.getName());
}
return cmdr;
}
// - /rp copyflag from to
if (checkCmd(args[0], "copyflag")) {
if (!RedProtect.get().ph.hasGenPerm(player, "copyflag")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
World w = player.getWorld();
Region from = RedProtect.get().rm.getRegion(args[1], w);
Region to = RedProtect.get().rm.getRegion(args[2], w);
if (from == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
return cmdr;
}
if (to == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return cmdr;
}
for (String key : from.flags.keySet()) {
to.setFlag(key, from.flags.get(key));
}
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.flag.copied") + args[1] + " > " + args[2]);
RedProtect.get().logger.addLog("Player " + player.getName() + " Copied FLAGS from " + args[1] + " to " + args[2]);
return cmdr;
}
}
if (args.length == 4 || args.length == 5) {
// rp add-rent <player> <valor> <date>
if (checkCmd(args[0], "add-rent") && player.hasPermission("redprotect.add-rent")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
if (!r.isLeader(player) && !player.hasPermission("redprotect.rent.others")) {
sendNoPermissionMessage(player);
return cmdr;
}
int value = 0;
long renewal = 0;
try {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(RedProtect.get().cfgs.getString("region-settings.date-format"));
cal.setTime(sdf.parse(args[3]));
renewal = cal.getTimeInMillis();
value = Integer.valueOf(args[2]);
} catch (Exception ex) {
RPLang.sendMessage(player, RPLang.get("correct.command") + " &b/rp " + getCmd("help"));
ex.printStackTrace();
return cmdr;
}
String play = RPUtil.PlayerToUUID(args[1]);
if (args.length == 4) {
r.addrent(play, value, renewal, RedProtect.get().cfgs.getString("region-settings.rent.default-level"));
} else if (args.length == 5) {
if (args[4].equalsIgnoreCase("member") || args[4].equalsIgnoreCase("admin") || args[4].equalsIgnoreCase("leader")) {
r.addrent(play, value, renewal, args[4]);
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.rent.validranks").replace("{ranks}", "member, admin, leader"));
return cmdr;
}
}
RPLang.sendMessage(player, RPLang.get("cmdmanager.rent.addedrent").replace("{player}", args[1]).replace("{date}", args[3]).replace("{cost}", args[2]));
if (RedProtect.get().serv.getPlayer(args[1]).isPresent()) {
RPLang.sendMessage(RedProtect.get().serv.getPlayer(args[1]).get(), RPLang.get("cmdmanager.rent.playeraddedrent").replace("{region}", r.getName()).replace("{date}", args[3]).replace("{cost}", args[2]));
}
return cmdr;
}
}
// rp expand-vert [region] [world]
if (checkCmd(args[0], "expand-vert")) {
if (!RedProtect.get().ph.hasGenPerm(player, "expandvert")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
Region r = null;
// rp expand-vert
if (args.length == 1) {
r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
} else // rp expand-vert [region]
if (args.length == 2) {
r = RedProtect.get().rm.getRegion(args[1], player.getWorld());
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
return cmdr;
}
} else // rp expand-vert [region] [world]
if (args.length == 3) {
if (!Sponge.getServer().getWorld(args[2]).isPresent()) {
RPLang.sendMessage(player, "cmdmanager.region.invalidworld");
return cmdr;
}
r = RedProtect.get().rm.getRegion(args[1], Sponge.getServer().getWorld(args[2]).get());
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[1]);
return cmdr;
}
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.help.expandvert").replace("{cmd}", getCmd("expandvert")).replace("{alias}", getCmdAlias("expandvert")));
return cmdr;
}
r.setMaxY(256);
r.setMinY(0);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.expandvert.success").replace("{region}", r.getName()).replace("{miny}", String.valueOf(r.getMinY())).replace("{maxy}", String.valueOf(r.getMaxY())));
return cmdr;
}
// rp setmaxy <size> [region] [world]
if (checkCmd(args[0], "setmaxy")) {
if (!RedProtect.get().ph.hasGenPerm(player, "setmaxy")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
Region r = null;
// rp setmaxy <size>
switch(args.length) {
case 2:
r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
break;
// rp setmaxy <size> [region]
case 3:
r = RedProtect.get().rm.getRegion(args[2], player.getWorld());
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return cmdr;
}
break;
// rp setmaxy <size> [region] [world]
case 4:
if (!Sponge.getServer().getWorld(args[3]).isPresent()) {
RPLang.sendMessage(player, "cmdmanager.region.invalidworld");
return cmdr;
}
r = RedProtect.get().rm.getRegion(args[2], Sponge.getServer().getWorld(args[3]).get());
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return cmdr;
}
break;
default:
RPLang.sendMessage(player, RPLang.get("cmdmanager.help.setmaxy").replace("{cmd}", getCmd("setmaxy")).replace("{alias}", getCmdAlias("setmaxy")));
return cmdr;
}
String from = String.valueOf(r.getMaxY());
try {
int size = Integer.parseInt(args[1]);
if ((size - r.getMinY()) <= 1) {
RPLang.sendMessage(player, "cmdmanager.region.ysiszesmatch");
return cmdr;
}
r.setMaxY(size);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.setmaxy.success").replace("{region}", r.getName()).replace("{fromsize}", from).replace("{size}", String.valueOf(size)));
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SETMAXY of region " + r.getName() + " to " + args[1]);
return cmdr;
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.invalid.number");
return cmdr;
}
}
// rp setmaxy <size> [region] [world]
if (checkCmd(args[0], "setminy")) {
if (!RedProtect.get().ph.hasGenPerm(player, "setminy")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
Region r = null;
// rp setmaxy <size>
switch(args.length) {
case 2:
r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
break;
// rp setmaxy <size> [region]
case 3:
r = RedProtect.get().rm.getRegion(args[2], player.getWorld());
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return cmdr;
}
break;
// rp setmaxy <size> [region] [world]
case 4:
if (!Sponge.getServer().getWorld(args[3]).isPresent()) {
RPLang.sendMessage(player, "cmdmanager.region.invalidworld");
return cmdr;
}
r = RedProtect.get().rm.getRegion(args[2], Sponge.getServer().getWorld(args[3]).get());
if (r == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.doesntexist") + ": " + args[2]);
return cmdr;
}
break;
default:
RPLang.sendMessage(player, RPLang.get("cmdmanager.help.setminy").replace("{cmd}", getCmd("setminy")).replace("{alias}", getCmdAlias("setminy")));
return cmdr;
}
String from = String.valueOf(r.getMinY());
try {
int size = Integer.parseInt(args[1]);
if ((r.getMaxY() - size) <= 1) {
RPLang.sendMessage(player, "cmdmanager.region.ysiszesmatch");
return cmdr;
}
r.setMinY(size);
RPLang.sendMessage(player, RPLang.get("cmdmanager.region.setminy.success").replace("{region}", r.getName()).replace("{fromsize}", from).replace("{size}", String.valueOf(size)));
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SETMINY of region " + r.getName() + " to " + args[1]);
return cmdr;
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.invalid.number");
return cmdr;
}
}
if (checkCmd(args[0], "buy") && RedProtect.get().ph.hasGenPerm(player, "redprotect.eco.buy")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
if (!r.isForSale()) {
RPLang.sendMessage(player, "economy.region.buy.notforsale");
return cmdr;
}
if (args.length == 1) {
buyHandler(player, r.getValue(), r);
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " BUY region " + r.getName() + " for " + r.getValue());
return cmdr;
}
}
if (checkCmd(args[0], "sell") && RedProtect.get().ph.hasGenPerm(player, "redprotect.eco.sell")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
if (r.isForSale()) {
RPLang.sendMessage(player, "economy.region.sell.already");
return cmdr;
}
if (args.length == 1) {
r.setValue(RPEconomy.getRegionValue(r));
if (r.isLeader(player)) {
sellHandler(r, player, RPUtil.PlayerToUUID(player.getName()), r.getValue());
} else {
sellHandler(r, player, r.getLeaders().get(0), r.getValue());
}
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SELL region " + r.getName() + " for " + r.getValue());
return cmdr;
}
if (args.length == 2) {
// rp sell <value/player>
try {
long value = Long.valueOf(args[1]);
if (RedProtect.get().ph.hasGenPerm(player, "redprotect.eco.setvalue")) {
r.setValue(value);
if (r.isLeader(player)) {
sellHandler(r, player, RPUtil.PlayerToUUID(player.getName()), r.getValue());
} else {
sellHandler(r, player, r.getLeaders().get(0), r.getValue());
}
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SELL region " + r.getName() + " for " + r.getValue());
return cmdr;
}
} catch (NumberFormatException e) {
if (RedProtect.get().ph.hasGenPerm(player, "redprotect.eco.others")) {
r.setValue(RPEconomy.getRegionValue(r));
sellHandler(r, player, RPUtil.PlayerToUUID(args[1]), r.getValue());
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SELL region " + r.getName() + " in name of player " + args[1] + " for " + r.getValue());
return cmdr;
}
}
}
if (args.length == 3) {
// rp sell player value
try {
long value = Long.valueOf(args[2]);
if (RedProtect.get().ph.hasGenPerm(player, "redprotect.eco.setvalue")) {
r.setValue(value);
sellHandler(r, player, RPUtil.PlayerToUUID(args[1]), value);
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " SELL region " + r.getName() + " in name of player " + args[1] + " for " + value);
return cmdr;
}
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.eco.notdouble");
return cmdr;
}
}
}
if (checkCmd(args[0], "teleport")) {
if (args.length == 1) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.help.teleport").replace("{cmd}", getCmd("teleport")).replace("{alias}", getCmdAlias("teleport")));
return cmdr;
}
if (args.length == 2) {
handletp(player, args[1], player.getWorld().getName(), null);
return cmdr;
}
if (args.length == 3) {
handletp(player, args[1], args[2], null);
return cmdr;
}
if (args.length == 4) {
// /rp tp <player> <region> <world>
Player play = null;
if (Sponge.getServer().getPlayer(args[1]).isPresent()) {
play = Sponge.getServer().getPlayer(args[1]).get();
}
if (play != null) {
handletp(player, args[2], args[3], play);
return cmdr;
} else {
RPLang.sendMessage(player, RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
RPLang.sendMessage(player, RPLang.get("cmdmanager.help.teleport").replace("{cmd}", getCmd("teleport")).replace("{alias}", getCmdAlias("teleport")));
return cmdr;
}
}
}
if (checkCmd(args[0], "limit")) {
if (!RedProtect.get().ph.hasUserPerm(player, "limit")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
if (args.length == 1) {
int limit = RedProtect.get().ph.getPlayerBlockLimit(player);
if (limit < 0 || RedProtect.get().ph.hasPerm(player, "redprotect.limit.blocks.unlimited")) {
RPLang.sendMessage(player, "cmdmanager.nolimit");
return cmdr;
}
String uuid = player.getUniqueId().toString();
if (!RedProtect.get().OnlineMode) {
uuid = player.getName().toLowerCase();
}
int currentUsed = RedProtect.get().rm.getTotalRegionSize(uuid, player.getPlayer().isPresent() ? player.getPlayer().get().getWorld().getName() : null);
RPLang.sendMessage(player, RPLang.get("cmdmanager.yourarea") + currentUsed + RPLang.get("general.color") + "/&e" + limit + RPLang.get("general.color"));
return cmdr;
}
if (!RedProtect.get().ph.hasPerm(player, "redprotect.other.limit")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
if (args.length == 2) {
User offp = RPUtil.getUser(args[1]);
if (offp == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
return cmdr;
}
int limit = RedProtect.get().ph.getPlayerBlockLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.blocks.unlimited")) {
RPLang.sendMessage(player, "cmdmanager.nolimit");
return cmdr;
}
int currentUsed = RedProtect.get().rm.getTotalRegionSize(RPUtil.PlayerToUUID(offp.getName()), offp.getPlayer().isPresent() ? offp.getPlayer().get().getWorld().getName() : null);
RPLang.sendMessage(player, RPLang.get("cmdmanager.yourarea") + currentUsed + RPLang.get("general.color") + "/&e" + limit + RPLang.get("general.color"));
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.limit").replace("{cmd}", getCmd("limit")).replace("{alias}", getCmdAlias("limit")));
return cmdr;
}
if (checkCmd(args[0], "claimlimit")) {
if (!RedProtect.get().ph.hasUserPerm(player, "claimlimit")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
if (args.length == 1) {
int limit = RedProtect.get().ph.getPlayerClaimLimit(player);
if (limit < 0 || RedProtect.get().ph.hasPerm(player, "redprotect.claimunlimited")) {
RPLang.sendMessage(player, "cmdmanager.nolimit");
return cmdr;
}
int currentUsed = RedProtect.get().rm.getRegions(RPUtil.PlayerToUUID(player.getName()), player.getWorld()).size();
RPLang.sendMessage(player, RPLang.get("cmdmanager.yourclaims") + currentUsed + RPLang.get("general.color") + "/&e" + limit + RPLang.get("general.color"));
return cmdr;
}
if (!RedProtect.get().ph.hasPerm(player, "redprotect.other.claimlimit")) {
RPLang.sendMessage(player, "no.permission");
return cmdr;
}
if (args.length == 2) {
User offp = RPUtil.getUser(args[1]);
if (offp == null) {
RPLang.sendMessage(player, RPLang.get("cmdmanager.noplayer.thisname").replace("{player}", args[1]));
return cmdr;
}
int limit = RedProtect.get().ph.getPlayerClaimLimit(offp);
if (limit < 0 || RedProtect.get().ph.hasPerm(offp, "redprotect.limit.claim.unlimited")) {
RPLang.sendMessage(player, "cmdmanager.nolimit");
return cmdr;
}
int currentUsed = RedProtect.get().rm.getRegions(RPUtil.PlayerToUUID(offp.getName()), player.getWorld()).size();
RPLang.sendMessage(player, RPLang.get("cmdmanager.yourclaims") + currentUsed + RPLang.get("general.color") + "/&e" + limit + RPLang.get("general.color"));
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.claimlimit").replace("{cmd}", getCmd("claimlimit")).replace("{alias}", getCmdAlias("claimlimit")));
return cmdr;
}
if (checkCmd(args[0], "welcome")) {
if (args.length >= 2) {
String wMessage = "";
if (args[1].equals("off")) {
handleWelcome(player, wMessage);
return cmdr;
} else {
for (int i = 1; i < args.length; i++) {
wMessage = wMessage + args[i] + " ";
}
handleWelcome(player, wMessage);
return cmdr;
}
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.welcome").replace("{cmd}", getCmd("welcome")).replace("{alias}", getCmdAlias("welcome")));
return cmdr;
}
if (checkCmd(args[0], "priority")) {
int prior = 0;
if (args.length == 2) {
try {
prior = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.notnumber");
return cmdr;
}
handlePriority(player, prior);
return cmdr;
}
if (args.length == 3) {
try {
prior = Integer.parseInt(args[2]);
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.notnumber");
return cmdr;
}
handlePrioritySingle(player, prior, args[1]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.priority").replace("{cmd}", getCmd("priority")).replace("{alias}", getCmdAlias("priority")));
return cmdr;
}
if (checkCmd(args[0], "delete")) {
// rp del [region] [world]
if (args.length == 1) {
handleDelete(player);
return cmdr;
}
if (args.length == 2) {
handleDeleteName(player, args[1], "");
return cmdr;
}
if (args.length == 3) {
handleDeleteName(player, args[1], args[2]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.delete").replace("{cmd}", getCmd("delete")).replace("{alias}", getCmdAlias("delete")));
return cmdr;
}
if (checkCmd(args[0], "info")) {
// rp info [region] [world]
if (args.length == 1) {
handleInfoTop(player);
return cmdr;
}
if (args.length == 2) {
handleInfo(player, args[1], "");
return cmdr;
}
if (args.length == 3) {
handleInfo(player, args[1], args[2]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.info").replace("{cmd}", getCmd("info")).replace("{alias}", getCmdAlias("info")));
return cmdr;
}
if (checkCmd(args[0], "addmember")) {
if (args.length == 2) {
handleAddMember(player, args[1]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.addmember").replace("{cmd}", getCmd("addmember")).replace("{alias}", getCmdAlias("addmember")));
return cmdr;
}
if (checkCmd(args[0], "addadmin")) {
if (args.length == 2) {
handleAddAdmin(player, args[1]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.addadmin").replace("{cmd}", getCmd("addadmin")).replace("{alias}", getCmdAlias("addadmin")));
return cmdr;
}
if (checkCmd(args[0], "addleader")) {
if (args.length == 2) {
handleAddLeader(player, args[1]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.addleader").replace("{cmd}", getCmd("addleader")).replace("{alias}", getCmdAlias("addleader")));
return cmdr;
}
if (checkCmd(args[0], "removemember")) {
if (args.length == 2) {
handleRemoveMember(player, args[1]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.removemember").replace("{cmd}", getCmd("removemember")).replace("{alias}", getCmdAlias("removemember")));
return cmdr;
}
if (checkCmd(args[0], "removeadmin")) {
if (args.length == 2) {
handleRemoveAdmin(player, args[1]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.removeadmin").replace("{cmd}", getCmd("removeadmin")).replace("{alias}", getCmdAlias("removeadmin")));
return cmdr;
}
if (checkCmd(args[0], "removeleader")) {
if (args.length == 2) {
handleRemoveLeader(player, args[1]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.removeleader").replace("{cmd}", getCmd("removeleader")).replace("{alias}", getCmdAlias("removeleader")));
return cmdr;
}
if (checkCmd(args[0], "rename")) {
if (args.length == 2) {
handleRename(player, args[1]);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.rename").replace("{cmd}", getCmd("rename")).replace("{alias}", getCmdAlias("rename")));
return cmdr;
}
if (checkCmd(args[0], "flag")) {
Region r = RedProtect.get().rm.getTopRegion(player.getLocation());
if (r == null) {
RPLang.sendMessage(player, "cmdmanager.region.todo.that");
return cmdr;
}
if (args.length == 2) {
if (RedProtect.get().cfgs.getBool("flags-configuration.change-flag-delay.enable")) {
if (RedProtect.get().cfgs.getStringList("flags-configuration.change-flag-delay.flags").contains(args[1])) {
if (!RedProtect.get().changeWait.contains(r.getName() + args[1])) {
RPUtil.startFlagChanger(r.getName(), args[1], player);
handleFlag(player, args[1], "", r);
return cmdr;
} else {
RPLang.sendMessage(player, RPLang.get("gui.needwait.tochange").replace("{seconds}", RedProtect.get().cfgs.getString("flags-configuration.change-flag-delay.seconds")));
return cmdr;
}
}
}
handleFlag(player, args[1], "", r);
return cmdr;
}
if (args.length >= 3) {
String text = "";
for (int i = 2; i < args.length; i++) {
text = text + " " + args[i];
}
if (RedProtect.get().cfgs.getBool("flags-configuration.change-flag-delay.enable")) {
if (RedProtect.get().cfgs.getStringList("flags-configuration.change-flag-delay.flags").contains(args[1])) {
if (!RedProtect.get().changeWait.contains(r.getName() + args[1])) {
RPUtil.startFlagChanger(r.getName(), args[1], player);
handleFlag(player, args[1], text.substring(1), r);
return cmdr;
} else {
RPLang.sendMessage(player, RPLang.get("gui.needwait.tochange").replace("{seconds}", RedProtect.get().cfgs.getString("flags-configuration.change-flag-delay.seconds")));
return cmdr;
}
}
}
handleFlag(player, args[1], text.substring(1), r);
return cmdr;
}
RPLang.sendMessage(player, RPLang.get("correct.usage") + " " + RPLang.get("cmdmanager.help.flag").replace("{cmd}", getCmd("flag")).replace("{alias}", getCmdAlias("flag")));
return cmdr;
}
if (checkCmd(args[0], "list")) {
// rp list
if (args.length == 1) {
handleList(player, RPUtil.PlayerToUUID(player.getName()), 1);
return cmdr;
}
// rp list [player]
if (args.length == 2) {
handleList(player, RPUtil.PlayerToUUID(args[1]), 1);
return cmdr;
}
// rp list [player] [page]
if (args.length == 3) {
try {
int Page = Integer.parseInt(args[2]);
handleList(player, RPUtil.PlayerToUUID(args[1]), Page);
return cmdr;
} catch (NumberFormatException e) {
RPLang.sendMessage(player, "cmdmanager.region.listpage.error");
return cmdr;
}
}
}
RPLang.sendMessage(player, RPLang.get("correct.command") + " &e/rp " + getCmd("help"));
return cmdr;
}
Aggregations