public boolean exec(IPlayer player, String[] args) { if (manager.isPlotWorld(player)) { if (player.hasPermission(PermissionNames.ADMIN_DONE)) { int page = 1; if (args.length == 2) { page = Integer.parseInt(args[1]); } int maxPage = (int) Math.ceil( plugin.getSqlManager().getFinishedPlotCount(player.getWorld().getName()) / 8F); if (page < 1) { page = 1; } else if (page > maxPage) { page = maxPage; } List<Plot> donePlots = plugin.getSqlManager().getDonePlots(player.getWorld().getName(), page, 8); if (donePlots.isEmpty()) { player.sendMessage(C("MsgNoPlotsFinished")); } else { player.sendMessage(C("MsgFinishedPlotsPage") + " " + page + "/" + maxPage); for (Plot plot : donePlots) { String startText = " §b" + plot.getId() + "§r -> " + plot.getOwner(); int textLength = MinecraftFontWidthCalculator.getStringWidth(startText); String line = startText + whitespace(550 - textLength) + "@" + plot.getFinishedDate(); player.sendMessage(line); } } } else { player.sendMessage("§c" + C("MsgPermissionDenied")); return false; } } else { player.sendMessage("§c" + C("MsgNotPlotWorld")); } return true; }
public boolean execute(ICommandSender sender, String[] args) { IPlayer player = (IPlayer) sender; if (player.hasPermission(PermissionNames.ADMIN_EXPIRED)) { if (manager.isPlotWorld(player.getWorld())) { PlotMapInfo pmi = manager.getMap(player); if (pmi.getDaysToExpiration() != 0) { int page = 1; if (args.length == 2) { page = Integer.parseInt(args[1]); } List<List<Plot>> partition = Lists.partition(plugin.getSqlManager().getExpiredPlots(player.getWorld()), 10); if (partition.isEmpty()) { player.sendMessage(C("MsgNoPlotExpired")); } else { player.sendMessage(C("MsgExpiredPlotsPage", page, partition.size())); for (Plot plot : partition.get(page - 1)) { assert plot.getExpiredDate() != null; player.sendMessage( plot.getId() + " -> " + plot.getOwner() + " @ " + plot.getExpiredDate().toString()); } } } else { return true; } } else { player.sendMessage(C("NotPlotWorld")); return true; } } else { return false; } return true; }
public boolean execute(ICommandSender sender, String[] args) { if (args.length > 1) { sender.sendMessage(getUsage()); return true; } IPlayer player = (IPlayer) sender; if (player.hasPermission(PermissionNames.ADMIN_CLEAR) || player.hasPermission(PermissionNames.USER_CLEAR)) { IWorld world = player.getWorld(); PlotMapInfo pmi = manager.getMap(world); if (manager.isPlotWorld(world)) { Plot plot = manager.getPlot(player); if (plot == null) { player.sendMessage(C("NoPlotFound")); return true; } else if (plot.isProtected()) { player.sendMessage(C("MsgPlotProtectedCannotClear")); } else { String playerName = player.getName(); if (player.getUniqueId().equals(plot.getOwnerId()) || player.hasPermission(PermissionNames.ADMIN_CLEAR)) { double price = 0.0; PlotClearEvent event = new PlotClearEvent(plot, player); if (manager.isEconomyEnabled(pmi)) { price = pmi.getClearPrice(); if (serverBridge.has(player, price)) { plugin.getEventBus().post(event); if (event.isCancelled()) { return true; } else { EconomyResponse er = serverBridge.withdrawPlayer(player, price); if (!er.transactionSuccess()) { player.sendMessage(er.errorMessage); serverBridge.getLogger().warning(er.errorMessage); return true; } } } else { player.sendMessage( C("MsgNotEnoughClear") + " " + C("WordMissing") + " " + serverBridge.getEconomy().get().format(price)); return true; } } else { plugin.getEventBus().post(event); } if (!event.isCancelled()) { manager.clear(plot, player, ClearReason.Clear); if (isAdvancedLogging()) { if (price == 0) { serverBridge .getLogger() .info(playerName + " " + C("MsgClearedPlot") + " " + plot.getId().getID()); } else { serverBridge .getLogger() .info( playerName + " " + C("MsgClearedPlot") + " " + plot.getId().getID() + (" " + C("WordFor") + " " + price)); } } } } else { player.sendMessage( C("MsgThisPlot") + "(" + plot.getId().getID() + ") " + C("MsgNotYoursNotAllowedClear")); } } } else { player.sendMessage(C("NotPlotWorld")); } } else { return false; } return true; }
public HashSet<String> getAllAllowed() { return _plot.allowed(); }
public boolean exec(Player p, String[] args) { if (plugin.cPerms(p, "PlotMe.admin.add") || plugin.cPerms(p, "PlotMe.use.add")) { if (!plugin.getPlotMeCoreManager().isPlotWorld(p)) { p.sendMessage(RED + C("MsgNotPlotWorld")); } else { String id = plugin.getPlotMeCoreManager().getPlotId(p.getLocation()); if (id.equals("")) { p.sendMessage(RED + C("MsgNoPlotFound")); } else { if (!plugin.getPlotMeCoreManager().isPlotAvailable(id, p)) { if (args.length < 2 || args[1].equals("")) { p.sendMessage( C("WordUsage") + " " + RED + "/plotme " + C("CommandAdd") + " <" + C("WordPlayer") + ">"); } else { Plot plot = plugin.getPlotMeCoreManager().getPlotById(p, id); String playername = p.getName(); String allowed = args[1]; if (plot.owner.equalsIgnoreCase(playername) || plugin.cPerms(p, "PlotMe.admin.add")) { if (plot.isAllowed(allowed)) { p.sendMessage( C("WordPlayer") + " " + RED + args[1] + RESET + " " + C("MsgAlreadyAllowed")); } else { World w = p.getWorld(); PlotMapInfo pmi = plugin.getPlotMeCoreManager().getMap(w); double price = 0; PlotAddAllowedEvent event = PlotMeEventFactory.callPlotAddAllowedEvent(plugin, w, plot, p, allowed); if (!event.isCancelled()) { if (plugin.getPlotMeCoreManager().isEconomyEnabled(w)) { price = pmi.AddPlayerPrice; double balance = plugin.getEconomy().getBalance(playername); if (balance >= price) { EconomyResponse er = plugin.getEconomy().withdrawPlayer(playername, price); if (!er.transactionSuccess()) { p.sendMessage(RED + er.errorMessage); plugin.getUtil().warn(er.errorMessage); return true; } } else { p.sendMessage( RED + C("MsgNotEnoughAdd") + " " + C("WordMissing") + " " + RESET + Util().moneyFormat(price - balance, false)); return true; } } plot.addAllowed(args[1]); p.sendMessage( C("WordPlayer") + " " + RED + allowed + RESET + " " + C("MsgNowAllowed") + " " + Util().moneyFormat(-price)); if (isAdv) { plugin .getLogger() .info( LOG + playername + " " + C("MsgAddedPlayer") + " " + allowed + " " + C("MsgToPlot") + " " + id + ((price != 0) ? " " + C("WordFor") + " " + price : "")); } } } } else { p.sendMessage( RED + C("MsgThisPlot") + "(" + id + ") " + C("MsgNotYoursNotAllowedAdd")); } } } else { p.sendMessage(RED + C("MsgThisPlot") + "(" + id + ") " + C("MsgHasNoOwner")); } } } } else { p.sendMessage(RED + C("MsgPermissionDenied")); } return true; }
public boolean execute(ICommandSender sender, String[] args) { if (args.length > 1) { sender.sendMessage(getUsage()); return true; } IPlayer player = (IPlayer) sender; if (player.hasPermission(PermissionNames.USER_INFO)) { IWorld world = player.getWorld(); if (manager.isPlotWorld(world)) { Plot plot = manager.getPlot(player); if (plot == null) { player.sendMessage(C("MsgNoPlotFound")); return true; } player.sendMessage("Internal ID: " + plot.getInternalID()); player.sendMessage( "ID: " + plot.getId().getID() + " " + C("InfoOwner") + ": " + plot.getOwner() + " " + C("InfoBiome") + ": " + plot.getBiome()); player.sendMessage("Likes: " + plot.getLikes()); player.sendMessage("Created: " + plot.getCreatedDate()); final String neverExpire = C("InfoExpire") + ": " + C("WordNever"); if (plot.getExpiredDate() == null) { if (plot.isFinished()) { if (plot.isProtected()) { player.sendMessage( neverExpire + " " + C("InfoFinished") + ": " + C("WordYes") + " " + C("InfoProtected") + ": " + C("WordYes")); } else { player.sendMessage( neverExpire + " " + C("InfoFinished") + ": " + C("WordYes") + " " + C("InfoProtected") + ": " + C("WordNo")); } } else { if (plot.isProtected()) { player.sendMessage( neverExpire + " " + C("InfoFinished") + ": " + C("WordNo") + " " + C("InfoProtected") + ": " + C("WordYes")); } else { player.sendMessage( neverExpire + " " + C("InfoFinished") + ": " + C("WordNo") + " " + C("InfoProtected") + ": " + C("WordNo")); } } } else if (plot.isProtected()) { if (plot.isFinished()) { player.sendMessage( neverExpire + " " + C("InfoFinished") + ": " + C("WordYes") + " " + C("InfoProtected") + ": " + C("WordYes")); } else { player.sendMessage( neverExpire + " " + C("InfoFinished") + ": " + C("WordNo") + " " + C("InfoProtected") + ": " + C("WordYes")); } } else if (plot.isFinished()) { player.sendMessage( C("InfoExpire") + ": " + plot.getExpiredDate() + " " + C("InfoFinished") + ": " + C("WordYes") + " " + C("InfoProtected") + ": " + C("WordNo")); } else { player.sendMessage( C("InfoExpire") + ": " + plot.getExpiredDate() + " " + C("InfoFinished") + ": " + C("WordNo") + " " + C("InfoProtected") + ": " + C("WordNo")); } if (!plot.getMembers().isEmpty()) { StringBuilder builder = new StringBuilder("Members: "); if (!plot.getMembers().containsKey("*")) { for (Map.Entry<String, Plot.AccessLevel> member : plot.getMembers().entrySet()) { builder .append( plugin .getServerBridge() .getOfflinePlayer(UUID.fromString(member.getKey())) .getName()) .append(" (") .append(member.getValue().toString()) .append(") "); } } else { builder.append("*"); } player.sendMessage(builder.toString()); } if (!plot.getDenied().isEmpty()) { StringBuilder builder = new StringBuilder(C("InfoDenied")); builder.append(": "); if (!plot.getDenied().contains("*")) { for (String s : plot.getDenied()) { builder .append(plugin.getServerBridge().getOfflinePlayer(UUID.fromString(s)).getName()) .append(" "); } } else { builder.append('*'); } player.sendMessage(builder.toString()); } if (manager.isEconomyEnabled(world)) { if (plot.isForSale()) { player.sendMessage(C("InfoForSale") + ": " + plot.getPrice()); } else { player.sendMessage(C("InfoForSale") + ": " + C("WordNo")); } } player.sendMessage(C("WordBottom") + ": " + plot.getPlotBottomLoc().toString()); player.sendMessage(C("WordTop") + ": " + plot.getPlotTopLoc()); } else { player.sendMessage(C("MsgNotPlotWorld")); } } else { return false; } return true; }
public boolean exec(Player p, String[] args) { if (plugin.getPlotMeCoreManager().isEconomyEnabled(p)) { PlotMapInfo pmi = plugin.getPlotMeCoreManager().getMap(p); if (pmi.CanSellToBank || pmi.CanPutOnSale) { if (plugin.cPerms(p, "PlotMe.use.sell") || plugin.cPerms(p, "PlotMe.admin.sell")) { Location l = p.getLocation(); String id = plugin.getPlotMeCoreManager().getPlotId(l); if (id.equals("")) { p.sendMessage(RED + C("MsgNoPlotFound")); } else { if (!plugin.getPlotMeCoreManager().isPlotAvailable(id, p)) { Plot plot = plugin.getPlotMeCoreManager().getPlotById(p, id); if (plot.owner.equalsIgnoreCase(p.getName()) || plugin.cPerms(p, "PlotMe.admin.sell")) { World w = p.getWorld(); String name = p.getName(); PlotSellChangeEvent event; if (plot.forsale) { event = PlotMeEventFactory.callPlotSellChangeEvent( plugin, w, plot, p, plot.customprice, false, false); if (!event.isCancelled()) { plot.customprice = 0; plot.forsale = false; plot.updateField("customprice", 0); plot.updateField("forsale", false); plugin.getPlotMeCoreManager().adjustWall(l); plugin.getPlotMeCoreManager().setSellSign(w, plot); p.sendMessage(C("MsgPlotNoLongerSale")); if (isAdv) plugin .getLogger() .info( LOG + name + " " + C("MsgRemovedPlot") + " " + id + " " + C("MsgFromBeingSold")); } } else { double price = pmi.SellToPlayerPrice; boolean bank = false; if (args.length == 2) { if (args[1].equalsIgnoreCase("bank")) { bank = true; } else { if (pmi.CanCustomizeSellPrice) { try { price = Double.parseDouble(args[1]); } catch (Exception e) { if (pmi.CanSellToBank) { p.sendMessage( C("WordUsage") + ": " + RED + " /plotme " + C("CommandSellBank") + "|<" + C("WordAmount") + ">"); p.sendMessage( " " + C("WordExample") + ": " + RED + "/plotme " + C("CommandSellBank") + " " + RESET + " or " + RED + " /plotme " + C("CommandSell") + " 200"); } else { p.sendMessage( C("WordUsage") + ": " + RED + " /plotme " + C("CommandSell") + " <" + C("WordAmount") + ">" + RESET + " " + C("WordExample") + ": " + RED + "/plotme " + C("CommandSell") + " 200"); } } } else { p.sendMessage(RED + C("MsgCannotCustomPriceDefault") + " " + price); return true; } } } if (bank) { if (!pmi.CanSellToBank) { p.sendMessage(RED + C("MsgCannotSellToBank")); } else { String currentbidder = plot.currentbidder; if (!currentbidder.equals("")) { double bid = plot.currentbid; EconomyResponse er = plugin.getEconomy().depositPlayer(currentbidder, bid); if (!er.transactionSuccess()) { p.sendMessage(RED + er.errorMessage); Util().warn(er.errorMessage); } else { for (Player player : Bukkit.getServer().getOnlinePlayers()) { if (player.getName().equalsIgnoreCase(currentbidder)) { player.sendMessage( C("WordPlot") + " " + id + " " + C("MsgOwnedBy") + " " + plot.owner + " " + C("MsgSoldToBank") + " " + Util().moneyFormat(bid)); break; } } } } double sellprice = pmi.SellToBankPrice; event = PlotMeEventFactory.callPlotSellChangeEvent( plugin, w, plot, p, pmi.BuyFromBankPrice, true, true); if (!event.isCancelled()) { EconomyResponse er = plugin.getEconomy().depositPlayer(name, sellprice); if (er.transactionSuccess()) { plot.owner = "$Bank$"; plot.forsale = true; plot.customprice = pmi.BuyFromBankPrice; plot.auctionned = false; plot.currentbidder = ""; plot.currentbid = 0; plot.removeAllAllowed(); plugin.getPlotMeCoreManager().setOwnerSign(w, plot); plugin.getPlotMeCoreManager().setSellSign(w, plot); plot.updateField("owner", plot.owner); plot.updateField("forsale", true); plot.updateField("auctionned", true); plot.updateField("customprice", plot.customprice); plot.updateField("currentbidder", ""); plot.updateField("currentbid", 0); p.sendMessage(C("MsgPlotSold") + " " + Util().moneyFormat(sellprice)); if (isAdv) plugin .getLogger() .info( LOG + name + " " + C("MsgSoldToBankPlot") + " " + id + " " + C("WordFor") + " " + sellprice); } else { p.sendMessage(" " + er.errorMessage); Util().warn(er.errorMessage); } } } } else { if (price < 0) { p.sendMessage(RED + C("MsgInvalidAmount")); } else { event = PlotMeEventFactory.callPlotSellChangeEvent( plugin, w, plot, p, price, false, true); if (!event.isCancelled()) { plot.customprice = price; plot.forsale = true; plot.updateField("customprice", price); plot.updateField("forsale", true); plugin.getPlotMeCoreManager().adjustWall(l); plugin.getPlotMeCoreManager().setSellSign(w, plot); p.sendMessage(C("MsgPlotForSale")); if (isAdv) plugin .getLogger() .info( LOG + name + " " + C("MsgPutOnSalePlot") + " " + id + " " + C("WordFor") + " " + price); } } } } } else { p.sendMessage(RED + C("MsgDoNotOwnPlot")); } } else { p.sendMessage(RED + C("MsgThisPlot") + "(" + id + ") " + C("MsgHasNoOwner")); } } } else { p.sendMessage(RED + C("MsgPermissionDenied")); } } else { p.sendMessage(RED + C("MsgSellingPlotsIsDisabledWorld")); } } else { p.sendMessage(RED + C("MsgEconomyDisabledWorld")); } return true; }