diff --git a/Testing/UDSPlugin1.jar b/Testing/UDSPlugin1.jar index 19703d0..3293c08 100644 Binary files a/Testing/UDSPlugin1.jar and b/Testing/UDSPlugin1.jar differ diff --git a/src/com/undeadscythes/udsplugin/PlayerCommandExecutor.java b/src/com/undeadscythes/udsplugin/PlayerCommandExecutor.java index 2afc34d..0c69dac 100644 --- a/src/com/undeadscythes/udsplugin/PlayerCommandExecutor.java +++ b/src/com/undeadscythes/udsplugin/PlayerCommandExecutor.java @@ -15,6 +15,7 @@ */ public abstract class PlayerCommandExecutor implements CommandExecutor { private SaveablePlayer player; + private String commandName; private int argsLength; /** @@ -23,14 +24,11 @@ public abstract class PlayerCommandExecutor implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(sender instanceof Player) { + commandName = command.getName(); player = UDSPlugin.getOnlinePlayers().get(sender.getName()); - if(hasPerm(Perm.valueOf(command.getName().toUpperCase()))) { - if(args.length == 1 && args[0].equals("help")) { - player.performCommand("help " + command.getName()); - } else { - argsLength = args.length; - playerExecute(player, args); - } + if(hasPerm(Perm.valueOf(commandName.toUpperCase()))) { + argsLength = args.length; + playerExecute(player, args); } return true; } else { @@ -92,6 +90,57 @@ public Region getShop() { } + public void subCmdHelp(String[] args) { + if(args.length == 1 && args[0].equalsIgnoreCase("help")) { + sendHelp(1); + } else if(args.length == 2 && args[0].equalsIgnoreCase("help") && args[1].matches("[0-9][0-9]*")) { + sendHelp(Integer.parseInt(args[1])); + } else { + subCmdHelp(); + } + } + + public void subCmdHelp() { + player.sendMessage(Color.ERROR + "That command is not recognized."); + sendHelp(1); + } + + public boolean numArgsHelp(int num) { + if(argsLength == num) { + return true; + } else { + numArgsHelpX(); + return false; + } + } + + public boolean minArgsHelp(int num) { + if(argsLength >= num) { + return true; + } else { + numArgsHelpX(); + return false; + } + } + + public boolean maxArgsHelp(int num) { + if(argsLength <= num) { + return true; + } else { + numArgsHelpX(); + return false; + } + } + + public void numArgsHelpX() { + player.sendMessage(Color.ERROR + "You have made an error using this command."); + sendHelp(1); + } + + public void sendHelp(int page) { + player.performCommand("help " + commandName + " " + page); + } + public boolean canRequest(SaveablePlayer target) { if(noRequests(target) && notIgnored(target)) { return true; @@ -753,63 +802,6 @@ public boolean notIgnored(SaveablePlayer target) { } } - /** - * Checks that the command has the correct number of arguments. - * @param length Number of arguments required. - * @return true if there are sufficient arguments, false if there are too few or too many. - */ - public boolean argsEq(int length) { - if(argsLength == length) { - return true; - } else { - player.sendMessage(Message.WRONG_NUM_ARGS); - return false; - } - } - - /** - * Checks that the command has the correct number of arguments. - * @param max Maximum number of arguments. - * @return true if there aren't too many arguments, false otherwise. - */ - public boolean argsLessEq(int max) { - if(argsLength <= max) { - return true; - } else { - player.sendMessage(Message.WRONG_NUM_ARGS); - return false; - } - } - - /** - * Checks that the command has the correct number of arguments. - * @param min Minimum number of arguments. - * @return true if there aren't enough arguments, false otherwise. - */ - public boolean argsMoreEq(int min) { - if(argsLength >= min) { - return true; - } else { - player.sendMessage(Message.WRONG_NUM_ARGS); - return false; - } - } - - /** - * Checks that the command has the correct number of arguments. - * @param min Minimum number of arguments. - * @param max Maximum number of arguments. - * @return true if there the right number of arguments, false otherwise. - */ - public boolean argsMoreLessInc(int min, int max) { - if(argsLength >= min && argsLength <= max) { - return true; - } else { - player.sendMessage(Message.WRONG_NUM_ARGS); - return false; - } - } - /** * Checks to see if a string is a positive number. * @param number String to check. diff --git a/src/com/undeadscythes/udsplugin/commands/AcceptRulesCmd.java b/src/com/undeadscythes/udsplugin/commands/AcceptRulesCmd.java index bc68f5a..99d4f53 100644 --- a/src/com/undeadscythes/udsplugin/commands/AcceptRulesCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/AcceptRulesCmd.java @@ -5,7 +5,7 @@ import org.bukkit.*; /** - * Lets a player get build rights and promotes them to member. + * Lets a player get build rights and promotes them to member. Ignores extra arguments. * @author UndeadScythes */ public class AcceptRulesCmd extends PlayerCommandExecutor { @@ -14,7 +14,7 @@ public class AcceptRulesCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(canAfford(Config.BUILD_COST) && argsEq(0)) { + if(canAfford(Config.BUILD_COST)) { player.setRank(PlayerRank.MEMBER); player.debit(Config.BUILD_COST); Bukkit.broadcastMessage(Color.BROADCAST + player.getDisplayName() + " has accepted the rules."); diff --git a/src/com/undeadscythes/udsplugin/commands/BackCmd.java b/src/com/undeadscythes/udsplugin/commands/BackCmd.java index 956b0ef..585b558 100644 --- a/src/com/undeadscythes/udsplugin/commands/BackCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/BackCmd.java @@ -12,10 +12,8 @@ public class BackCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - if(!player.quietTeleport(player.getBack())) { - player.sendMessage(Color.ERROR + "You can't teleport back at this time."); - } + if(!player.quietTeleport(player.getBack())) { + player.sendMessage(Color.ERROR + "You can't teleport back at this time."); } } diff --git a/src/com/undeadscythes/udsplugin/commands/BanCmd.java b/src/com/undeadscythes/udsplugin/commands/BanCmd.java index 75bb5a5..53f67aa 100644 --- a/src/com/undeadscythes/udsplugin/commands/BanCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/BanCmd.java @@ -15,7 +15,7 @@ public class BanCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsMoreEq(1) && (target = getMatchingOtherPlayer(args[0])) != null) { + if(minArgsHelp(1) && (target = getMatchingOtherPlayer(args[0])) != null) { String message = "You have been banned for breaking the rules."; if(args.length > 1) { message = StringUtils.join(args, " ", 1, args.length - 1); diff --git a/src/com/undeadscythes/udsplugin/commands/BountyCmd.java b/src/com/undeadscythes/udsplugin/commands/BountyCmd.java index 8ba5d1d..9668295 100644 --- a/src/com/undeadscythes/udsplugin/commands/BountyCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/BountyCmd.java @@ -14,19 +14,17 @@ public class BountyCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(2)) { - int bounty; - int page; - SaveablePlayer target; - if(args.length == 0) { - sendPage(1, player); - } else if(args.length == 1 && (page = parseInt(args[0])) != -1) { - sendPage(page, player); - } else if(args.length == 2 && (target = getMatchingOtherPlayer(args[0])) != null && (bounty = getAffordablePrice(args[1])) != -1) { - player.debit(bounty); - target.addBounty(bounty); - Bukkit.broadcastMessage(Color.BROADCAST + player.getDisplayName() + " placed a bounty on " + target.getDisplayName() + "."); - } + int bounty; + int page; + SaveablePlayer target; + if(args.length == 0) { + sendPage(1, player); + } else if(args.length == 1 && (page = parseInt(args[0])) != -1) { + sendPage(page, player); + } else if(numArgsHelp(2) && (target = getMatchingOtherPlayer(args[0])) != null && (bounty = getAffordablePrice(args[1])) != -1) { + player.debit(bounty); + target.addBounty(bounty); + Bukkit.broadcastMessage(Color.BROADCAST + player.getDisplayName() + " placed a bounty on " + target.getDisplayName() + "."); } } diff --git a/src/com/undeadscythes/udsplugin/commands/BroadcastCmd.java b/src/com/undeadscythes/udsplugin/commands/BroadcastCmd.java index 192da55..cdb768d 100644 --- a/src/com/undeadscythes/udsplugin/commands/BroadcastCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/BroadcastCmd.java @@ -14,7 +14,7 @@ public class BroadcastCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreEq(1)) { + if(minArgsHelp(1)) { Bukkit.broadcastMessage(Color.BROADCAST + StringUtils.join(args, " ")); } } diff --git a/src/com/undeadscythes/udsplugin/commands/ButcherCmd.java b/src/com/undeadscythes/udsplugin/commands/ButcherCmd.java index 8debd43..f33cbfc 100644 --- a/src/com/undeadscythes/udsplugin/commands/ButcherCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/ButcherCmd.java @@ -13,7 +13,7 @@ public class ButcherCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(1)) { + if(maxArgsHelp(1)) { boolean all = false; if(args.length == 1 && (args[0].equals("a") || args[0].equals("all"))) { all = true; diff --git a/src/com/undeadscythes/udsplugin/commands/CallCmd.java b/src/com/undeadscythes/udsplugin/commands/CallCmd.java index 5593596..81bc5e8 100644 --- a/src/com/undeadscythes/udsplugin/commands/CallCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/CallCmd.java @@ -13,7 +13,7 @@ public class CallCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsEq(1) && (target = getMatchingOtherOnlinePlayer(args[0])) != null && canRequest(target) && notJailed(target) && canTP()) { + if(numArgsHelp(1) && (target = getMatchingOtherOnlinePlayer(args[0])) != null && canRequest(target) && notJailed(target) && canTP()) { UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.TP, "", target)); player.sendMessage(Message.REQUEST_SENT); target.sendMessage(Color.MESSAGE + player.getName() + " wishes to teleport to you."); diff --git a/src/com/undeadscythes/udsplugin/commands/ChallengeCmd.java b/src/com/undeadscythes/udsplugin/commands/ChallengeCmd.java index 6b9e779..1ccaa5e 100644 --- a/src/com/undeadscythes/udsplugin/commands/ChallengeCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/ChallengeCmd.java @@ -14,7 +14,7 @@ public class ChallengeCmd extends PlayerCommandExecutor { public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; int wager; - if(notJailed() && argsEq(2) && (target = getMatchingPlayer(args[0])) != null && isOnline(target) && notJailed(target) && (wager = parseInt(args[1])) != -1 && canAfford(wager) && noRequests(target) && notDueling(target) && notSelf(target)) { + if(numArgsHelp(2) && notJailed() && (target = getMatchingPlayer(args[0])) != null && isOnline(target) && notJailed(target) && (wager = parseInt(args[1])) != -1 && canAfford(wager) && noRequests(target) && notDueling(target) && notSelf(target)) { UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.PVP, wager, target)); target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has challenged you to a duel for " + wager + " credits."); target.sendMessage(Message.REQUEST_Y_N); diff --git a/src/com/undeadscythes/udsplugin/commands/CheckCmd.java b/src/com/undeadscythes/udsplugin/commands/CheckCmd.java index 13718bd..a125cfe 100644 --- a/src/com/undeadscythes/udsplugin/commands/CheckCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/CheckCmd.java @@ -12,6 +12,8 @@ public class CheckCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - player.quietTeleport(player.getCheckPoint()); + if(!player.quietTeleport(player.getCheckPoint())) { + player.sendMessage(Color.ERROR + "You do not currently have a checkpoint set."); + } } } diff --git a/src/com/undeadscythes/udsplugin/commands/CiCmd.java b/src/com/undeadscythes/udsplugin/commands/CiCmd.java index 7f0117a..a234e10 100644 --- a/src/com/undeadscythes/udsplugin/commands/CiCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/CiCmd.java @@ -12,9 +12,7 @@ public class CiCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - player.getInventory().clear(-1, -1); - player.sendMessage(Color.MESSAGE + "Inventory cleared."); - } + player.getInventory().clear(-1, -1); + player.sendMessage(Color.MESSAGE + "Inventory cleared."); } } diff --git a/src/com/undeadscythes/udsplugin/commands/CityCmd.java b/src/com/undeadscythes/udsplugin/commands/CityCmd.java index e95e599..7791576 100644 --- a/src/com/undeadscythes/udsplugin/commands/CityCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/CityCmd.java @@ -15,59 +15,63 @@ public class CityCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(1, 3)) { - Region city; - if(args.length == 1) { - if(args[0].equals("set") && (city = getCurrentRegion()).getType() == Region.RegionType.CITY && getMunicipality(city.getName()) != null) { - city.setWarp(player.getLocation()); - player.sendMessage(Color.MESSAGE + "City spawn point set."); - } else if(args[0].equals("list")) { - sendPage(1, player); + Region city; + if(args.length == 1) { + if(args[0].equals("set") && (city = getCurrentRegion()).getType() == Region.RegionType.CITY && getMunicipality(city.getName()) != null) { + city.setWarp(player.getLocation()); + player.sendMessage(Color.MESSAGE + "City spawn point set."); + } else if(args[0].equals("list")) { + sendPage(1, player); + } else { + subCmdHelp(args); + } + } else if(args.length == 2) { + int page; + if(args[0].equals("new") && canAfford(Config.CITY_COST) && noCensor(args[1]) && notRegion(args[1])) { + Vector min = player.getLocation().add(-100, 0, -100).toVector().setY(0); + Vector max = player.getLocation().add(100, 0, 100).toVector().setY(player.getWorld().getMaxHeight()); + city = new Region(args[1], min, max, player.getLocation(), player, "", Region.RegionType.CITY); + if(noOverlaps(city)) { + player.debit(Config.CITY_COST); + UDSPlugin.getRegions().put(args[1], city); + UDSPlugin.getCities().put(args[1], city); + city.placeMoreMarkers(); + city.placeTowers(); + player.sendMessage(Color.MESSAGE + "City founded."); + Bukkit.broadcastMessage(Color.BROADCAST + player.getDisplayName() + " has just founded " + args[1] + "."); + } + } else if(args[0].equals("leave") && (city = getMatchingCity(args[1])) != null) { + if(city.delMember(player)) { + player.sendMessage(Color.MESSAGE + "You have left " + city.getName() + "."); + } else { + player.sendMessage(Color.ERROR + "You are not a citizen of " + city.getName() + "."); } - } else if(args.length == 2) { - int page; - if(args[0].equals("new") && canAfford(Config.CITY_COST) && noCensor(args[1]) && notRegion(args[1])) { - Vector min = player.getLocation().add(-100, 0, -100).toVector().setY(0); - Vector max = player.getLocation().add(100, 0, 100).toVector().setY(player.getWorld().getMaxHeight()); - city = new Region(args[1], min, max, player.getLocation(), player, "", Region.RegionType.CITY); - if(noOverlaps(city)) { - player.debit(Config.CITY_COST); - UDSPlugin.getRegions().put(args[1], city); - UDSPlugin.getCities().put(args[1], city); - city.placeMoreMarkers(); - city.placeTowers(); - player.sendMessage(Color.MESSAGE + "City founded."); - Bukkit.broadcastMessage(Color.BROADCAST + player.getDisplayName() + " has just founded " + args[1] + "."); - } - } else if(args[0].equals("leave") && (city = getMatchingCity(args[1])) != null) { - if(city.delMember(player)) { - player.sendMessage(Color.MESSAGE + "You have left " + city.getName() + "."); - } else { - player.sendMessage(Color.ERROR + "You are not a citizen of " + city.getName() + "."); - } - } else if(args[0].equals("warp") && (city = getMatchingCity(args[1])) != null && notJailed() && notPinned()) { - player.quietTeleport(city.getWarp()); - } else if(args[0].equals("list") && (page = parseInt(args[1])) != -1) { - sendPage(page, player); + } else if(args[0].equals("warp") && (city = getMatchingCity(args[1])) != null && notJailed() && notPinned()) { + player.quietTeleport(city.getWarp()); + } else if(args[0].equals("list") && (page = parseInt(args[1])) != -1) { + sendPage(page, player); + } else { + subCmdHelp(args); + } + } else if(numArgsHelp(3)) { + SaveablePlayer target; + if(args[0].equals("invite") && (city = getMunicipality(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { + if(city.addMember(target)) { + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " was added as a citizen of " + city.getName() + "."); + target.sendMessage(Color.MESSAGE + "You have been added as a citizen of " + city.getName()); + } else { + player.sendMessage(Color.ERROR + target.getDisplayName() + " is already a citizen of " + city.getName() + "."); } - } else if(args.length == 3) { - SaveablePlayer target; - if(args[0].equals("invite") && (city = getMunicipality(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { - if(city.addMember(target)) { - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " was added as a citizen of " + city.getName() + "."); - target.sendMessage(Color.MESSAGE + "You have been added as a citizen of " + city.getName()); - } else { - player.sendMessage(Color.ERROR + target.getDisplayName() + " is already a citizen of " + city.getName() + "."); - } - } else if(args[0].equals("banish") && (city = getMunicipality(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { - if(city.delMember(target)) { - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been banished from " + city.getName() + "."); - target.sendMessage(Color.MESSAGE + "You have been banished from " + city.getName() + "."); - target.quietTeleport(city.getWarp()); - } else { - player.sendMessage(Color.ERROR + target.getDisplayName() + " is not a citizen of " + city.getName() + "."); - } + } else if(args[0].equals("banish") && (city = getMunicipality(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { + if(city.delMember(target)) { + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been banished from " + city.getName() + "."); + target.sendMessage(Color.MESSAGE + "You have been banished from " + city.getName() + "."); + target.quietTeleport(city.getWarp()); + } else { + player.sendMessage(Color.ERROR + target.getDisplayName() + " is not a citizen of " + city.getName() + "."); } + } else { + subCmdHelp(); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/ClanCmd.java b/src/com/undeadscythes/udsplugin/commands/ClanCmd.java index 779bcbe..ddbdb16 100644 --- a/src/com/undeadscythes/udsplugin/commands/ClanCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/ClanCmd.java @@ -16,145 +16,149 @@ public class ClanCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(1, 3)) { - Clan clan; - Region base; - SaveablePlayer target; - if(args.length == 1) { - if(args[0].equals("base") && (clan = getClan()) != null && (base = getBase(clan)) != null && notJailed() && notPinned()) { - player.teleport(base.getWarp()); - } else if(args[0].equals("leave") && (clan = getClan()) != null) { - if(clan.delMember(player)) { - if((base = UDSPlugin.getBases().get(clan.getName() + "base")) != null) { - base.delMember(player); - } - clan.sendMessage(player.getDisplayName() + " has left the clan."); - } else { - UDSPlugin.getClans().remove(clan.getName()); - UDSPlugin.getBases().remove(clan.getName() + "base"); - UDSPlugin.getRegions().remove(clan.getName() + "base"); - Bukkit.broadcastMessage(Color.BROADCAST + clan.getName() + " no longer exists as all members have left."); - } - player.setClan(null); - player.sendMessage(Color.MESSAGE + "You have left " + clan.getName()); - } else if(args[0].equals("members") && (clan = getClan()) != null) { - String members = ""; - for(SaveablePlayer member : clan.getMembers()) { - if(!member.equals(player)) { - members = members.concat(member.getDisplayName() + ", "); - } - } - if(!clan.getLeader().equals(player)) { - player.sendMessage(Color.MESSAGE + "Your clan leader is " + clan.getLeader() + "."); - } - if(!members.isEmpty()) { - player.sendMessage(Color.MESSAGE + "Your fellow clan members are:"); - player.sendMessage(Color.TEXT + members.substring(0, members.length() - 2)); - } else { - player.sendMessage(Color.MESSAGE + "Your clan has no other members."); + Clan clan; + Region base; + SaveablePlayer target; + if(args.length == 1) { + if(args[0].equals("base") && (clan = getClan()) != null && (base = getBase(clan)) != null && notJailed() && notPinned()) { + player.teleport(base.getWarp()); + } else if(args[0].equals("leave") && (clan = getClan()) != null) { + if(clan.delMember(player)) { + if((base = UDSPlugin.getBases().get(clan.getName() + "base")) != null) { + base.delMember(player); } - } else if(args[0].equals("list")) { - sendPage(1, player); - } else if(args[0].equals("disband") && (clan = getClan()) != null && isLeader(clan)) { - Bukkit.broadcastMessage(Color.BROADCAST + clan.getName() + " has been disbanded."); + clan.sendMessage(player.getDisplayName() + " has left the clan."); + } else { UDSPlugin.getClans().remove(clan.getName()); - clan.sendMessage("Your clan has been disbanded."); - for(SaveablePlayer member : clan.getMembers()) { - member.setClan(null); - } UDSPlugin.getBases().remove(clan.getName() + "base"); - } else if(args[0].equals("stats") && (clan = getClan()) != null) { - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - player.sendMessage(Color.MESSAGE + clan.getName() + "'s stats:"); - player.sendMessage(Color.ITEM + "Members: " + Color.TEXT + clan.getMembers().size()); - player.sendMessage(Color.ITEM + "Kills: " + Color.TEXT + clan.getKills()); - player.sendMessage(Color.ITEM + "Deaths: " + Color.TEXT + clan.getDeaths()); - player.sendMessage(Color.ITEM + "KDR: " + Color.TEXT + decimalFormat.format(clan.getRatio())); + UDSPlugin.getRegions().remove(clan.getName() + "base"); + Bukkit.broadcastMessage(Color.BROADCAST + clan.getName() + " no longer exists as all members have left."); } - } else if(args.length == 2) { - int page; - if(args[0].equals("new") && isClanless() && canAfford(Config.CLAN_COST) && noCensor(args[1]) && notClan(args[1])) { - player.debit(Config.CLAN_COST); - clan = new Clan(args[1], player); - player.setClan(clan); - UDSPlugin.getClans().put(args[1], clan); - Bukkit.broadcastMessage(Color.BROADCAST + player.getDisplayName() + " just created " + args[1] + "."); - } else if(args[0].equals("invite") && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && (clan = getClan()) != null && isLeader(clan) && notSelf(target)) { - UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.CLAN, clan.getName(), target)); - player.sendMessage(Message.REQUEST_SENT); - target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has invited you to join " + clan.getName() + "."); - target.sendMessage(Message.REQUEST_Y_N); - } else if(args[0].equals("kick") && (target = getMatchingPlayer(args[1])) != null && (clan = getClan()) != null && isInClan(target, clan)) { - clan.delMember(target); - target.setClan(null); - if((base = UDSPlugin.getBases().get(clan.getName() + "base")) != null) { - base.delMember(target); - } - target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has kicked you out of " + clan.getName() + "."); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been kicked out of your clan."); - clan.sendMessage(target.getDisplayName() + " has left the clan."); - } else if(args[0].equals("members") && (clan = getClan(args[1])) != null) { - String members = ""; - for(SaveablePlayer member : clan.getMembers()) { + player.setClan(null); + player.sendMessage(Color.MESSAGE + "You have left " + clan.getName()); + } else if(args[0].equals("members") && (clan = getClan()) != null) { + String members = ""; + for(SaveablePlayer member : clan.getMembers()) { + if(!member.equals(player)) { members = members.concat(member.getDisplayName() + ", "); } - player.sendMessage(Color.MESSAGE + clan.getName() + "'s leader is " + clan.getLeader() + "."); - player.sendMessage(Color.MESSAGE + clan.getName() + "'s members are:"); + } + if(!clan.getLeader().equals(player)) { + player.sendMessage(Color.MESSAGE + "Your clan leader is " + clan.getLeader() + "."); + } + if(!members.isEmpty()) { + player.sendMessage(Color.MESSAGE + "Your fellow clan members are:"); player.sendMessage(Color.TEXT + members.substring(0, members.length() - 2)); - } else if(args[0].equals("list") && (page = parseInt(args[1])) != -1) { - sendPage(page, player); - } else if(args[0].equals("stats") && (clan = getClan(args[1])) != null) { - DecimalFormat decimalFormat = new DecimalFormat("#.##"); - player.sendMessage(Color.MESSAGE + clan.getName() + "'s stats:"); - player.sendMessage(Color.ITEM + "Members: " + Color.TEXT + clan.getMembers().size()); - player.sendMessage(Color.ITEM + "Kills: " + Color.TEXT + clan.getKills()); - player.sendMessage(Color.ITEM + "Deaths: " + Color.TEXT + clan.getDeaths()); - player.sendMessage(Color.ITEM + "KDR: " + Color.TEXT + decimalFormat.format(clan.getRatio())); - } else if(args[0].equals("rename") && (clan = getClan()) != null && isLeader(clan) && noCensor(args[1]) && notClan(args[1]) && canAfford(Config.CLAN_COST)) { - player.debit(Config.CLAN_COST); - UDSPlugin.getClans().remove(clan.getName()); - if((base = UDSPlugin.getBases().remove(clan.getName() + "base")) != null) { - UDSPlugin.getRegions().remove(clan.getName() + "base"); - base.rename(args[1] + "base"); - UDSPlugin.getRegions().put(args[1] + "base", base); - UDSPlugin.getBases().put(args[1] + "base", base); - } - clan.rename(args[1]); - UDSPlugin.getClans().put(args[1], clan); - clan.sendMessage("Your clan has been renamed " + args[1] + "."); - Bukkit.broadcastMessage(Color.BROADCAST + player.getDisplayName() + " has rebranded their clan as " + args[1] + "."); - } else if(args[0].equals("owner") && (clan = getClan()) != null && isLeader(clan) && (target = getMatchingPlayer(args[1])) != null && isInClan(target, clan)) { - clan.changeLeader(target); - clan.sendMessage("Your new leader is " + target.getDisplayName()); - if(target.isOnline()) { - target.sendMessage(Color.MESSAGE + "You are the new leader of " + clan.getName()); - } - player.sendMessage(Color.MESSAGE + "You have resigned as leader of " + clan.getName()); - } else if(args[0].equals("base") && (clan = getClan()) != null && isLeader(clan)) { - if(args[1].equals("make") && noBase(clan) && canAfford(Config.BASE_COST)) { - Vector min = player.getLocation().add(-25, 0, -25).toVector().setY(20); - Vector max = player.getLocation().add(25, 0, 25).toVector().setY(220); - base = new Region(clan.getName() + "base", min, max, player.getLocation(), null, "", Region.RegionType.BASE); - if(noOverlaps(base)) { - player.debit(Config.BASE_COST); - UDSPlugin.getRegions().put(base.getName(), base); - UDSPlugin.getBases().put(base.getName(), base); - base.placeMoreMarkers(); - base.placeTowers(); - clan.sendMessage("Your clan base has just been set up. Use /clan base to teleport to it."); - for(SaveablePlayer member : clan.getMembers()) { - base.addMember(member); - } + } else { + player.sendMessage(Color.MESSAGE + "Your clan has no other members."); + } + } else if(args[0].equals("list")) { + sendPage(1, player); + } else if(args[0].equals("disband") && (clan = getClan()) != null && isLeader(clan)) { + Bukkit.broadcastMessage(Color.BROADCAST + clan.getName() + " has been disbanded."); + UDSPlugin.getClans().remove(clan.getName()); + clan.sendMessage("Your clan has been disbanded."); + for(SaveablePlayer member : clan.getMembers()) { + member.setClan(null); + } + UDSPlugin.getBases().remove(clan.getName() + "base"); + } else if(args[0].equals("stats") && (clan = getClan()) != null) { + DecimalFormat decimalFormat = new DecimalFormat("#.##"); + player.sendMessage(Color.MESSAGE + clan.getName() + "'s stats:"); + player.sendMessage(Color.ITEM + "Members: " + Color.TEXT + clan.getMembers().size()); + player.sendMessage(Color.ITEM + "Kills: " + Color.TEXT + clan.getKills()); + player.sendMessage(Color.ITEM + "Deaths: " + Color.TEXT + clan.getDeaths()); + player.sendMessage(Color.ITEM + "KDR: " + Color.TEXT + decimalFormat.format(clan.getRatio())); + } else { + subCmdHelp(args); + } + } else if(numArgsHelp(2)) { + int page; + if(args[0].equals("new") && isClanless() && canAfford(Config.CLAN_COST) && noCensor(args[1]) && notClan(args[1])) { + player.debit(Config.CLAN_COST); + clan = new Clan(args[1], player); + player.setClan(clan); + UDSPlugin.getClans().put(args[1], clan); + Bukkit.broadcastMessage(Color.BROADCAST + player.getDisplayName() + " just created " + args[1] + "."); + } else if(args[0].equals("invite") && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && (clan = getClan()) != null && isLeader(clan) && notSelf(target)) { + UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.CLAN, clan.getName(), target)); + player.sendMessage(Message.REQUEST_SENT); + target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has invited you to join " + clan.getName() + "."); + target.sendMessage(Message.REQUEST_Y_N); + } else if(args[0].equals("kick") && (target = getMatchingPlayer(args[1])) != null && (clan = getClan()) != null && isInClan(target, clan)) { + clan.delMember(target); + target.setClan(null); + if((base = UDSPlugin.getBases().get(clan.getName() + "base")) != null) { + base.delMember(target); + } + target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has kicked you out of " + clan.getName() + "."); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been kicked out of your clan."); + clan.sendMessage(target.getDisplayName() + " has left the clan."); + } else if(args[0].equals("members") && (clan = getClan(args[1])) != null) { + String members = ""; + for(SaveablePlayer member : clan.getMembers()) { + members = members.concat(member.getDisplayName() + ", "); + } + player.sendMessage(Color.MESSAGE + clan.getName() + "'s leader is " + clan.getLeader() + "."); + player.sendMessage(Color.MESSAGE + clan.getName() + "'s members are:"); + player.sendMessage(Color.TEXT + members.substring(0, members.length() - 2)); + } else if(args[0].equals("list") && (page = parseInt(args[1])) != -1) { + sendPage(page, player); + } else if(args[0].equals("stats") && (clan = getClan(args[1])) != null) { + DecimalFormat decimalFormat = new DecimalFormat("#.##"); + player.sendMessage(Color.MESSAGE + clan.getName() + "'s stats:"); + player.sendMessage(Color.ITEM + "Members: " + Color.TEXT + clan.getMembers().size()); + player.sendMessage(Color.ITEM + "Kills: " + Color.TEXT + clan.getKills()); + player.sendMessage(Color.ITEM + "Deaths: " + Color.TEXT + clan.getDeaths()); + player.sendMessage(Color.ITEM + "KDR: " + Color.TEXT + decimalFormat.format(clan.getRatio())); + } else if(args[0].equals("rename") && (clan = getClan()) != null && isLeader(clan) && noCensor(args[1]) && notClan(args[1]) && canAfford(Config.CLAN_COST)) { + player.debit(Config.CLAN_COST); + UDSPlugin.getClans().remove(clan.getName()); + if((base = UDSPlugin.getBases().remove(clan.getName() + "base")) != null) { + UDSPlugin.getRegions().remove(clan.getName() + "base"); + base.rename(args[1] + "base"); + UDSPlugin.getRegions().put(args[1] + "base", base); + UDSPlugin.getBases().put(args[1] + "base", base); + } + clan.rename(args[1]); + UDSPlugin.getClans().put(args[1], clan); + clan.sendMessage("Your clan has been renamed " + args[1] + "."); + Bukkit.broadcastMessage(Color.BROADCAST + player.getDisplayName() + " has rebranded their clan as " + args[1] + "."); + } else if(args[0].equals("owner") && (clan = getClan()) != null && isLeader(clan) && (target = getMatchingPlayer(args[1])) != null && isInClan(target, clan)) { + clan.changeLeader(target); + clan.sendMessage("Your new leader is " + target.getDisplayName()); + if(target.isOnline()) { + target.sendMessage(Color.MESSAGE + "You are the new leader of " + clan.getName()); + } + player.sendMessage(Color.MESSAGE + "You have resigned as leader of " + clan.getName()); + } else if(args[0].equals("base") && (clan = getClan()) != null && isLeader(clan)) { + if(args[1].equals("make") && noBase(clan) && canAfford(Config.BASE_COST)) { + Vector min = player.getLocation().add(-25, 0, -25).toVector().setY(20); + Vector max = player.getLocation().add(25, 0, 25).toVector().setY(220); + base = new Region(clan.getName() + "base", min, max, player.getLocation(), null, "", Region.RegionType.BASE); + if(noOverlaps(base)) { + player.debit(Config.BASE_COST); + UDSPlugin.getRegions().put(base.getName(), base); + UDSPlugin.getBases().put(base.getName(), base); + base.placeMoreMarkers(); + base.placeTowers(); + clan.sendMessage("Your clan base has just been set up. Use /clan base to teleport to it."); + for(SaveablePlayer member : clan.getMembers()) { + base.addMember(member); } - } else if(args[1].equals("clear") && (base = getBase(clan)) != null) { - UDSPlugin.getRegions().remove(base.getName()); - UDSPlugin.getBases().remove(base.getName()); - clan.sendMessage("Your clan base has been removed."); - } else if(args[1].equals("set") && (base = getBase(clan)) != null) { - base.setWarp(player.getLocation()); - player.sendMessage(Color.MESSAGE + "Clan base warp point set."); } + } else if(args[1].equals("clear") && (base = getBase(clan)) != null) { + UDSPlugin.getRegions().remove(base.getName()); + UDSPlugin.getBases().remove(base.getName()); + clan.sendMessage("Your clan base has been removed."); + } else if(args[1].equals("set") && (base = getBase(clan)) != null) { + base.setWarp(player.getLocation()); + player.sendMessage(Color.MESSAGE + "Clan base warp point set."); + } else { + subCmdHelp(args); } + } else { + subCmdHelp(); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/DayCmd.java b/src/com/undeadscythes/udsplugin/commands/DayCmd.java index 950d16d..f316d88 100644 --- a/src/com/undeadscythes/udsplugin/commands/DayCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/DayCmd.java @@ -12,9 +12,7 @@ public class DayCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - player.getWorld().setTime(0); - player.sendMessage(Color.MESSAGE + "Summoning the sun."); - } + player.getWorld().setTime(0); + player.sendMessage(Color.MESSAGE + "Summoning the sun."); } } diff --git a/src/com/undeadscythes/udsplugin/commands/DelWarpCmd.java b/src/com/undeadscythes/udsplugin/commands/DelWarpCmd.java index 8f417bd..c2f2e35 100644 --- a/src/com/undeadscythes/udsplugin/commands/DelWarpCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/DelWarpCmd.java @@ -13,7 +13,7 @@ public class DelWarpCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { Warp warp; - if(argsEq(1) && (warp = getWarp(args[0])) != null) { + if(numArgsHelp(1) && (warp = getWarp(args[0])) != null) { UDSPlugin.getWarps().remove(warp.getName()); player.sendMessage(Color.MESSAGE + "Warp removed."); } diff --git a/src/com/undeadscythes/udsplugin/commands/DemoteCmd.java b/src/com/undeadscythes/udsplugin/commands/DemoteCmd.java index e8afe7b..977c78d 100644 --- a/src/com/undeadscythes/udsplugin/commands/DemoteCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/DemoteCmd.java @@ -1,7 +1,7 @@ package com.undeadscythes.udsplugin.commands; -import com.undeadscythes.udsplugin.SaveablePlayer.PlayerRank; import com.undeadscythes.udsplugin.*; +import com.undeadscythes.udsplugin.SaveablePlayer.PlayerRank; /** * Demote a player by a single rank. @@ -14,7 +14,7 @@ public class DemoteCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsEq(1) && (target = getMatchingPlayer(args[0])) != null && notSelf(target)) { + if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null && notSelf(target)) { PlayerRank rank; if((rank = target.demote()) != null) { player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been demoted to " + rank.toString() + "."); diff --git a/src/com/undeadscythes/udsplugin/commands/EnchantCmd.java b/src/com/undeadscythes/udsplugin/commands/EnchantCmd.java index c983e92..2bcfeba 100644 --- a/src/com/undeadscythes/udsplugin/commands/EnchantCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/EnchantCmd.java @@ -13,22 +13,20 @@ public class EnchantCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(0, 2)) { - int level; - Enchantment enchantment; - if(args.length == 0) { - sendPage(1, player); - } else if(args.length == 1) { - if(args[0].matches("[0-9][0-9]*")) { - sendPage(Integer.parseInt(args[0]), player); - } else { - if((enchantment = getEnchantment(args[0])) != null) { - player.getItemInHand().addEnchantment(enchantment, enchantment.getMaxLevel()); - } + int level; + Enchantment enchantment; + if(args.length == 0) { + sendPage(1, player); + } else if(args.length == 1) { + if(args[0].matches("[0-9][0-9]*")) { + sendPage(Integer.parseInt(args[0]), player); + } else { + if((enchantment = getEnchantment(args[0])) != null) { + player.getItemInHand().addEnchantment(enchantment, enchantment.getMaxLevel()); } - } else if((enchantment = getEnchantment(args[0])) != null && (level = parseInt(args[1])) != 0 && goodEnchantLevel(enchantment, level) && canEnchant(enchantment, player.getItemInHand())) { - player.getItemInHand().addEnchantment(enchantment, level); } + } else if(numArgsHelp(2) && (enchantment = getEnchantment(args[0])) != null && (level = parseInt(args[1])) != 0 && goodEnchantLevel(enchantment, level) && canEnchant(enchantment, player.getItemInHand())) { + player.getItemInHand().addEnchantment(enchantment, level); } } diff --git a/src/com/undeadscythes/udsplugin/commands/FaceCmd.java b/src/com/undeadscythes/udsplugin/commands/FaceCmd.java index 2df46a9..3d38426 100644 --- a/src/com/undeadscythes/udsplugin/commands/FaceCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/FaceCmd.java @@ -13,15 +13,13 @@ public class FaceCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(1)) { - Bearing.Direction direction; - if(args.length == 0) { - player.sendMessage(Color.MESSAGE + "You are facing " + Bearing.Direction.valueOf(player.getLocation()).toString() + "."); - } else if((direction = getDirection(args[0])) != null) { - Location location = player.getLocation(); - location.setYaw(direction.getYaw()); - player.teleport(location); - } + Bearing.Direction direction; + if(args.length == 0) { + player.sendMessage(Color.MESSAGE + "You are facing " + Bearing.Direction.valueOf(player.getLocation()).toString() + "."); + } else if(numArgsHelp(1) && (direction = getDirection(args[0])) != null) { + Location location = player.getLocation(); + location.setYaw(direction.getYaw()); + player.teleport(location); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/GiftCmd.java b/src/com/undeadscythes/udsplugin/commands/GiftCmd.java index e3cf38e..e21abf6 100644 --- a/src/com/undeadscythes/udsplugin/commands/GiftCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/GiftCmd.java @@ -16,7 +16,7 @@ public class GiftCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsMoreEq(1) && (target = getMatchingPlayer(args[0])) != null) { + if(minArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null) { ItemStack gift = player.getItemInHand().clone(); if(notAirHand()) { String message = Color.MESSAGE + "[Gifting Service] You have recieved a free gift!"; diff --git a/src/com/undeadscythes/udsplugin/commands/GodCmd.java b/src/com/undeadscythes/udsplugin/commands/GodCmd.java index d188db1..30320e6 100644 --- a/src/com/undeadscythes/udsplugin/commands/GodCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/GodCmd.java @@ -12,14 +12,12 @@ public class GodCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(1)) { - SaveablePlayer target; - if(args.length == 0) { - player.sendMessage(Color.MESSAGE + "You now have god mode " + (player.toggleGodMode() ? "en" : "dis") + "abled."); - } else if((target = getMatchingOtherPlayer(args[0])) != null) { - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " now has god mode " + (target.toggleGodMode() ? "en" : "dis") + "abled."); - target.sendMessage(Color.MESSAGE + "You now have god mode " + (target.hasGodMode() ? "en" : "dis") + "abled."); - } + SaveablePlayer target; + if(args.length == 0) { + player.sendMessage(Color.MESSAGE + "You now have god mode " + (player.toggleGodMode() ? "en" : "dis") + "abled."); + } else if(numArgsHelp(1) && (target = getMatchingOtherPlayer(args[0])) != null) { + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " now has god mode " + (target.toggleGodMode() ? "en" : "dis") + "abled."); + target.sendMessage(Color.MESSAGE + "You now have god mode " + (target.hasGodMode() ? "en" : "dis") + "abled."); } } diff --git a/src/com/undeadscythes/udsplugin/commands/HealCmd.java b/src/com/undeadscythes/udsplugin/commands/HealCmd.java index a053f5d..cb38e1a 100644 --- a/src/com/undeadscythes/udsplugin/commands/HealCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/HealCmd.java @@ -12,20 +12,18 @@ public class HealCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(1)) { - SaveablePlayer target; - String message = Color.MESSAGE + "You have been healed."; - if(args.length == 0) { - player.setHealth(player.getMaxHealth()); - player.setFoodLevel(20); - player.sendMessage(message); - } else if((target = getMatchingPlayer(args[0])) != null) { - target.setHealth(player.getMaxHealth()); - target.sendMessage(message); - target.setFoodLevel(20); - if(!player.equals(target)) { - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been healed."); - } + SaveablePlayer target; + String message = Color.MESSAGE + "You have been healed."; + if(args.length == 0) { + player.setHealth(player.getMaxHealth()); + player.setFoodLevel(20); + player.sendMessage(message); + } else if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null) { + target.setHealth(player.getMaxHealth()); + target.sendMessage(message); + target.setFoodLevel(20); + if(!player.equals(target)) { + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been healed."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/HelpCmd.java b/src/com/undeadscythes/udsplugin/commands/HelpCmd.java index 0609c02..7fadf90 100644 --- a/src/com/undeadscythes/udsplugin/commands/HelpCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/HelpCmd.java @@ -211,7 +211,7 @@ public String cmd() { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(2)) { + if(maxArgsHelp(2)) { if(args.length == 0 || (args.length == 1 && args[0].matches("[0-9][0-9]*"))) { TreeSet usages = new TreeSet(); for(Usage usage : Usage.values()) { diff --git a/src/com/undeadscythes/udsplugin/commands/HomeCmd.java b/src/com/undeadscythes/udsplugin/commands/HomeCmd.java index 2322edf..414482d 100644 --- a/src/com/undeadscythes/udsplugin/commands/HomeCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/HomeCmd.java @@ -15,97 +15,99 @@ public class HomeCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(0, 3)) { - Region home; - SaveablePlayer target; - int price; - if(args.length == 0 && (home = getHome()) != null && notJailed() && notPinned()) { - player.teleport(home.getWarp()); - } else if(args.length == 1) { - if(args[0].equals("make") && canAfford(Config.HOME_COST) && noHome()) { - Vector min = player.getLocation().add(-10, 28, -10).toVector(); - Vector max = player.getLocation().add(10, 12, 10).toVector(); - home = new Region(player.getName() + "home", min, max, player.getLocation(), player, "", Region.RegionType.HOME); - if(noOverlaps(home)) { - player.debit(Config.HOME_COST); - UDSPlugin.getRegions().put(home.getName(), home); - UDSPlugin.getHomes().put(home.getName(), home); - home.placeCornerMarkers(); - player.sendMessage(Color.MESSAGE + "Home area protected."); + Region home; + SaveablePlayer target; + int price; + if(args.length == 0 && (home = getHome()) != null && notJailed() && notPinned()) { + player.teleport(home.getWarp()); + } else if(args.length == 1) { + if(args[0].equals("make") && canAfford(Config.HOME_COST) && noHome()) { + Vector min = player.getLocation().add(-10, 28, -10).toVector(); + Vector max = player.getLocation().add(10, 12, 10).toVector(); + home = new Region(player.getName() + "home", min, max, player.getLocation(), player, "", Region.RegionType.HOME); + if(noOverlaps(home)) { + player.debit(Config.HOME_COST); + UDSPlugin.getRegions().put(home.getName(), home); + UDSPlugin.getHomes().put(home.getName(), home); + home.placeCornerMarkers(); + player.sendMessage(Color.MESSAGE + "Home area protected."); + } + } else if(args[0].equals("clear") && (home = getHome()) != null) { + UDSPlugin.getRegions().remove(home.getName()); + UDSPlugin.getHomes().remove(home.getName()); + player.sendMessage(Color.MESSAGE + "Home protection removed."); + } else if(args[0].equals("set") && (home = getHome()) != null) { + home.setWarp(player.getLocation()); + player.sendMessage(Color.MESSAGE + "Home warp point set."); + } else if(args[0].equals("roomies")) { + String message = ""; + for(Region otherHome : UDSPlugin.getHomes().values()) { + if(otherHome.hasMember(player)) { + message = message.concat(otherHome.getOwner().getDisplayName() + ", "); } - } else if(args[0].equals("clear") && (home = getHome()) != null) { - UDSPlugin.getRegions().remove(home.getName()); - UDSPlugin.getHomes().remove(home.getName()); - player.sendMessage(Color.MESSAGE + "Home protection removed."); - } else if(args[0].equals("set") && (home = getHome()) != null) { - home.setWarp(player.getLocation()); - player.sendMessage(Color.MESSAGE + "Home warp point set."); - } else if(args[0].equals("roomies")) { - String message = ""; - for(Region otherHome : UDSPlugin.getHomes().values()) { - if(otherHome.hasMember(player)) { - message = message.concat(otherHome.getOwner().getDisplayName() + ", "); - } - if(!message.isEmpty()) { - player.sendMessage(Color.MESSAGE + "You are room mates with:"); - player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); - } - message = ""; - if((home = UDSPlugin.getHomes().get(player.getName() + "home")) != null) { - for(SaveablePlayer member : home.getMembers()) { - message = message.concat(member.getDisplayName() + ", "); - } - } - if(!message.equals("")) { - player.sendMessage(Color.MESSAGE + "Your room mates are:"); - player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); - } else { - player.sendMessage(Color.MESSAGE + "You have no room mates."); + if(!message.isEmpty()) { + player.sendMessage(Color.MESSAGE + "You are room mates with:"); + player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); + } + message = ""; + if((home = UDSPlugin.getHomes().get(player.getName() + "home")) != null) { + for(SaveablePlayer member : home.getMembers()) { + message = message.concat(member.getDisplayName() + ", "); } } - } else if(args[0].equals("lock") && (home = getHome()) != null) { - home.setFlag(RegionFlag.LOCK); - player.sendMessage(Color.MESSAGE + "Your home is now locked."); - } else if(args[0].equals("unlock") && (home = getHome()) != null) { - home.setFlag(RegionFlag.LOCK); - home.toggleFlag(RegionFlag.LOCK); - player.sendMessage(Color.MESSAGE + "Your home is now unlocked."); - } else if((target = getMatchingPlayer(args[0])) != null && (home = getHome(target)) != null && (isRoomie(home) || hasPerm(Perm.HOME_OTHER)) && notJailed() && notPinned()) { - player.teleport(home.getWarp()); - } - } else if(args.length == 2) { - Direction direction; - if(args[0].equals("expand") && (home = getHome()) != null && canAfford(Config.EXPAND_COST) && (direction = getCardinalDirection(args[1])) != null) { - home.expand(direction, 1); - if(noOverlaps(home)) { - player.debit(Config.EXPAND_COST); - player.sendMessage(Color.MESSAGE + "Your home ahs been expanded."); + if(!message.equals("")) { + player.sendMessage(Color.MESSAGE + "Your room mates are:"); + player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); } else { - home.expand(direction, -1); - } - } else if(args[0].equals("boot") && (home = getHome()) != null && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && isInHome(target, home)) { - target.teleport(player.getWorld().getSpawnLocation()); - target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has booted you from their home."); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been booted."); - } else if(args[0].equals("add") && (target = getMatchingPlayer(args[1])) != null && (home = getHome()) != null) { - home.addMember(target); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been added as your room mate."); - if(target.isOnline()) { - target.sendMessage(Color.MESSAGE + "You have been added as " + player.getDisplayName() + "'s room mate."); - } - } else if(args[0].equals("kick") && (target = getMatchingPlayer(args[1])) != null && (home = getHome()) != null && isRoomie(target, home)) { - home.delMember(target); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " is no longer your room mate."); - if(target.isOnline()) { - target.sendMessage(Color.MESSAGE + "You are no longer " + player.getDisplayName() + "'s room mate."); + player.sendMessage(Color.MESSAGE + "You have no room mates."); } } - } else if(args[0].equals("sell") && (getHome()) != null && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && (price = parseInt(args[2])) != -1) { - player.sendMessage(Message.REQUEST_SENT); - target.sendMessage(Color.MESSAGE + player.getDisplayName() + " wants to sell you their house for " + price + " " + Config.CURRENCIES + "."); - target.sendMessage(Message.REQUEST_Y_N); - UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.HOME, price, target)); + } else if(args[0].equals("lock") && (home = getHome()) != null) { + home.setFlag(RegionFlag.LOCK); + player.sendMessage(Color.MESSAGE + "Your home is now locked."); + } else if(args[0].equals("unlock") && (home = getHome()) != null) { + home.setFlag(RegionFlag.LOCK); + home.toggleFlag(RegionFlag.LOCK); + player.sendMessage(Color.MESSAGE + "Your home is now unlocked."); + } else if((target = getMatchingPlayer(args[0])) != null && (home = getHome(target)) != null && (isRoomie(home) || hasPerm(Perm.HOME_OTHER)) && notJailed() && notPinned()) { + player.teleport(home.getWarp()); + } else { + subCmdHelp(args); + } + } else if(args.length == 2) { + Direction direction; + if(args[0].equals("expand") && (home = getHome()) != null && canAfford(Config.EXPAND_COST) && (direction = getCardinalDirection(args[1])) != null) { + home.expand(direction, 1); + if(noOverlaps(home)) { + player.debit(Config.EXPAND_COST); + player.sendMessage(Color.MESSAGE + "Your home ahs been expanded."); + } else { + home.expand(direction, -1); + } + } else if(args[0].equals("boot") && (home = getHome()) != null && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && isInHome(target, home)) { + target.teleport(player.getWorld().getSpawnLocation()); + target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has booted you from their home."); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been booted."); + } else if(args[0].equals("add") && (target = getMatchingPlayer(args[1])) != null && (home = getHome()) != null) { + home.addMember(target); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been added as your room mate."); + if(target.isOnline()) { + target.sendMessage(Color.MESSAGE + "You have been added as " + player.getDisplayName() + "'s room mate."); + } + } else if(args[0].equals("kick") && (target = getMatchingPlayer(args[1])) != null && (home = getHome()) != null && isRoomie(target, home)) { + home.delMember(target); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " is no longer your room mate."); + if(target.isOnline()) { + target.sendMessage(Color.MESSAGE + "You are no longer " + player.getDisplayName() + "'s room mate."); + } + } else { + subCmdHelp(args); } + } else if(numArgsHelp(3) && args[0].equals("sell") && (getHome()) != null && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && (price = parseInt(args[2])) != -1) { + player.sendMessage(Message.REQUEST_SENT); + target.sendMessage(Color.MESSAGE + player.getDisplayName() + " wants to sell you their house for " + price + " " + Config.CURRENCIES + "."); + target.sendMessage(Message.REQUEST_Y_N); + UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.HOME, price, target)); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/ICmd.java b/src/com/undeadscythes/udsplugin/commands/ICmd.java index 98fb0f3..a5b3454 100644 --- a/src/com/undeadscythes/udsplugin/commands/ICmd.java +++ b/src/com/undeadscythes/udsplugin/commands/ICmd.java @@ -13,7 +13,7 @@ public class ICmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(1, 2)) { + if(minArgsHelp(1) && maxArgsHelp(2)) { ItemStack item; if((item = getItem(args[0])) != null) { int amount; @@ -26,7 +26,7 @@ public void playerExecute(SaveablePlayer player, String[] args) { if(player.hasPermission(Perm.I_ADMIN)) { player.getInventory().addItem(item); } else if(player.getVIPSpawns() > 0) { - if(Config.WHITELIST.contains(item.getTypeId())) { + if(Config.WHITELIST.contains(item.getType())) { if(item.getAmount() > player.getVIPSpawns()) { item.setAmount(player.getVIPSpawns()); } diff --git a/src/com/undeadscythes/udsplugin/commands/IgnoreCmd.java b/src/com/undeadscythes/udsplugin/commands/IgnoreCmd.java index a4d1bc7..83ebe3b 100644 --- a/src/com/undeadscythes/udsplugin/commands/IgnoreCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/IgnoreCmd.java @@ -1,7 +1,7 @@ package com.undeadscythes.udsplugin.commands; -import com.undeadscythes.udsplugin.SaveablePlayer.PlayerRank; import com.undeadscythes.udsplugin.*; +import com.undeadscythes.udsplugin.SaveablePlayer.PlayerRank; /** * Let's a player ignore other players in public chat. @@ -14,7 +14,7 @@ public class IgnoreCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsEq(1) && (target = getMatchingPlayer(args[0])) != null && notSelf(target)) { + if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null && notSelf(target)) { if(target.getRank().compareTo(PlayerRank.WARDEN) < 0) { if(player.ignorePlayer(target)) { player.sendMessage(Color.MESSAGE + "you are now ignoring " + target.getDisplayName() + "."); diff --git a/src/com/undeadscythes/udsplugin/commands/InvSeeCmd.java b/src/com/undeadscythes/udsplugin/commands/InvSeeCmd.java index 20f99ef..1a7e0b0 100644 --- a/src/com/undeadscythes/udsplugin/commands/InvSeeCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/InvSeeCmd.java @@ -13,27 +13,25 @@ public class InvSeeCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsLessEq(1)) { - if(args.length == 0) { - if(player.getInventoryCopy() != null) { - player.loadInventory(); - player.loadArmor(); - player.sendMessage(Color.MESSAGE + "Your inventory has been restored."); - } else { - player.sendMessage(Color.ERROR + "You have no saved inventory."); - } - } else if((target = getMatchingPlayer(args[0])) != null && isOnline(target) && notSelf(target)) { - if(player.getInventoryCopy() == null) { - player.saveInventory(); - player.saveArmor(); - player.getInventory().setContents(target.getInventory().getContents()); - player.getInventory().setArmorContents(target.getInventory().getArmorContents()); - } else { - player.getInventory().setContents(target.getInventory().getContents()); - player.getInventory().setArmorContents(target.getInventory().getArmorContents()); - } - player.sendMessage(Color.MESSAGE + "You now have a copy of " + target.getDisplayName() + "'s inventory."); + if(args.length == 0) { + if(player.getInventoryCopy() != null) { + player.loadInventory(); + player.loadArmor(); + player.sendMessage(Color.MESSAGE + "Your inventory has been restored."); + } else { + player.sendMessage(Color.ERROR + "You have no saved inventory."); } + } else if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null && isOnline(target) && notSelf(target)) { + if(player.getInventoryCopy() == null) { + player.saveInventory(); + player.saveArmor(); + player.getInventory().setContents(target.getInventory().getContents()); + player.getInventory().setArmorContents(target.getInventory().getArmorContents()); + } else { + player.getInventory().setContents(target.getInventory().getContents()); + player.getInventory().setArmorContents(target.getInventory().getArmorContents()); + } + player.sendMessage(Color.MESSAGE + "You now have a copy of " + target.getDisplayName() + "'s inventory."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/JailCmd.java b/src/com/undeadscythes/udsplugin/commands/JailCmd.java index d6dd908..9c943de 100644 --- a/src/com/undeadscythes/udsplugin/commands/JailCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/JailCmd.java @@ -15,17 +15,19 @@ public class JailCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsMoreLessInc(1, 3) && (target = getMatchingPlayer(args[0])) != null && isOnline(target) && notSelf(target) && notJailed(target)) { - long sentence = 5; - int bail = 1000; - if(args.length > 1 && (sentence = parseInt(args[1])) != -1) { - if(args.length > 2 && (bail = parseInt(args[2])) != -1) { - target.sendMessage(Color.MESSAGE + "You have been jailed for breaking the rules."); - try { - target.jail(sentence, bail); - Bukkit.broadcastMessage(Color.BROADCAST + target.getDisplayName() + " has been jailed for breaking the rules."); - } catch (IOException ex) { - player.sendMessage(Color.ERROR + "There is no 'jailin' warp point " + target.getDisplayName() + " is wandering free."); + if(minArgsHelp(1) && maxArgsHelp(3)) { + if((target = getMatchingPlayer(args[0])) != null && isOnline(target) && notSelf(target) && notJailed(target)) { + long sentence = 5; + int bail = 1000; + if(args.length > 1 && (sentence = parseInt(args[1])) != -1) { + if(args.length > 2 && (bail = parseInt(args[2])) != -1) { + target.sendMessage(Color.MESSAGE + "You have been jailed for breaking the rules."); + try { + target.jail(sentence, bail); + Bukkit.broadcastMessage(Color.BROADCAST + target.getDisplayName() + " has been jailed for breaking the rules."); + } catch (IOException ex) { + player.sendMessage(Color.ERROR + "There is no 'jailin' warp point " + target.getDisplayName() + " is wandering free."); + } } } } diff --git a/src/com/undeadscythes/udsplugin/commands/KickCmd.java b/src/com/undeadscythes/udsplugin/commands/KickCmd.java index 96048f3..dc71e1a 100644 --- a/src/com/undeadscythes/udsplugin/commands/KickCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/KickCmd.java @@ -1,7 +1,7 @@ package com.undeadscythes.udsplugin.commands; -import com.undeadscythes.udsplugin.SaveablePlayer.PlayerRank; import com.undeadscythes.udsplugin.*; +import com.undeadscythes.udsplugin.SaveablePlayer.PlayerRank; import org.apache.commons.lang.*; import org.bukkit.*; @@ -16,10 +16,10 @@ public class KickCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsMoreEq(1) && (target = getMatchingPlayer(args[0])) != null && isOnline(target)) { + if(minArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null && isOnline(target)) { if(target.getRank().compareTo(PlayerRank.MOD) < 0) { String message = "You have been kicked for breaking the rules."; - if(args.length > 1) { + if(args.length >= 2) { message = StringUtils.join(args, " ", 1, args.length - 1); } target.getWorld().strikeLightningEffect(target.getLocation()); diff --git a/src/com/undeadscythes/udsplugin/commands/KitCmd.java b/src/com/undeadscythes/udsplugin/commands/KitCmd.java index 595327f..d475a23 100644 --- a/src/com/undeadscythes/udsplugin/commands/KitCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/KitCmd.java @@ -13,30 +13,28 @@ public class KitCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(0, 1)) { - if(args.length == 0) { - player.sendMessage(Color.MESSAGE + "--- Available Kits ---"); - for(Kit kit : Config.KITS) { - String contents = ""; - for(ItemStack item : kit.getItems()) { - contents = contents.concat(item.getType().toString().toLowerCase().replace("_", " ") + ", "); - } - player.sendMessage(Color.ITEM + kit.getName() + " (" + kit.getPrice() + "): " + Color.TEXT + contents.substring(0, contents.length() - 2)); + if(args.length == 0) { + player.sendMessage(Color.MESSAGE + "--- Available Kits ---"); + for(Kit kit : Config.KITS) { + String contents = ""; + for(ItemStack item : kit.getItems()) { + contents = contents.concat(item.getType().toString().toLowerCase().replace("_", " ") + ", "); } - } else { - boolean given = false; - for(Kit kit : Config.KITS) { - if(kit.getName().equalsIgnoreCase(args[0]) && canAfford(kit.getPrice())) { - for(ItemStack item : kit.getItems()) { - player.giveAndDrop(item); - } - player.debit(kit.getPrice()); - given = true; + player.sendMessage(Color.ITEM + kit.getName() + " (" + kit.getPrice() + "): " + Color.TEXT + contents.substring(0, contents.length() - 2)); + } + } else if(numArgsHelp(1)) { + boolean given = false; + for(Kit kit : Config.KITS) { + if(kit.getName().equalsIgnoreCase(args[0]) && canAfford(kit.getPrice())) { + for(ItemStack item : kit.getItems()) { + player.giveAndDrop(item); } + player.debit(kit.getPrice()); + given = true; } - if(!given) { - player.sendMessage(Color.ERROR + "No kit found by that name."); - } + } + if(!given) { + player.sendMessage(Color.ERROR + "No kit found by that name."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/LockdownCmd.java b/src/com/undeadscythes/udsplugin/commands/LockdownCmd.java index 32857fc..023d8ac 100644 --- a/src/com/undeadscythes/udsplugin/commands/LockdownCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/LockdownCmd.java @@ -12,15 +12,13 @@ public class LockdownCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(1)) { - SaveablePlayer target; - if(args.length == 0) { - UDSPlugin.serverInLockdown ^= true; - player.sendMessage(Color.MESSAGE + "The server is " + (UDSPlugin.serverInLockdown ? "now" : "no longer") + " in lockdown."); - } else if((target = getMatchingPlayer(args[0])) != null) { - target.toggleLockdownPass(); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + (target.hasLockdownPass() ? " now" : " no longer") + " has a lockdown pass."); - } + SaveablePlayer target; + if(args.length == 0) { + UDSPlugin.serverInLockdown ^= true; + player.sendMessage(Color.MESSAGE + "The server is " + (UDSPlugin.serverInLockdown ? "now" : "no longer") + " in lockdown."); + } else if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null) { + target.toggleLockdownPass(); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + (target.hasLockdownPass() ? " now" : " no longer") + " has a lockdown pass."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/MapCmd.java b/src/com/undeadscythes/udsplugin/commands/MapCmd.java index f0f378e..ccb3d0f 100644 --- a/src/com/undeadscythes/udsplugin/commands/MapCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/MapCmd.java @@ -14,7 +14,7 @@ public class MapCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0) && canAfford(Config.MAP_COST)) { + if(canAfford(Config.MAP_COST)) { player.giveAndDrop(new ItemStack(Material.MAP, 1, (short)0, Config.MAP_DATA)); } } diff --git a/src/com/undeadscythes/udsplugin/commands/MeCmd.java b/src/com/undeadscythes/udsplugin/commands/MeCmd.java index 3f98ba4..c1ac5b9 100644 --- a/src/com/undeadscythes/udsplugin/commands/MeCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/MeCmd.java @@ -15,7 +15,7 @@ public class MeCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { String action = StringUtils.join(args, " "); - if(argsMoreEq(1) && noCensor(action)) { + if(minArgsHelp(2) && noCensor(action)) { Bukkit.broadcastMessage(Color.TEXT + "*" + player.getDisplayName() + " " + action); } } diff --git a/src/com/undeadscythes/udsplugin/commands/MoneyCmd.java b/src/com/undeadscythes/udsplugin/commands/MoneyCmd.java index d1b0a9d..a7d91b3 100644 --- a/src/com/undeadscythes/udsplugin/commands/MoneyCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/MoneyCmd.java @@ -15,51 +15,53 @@ public class MoneyCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsMoreLessInc(0, 3)) { - if(args.length == 0) { - player.sendMessage(Color.MESSAGE + "You have " + player.getMoney() + " credits."); - } else if(args.length == 1) { - if(args[0].equals("prices")) { - player.sendMessage(Color.MESSAGE + "--- Server Prices ---"); - player.sendMessage(Color.ITEM + "Build rights: " + Color.TEXT + Config.BUILD_COST + " " + Config.CURRENCIES); - player.sendMessage(Color.ITEM + "Map of spawn: " + Color.TEXT + Config.MAP_COST + " " + Config.CURRENCIES); - player.sendMessage(Color.ITEM + "Home protection: " + Color.TEXT + Config.HOME_COST + " " + Config.CURRENCIES); - player.sendMessage(Color.ITEM + "City shop: " + Color.TEXT + Config.SHOP_COST + " " + Config.CURRENCIES); - player.sendMessage(Color.ITEM + "VIP rank: " + Color.TEXT + Config.VIP_COST + " " + Config.CURRENCIES); - player.sendMessage(Color.ITEM + "Clan cost: " + Color.TEXT + Config.CLAN_COST + " " + Config.CURRENCIES); - player.sendMessage(Color.ITEM + "Clan base cost: " + Color.TEXT + Config.BASE_COST + " " + Config.CURRENCIES); - player.sendMessage(Color.ITEM + "City cost: " + Color.TEXT + Config.CITY_COST + " " + Config.CURRENCIES); - } else if(args[0].equals("rank")) { - ArrayList players = UDSPlugin.getPlayers().getSortedValues(new SortByMoney()); - int printed = 0; - player.sendMessage(Color.MESSAGE + "Top 5 Richest Players:"); - for(SaveablePlayer ranker : players) { - if(printed < 5 && ranker.getRank().compareTo(PlayerRank.MOD) < 0) { - player.sendMessage(Color.TEXT.toString() + (printed + 1) + ": " + ranker.getRank().color() + ranker.getDisplayName() + ", " + Color.TEXT + ranker.getMoney() + " " + Config.CURRENCIES); - printed++; - } + if(args.length == 0) { + player.sendMessage(Color.MESSAGE + "You have " + player.getMoney() + " credits."); + } else if(args.length == 1) { + if(args[0].equals("prices")) { + player.sendMessage(Color.MESSAGE + "--- Server Prices ---"); + player.sendMessage(Color.ITEM + "Build rights: " + Color.TEXT + Config.BUILD_COST + " " + Config.CURRENCIES); + player.sendMessage(Color.ITEM + "Map of spawn: " + Color.TEXT + Config.MAP_COST + " " + Config.CURRENCIES); + player.sendMessage(Color.ITEM + "Home protection: " + Color.TEXT + Config.HOME_COST + " " + Config.CURRENCIES); + player.sendMessage(Color.ITEM + "City shop: " + Color.TEXT + Config.SHOP_COST + " " + Config.CURRENCIES); + player.sendMessage(Color.ITEM + "VIP rank: " + Color.TEXT + Config.VIP_COST + " " + Config.CURRENCIES); + player.sendMessage(Color.ITEM + "Clan cost: " + Color.TEXT + Config.CLAN_COST + " " + Config.CURRENCIES); + player.sendMessage(Color.ITEM + "Clan base cost: " + Color.TEXT + Config.BASE_COST + " " + Config.CURRENCIES); + player.sendMessage(Color.ITEM + "City cost: " + Color.TEXT + Config.CITY_COST + " " + Config.CURRENCIES); + } else if(args[0].equals("rank")) { + ArrayList players = UDSPlugin.getPlayers().getSortedValues(new SortByMoney()); + int printed = 0; + player.sendMessage(Color.MESSAGE + "Top 5 Richest Players:"); + for(SaveablePlayer ranker : players) { + if(printed < 5 && ranker.getRank().compareTo(PlayerRank.MOD) < 0) { + player.sendMessage(Color.TEXT.toString() + (printed + 1) + ": " + ranker.getRank().color() + ranker.getDisplayName() + ", " + Color.TEXT + ranker.getMoney() + " " + Config.CURRENCIES); + printed++; } - int rank = players.indexOf(player); - if(rank > 5 && player.getRank().compareTo(PlayerRank.MOD) < 0) { - player.sendMessage(Color.MESSAGE + "Your rank is " + rank + "."); - } - } else if((target = getMatchingPlayer(args[0])) != null && notSelf(target) && hasPerm(Perm.MONEY_OTHER)) { - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has " + target.getMoney() + " " + Config.CURRENCIES + "."); } - } else if(args.length == 3) { - int amount; - if(args[0].equals("set") && hasPerm(Perm.MONEY_ADMIN) && (target = getMatchingPlayer(args[1])) != null && (amount = parseInt(args[2])) != -1) { - target.setMoney(amount); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + "'s account has been set to " + amount + " " + Config.CURRENCIES + "."); - } else if(args[0].equals("grant") && hasPerm(Perm.MONEY_ADMIN) && (target = getMatchingPlayer(args[1])) != null && (amount = parseInt(args[2])) != -1) { - target.credit(amount); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + "'s account has been credited " + amount + " " + Config.CURRENCIES + "."); - } else if(args[0].equals("pay") && (target = getMatchingPlayer(args[1])) != null && (amount = parseInt(args[2])) != -1 && canAfford(amount) && notSelf(target)) { - target.credit(amount); - player.debit(amount); - player.sendMessage(Color.MESSAGE.toString() + amount + " " + Config.CURRENCIES + " have been sent to " + target.getDisplayName() + "."); - target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has just paid you " + amount + " " + Config.CURRENCIES + "."); + int rank = players.indexOf(player); + if(rank > 5 && player.getRank().compareTo(PlayerRank.MOD) < 0) { + player.sendMessage(Color.MESSAGE + "Your rank is " + rank + "."); } + } else if((target = getMatchingPlayer(args[0])) != null && notSelf(target) && hasPerm(Perm.MONEY_OTHER)) { + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has " + target.getMoney() + " " + Config.CURRENCIES + "."); + } else { + subCmdHelp(args); + } + } else if(numArgsHelp(3)) { + int amount; + if(args[0].equals("set") && hasPerm(Perm.MONEY_ADMIN) && (target = getMatchingPlayer(args[1])) != null && (amount = parseInt(args[2])) != -1) { + target.setMoney(amount); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + "'s account has been set to " + amount + " " + Config.CURRENCIES + "."); + } else if(args[0].equals("grant") && hasPerm(Perm.MONEY_ADMIN) && (target = getMatchingPlayer(args[1])) != null && (amount = parseInt(args[2])) != -1) { + target.credit(amount); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + "'s account has been credited " + amount + " " + Config.CURRENCIES + "."); + } else if(args[0].equals("pay") && (target = getMatchingPlayer(args[1])) != null && (amount = parseInt(args[2])) != -1 && canAfford(amount) && notSelf(target)) { + target.credit(amount); + player.debit(amount); + player.sendMessage(Color.MESSAGE.toString() + amount + " " + Config.CURRENCIES + " have been sent to " + target.getDisplayName() + "."); + target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has just paid you " + amount + " " + Config.CURRENCIES + "."); + } else { + subCmdHelp(); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/NCmd.java b/src/com/undeadscythes/udsplugin/commands/NCmd.java index 0390411..4509bef 100644 --- a/src/com/undeadscythes/udsplugin/commands/NCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/NCmd.java @@ -13,7 +13,7 @@ public class NCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { Request request; - if(argsEq(0) && (request = getRequest()) != null) { + if((request = getRequest()) != null) { UDSPlugin.getRequests().remove(player.getName()); SaveablePlayer sender = UDSPlugin.getPlayers().get(request.getSender().getName()); if(sender.isOnline()) { diff --git a/src/com/undeadscythes/udsplugin/commands/NickCmd.java b/src/com/undeadscythes/udsplugin/commands/NickCmd.java index f0aea73..cf9a7b7 100644 --- a/src/com/undeadscythes/udsplugin/commands/NickCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/NickCmd.java @@ -12,20 +12,18 @@ public class NickCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(1, 2)) { - SaveablePlayer target; - if(args.length == 1 && noCensor(args[0])) { - if(player.getName().toLowerCase().contains(args[0].toLowerCase()) || hasPerm(Perm.NICK_OTHER)) { - player.setDisplayName(args[0]); - player.sendMessage(Color.MESSAGE + "Your nickname has been changed to " + args[0] + "."); - } else { - player.sendMessage(Color.ERROR + "Your nickname must be a shortened version of your Minecraft name."); - } - } else if(hasPerm(Perm.NICK_OTHER) && (target = getMatchingPlayer(args[0])) != null && noCensor(args[1])) { - target.setDisplayName(args[1]); - player.sendMessage(Color.MESSAGE + player.getName() + "'s nickname has been changed to " + args[1] + "."); - target.sendMessage(Color.MESSAGE + "Your nickname has been changed to " + args[1] + "."); + SaveablePlayer target; + if(args.length == 1 && noCensor(args[0])) { + if(player.getName().toLowerCase().contains(args[0].toLowerCase()) || hasPerm(Perm.NICK_OTHER)) { + player.setDisplayName(args[0]); + player.sendMessage(Color.MESSAGE + "Your nickname has been changed to " + args[0] + "."); + } else { + player.sendMessage(Color.ERROR + "Your nickname must be a shortened version of your Minecraft name."); } + } else if(numArgsHelp(2) && hasPerm(Perm.NICK_OTHER) && (target = getMatchingPlayer(args[0])) != null && noCensor(args[1])) { + target.setDisplayName(args[1]); + player.sendMessage(Color.MESSAGE + player.getName() + "'s nickname has been changed to " + args[1] + "."); + target.sendMessage(Color.MESSAGE + "Your nickname has been changed to " + args[1] + "."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/NightCmd.java b/src/com/undeadscythes/udsplugin/commands/NightCmd.java index b7b704f..c763b55 100644 --- a/src/com/undeadscythes/udsplugin/commands/NightCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/NightCmd.java @@ -12,10 +12,8 @@ public class NightCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - player.getWorld().setTime(14000); - player.sendMessage(Color.MESSAGE + "Summoning the moon."); - } + player.getWorld().setTime(14000); + player.sendMessage(Color.MESSAGE + "Summoning the moon."); } } diff --git a/src/com/undeadscythes/udsplugin/commands/PayBailCmd.java b/src/com/undeadscythes/udsplugin/commands/PayBailCmd.java index aff1c24..86c15fc 100644 --- a/src/com/undeadscythes/udsplugin/commands/PayBailCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/PayBailCmd.java @@ -12,7 +12,7 @@ public class PayBailCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0) && isJailed() && canAfford(player.getBail())) { + if(isJailed() && canAfford(player.getBail())) { player.debit(player.getBail()); player.sendMessage(Color.MESSAGE + "You have paid your bail."); player.release(); diff --git a/src/com/undeadscythes/udsplugin/commands/PetCmd.java b/src/com/undeadscythes/udsplugin/commands/PetCmd.java index 712a46d..8e94373 100644 --- a/src/com/undeadscythes/udsplugin/commands/PetCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/PetCmd.java @@ -14,26 +14,24 @@ public class PetCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(2, 3)) { - SaveablePlayer target; - UUID pet; - int price; - if(args.length == 2 && args[0].equals("give") && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && (pet = getSelectedPet()) != null) { - for(Entity entity : player.getWorld().getEntities()) { - if(entity.getUniqueId().equals(pet)) { - ((Tameable)entity).setOwner(target); - entity.teleport(target); - player.sendMessage(Color.MESSAGE + "Your pet has been sent to " + target.getDisplayName() + "."); - target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has just sent you a pet."); - break; - } + SaveablePlayer target; + UUID pet; + int price; + if(args.length == 2 && args[0].equals("give") && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && (pet = getSelectedPet()) != null) { + for(Entity entity : player.getWorld().getEntities()) { + if(entity.getUniqueId().equals(pet)) { + ((Tameable)entity).setOwner(target); + entity.teleport(target); + player.sendMessage(Color.MESSAGE + "Your pet has been sent to " + target.getDisplayName() + "."); + target.sendMessage(Color.MESSAGE + player.getDisplayName() + " has just sent you a pet."); + break; } - } else if(args[0].equals("sell") && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && getSelectedPet() != null && (price = parseInt(args[2])) != -1) { - UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.PET, price, target)); - player.sendMessage(Message.REQUEST_SENT); - target.sendMessage(Color.MESSAGE + player.getDisplayName() + " wants to sell their pet to you for " + price + " " + Config.CURRENCIES + "."); - target.sendMessage(Message.REQUEST_Y_N); } + } else if(numArgsHelp(3) && args[0].equals("sell") && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && getSelectedPet() != null && (price = parseInt(args[2])) != -1) { + UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.PET, price, target)); + player.sendMessage(Message.REQUEST_SENT); + target.sendMessage(Color.MESSAGE + player.getDisplayName() + " wants to sell their pet to you for " + price + " " + Config.CURRENCIES + "."); + target.sendMessage(Message.REQUEST_Y_N); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/PowertoolCmd.java b/src/com/undeadscythes/udsplugin/commands/PowertoolCmd.java index e5855ac..dbe67a9 100644 --- a/src/com/undeadscythes/udsplugin/commands/PowertoolCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/PowertoolCmd.java @@ -13,16 +13,14 @@ public class PowertoolCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreEq(1)) { - if(args.length > 0 && notAirHand()) { - player.setPowertoolID(player.getItemInHand().getTypeId()); - player.setPowertool(StringUtils.join(args, " ").replaceFirst("/", "")); - player.sendMessage(Color.MESSAGE + "Powertool set."); - } else { - player.setPowertoolID(0); - player.setPowertool(""); - player.sendMessage(Color.MESSAGE + "Powertool removed."); - } + if(args.length >= 1 && notAirHand()) { + player.setPowertoolID(player.getItemInHand().getTypeId()); + player.setPowertool(StringUtils.join(args, " ").replaceFirst("/", "")); + player.sendMessage(Color.MESSAGE + "Powertool set."); + } else { + player.setPowertoolID(0); + player.setPowertool(""); + player.sendMessage(Color.MESSAGE + "Powertool removed."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/PrivateCmd.java b/src/com/undeadscythes/udsplugin/commands/PrivateCmd.java index 9ddf472..6b284e2 100644 --- a/src/com/undeadscythes/udsplugin/commands/PrivateCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/PrivateCmd.java @@ -12,7 +12,7 @@ public class PrivateCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(1)) { + if(numArgsHelp(1)) { ChatRoom chatRoom = UDSPlugin.getChatRooms().get(args[0]); if(chatRoom == null) { UDSPlugin.getChatRooms().put(args[0], new ChatRoom(player, args[0])); diff --git a/src/com/undeadscythes/udsplugin/commands/PromoteCmd.java b/src/com/undeadscythes/udsplugin/commands/PromoteCmd.java index 6e65288..334ba1d 100644 --- a/src/com/undeadscythes/udsplugin/commands/PromoteCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/PromoteCmd.java @@ -1,7 +1,7 @@ package com.undeadscythes.udsplugin.commands; -import com.undeadscythes.udsplugin.SaveablePlayer.PlayerRank; import com.undeadscythes.udsplugin.*; +import com.undeadscythes.udsplugin.SaveablePlayer.PlayerRank; /** * Promote a player by a single rank. @@ -14,7 +14,7 @@ public class PromoteCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsEq(1) && (target = getMatchingPlayer(args[0])) != null && notSelf(target)) { + if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null && notSelf(target)) { PlayerRank rank; if(player.getRank().compareTo(target.getRank()) > 0 && (rank = target.promote()) != null) { player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been promoted to " + rank.toString() + "."); diff --git a/src/com/undeadscythes/udsplugin/commands/RCmd.java b/src/com/undeadscythes/udsplugin/commands/RCmd.java index bd6c37e..0ce3050 100644 --- a/src/com/undeadscythes/udsplugin/commands/RCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/RCmd.java @@ -14,7 +14,7 @@ public class RCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsMoreEq(1) && (target = getWhisperer()) != null && isOnline(target)) { + if(minArgsHelp(1) && (target = getWhisperer()) != null && isOnline(target)) { String message = player.getDisplayName() + " > " + target.getDisplayName() + ": " + StringUtils.join(args, " "); player.sendMessage(Color.WHISPER + message); target.sendMessage(Color.WHISPER + message); diff --git a/src/com/undeadscythes/udsplugin/commands/RainCmd.java b/src/com/undeadscythes/udsplugin/commands/RainCmd.java index 4c540d1..d0a0dc3 100644 --- a/src/com/undeadscythes/udsplugin/commands/RainCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/RainCmd.java @@ -12,17 +12,15 @@ public class RainCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(0,1)) { - int duration; - if(args.length == 0) { - player.getWorld().setStorm(true); - player.getWorld().setWeatherDuration(6000); - player.sendMessage(Color.MESSAGE + "5 minute storm on the way."); - } else if((duration = parseInt(args[0])) != -1) { - player.getWorld().setStorm(true); - player.getWorld().setWeatherDuration((int)(duration * Timer.MINUTE / Timer.TICKS)); - player.sendMessage(Color.MESSAGE.toString() + duration + " minute storm on the way."); - } + int duration; + if(args.length == 0) { + player.getWorld().setStorm(true); + player.getWorld().setWeatherDuration(6000); + player.sendMessage(Color.MESSAGE + "5 minute storm on the way."); + } else if(numArgsHelp(1) && (duration = parseInt(args[0])) != -1) { + player.getWorld().setStorm(true); + player.getWorld().setWeatherDuration((int)(duration * Timer.MINUTE / Timer.TICKS)); + player.sendMessage(Color.MESSAGE.toString() + duration + " minute storm on the way."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/RegionCmd.java b/src/com/undeadscythes/udsplugin/commands/RegionCmd.java index dd9a645..ccc89ab 100644 --- a/src/com/undeadscythes/udsplugin/commands/RegionCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/RegionCmd.java @@ -15,132 +15,136 @@ public class RegionCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(1, 4)) { - Session session; - Region region; - Region.RegionType type; - SaveablePlayer target; - RegionFlag flag; - if(args.length == 1) { - if(args[0].equals("vert") && (session = getSession()) != null && hasTwoPoints(session)) { - session.vert(); - player.sendMessage(Color.MESSAGE + "Region extended from bedrock to build limit."); - } else if(args[0].equals("list")) { - String list = ""; - for(Region test : UDSPlugin.getRegions().values()) { - if(test.getType().equals(RegionType.NORMAL)) { - list = list.concat(test.getName() + ", "); - } + Session session; + Region region; + Region.RegionType type; + SaveablePlayer target; + RegionFlag flag; + if(args.length == 1) { + if(args[0].equals("vert") && (session = getSession()) != null && hasTwoPoints(session)) { + session.vert(); + player.sendMessage(Color.MESSAGE + "Region extended from bedrock to build limit."); + } else if(args[0].equals("list")) { + String list = ""; + for(Region test : UDSPlugin.getRegions().values()) { + if(test.getType().equals(RegionType.NORMAL)) { + list = list.concat(test.getName() + ", "); } - if(!list.isEmpty()) { - player.sendMessage(Color.MESSAGE + RegionType.NORMAL.name().toLowerCase() + " Regions:"); - player.sendMessage(Color.TEXT + list.substring(0, list.length() - 2)); - } else { - player.sendMessage(Color.MESSAGE + "There are no " + RegionType.NORMAL.name().toLowerCase() + " regions."); - } - } else if(args[0].equals("flag")) { - player.sendMessage(Color.MESSAGE + "Available region flags:"); - String message = ""; - for(RegionFlag test : RegionFlag.values()) { - message = message.concat(test.name() + ", "); - } - player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); } - } else if(args.length == 2) { - if(args[0].equals("del") && (region = getRegion(args[1])) != null) { - UDSPlugin.getRegions().remove(region.getName()); - player.sendMessage(Color.MESSAGE + "Region deleted."); - } else if(args[0].equals("list") && (type = getRegionType(args[1])) != null) { - String list = ""; - for(Region test : UDSPlugin.getRegions().values()) { - if(test.getType().equals(type)) { - list = list.concat(test.getName() + ", "); - } - } - if(!list.isEmpty()) { - player.sendMessage(Color.MESSAGE + type.name().toLowerCase() + " Regions:"); - player.sendMessage(Color.TEXT + list.substring(0, list.length() - 2)); - } else { - player.sendMessage(Color.MESSAGE + "There are no " + type.name().toLowerCase() + " regions."); - } - } else if(args[0].equals("tp") && (region = getRegion(args[1])) != null) { - player.teleport(region.getWarp()); - } else if(args[0].equals("info") && (region = getRegion(args[1])) != null) { - player.sendMessage(Color.MESSAGE + "Region " + region.getName() + " info:"); - player.sendMessage(Color.TEXT + "Owner: " + region.getOwnerName()); - player.sendMessage(Color.TEXT + "Members: " + StringUtils.join(region.getMembers(), ", ")); - player.sendMessage(Color.TEXT + "Type: " + region.getType().toString()); - String flags = ""; - if(!region.getFlags().isEmpty()) { - for(RegionFlag test : region.getFlags()) { - flags = flags.concat(test.toString() + ", "); - } - } - if(!flags.isEmpty()) { - player.sendMessage(Color.TEXT + "Flags: " + flags.substring(0, flags.length() - 2)); - } - } else if(args[0].equals("reset") && (session = getSession()) != null && hasTwoPoints(session) && (region = getRegion(args[1])) != null) { - region.changeV(session.getV1(), session.getV2()); - player.sendMessage(Color.MESSAGE + "Region reset with new points."); - } else if(args[0].equals("select") && (region = getRegion(args[1])) != null) { - session = player.forceSession(); - session.setV1(region.getV1()); - session.setV2(region.getV2()); - player.sendMessage(Color.MESSAGE + "Points set. " + session.getVolume() + " blocks selected."); - } else if(args[0].equals("set") && (session = getSession()) != null && hasTwoPoints(session) && notRegion(args[1]) && noCensor(args[1])) { - region = new Region(args[1], session.getV1(), session.getV2(), player.getLocation(), null, "", RegionType.NORMAL); - UDSPlugin.getRegions().put(region.getName(), region); - player.sendMessage(Color.MESSAGE + "Region " + region.getName() + " set."); + if(!list.isEmpty()) { + player.sendMessage(Color.MESSAGE + RegionType.NORMAL.name().toLowerCase() + " Regions:"); + player.sendMessage(Color.TEXT + list.substring(0, list.length() - 2)); + } else { + player.sendMessage(Color.MESSAGE + "There are no " + RegionType.NORMAL.name().toLowerCase() + " regions."); + } + } else if(args[0].equals("flag")) { + player.sendMessage(Color.MESSAGE + "Available region flags:"); + String message = ""; + for(RegionFlag test : RegionFlag.values()) { + message = message.concat(test.name() + ", "); } - } else if(args.length == 3) { - if(args[0].equals("addmember") && (region = getRegion(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { - region.addMember(target); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " add to region " + region.getName() + "."); - } else if(args[0].equals("delmember") && (region = getRegion(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { - region.delMember(target); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " removed from region " + region.getName() + "."); - } else if(args[0].equals("owner") && (region = getRegion(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { - region.changeOwner(target); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " made owner of region " + region.getName() + "."); - } else if(args[0].equals("flag") && (region = getRegion(args[1])) != null && (flag = getFlag(args[2])) != null) { - player.sendMessage(Color.MESSAGE + region.getName() + " flag " + flag.toString() + " now set to " + region.toggleFlag(flag) + "."); - } else if(args[0].equals("rename") && (region = getRegion(args[1])) != null && noCensor(args[1]) && notRegion(args[2])) { - String oldName = region.getName(); - UDSPlugin.getRegions().remove(oldName); - region.changeName(args[2]); - UDSPlugin.getRegions().put(region.getName(), region); - if(region.getType().equals(RegionType.ARENA)) { - UDSPlugin.getArenas().replace(oldName, region.getName(), region); - } else if(region.getType().equals(RegionType.BASE)) { - UDSPlugin.getBases().replace(oldName, region.getName(), region); - } else if(region.getType().equals(RegionType.CITY)) { - UDSPlugin.getCities().replace(oldName, region.getName(), region); - } else if(region.getType().equals(RegionType.HOME)) { - UDSPlugin.getHomes().replace(oldName, region.getName(), region); - } else if(region.getType().equals(RegionType.QUARRY)) { - UDSPlugin.getQuarries().replace(oldName, region.getName(), region); - } else if(region.getType().equals(RegionType.SHOP)) { - UDSPlugin.getShops().replace(oldName, region.getName(), region); + player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); + } else { + subCmdHelp(args); + } + } else if(args.length == 2) { + if(args[0].equals("del") && (region = getRegion(args[1])) != null) { + UDSPlugin.getRegions().remove(region.getName()); + player.sendMessage(Color.MESSAGE + "Region deleted."); + } else if(args[0].equals("list") && (type = getRegionType(args[1])) != null) { + String list = ""; + for(Region test : UDSPlugin.getRegions().values()) { + if(test.getType().equals(type)) { + list = list.concat(test.getName() + ", "); } - player.sendMessage(Color.MESSAGE + "Region " + oldName + " renamed to " + region.getName()); - } else if(args[0].equals("set") && (session = getSession()) != null && hasTwoPoints(session) && notRegion(args[1]) && noCensor(args[1]) && (type = getRegionType(args[2])) != null) { - region = new Region(args[1], session.getV1(), session.getV2(), player.getLocation(), null, "", type); - UDSPlugin.getRegions().put(region.getName(), region); - if(region.getType().equals(RegionType.ARENA)) { - UDSPlugin.getArenas().put(region.getName(), region); - } else if(region.getType().equals(RegionType.BASE)) { - UDSPlugin.getBases().put(region.getName(), region); - } else if(region.getType().equals(RegionType.CITY)) { - UDSPlugin.getCities().put(region.getName(), region); - } else if(region.getType().equals(RegionType.HOME)) { - UDSPlugin.getHomes().put(region.getName(), region); - } else if(region.getType().equals(RegionType.QUARRY)) { - UDSPlugin.getQuarries().put(region.getName(), region); - } else if(region.getType().equals(RegionType.SHOP)) { - UDSPlugin.getShops().put(region.getName(), region); + } + if(!list.isEmpty()) { + player.sendMessage(Color.MESSAGE + type.name().toLowerCase() + " Regions:"); + player.sendMessage(Color.TEXT + list.substring(0, list.length() - 2)); + } else { + player.sendMessage(Color.MESSAGE + "There are no " + type.name().toLowerCase() + " regions."); + } + } else if(args[0].equals("tp") && (region = getRegion(args[1])) != null) { + player.teleport(region.getWarp()); + } else if(args[0].equals("info") && (region = getRegion(args[1])) != null) { + player.sendMessage(Color.MESSAGE + "Region " + region.getName() + " info:"); + player.sendMessage(Color.TEXT + "Owner: " + region.getOwnerName()); + player.sendMessage(Color.TEXT + "Members: " + StringUtils.join(region.getMembers(), ", ")); + player.sendMessage(Color.TEXT + "Type: " + region.getType().toString()); + String flags = ""; + if(!region.getFlags().isEmpty()) { + for(RegionFlag test : region.getFlags()) { + flags = flags.concat(test.toString() + ", "); } - player.sendMessage(Color.MESSAGE + "Region " + region.getName() + " set."); } + if(!flags.isEmpty()) { + player.sendMessage(Color.TEXT + "Flags: " + flags.substring(0, flags.length() - 2)); + } + } else if(args[0].equals("reset") && (session = getSession()) != null && hasTwoPoints(session) && (region = getRegion(args[1])) != null) { + region.changeV(session.getV1(), session.getV2()); + player.sendMessage(Color.MESSAGE + "Region reset with new points."); + } else if(args[0].equals("select") && (region = getRegion(args[1])) != null) { + session = player.forceSession(); + session.setV1(region.getV1()); + session.setV2(region.getV2()); + player.sendMessage(Color.MESSAGE + "Points set. " + session.getVolume() + " blocks selected."); + } else if(args[0].equals("set") && (session = getSession()) != null && hasTwoPoints(session) && notRegion(args[1]) && noCensor(args[1])) { + region = new Region(args[1], session.getV1(), session.getV2(), player.getLocation(), null, "", RegionType.NORMAL); + UDSPlugin.getRegions().put(region.getName(), region); + player.sendMessage(Color.MESSAGE + "Region " + region.getName() + " set."); + } else { + subCmdHelp(args); + } + } else if(numArgsHelp(3)) { + if(args[0].equals("addmember") && (region = getRegion(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { + region.addMember(target); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " add to region " + region.getName() + "."); + } else if(args[0].equals("delmember") && (region = getRegion(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { + region.delMember(target); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " removed from region " + region.getName() + "."); + } else if(args[0].equals("owner") && (region = getRegion(args[1])) != null && (target = getMatchingPlayer(args[2])) != null) { + region.changeOwner(target); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " made owner of region " + region.getName() + "."); + } else if(args[0].equals("flag") && (region = getRegion(args[1])) != null && (flag = getFlag(args[2])) != null) { + player.sendMessage(Color.MESSAGE + region.getName() + " flag " + flag.toString() + " now set to " + region.toggleFlag(flag) + "."); + } else if(args[0].equals("rename") && (region = getRegion(args[1])) != null && noCensor(args[1]) && notRegion(args[2])) { + String oldName = region.getName(); + UDSPlugin.getRegions().remove(oldName); + region.changeName(args[2]); + UDSPlugin.getRegions().put(region.getName(), region); + if(region.getType().equals(RegionType.ARENA)) { + UDSPlugin.getArenas().replace(oldName, region.getName(), region); + } else if(region.getType().equals(RegionType.BASE)) { + UDSPlugin.getBases().replace(oldName, region.getName(), region); + } else if(region.getType().equals(RegionType.CITY)) { + UDSPlugin.getCities().replace(oldName, region.getName(), region); + } else if(region.getType().equals(RegionType.HOME)) { + UDSPlugin.getHomes().replace(oldName, region.getName(), region); + } else if(region.getType().equals(RegionType.QUARRY)) { + UDSPlugin.getQuarries().replace(oldName, region.getName(), region); + } else if(region.getType().equals(RegionType.SHOP)) { + UDSPlugin.getShops().replace(oldName, region.getName(), region); + } + player.sendMessage(Color.MESSAGE + "Region " + oldName + " renamed to " + region.getName()); + } else if(args[0].equals("set") && (session = getSession()) != null && hasTwoPoints(session) && notRegion(args[1]) && noCensor(args[1]) && (type = getRegionType(args[2])) != null) { + region = new Region(args[1], session.getV1(), session.getV2(), player.getLocation(), null, "", type); + UDSPlugin.getRegions().put(region.getName(), region); + if(region.getType().equals(RegionType.ARENA)) { + UDSPlugin.getArenas().put(region.getName(), region); + } else if(region.getType().equals(RegionType.BASE)) { + UDSPlugin.getBases().put(region.getName(), region); + } else if(region.getType().equals(RegionType.CITY)) { + UDSPlugin.getCities().put(region.getName(), region); + } else if(region.getType().equals(RegionType.HOME)) { + UDSPlugin.getHomes().put(region.getName(), region); + } else if(region.getType().equals(RegionType.QUARRY)) { + UDSPlugin.getQuarries().put(region.getName(), region); + } else if(region.getType().equals(RegionType.SHOP)) { + UDSPlugin.getShops().put(region.getName(), region); + } + player.sendMessage(Color.MESSAGE + "Region " + region.getName() + " set."); + } else { + subCmdHelp(); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/RulesCmd.java b/src/com/undeadscythes/udsplugin/commands/RulesCmd.java index 6036886..66153af 100644 --- a/src/com/undeadscythes/udsplugin/commands/RulesCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/RulesCmd.java @@ -12,11 +12,9 @@ public class RulesCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - player.sendMessage(Color.MESSAGE + "--- Server Rules ---"); - for(String rules : Config.SERVER_RULES) { - player.sendMessage(Color.TEXT + "- " + rules); - } + player.sendMessage(Color.MESSAGE + "--- Server Rules ---"); + for(String rules : Config.SERVER_RULES) { + player.sendMessage(Color.TEXT + "- " + rules); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/ScubaCmd.java b/src/com/undeadscythes/udsplugin/commands/ScubaCmd.java index 8d47e30..7d0b8cd 100644 --- a/src/com/undeadscythes/udsplugin/commands/ScubaCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/ScubaCmd.java @@ -14,27 +14,25 @@ public class ScubaCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - if(player.getInventory().getHelmet() == null) { - if(player.getItemInHand().getType() == Material.GLASS) { - player.getInventory().setHelmet(new ItemStack(Material.GLASS)); - final ItemStack glass = player.getItemInHand().clone(); - glass.setAmount(glass.getAmount() - 1); - player.setItemInHand(glass); - player.sendMessage(Color.MESSAGE + "You put on your scuba gear."); - } else { - player.sendMessage(Color.ERROR + "You need glass in your hand to do this."); - } - } else if(player.getInventory().getHelmet().getType() != Material.GLASS) { - player.sendMessage(Color.ERROR + "You cannot do this while you have a normal helmet on."); - } else if(player.getInventory().getHelmet().getType() == Material.GLASS) { - player.getInventory().setHelmet(new ItemStack(Material.AIR)); - if(!player.getInventory().addItem(new ItemStack(Material.GLASS)).isEmpty()) { - player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(Material.GLASS)); - player.sendMessage(Color.MESSAGE + "You dropped your scuba gear on the floor."); - } else { - player.sendMessage(Color.MESSAGE + "You take off your scuba gear."); - } + if(player.getInventory().getHelmet() == null) { + if(player.getItemInHand().getType() == Material.GLASS) { + player.getInventory().setHelmet(new ItemStack(Material.GLASS)); + final ItemStack glass = player.getItemInHand().clone(); + glass.setAmount(glass.getAmount() - 1); + player.setItemInHand(glass); + player.sendMessage(Color.MESSAGE + "You put on your scuba gear."); + } else { + player.sendMessage(Color.ERROR + "You need glass in your hand to do this."); + } + } else if(player.getInventory().getHelmet().getType() != Material.GLASS) { + player.sendMessage(Color.ERROR + "You cannot do this while you have a normal helmet on."); + } else if(player.getInventory().getHelmet().getType() == Material.GLASS) { + player.getInventory().setHelmet(new ItemStack(Material.AIR)); + if(!player.getInventory().addItem(new ItemStack(Material.GLASS)).isEmpty()) { + player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(Material.GLASS)); + player.sendMessage(Color.MESSAGE + "You dropped your scuba gear on the floor."); + } else { + player.sendMessage(Color.MESSAGE + "You take off your scuba gear."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/ServerCmd.java b/src/com/undeadscythes/udsplugin/commands/ServerCmd.java index 6003f62..6ee5681 100644 --- a/src/com/undeadscythes/udsplugin/commands/ServerCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/ServerCmd.java @@ -13,13 +13,11 @@ public class ServerCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(1)) { - if(args[0].equals("stop")) { - for(SaveablePlayer target : UDSPlugin.getOnlinePlayers().values()) { - target.kickPlayer("Server is shutting down."); - } - Bukkit.shutdown(); + if(numArgsHelp(1) && args[0].equals("stop")) { + for(SaveablePlayer target : UDSPlugin.getOnlinePlayers().values()) { + target.kickPlayer("Server is shutting down."); } + Bukkit.shutdown(); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/SetSpawnCmd.java b/src/com/undeadscythes/udsplugin/commands/SetSpawnCmd.java index 6e94aa3..76f9913 100644 --- a/src/com/undeadscythes/udsplugin/commands/SetSpawnCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/SetSpawnCmd.java @@ -12,9 +12,7 @@ public class SetSpawnCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - new WEWorld(player.getWorld()).setSpawnLocation(player.getLocation()); - player.sendMessage(Color.MESSAGE + "Spawn location moved."); - } + new WEWorld(player.getWorld()).setSpawnLocation(player.getLocation()); + player.sendMessage(Color.MESSAGE + "Spawn location moved."); } } diff --git a/src/com/undeadscythes/udsplugin/commands/SetWarpCmd.java b/src/com/undeadscythes/udsplugin/commands/SetWarpCmd.java index 530d435..d28b220 100644 --- a/src/com/undeadscythes/udsplugin/commands/SetWarpCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/SetWarpCmd.java @@ -13,21 +13,19 @@ public class SetWarpCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(1, 3)) { - PlayerRank rank; - int price; - String message = Color.MESSAGE + "Warp point set."; - if(args.length == 1 && notWarp(args[0]) && noCensor(args[0])) { - UDSPlugin.getWarps().put(args[0], new Warp(args[0], player.getLocation(), PlayerRank.DEFAULT, 0)); - player.sendMessage(message); - } else if(args.length == 2 && notWarp(args[0]) && noCensor(args[0]) && (rank = getRank(args[1])) != null) { - UDSPlugin.getWarps().put(args[0], new Warp(args[0], player.getLocation(), rank, 0)); - player.sendMessage(message); + PlayerRank rank; + int price; + String message = Color.MESSAGE + "Warp point set."; + if(args.length == 1 && notWarp(args[0]) && noCensor(args[0])) { + UDSPlugin.getWarps().put(args[0], new Warp(args[0], player.getLocation(), PlayerRank.DEFAULT, 0)); + player.sendMessage(message); + } else if(args.length == 2 && notWarp(args[0]) && noCensor(args[0]) && (rank = getRank(args[1])) != null) { + UDSPlugin.getWarps().put(args[0], new Warp(args[0], player.getLocation(), rank, 0)); + player.sendMessage(message); - } else if(args.length == 3 && notWarp(args[0]) && noCensor(args[0]) && (rank = getRank(args[1])) != null && (price = parseInt(args[2])) != -1) { - UDSPlugin.getWarps().put(args[0], new Warp(args[0], player.getLocation(), rank, price)); - player.sendMessage(message); - } + } else if(numArgsHelp(3) && notWarp(args[0]) && noCensor(args[0]) && (rank = getRank(args[1])) != null && (price = parseInt(args[2])) != -1) { + UDSPlugin.getWarps().put(args[0], new Warp(args[0], player.getLocation(), rank, price)); + player.sendMessage(message); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/ShopCmd.java b/src/com/undeadscythes/udsplugin/commands/ShopCmd.java index 8f596c6..a9f586a 100644 --- a/src/com/undeadscythes/udsplugin/commands/ShopCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/ShopCmd.java @@ -13,88 +13,90 @@ public class ShopCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(0, 3)) { - Region shop; - SaveablePlayer target; - int price; - if(args.length == 0 && (shop = getShop()) != null && notJailed() && notPinned()) { - player.teleport(shop.getWarp()); - } else if(args.length == 1) { - if(args[0].equals("make") && hasPerm(Perm.SHOP_ADMIN)) { - player.performCommand("region set " + nextShopName() + " shop"); - } else if(args[0].equals("clear") && (shop = getShop()) != null) { - UDSPlugin.getRegions().replace(shop.getName(), nextShopName(), shop); - UDSPlugin.getShops().replace(shop.getName(), nextShopName(), shop); - shop.clearMembers(); - shop.changeOwner(null); - player.sendMessage(Color.MESSAGE + "Shop put back up for sale."); - player.credit(Config.SHOP_COST / 2); - } else if(args[0].equals("set") && (shop = getShop()) != null) { - shop.setWarp(player.getLocation()); - player.sendMessage(Color.MESSAGE + "Shop warp point set."); - } else if(args[0].equals("workers")) { - String message = ""; - for(Region otherShop : UDSPlugin.getShops().values()) { - if(otherShop.hasMember(player)) { - message = message.concat(otherShop.getOwner().getDisplayName() + ", "); - } - if(!message.isEmpty()) { - player.sendMessage(Color.MESSAGE + "You work for:"); - player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); - } - message = ""; - if((shop = UDSPlugin.getShops().get(player.getName() + "shop")) != null) { - for(SaveablePlayer member : shop.getMembers()) { - message = message.concat(member.getDisplayName() + ", "); - } - } - if(!message.equals("")) { - player.sendMessage(Color.MESSAGE + "Your workers are:"); - player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); - } else { - player.sendMessage(Color.MESSAGE + "You have no workers."); - } + Region shop; + SaveablePlayer target; + int price; + if(args.length == 0 && (shop = getShop()) != null && notJailed() && notPinned()) { + player.teleport(shop.getWarp()); + } else if(args.length == 1) { + if(args[0].equals("make") && hasPerm(Perm.SHOP_ADMIN)) { + player.performCommand("region set " + nextShopName() + " shop"); + } else if(args[0].equals("clear") && (shop = getShop()) != null) { + UDSPlugin.getRegions().replace(shop.getName(), nextShopName(), shop); + UDSPlugin.getShops().replace(shop.getName(), nextShopName(), shop); + shop.clearMembers(); + shop.changeOwner(null); + player.sendMessage(Color.MESSAGE + "Shop put back up for sale."); + player.credit(Config.SHOP_COST / 2); + } else if(args[0].equals("set") && (shop = getShop()) != null) { + shop.setWarp(player.getLocation()); + player.sendMessage(Color.MESSAGE + "Shop warp point set."); + } else if(args[0].equals("workers")) { + String message = ""; + for(Region otherShop : UDSPlugin.getShops().values()) { + if(otherShop.hasMember(player)) { + message = message.concat(otherShop.getOwner().getDisplayName() + ", "); } - } else if(args[0].equals("buy") && (shop = getContainingShop()) != null && canAfford(Config.SHOP_COST) && isEmptyShop(shop)) { - player.debit(Config.SHOP_COST); - UDSPlugin.getRegions().replace(shop.getName(), player.getName() + "shop", shop); - UDSPlugin.getShops().replace(shop.getName(), player.getName() + "shop", shop); - shop.changeName(player.getName() + "shop"); - player.sendMessage(Color.MESSAGE + "Shop bought."); - } else if(args[0].equals("sign")) { - player.sendMessage(Color.MESSAGE + "Correct shop sign format:"); - player.sendMessage(Color.ITEM + "Line 1 - " + Color.TEXT + "Leave this line blank.\n"); - player.sendMessage(Color.ITEM + "Line 2 - " + Color.TEXT + "shop\n"); - player.sendMessage(Color.ITEM + "Line 3 - " + Color.TEXT + "\n"); - player.sendMessage(Color.ITEM + "Line 4 - " + Color.TEXT + ":"); - player.sendMessage(Color.TEXT + "The buy price is how much people pay to buy from the shop."); - player.sendMessage(Color.TEXT + "The sell price is how much people pay to sell to the shop."); - } else if(args[0].equals("item")) { - ItemStack item = player.getItemInHand(); - player.sendMessage(Color.MESSAGE + item.getType().name() + " - " + Color.TEXT + item.getTypeId() + ":" + item.getData().getData()); - } else if((target = getMatchingPlayer(args[0])) != null && (shop = getShop(target)) != null && notJailed() && notPinned()) { - player.teleport(shop.getWarp()); - } - } else if(args.length == 2) { - if(args[0].equals("hire") && (target = getMatchingPlayer(args[1])) != null && (shop = getShop()) != null) { - shop.addMember(target); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been added as your worker."); - if(target.isOnline()) { - target.sendMessage(Color.MESSAGE + "You have been added as " + player.getDisplayName() + "'s worker."); + if(!message.isEmpty()) { + player.sendMessage(Color.MESSAGE + "You work for:"); + player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); } - } else if(args[0].equals("fire") && (target = getMatchingPlayer(args[1])) != null && (shop = getShop()) != null && isWorker(target, shop)) { - shop.delMember(target); - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " is no longer your worker."); - if(target.isOnline()) { - target.sendMessage(Color.MESSAGE + "You are no longer " + player.getDisplayName() + "'s worker."); + message = ""; + if((shop = UDSPlugin.getShops().get(player.getName() + "shop")) != null) { + for(SaveablePlayer member : shop.getMembers()) { + message = message.concat(member.getDisplayName() + ", "); + } + } + if(!message.equals("")) { + player.sendMessage(Color.MESSAGE + "Your workers are:"); + player.sendMessage(Color.TEXT + message.substring(0, message.length() - 2)); + } else { + player.sendMessage(Color.MESSAGE + "You have no workers."); } } - } else if(args[0].equals("shop") && (getShop()) != null && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && (price = parseInt(args[2])) != -1) { - player.sendMessage(Message.REQUEST_SENT); - target.sendMessage(Color.MESSAGE + player.getDisplayName() + " wants to sell you their shop for " + price + " " + Config.CURRENCIES + "."); - target.sendMessage(Message.REQUEST_Y_N); - UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.SHOP, price, target)); + } else if(args[0].equals("buy") && (shop = getContainingShop()) != null && canAfford(Config.SHOP_COST) && isEmptyShop(shop)) { + player.debit(Config.SHOP_COST); + UDSPlugin.getRegions().replace(shop.getName(), player.getName() + "shop", shop); + UDSPlugin.getShops().replace(shop.getName(), player.getName() + "shop", shop); + shop.changeName(player.getName() + "shop"); + player.sendMessage(Color.MESSAGE + "Shop bought."); + } else if(args[0].equals("sign")) { + player.sendMessage(Color.MESSAGE + "Correct shop sign format:"); + player.sendMessage(Color.ITEM + "Line 1 - " + Color.TEXT + "Leave this line blank.\n"); + player.sendMessage(Color.ITEM + "Line 2 - " + Color.TEXT + "shop\n"); + player.sendMessage(Color.ITEM + "Line 3 - " + Color.TEXT + "\n"); + player.sendMessage(Color.ITEM + "Line 4 - " + Color.TEXT + ":"); + player.sendMessage(Color.TEXT + "The buy price is how much people pay to buy from the shop."); + player.sendMessage(Color.TEXT + "The sell price is how much people pay to sell to the shop."); + } else if(args[0].equals("item")) { + ItemStack item = player.getItemInHand(); + player.sendMessage(Color.MESSAGE + item.getType().name() + " - " + Color.TEXT + item.getTypeId() + ":" + item.getData().getData()); + } else if((target = getMatchingPlayer(args[0])) != null && (shop = getShop(target)) != null && notJailed() && notPinned()) { + player.teleport(shop.getWarp()); + } else { + subCmdHelp(args); + } + } else if(args.length == 2) { + if(args[0].equals("hire") && (target = getMatchingPlayer(args[1])) != null && (shop = getShop()) != null) { + shop.addMember(target); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " has been added as your worker."); + if(target.isOnline()) { + target.sendMessage(Color.MESSAGE + "You have been added as " + player.getDisplayName() + "'s worker."); + } + } else if(args[0].equals("fire") && (target = getMatchingPlayer(args[1])) != null && (shop = getShop()) != null && isWorker(target, shop)) { + shop.delMember(target); + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " is no longer your worker."); + if(target.isOnline()) { + target.sendMessage(Color.MESSAGE + "You are no longer " + player.getDisplayName() + "'s worker."); + } + } else { + subCmdHelp(args); } + } else if(numArgsHelp(3) && args[0].equals("shop") && (getShop()) != null && (target = getMatchingPlayer(args[1])) != null && isOnline(target) && (price = parseInt(args[2])) != -1) { + player.sendMessage(Message.REQUEST_SENT); + target.sendMessage(Color.MESSAGE + player.getDisplayName() + " wants to sell you their shop for " + price + " " + Config.CURRENCIES + "."); + target.sendMessage(Message.REQUEST_Y_N); + UDSPlugin.getRequests().put(target.getName(), new Request(player, Request.RequestType.SHOP, price, target)); } } diff --git a/src/com/undeadscythes/udsplugin/commands/SignsCmd.java b/src/com/undeadscythes/udsplugin/commands/SignsCmd.java index 706d210..1bb95a1 100644 --- a/src/com/undeadscythes/udsplugin/commands/SignsCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/SignsCmd.java @@ -12,26 +12,24 @@ public class SignsCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - player.sendMessage(Color.MESSAGE + "Special signs available to you and format (lines 1-4):"); - if(player.hasPermission("udsplugin.sign.checkpoint")) { - player.sendMessage(Color.ITEM + "Checkpoint - " + Color.TEXT + "1: [checkpoint], 2-4: Anything"); - } - if(player.hasPermission("udsplugin.sign.minecart")) { - player.sendMessage(Color.ITEM + "Minecart - " + Color.TEXT + "1: [minecart], 2-4: Anything"); - } - if(player.hasPermission("udsplugin.sign.item")) { - player.sendMessage(Color.ITEM + "Item - " + Color.TEXT + "1: [item], 2: , 3: , 4: Anything"); - } - if(player.hasPermission("udsplugin.sign.prize")) { - player.sendMessage(Color.ITEM + "Prize - " + Color.TEXT + "1: [prize], 2: , 3: , 4: Anything"); - } - if(player.hasPermission("udsplugin.sign.warp")) { - player.sendMessage(Color.ITEM + "Warp - " + Color.TEXT + "1: [warp], 2: , 3-4: Anything"); - } - if(player.hasPermission("udsplugin.sign.spleef")) { - player.sendMessage(Color.ITEM + "Spleef - " + Color.TEXT + "1: [spleef], 2: , 3-4: Anything"); - } + player.sendMessage(Color.MESSAGE + "Special signs available to you and format (lines 1-4):"); + if(player.hasPermission("udsplugin.sign.checkpoint")) { + player.sendMessage(Color.ITEM + "Checkpoint - " + Color.TEXT + "1: [checkpoint], 2-4: Anything"); + } + if(player.hasPermission("udsplugin.sign.minecart")) { + player.sendMessage(Color.ITEM + "Minecart - " + Color.TEXT + "1: [minecart], 2-4: Anything"); + } + if(player.hasPermission("udsplugin.sign.item")) { + player.sendMessage(Color.ITEM + "Item - " + Color.TEXT + "1: [item], 2: , 3: , 4: Anything"); + } + if(player.hasPermission("udsplugin.sign.prize")) { + player.sendMessage(Color.ITEM + "Prize - " + Color.TEXT + "1: [prize], 2: , 3: , 4: Anything"); + } + if(player.hasPermission("udsplugin.sign.warp")) { + player.sendMessage(Color.ITEM + "Warp - " + Color.TEXT + "1: [warp], 2: , 3-4: Anything"); + } + if(player.hasPermission("udsplugin.sign.spleef")) { + player.sendMessage(Color.ITEM + "Spleef - " + Color.TEXT + "1: [spleef], 2: , 3-4: Anything"); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/SitCmd.java b/src/com/undeadscythes/udsplugin/commands/SitCmd.java index 5a71db4..ad4fcbb 100644 --- a/src/com/undeadscythes/udsplugin/commands/SitCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/SitCmd.java @@ -18,51 +18,49 @@ public class SitCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - if(!player.isInsideVehicle()) { - final Block target = player.getTargetBlock(null, 3); - final boolean a = target.getTypeId() == 53; - final boolean b = target.getTypeId() == 67; - final boolean c = target.getTypeId() == 108; - final boolean d = target.getTypeId() == 109; - final boolean e = target.getTypeId() == 114; - final boolean f = target.getTypeId() == 128; - final boolean g = target.getRelative(BlockFace.DOWN).getTypeId() != 0; - if((a || b || c || d || e || f) && g) { - //final Entity arrow = player.getWorld().spawn(target.getLocation().add(0.5, 0.5, 0.5), Arrow.class); - //arrow.setPassenger(player); - final Item seat = player.getWorld().dropItemNaturally(target.getLocation(), new ItemStack(Material.SNOW_BALL)); - seat.setPickupDelay(2147483647); - seat.teleport(target.getLocation().add(0.5, -0.5, 0.5)); - seat.setVelocity(new Vector(0, 0, 0)); - final Stairs chair = (Stairs)target.getState().getData(); - Location view = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()); - if(chair.getDescendingDirection() == BlockFace.NORTH) { - view.setYaw(90); - } else if(chair.getDescendingDirection() == BlockFace.EAST) { - view.setYaw(180); - } else if(chair.getDescendingDirection() == BlockFace.SOUTH) { - view.setYaw(270); - } else { - view.setYaw(0); - } - player.teleport(view); - seat.setPassenger(player); - } - } else { - final Entity seat = player.getVehicle(); - seat.eject(); - seat.remove(); - final Stairs chair = (Stairs)player.getWorld().getBlockAt(player.getLocation()).getState().getData(); + if(!player.isInsideVehicle()) { + final Block target = player.getTargetBlock(null, 3); + final boolean a = target.getTypeId() == 53; + final boolean b = target.getTypeId() == 67; + final boolean c = target.getTypeId() == 108; + final boolean d = target.getTypeId() == 109; + final boolean e = target.getTypeId() == 114; + final boolean f = target.getTypeId() == 128; + final boolean g = target.getRelative(BlockFace.DOWN).getTypeId() != 0; + if((a || b || c || d || e || f) && g) { + //final Entity arrow = player.getWorld().spawn(target.getLocation().add(0.5, 0.5, 0.5), Arrow.class); + //arrow.setPassenger(player); + final Item seat = player.getWorld().dropItemNaturally(target.getLocation(), new ItemStack(Material.SNOW_BALL)); + seat.setPickupDelay(2147483647); + seat.teleport(target.getLocation().add(0.5, -0.5, 0.5)); + seat.setVelocity(new Vector(0, 0, 0)); + final Stairs chair = (Stairs)target.getState().getData(); + Location view = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()); if(chair.getDescendingDirection() == BlockFace.NORTH) { - player.teleport(player.getLocation().add(-1, 0, 0)); + view.setYaw(90); } else if(chair.getDescendingDirection() == BlockFace.EAST) { - player.teleport(player.getLocation().add(0, 0, -1)); + view.setYaw(180); } else if(chair.getDescendingDirection() == BlockFace.SOUTH) { - player.teleport(player.getLocation().add(1, 0, 0)); + view.setYaw(270); } else { - player.teleport(player.getLocation().add(0, 0, 1)); + view.setYaw(0); } + player.teleport(view); + seat.setPassenger(player); + } + } else { + final Entity seat = player.getVehicle(); + seat.eject(); + seat.remove(); + final Stairs chair = (Stairs)player.getWorld().getBlockAt(player.getLocation()).getState().getData(); + if(chair.getDescendingDirection() == BlockFace.NORTH) { + player.teleport(player.getLocation().add(-1, 0, 0)); + } else if(chair.getDescendingDirection() == BlockFace.EAST) { + player.teleport(player.getLocation().add(0, 0, -1)); + } else if(chair.getDescendingDirection() == BlockFace.SOUTH) { + player.teleport(player.getLocation().add(1, 0, 0)); + } else { + player.teleport(player.getLocation().add(0, 0, 1)); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/SpawnCmd.java b/src/com/undeadscythes/udsplugin/commands/SpawnCmd.java index 96451a3..416a553 100644 --- a/src/com/undeadscythes/udsplugin/commands/SpawnCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/SpawnCmd.java @@ -12,7 +12,7 @@ public class SpawnCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0) && notPinned() && notJailed()) { + if(notPinned() && notJailed()) { player.teleport(Config.WORLD.getSpawnLocation()); } } diff --git a/src/com/undeadscythes/udsplugin/commands/SpawnerCmd.java b/src/com/undeadscythes/udsplugin/commands/SpawnerCmd.java index c1e62be..0ecfd2e 100644 --- a/src/com/undeadscythes/udsplugin/commands/SpawnerCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/SpawnerCmd.java @@ -15,7 +15,7 @@ public class SpawnerCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(1)) { + if(numArgsHelp(1)) { final Block block = player.getTargetBlock(null, 5); if(block.getType() == Material.MOB_SPAWNER) { final EntityType mob = EntityType.fromName(args[0]); @@ -23,7 +23,7 @@ public void playerExecute(SaveablePlayer player, String[] args) { ((CreatureSpawner)block.getState()).setSpawnedType(mob); player.sendMessage(Color.MESSAGE + "Spawner set to " + mob.toString().toLowerCase().replace("_", " ") + "."); } else { - player.sendMessage(Color.ERROR + "Not a vliad mob type."); + player.sendMessage(Color.ERROR + "Not a valid mob type."); } } else { player.sendMessage(Color.ERROR + "You need to be looking at a mob spawner."); diff --git a/src/com/undeadscythes/udsplugin/commands/StackCmd.java b/src/com/undeadscythes/udsplugin/commands/StackCmd.java index 0eaa666..6ca9a74 100644 --- a/src/com/undeadscythes/udsplugin/commands/StackCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/StackCmd.java @@ -13,41 +13,39 @@ public class StackCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - ItemStack[] items = player.getInventory().getContents(); - final int len = items.length; - boolean affected = false; - for (int i = 0; i < len; i++) { - final ItemStack item = items[i]; - if (item != null && item.getAmount() > 0 && item.getMaxStackSize() > 1) { - final int max = item.getMaxStackSize(); - if (item.getAmount() < max) { - int needed = max - item.getAmount(); - for (int j = i + 1; j < len; j++) { - final ItemStack item2 = items[j]; - if (item2 != null && item2.getAmount() > 0 && item.getMaxStackSize() > 1) { - final boolean a = item2.getTypeId() == item.getTypeId(); - final boolean b = item.getDurability() == item2.getDurability(); - final boolean c = item.getEnchantments().equals(item2.getEnchantments()); - if (a && b && c) { - if (item2.getAmount() > needed) { - item.setAmount(64); - item2.setAmount(item2.getAmount() - needed); - break; - } - items[j] = null; - item.setAmount(item.getAmount() + item2.getAmount()); - needed = 64 - item.getAmount(); - affected = true; + ItemStack[] items = player.getInventory().getContents(); + final int len = items.length; + boolean affected = false; + for (int i = 0; i < len; i++) { + final ItemStack item = items[i]; + if (item != null && item.getAmount() > 0 && item.getMaxStackSize() > 1) { + final int max = item.getMaxStackSize(); + if (item.getAmount() < max) { + int needed = max - item.getAmount(); + for (int j = i + 1; j < len; j++) { + final ItemStack item2 = items[j]; + if (item2 != null && item2.getAmount() > 0 && item.getMaxStackSize() > 1) { + final boolean a = item2.getTypeId() == item.getTypeId(); + final boolean b = item.getDurability() == item2.getDurability(); + final boolean c = item.getEnchantments().equals(item2.getEnchantments()); + if (a && b && c) { + if (item2.getAmount() > needed) { + item.setAmount(64); + item2.setAmount(item2.getAmount() - needed); + break; } + items[j] = null; + item.setAmount(item.getAmount() + item2.getAmount()); + needed = 64 - item.getAmount(); + affected = true; } } } } } - if(affected) { - player.getInventory().setContents(items); - } + } + if(affected) { + player.getInventory().setContents(items); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/StatsCmd.java b/src/com/undeadscythes/udsplugin/commands/StatsCmd.java index 2287e6b..7dc92c2 100644 --- a/src/com/undeadscythes/udsplugin/commands/StatsCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/StatsCmd.java @@ -13,7 +13,7 @@ public class StatsCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsEq(1) && (target = getMatchingPlayer(args[0])) != null) { + if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null) { player.sendMessage(Color.MESSAGE + target.getDisplayName() + "'s stats:"); player.sendMessage(Color.TEXT + "Minecraft name: " + target.getName()); player.sendMessage(Color.TEXT + "Rank: " + target.getRank().color() + target.getRank().toString()); diff --git a/src/com/undeadscythes/udsplugin/commands/StormCmd.java b/src/com/undeadscythes/udsplugin/commands/StormCmd.java index e042ce3..2f58c78 100644 --- a/src/com/undeadscythes/udsplugin/commands/StormCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/StormCmd.java @@ -12,21 +12,19 @@ public class StormCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsMoreLessInc(0, 1)) { - int duration; - if(args.length == 0) { - player.getWorld().setStorm(true); - player.getWorld().setThundering(true); - player.getWorld().setWeatherDuration(6000); - player.getWorld().setThunderDuration(6000); - player.sendMessage(Color.MESSAGE + "5 minutes thunder storm on the way."); - } else if((duration = parseInt(args[0])) != -1) { - player.getWorld().setStorm(true); - player.getWorld().setThundering(true); - player.getWorld().setWeatherDuration((int)(duration * Timer.MINUTE / Timer.TICKS)); - player.getWorld().setThunderDuration((int)(duration * Timer.MINUTE / Timer.TICKS)); - player.sendMessage(Color.MESSAGE.toString() + duration + " minutes thunder storm on the way."); - } + int duration; + if(args.length == 0) { + player.getWorld().setStorm(true); + player.getWorld().setThundering(true); + player.getWorld().setWeatherDuration(6000); + player.getWorld().setThunderDuration(6000); + player.sendMessage(Color.MESSAGE + "5 minutes thunder storm on the way."); + } else if(numArgsHelp(1) && (duration = parseInt(args[0])) != -1) { + player.getWorld().setStorm(true); + player.getWorld().setThundering(true); + player.getWorld().setWeatherDuration((int)(duration * Timer.MINUTE / Timer.TICKS)); + player.getWorld().setThunderDuration((int)(duration * Timer.MINUTE / Timer.TICKS)); + player.sendMessage(Color.MESSAGE.toString() + duration + " minutes thunder storm on the way."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/SunCmd.java b/src/com/undeadscythes/udsplugin/commands/SunCmd.java index 295d47a..4035297 100644 --- a/src/com/undeadscythes/udsplugin/commands/SunCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/SunCmd.java @@ -3,7 +3,7 @@ import com.undeadscythes.udsplugin.*; /** - * Make it sunn yin the world. + * Make it sunny in the players world. * @author UndeadScythes */ public class SunCmd extends PlayerCommandExecutor { @@ -12,10 +12,8 @@ public class SunCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - player.getWorld().setStorm(false); - player.getWorld().setThundering(false); - player.sendMessage(Color.MESSAGE + "Clear skies on the way."); - } + player.getWorld().setStorm(false); + player.getWorld().setThundering(false); + player.sendMessage(Color.MESSAGE + "Clear skies on the way."); } } diff --git a/src/com/undeadscythes/udsplugin/commands/TGMCmd.java b/src/com/undeadscythes/udsplugin/commands/TGMCmd.java index 94aa985..86d9dfd 100644 --- a/src/com/undeadscythes/udsplugin/commands/TGMCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/TGMCmd.java @@ -12,17 +12,15 @@ public class TGMCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(1)) { - SaveablePlayer target; - if(args.length == 0) { - player.sendMessage(Color.MESSAGE + "You now have creative mode " + (player.toggleGameMode() ? "en" : "dis") + "abled."); - } else if(args.length == 1 && (target = getMatchingPlayer(args[0])) != null) { - boolean gameMode = target.toggleGameMode(); - if(!player.equals(target)) { - player.sendMessage(Color.MESSAGE + target.getDisplayName() + " now has creative mode " + (gameMode ? "en" : "dis") + "abled."); - } - target.sendMessage(Color.MESSAGE + "You now have creative mode " + (gameMode ? "en" : "dis") + "abled."); + SaveablePlayer target; + if(args.length == 0) { + player.sendMessage(Color.MESSAGE + "You now have creative mode " + (player.toggleGameMode() ? "en" : "dis") + "abled."); + } else if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null) { + boolean gameMode = target.toggleGameMode(); + if(!player.equals(target)) { + player.sendMessage(Color.MESSAGE + target.getDisplayName() + " now has creative mode " + (gameMode ? "en" : "dis") + "abled."); } + target.sendMessage(Color.MESSAGE + "You now have creative mode " + (gameMode ? "en" : "dis") + "abled."); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/TPCmd.java b/src/com/undeadscythes/udsplugin/commands/TPCmd.java index 3a81ded..46f9796 100644 --- a/src/com/undeadscythes/udsplugin/commands/TPCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/TPCmd.java @@ -14,14 +14,12 @@ public class TPCmd extends PlayerCommandExecutor { public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer targetFrom; SaveablePlayer targetTo; - if(argsMoreLessInc(1, 2)) { - if(args.length == 1 && (targetTo = getMatchingPlayer(args[0])) != null && isOnline(targetTo) && notSelf(targetTo)) { - player.setBackPoint(); - player.teleport(targetTo); - } else if((targetFrom = getMatchingPlayer(args[0])) != null && isOnline(targetFrom) && (targetTo = getMatchingPlayer(args[1])) != null && isOnline(targetTo)) { - targetFrom.setBackPoint(); - targetFrom.teleport(targetTo); - } + if(args.length == 1 && (targetTo = getMatchingPlayer(args[0])) != null && isOnline(targetTo) && notSelf(targetTo)) { + player.setBackPoint(); + player.teleport(targetTo); + } else if(numArgsHelp(2) && (targetFrom = getMatchingPlayer(args[0])) != null && isOnline(targetFrom) && (targetTo = getMatchingPlayer(args[1])) != null && isOnline(targetTo)) { + targetFrom.setBackPoint(); + targetFrom.teleport(targetTo); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/TellCmd.java b/src/com/undeadscythes/udsplugin/commands/TellCmd.java index 4023408..4dc8372 100644 --- a/src/com/undeadscythes/udsplugin/commands/TellCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/TellCmd.java @@ -14,7 +14,7 @@ public class TellCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsMoreEq(2) && (target = getMatchingPlayer(args[0])) != null && isOnline(target) && notIgnored(target)) { + if(minArgsHelp(2) && (target = getMatchingPlayer(args[0])) != null && isOnline(target) && notIgnored(target)) { String message = player.getDisplayName() + " > " + target.getDisplayName() + ": " + StringUtils.join(args, " ", 1, args.length); player.sendMessage(Color.WHISPER + message); target.sendMessage(Color.WHISPER + message); diff --git a/src/com/undeadscythes/udsplugin/commands/UnBanCmd.java b/src/com/undeadscythes/udsplugin/commands/UnBanCmd.java index 1ad1011..3e4312f 100644 --- a/src/com/undeadscythes/udsplugin/commands/UnBanCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/UnBanCmd.java @@ -13,7 +13,7 @@ public class UnBanCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsEq(1) && (target = getMatchingPlayer(args[0])) != null && isBanned(target) && notSelf(target)) { + if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null && isBanned(target) && notSelf(target)) { target.setBanned(false); player.sendMessage(Color.MESSAGE + target.getDisplayName() + " is no longer banned."); } diff --git a/src/com/undeadscythes/udsplugin/commands/UnJailCmd.java b/src/com/undeadscythes/udsplugin/commands/UnJailCmd.java index eda17eb..909074d 100644 --- a/src/com/undeadscythes/udsplugin/commands/UnJailCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/UnJailCmd.java @@ -3,7 +3,7 @@ import com.undeadscythes.udsplugin.*; /** - * Description. + * Description. Sends help on wrong arguments. * @author UndeadScythes */ public class UnJailCmd extends PlayerCommandExecutor { @@ -13,7 +13,7 @@ public class UnJailCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsEq(1) && (target = getMatchingPlayer(args[0])) != null && isJailed(target)) { + if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null && isJailed(target)) { target.release(); target.sendMessage(Color.MESSAGE + "You have been released early."); player.sendMessage(Color.MESSAGE + "You have released " + target.getDisplayName() + "."); diff --git a/src/com/undeadscythes/udsplugin/commands/VIPCmd.java b/src/com/undeadscythes/udsplugin/commands/VIPCmd.java index 0044175..77bcedc 100644 --- a/src/com/undeadscythes/udsplugin/commands/VIPCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/VIPCmd.java @@ -5,7 +5,7 @@ import org.bukkit.*; /** - * Rent VIP rank and perform other tasks. + * Rent VIP rank and perform other tasks. Sends help on wrong arguments. * @author UndeadScythes */ public class VIPCmd extends PlayerCommandExecutor { @@ -14,25 +14,25 @@ public class VIPCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(2)) { - if(args.length == 0) { - if(player.getRank().equals(PlayerRank.VIP)) { - player.sendMessage(Color.MESSAGE + "You have " + player.getVIPTimeString()+ " left in VIP."); - } else if(canAfford(Config.VIP_COST) && notJailed() && hasPerm(Perm.VIP_BUY)) { - player.setRank(PlayerRank.VIP); - player.setVIPTime(System.currentTimeMillis()); - player.setVIPSpawns(Config.VIP_SPAWNS); - player.sendMessage(Color.MESSAGE + "Welcome to the elite, enjoy your VIP status."); + if(args.length == 0) { + if(player.getRank().equals(PlayerRank.VIP)) { + player.sendMessage(Color.MESSAGE + "You have " + player.getVIPTimeString()+ " left in VIP."); + } else if(canAfford(Config.VIP_COST) && notJailed() && hasPerm(Perm.VIP_BUY)) { + player.setRank(PlayerRank.VIP); + player.setVIPTime(System.currentTimeMillis()); + player.setVIPSpawns(Config.VIP_SPAWNS); + player.sendMessage(Color.MESSAGE + "Welcome to the elite, enjoy your VIP status."); + } + } else if(maxArgsHelp(2)) { + if(args[0].equals("spawns")) { + int page; + if(args.length == 2 && (page = parseInt(args[1])) != -1) { + sendPage(page, player); + } else { + sendPage(1, player); } } else { - if(args[0].equals("spawns")) { - int page; - if(args.length == 2 && (page = parseInt(args[1])) != -1) { - sendPage(page, player); - } else { - sendPage(1, player); - } - } + subCmdHelp(); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/WECmd.java b/src/com/undeadscythes/udsplugin/commands/WECmd.java index 0eec7e2..72593ee 100644 --- a/src/com/undeadscythes/udsplugin/commands/WECmd.java +++ b/src/com/undeadscythes/udsplugin/commands/WECmd.java @@ -3,7 +3,7 @@ import com.undeadscythes.udsplugin.*; /** - * Toggles the admin chat channel. + * WorldEdit-like tools. * @author UndeadScythes */ public class WECmd extends PlayerCommandExecutor { diff --git a/src/com/undeadscythes/udsplugin/commands/WarpCmd.java b/src/com/undeadscythes/udsplugin/commands/WarpCmd.java index 2a9be73..3ba3ffb 100644 --- a/src/com/undeadscythes/udsplugin/commands/WarpCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/WarpCmd.java @@ -14,25 +14,23 @@ public class WarpCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsLessEq(1)) { - Warp warp; - if(args.length == 0) { - TreeSet warps = new TreeSet(); - for(Warp test : UDSPlugin.getWarps().values()) { - if(player.getRank().compareTo(test.getRank()) >= 0) { - warps.add(test.getName() + (test.getPrice() > 0 ? " (" + test.getPrice() + ")" : "")); - } + Warp warp; + if(args.length == 0) { + TreeSet warps = new TreeSet(); + for(Warp test : UDSPlugin.getWarps().values()) { + if(player.getRank().compareTo(test.getRank()) >= 0) { + warps.add(test.getName() + (test.getPrice() > 0 ? " (" + test.getPrice() + ")" : "")); } - if(!warps.isEmpty()) { - player.sendMessage(Color.MESSAGE + "Available warps (with prices):"); - player.sendMessage(Color.TEXT + StringUtils.join(warps.toArray(), ", ")); - } else { - player.sendMessage(Color.MESSAGE + "You don't have access to any warps."); - } - } else if((warp = getWarp(args[0])) != null && hasRank(warp.getRank()) && canAfford(warp.getPrice())) { - player.debit(warp.getPrice()); - player.teleport(warp); } + if(!warps.isEmpty()) { + player.sendMessage(Color.MESSAGE + "Available warps (with prices):"); + player.sendMessage(Color.TEXT + StringUtils.join(warps.toArray(), ", ")); + } else { + player.sendMessage(Color.MESSAGE + "You don't have access to any warps."); + } + } else if(numArgsHelp(1) && (warp = getWarp(args[0])) != null && hasRank(warp.getRank()) && canAfford(warp.getPrice())) { + player.debit(warp.getPrice()); + player.teleport(warp); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/WhereCmd.java b/src/com/undeadscythes/udsplugin/commands/WhereCmd.java index 906a4ce..87de5e3 100644 --- a/src/com/undeadscythes/udsplugin/commands/WhereCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/WhereCmd.java @@ -12,18 +12,16 @@ public class WhereCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - int distance = (int)(Math.sqrt(Math.pow(player.getLocation().getBlockX(), 2) + Math.pow(player.getLocation().getBlockZ(), 2))); - String message = "You are " + distance + " blocks from spawn"; - if(player.getLocation().getBlockY() < 64) { - message = message.concat(" " + (64 - player.getLocation().getBlockY()) + " blocks below sea level"); - } else if(player.getLocation().getBlockY() > 64) { - message = message.concat(" " + (player.getLocation().getBlockY() - 64) + " blocks above sea level"); - } else { - message = message.concat(" at sea level"); - } - message = message.concat(" in a " + player.getLocation().getBlock().getBiome().toString().toLowerCase().replace("_", " ") + " biome"); - player.sendMessage(Color.MESSAGE + message); + int distance = (int)(Math.sqrt(Math.pow(player.getLocation().getBlockX(), 2) + Math.pow(player.getLocation().getBlockZ(), 2))); + String message = "You are " + distance + " blocks from spawn"; + if(player.getLocation().getBlockY() < 64) { + message = message.concat(" " + (64 - player.getLocation().getBlockY()) + " blocks below sea level"); + } else if(player.getLocation().getBlockY() > 64) { + message = message.concat(" " + (player.getLocation().getBlockY() - 64) + " blocks above sea level"); + } else { + message = message.concat(" at sea level"); } + message = message.concat(" in a " + player.getLocation().getBlock().getBiome().toString().toLowerCase().replace("_", " ") + " biome"); + player.sendMessage(Color.MESSAGE + message); } } diff --git a/src/com/undeadscythes/udsplugin/commands/WhoCmd.java b/src/com/undeadscythes/udsplugin/commands/WhoCmd.java index efbda52..28fc4bd 100644 --- a/src/com/undeadscythes/udsplugin/commands/WhoCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/WhoCmd.java @@ -15,20 +15,18 @@ public class WhoCmd extends PlayerCommandExecutor { */ @Override public void playerExecute(SaveablePlayer player, String[] args) { - if(argsEq(0)) { - TreeMap lists = new TreeMap(); - for(PlayerRank rank : PlayerRank.values()) { - lists.put(rank, ""); - } - for(SaveablePlayer onlinePlayer : UDSPlugin.getOnlinePlayers().values()) { - String current = lists.get(onlinePlayer.getRank()); - lists.put(onlinePlayer.getRank(), current + (player.getGameMode() == GameMode.CREATIVE ? "[C]" : (player.hasGodMode() ? "[G]" : "")) + onlinePlayer.getDisplayName() + " "); - } - player.sendMessage(Color.MESSAGE + "--- Online Players (" + UDSPlugin.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers() + ") ---"); - for(Map.Entry entry : lists.entrySet()) { - if(!entry.getValue().equals("")) { - player.sendMessage(entry.getKey().color() + entry.getValue()); - } + TreeMap lists = new TreeMap(); + for(PlayerRank rank : PlayerRank.values()) { + lists.put(rank, ""); + } + for(SaveablePlayer onlinePlayer : UDSPlugin.getOnlinePlayers().values()) { + String current = lists.get(onlinePlayer.getRank()); + lists.put(onlinePlayer.getRank(), current + (player.getGameMode() == GameMode.CREATIVE ? "[C]" : (player.hasGodMode() ? "[G]" : "")) + onlinePlayer.getDisplayName() + " "); + } + player.sendMessage(Color.MESSAGE + "--- Online Players (" + UDSPlugin.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers() + ") ---"); + for(Map.Entry entry : lists.entrySet()) { + if(!entry.getValue().equals("")) { + player.sendMessage(entry.getKey().color() + entry.getValue()); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/WhoIsCmd.java b/src/com/undeadscythes/udsplugin/commands/WhoIsCmd.java index 0dc37b9..0be957e 100644 --- a/src/com/undeadscythes/udsplugin/commands/WhoIsCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/WhoIsCmd.java @@ -3,7 +3,7 @@ import com.undeadscythes.udsplugin.*; /** - * Description. + * Checks the identity of a player. * @author UndeadScythes */ public class WhoIsCmd extends PlayerCommandExecutor { @@ -13,7 +13,7 @@ public class WhoIsCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsEq(1) && (target = getMatchingPlayer(args[0])) != null) { + if(numArgsHelp(1) && (target = getMatchingPlayer(args[0])) != null) { player.sendMessage(Color.MESSAGE + target.getDisplayName() + " is " + target.getName() + "."); } } diff --git a/src/com/undeadscythes/udsplugin/commands/XPCmd.java b/src/com/undeadscythes/udsplugin/commands/XPCmd.java index 6243bd1..27aa45b 100644 --- a/src/com/undeadscythes/udsplugin/commands/XPCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/XPCmd.java @@ -14,7 +14,7 @@ public class XPCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { SaveablePlayer target; - if(argsEq(2) && (target = getMatchingOnlinePlayer(args[0])) != null) { + if(numArgsHelp(2) && (target = getMatchingOnlinePlayer(args[0])) != null) { if(args[1].matches("[0-9][0-9]*")) { for(int i = 0; i < 10; i++) { target.getWorld().spawnEntity(target.getLocation(), EntityType.EXPERIENCE_ORB); @@ -26,7 +26,7 @@ public void playerExecute(SaveablePlayer player, String[] args) { target.setLevel(0); player.sendMessage(Color.MESSAGE + target.getDisplayName() + "'s experience has been reset."); } else { - player.performCommand("help xp"); + subCmdHelp(args); } } } diff --git a/src/com/undeadscythes/udsplugin/commands/YCmd.java b/src/com/undeadscythes/udsplugin/commands/YCmd.java index 5467b94..b5ca19d 100644 --- a/src/com/undeadscythes/udsplugin/commands/YCmd.java +++ b/src/com/undeadscythes/udsplugin/commands/YCmd.java @@ -1,11 +1,10 @@ package com.undeadscythes.udsplugin.commands; -import com.undeadscythes.udsplugin.Request.RequestType; import com.undeadscythes.udsplugin.*; import org.bukkit.entity.*; /** - * Accept a request. + * Accept a request sent by another player. * @author UndeadScythes */ public class YCmd extends PlayerCommandExecutor { @@ -15,57 +14,67 @@ public class YCmd extends PlayerCommandExecutor { @Override public void playerExecute(SaveablePlayer player, String[] args) { Request request; - if(argsEq(0) && (request = getRequest()) != null) { - SaveablePlayer sender = request.getSender(); + SaveablePlayer sender; + if((request = getRequest()) != null && (sender = request.getSender()) != null && sender.isOnline()) { int price; - if(sender.isOnline()) { - if(request.getType().equals(RequestType.TP)) { - sender.teleport(player); - } else if(request.getType().equals(RequestType.CLAN)) { - Clan clan = UDSPlugin.getClans().get(request.getData()); - clan.addMember(player); - clan.sendMessage(player.getDisplayName() + " has joined the clan."); - Region base; - if((base = UDSPlugin.getBases().get(clan.getName() + "base")) != null) { - base.addMember(player); - } - } else if(request.getType().equals(RequestType.HOME) && canAfford(price = Integer.parseInt(request.getData())) && noHome()) { - Region home = UDSPlugin.getHomes().get(sender.getName() + "home"); - home.clearMembers(); - home.changeOwner(player); - player.debit(price); - sender.credit(price); - } else if(request.getType().equals(RequestType.PET) && canAfford(price = Integer.parseInt(request.getData()))) { - for(Entity entity : sender.getWorld().getEntities()) { - if(entity.getUniqueId().equals(sender.getSelectedPet())) { - player.debit(Integer.parseInt(request.getData())); - sender.credit(Integer.parseInt(request.getData())); - ((Tameable)entity).setOwner(player); - entity.teleport(player); - player.sendMessage(Color.MESSAGE + "Your bought " + sender.getDisplayName() + "'s pet."); - sender.sendMessage(Color.MESSAGE + player.getDisplayName() + " bought your pet."); - } - } - } else if(request.getType().equals(RequestType.PVP) && canAfford(price = Integer.parseInt(request.getData()))) { - sender.sendMessage(Color.MESSAGE + player.getDisplayName() + " accepted your duel, may the best player win."); - player.sendMessage(Color.MESSAGE + "Duel accepted, may the best player win."); - player.setChallenger(sender); - sender.setChallenger(sender); - player.setWager(price); - sender.setWager(price); - } else if(request.getType().equals(RequestType.SHOP) && canAfford(price = Integer.parseInt(request.getData())) && noShop()) { - Region shop = UDSPlugin.getShops().get(sender.getName() + "shop"); - shop.clearMembers(); - shop.changeOwner(player); - player.debit(price); - sender.credit(price); - } else { - sender.sendMessage(Color.MESSAGE + player.getDisplayName() + " was unable to accept your request."); - } - } else { - player.sendMessage(Color.MESSAGE + "The player who sent this request is no longer online."); + switch (request.getType()) { + case TP: sender.teleport(player); + break; + + case CLAN: Clan clan = UDSPlugin.getClans().get(request.getData()); + clan.addMember(player); + clan.sendMessage(player.getDisplayName() + " has joined the clan."); + Region base; + if((base = UDSPlugin.getBases().get(clan.getName() + "base")) != null) { + base.addMember(player); + } + break; + + case HOME: if(canAfford(price = Integer.parseInt(request.getData())) && noHome()) { + Region home = UDSPlugin.getHomes().get(sender.getName() + "home"); + home.clearMembers(); + home.changeOwner(player); + player.debit(price); + sender.credit(price); + } + break; + + case PET: if(canAfford(price = Integer.parseInt(request.getData()))) { + for(Entity entity : sender.getWorld().getEntities()) { + if(entity.getUniqueId().equals(sender.getSelectedPet())) { + player.debit(price); + sender.credit(price); + ((Tameable)entity).setOwner(player); + entity.teleport(player); + player.sendMessage(Color.MESSAGE + "Your bought " + sender.getDisplayName() + "'s pet."); + sender.sendMessage(Color.MESSAGE + player.getDisplayName() + " bought your pet."); + } + } + } + break; + + case PVP: if(canAfford(price = Integer.parseInt(request.getData()))) { + sender.sendMessage(Color.MESSAGE + player.getDisplayName() + " accepted your duel, may the best player win."); + player.sendMessage(Color.MESSAGE + "Duel accepted, may the best player win."); + player.setChallenger(sender); + sender.setChallenger(sender); + player.setWager(price); + sender.setWager(price); + } + break; + + case SHOP: if(canAfford(price = Integer.parseInt(request.getData())) && noShop()) { + Region shop = UDSPlugin.getShops().get(sender.getName() + "shop"); + shop.clearMembers(); + shop.changeOwner(player); + player.debit(price); + sender.credit(price); + } + break; + + default: sender.sendMessage(Color.MESSAGE + player.getDisplayName() + " was unable to accept your request."); } - UDSPlugin.getRequests().remove(player.getName()); } + UDSPlugin.getRequests().remove(player.getName()); } } diff --git a/src/plugin.yml b/src/plugin.yml index 25f6f87..b3e4e0e 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: UDSPlugin main: com.undeadscythes.udsplugin.UDSPlugin -version: 0.22 +version: 0.23 description: UDSPlugin1 for CB 1.4.5-R0.3 #2499. author: UndeadScythes - daveyognaut2@gmail.com website: http://undeadscythes.webs.com/