diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index 9232021f8..d7a64f3c9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -88,13 +88,15 @@ public class Buy extends SubCommand { if (flag == null) { return sendMessage(plr, C.NOT_FOR_SALE); } - double price = Double.parseDouble(flag.getValue()); + double initPrice = Double.parseDouble(flag.getValue()); + double price = initPrice; PlotId id = plot.id; PlotId id2 = PlayerFunctions.getTopPlot(world, plot).id; int size = PlayerFunctions.getPlotSelectionIds(world, id, id2).size(); PlotWorld plotworld = PlotMain.getWorldSettings(world); if (plotworld.USE_ECONOMY) { price += plotworld.PLOT_PRICE * size; + initPrice += plotworld.SELL_PRICE * size; } if (price > 0d) { final Economy economy = PlotMain.economy; @@ -103,9 +105,15 @@ public class Buy extends SubCommand { } economy.withdrawPlayer(plr, price); sendMessage(plr, C.REMOVED_BALANCE, price + ""); + economy.depositPlayer(UUIDHandler.uuidWrapper.getOfflinePlayer(plot.owner), initPrice); + Player owner = UUIDHandler.uuidWrapper.getPlayer(plot.owner); + if (owner != null) { + sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + ""); + } } plot.owner = UUIDHandler.getUUID(plr); DBFunc.setOwner(plot, plot.owner); PlayerFunctions.sendMessage(plr, C.CLAIMED); + return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index ea9149cd3..185dde60f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -48,7 +48,7 @@ public class MainCommand implements CommandExecutor, TabCompleter { */ public static final String MAIN_PERMISSION = "plots.use"; - private final static SubCommand[] _subCommands = new SubCommand[]{new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim()}; + private final static SubCommand[] _subCommands = new SubCommand[]{new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Ban(), new Unban(), new OP(), new DEOP(), new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new Buy()}; public final static ArrayList subCommands = new ArrayList() { { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index 095ace3b8..da44eddc3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -23,11 +23,14 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.flag.Flag; +import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.PlayerFunctions; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.UUIDHandler; + import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -40,7 +43,7 @@ import java.util.UUID; public class list extends SubCommand { public list() { - super(Command.LIST, "List all plots", "list {mine|shared|all|world}", CommandCategory.INFO, false); + super(Command.LIST, "List all plots", "list {mine|shared|all|world|forsale}", CommandCategory.INFO, false); } private static String getName(final UUID id) { @@ -60,13 +63,32 @@ public class list extends SubCommand { final StringBuilder builder = new StringBuilder(); builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s()); if (plr != null) { - builder.append(getArgumentList(new String[]{"mine", "shared", "world", "all"})); + builder.append(getArgumentList(new String[]{"mine", "shared", "world", "all", "forsale"})); } else { builder.append(getArgumentList(new String[]{"all"})); } PlayerFunctions.sendMessage(plr, builder.toString()); return true; } + if (args[0].equalsIgnoreCase("forsale") && (plr != null)) { + final StringBuilder string = new StringBuilder(); + string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your")).append("\n"); + int idx = 0; + for (final Plot p : PlotMain.getPlots(plr.getWorld()).values()) { + Flag price = FlagManager.getPlotFlag(p, "price"); + if (price != null) { + string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", idx + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", price.getValue()).replaceAll("%owner", getName(p.owner))).append("\n"); + idx++; + } + } + if (idx == 0) { + PlayerFunctions.sendMessage(plr, C.NO_PLOTS); + return true; + } + string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "You have").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1 ? "plot" : "plots")); + PlayerFunctions.sendMessage(plr, string.toString()); + return true; + } if (args[0].equalsIgnoreCase("mine") && (plr != null)) { final StringBuilder string = new StringBuilder(); string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your")).append("\n"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index e24aeca4f..d108a613b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -85,6 +85,7 @@ public enum C { ECON_DISABLED("&cEconomy is not enabled"), CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"), NOT_FOR_SALE("&cThis plot is not for sale"), + PLOT_SOLD("&aYour plot; &6%s&a, has been sold to &6%s&a for &6$%s"), CANNOT_AFFORD_MERGE("&cYou cannot afford to merge the plots. It costs &6%s"), ADDED_BALANCE("&6%s &chas been added to your balance"), REMOVED_BALANCE("&6%s &chas been taken from your balance"), @@ -356,6 +357,7 @@ public enum C { HELPER_REMOVED("&6You successfully removed a helper from the plot"), HELPER_NEED_ARGUMENT("&cArguments are missing. &6/plot helpers add &cor &6/plot helpers remove "), WAS_NOT_ADDED("&cThat player was not added as a helper on this plot"), + PLOT_REMOVED_HELPER("&6Plot %s of which you were added to has been deleted due to owner inactivity"), /* * Trusted */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 4981d9982..f3cfc2d3b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -6,6 +6,7 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; + import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.World; @@ -13,6 +14,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.commands.Auto; +import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; @@ -80,6 +82,14 @@ public class ExpireManager { event.setCancelled(true); return; } + + for (UUID helper : plot.helpers) { + Player player = UUIDHandler.uuidWrapper.getPlayer(helper); + if (player != null) { + PlayerFunctions.sendMessage(player, C.PLOT_REMOVED_HELPER, plot.id.toString()); + } + } + final World worldobj = Bukkit.getWorld(world); final PlotManager manager = PlotMain.getPlotManager(world); manager.clearPlot(worldobj, plot, false); @@ -95,7 +105,7 @@ public class ExpireManager { } } - }, 1200, 1200); + }, 2400, 2400); } public static boolean isExpired(UUID uuid) {