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 d7a64f3c9..bc0d35542 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -84,6 +84,9 @@ public class Buy extends SubCommand { if (!plot.hasOwner()) { return sendMessage(plr, C.PLOT_UNOWNED); } + if (plot.owner.equals(UUIDHandler.getUUID(plr))) { + return sendMessage(plr, C.CANNOT_BUY_OWN); + } Flag flag = FlagManager.getPlotFlag(plot, "price"); if (flag == null) { return sendMessage(plr, C.NOT_FOR_SALE); @@ -110,6 +113,7 @@ public class Buy extends SubCommand { if (owner != null) { sendMessage(plr, C.PLOT_SOLD, plot.id + "", plr.getName(), initPrice + ""); } + FlagManager.removePlotFlag(plot, "price"); } plot.owner = UUIDHandler.getUUID(plr); DBFunc.setOwner(plot, plot.owner); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java index 6660b479a..98b61f56a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Command.java @@ -36,7 +36,7 @@ public enum Command { // (Rating system) (ratings can be stored as the average, and number of // ratings) // - /plot rate - BUY("b"), + BUY("buy","b"), /** * */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index 9a5f53ccf..087941187 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -57,10 +57,8 @@ public class Comment extends SubCommand { final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " "); final PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase())); plot.settings.addComment(comment); - DBFunc.setComment(plr.getWorld().getName(), plot, comment); - - return true; + return sendMessage(plr, C.COMMENT_ADDED); } else { return sendMessage(plr, C.NO_PERMISSION, "plots.comment." + args[0].toLowerCase()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index be77723a9..7a9901e1d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -40,7 +40,7 @@ import java.util.UUID; public class Inbox extends SubCommand { public Inbox() { - super(Command.INBOX, "Review a the comments for a plot", "inbox", CommandCategory.ACTIONS, true); + super(Command.INBOX, "Review the comments for a plot", "inbox", CommandCategory.ACTIONS, true); } @Override @@ -125,7 +125,7 @@ public class Inbox extends SubCommand { public void run() { ArrayList comments = plot.settings.getComments(tier2); if (comments == null) { - comments = DBFunc.getCommenst(world, plot, tier2); + comments = DBFunc.getComments(world, plot, tier2); plot.settings.setComments(comments); } 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 da44eddc3..a72a77fa4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -71,8 +71,11 @@ public class list extends SubCommand { return true; } if (args[0].equalsIgnoreCase("forsale") && (plr != null)) { + if (PlotMain.economy == null) { + return sendMessage(plr, C.ECON_DISABLED); + } final StringBuilder string = new StringBuilder(); - string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your")).append("\n"); + string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "buyable")).append("\n"); int idx = 0; for (final Plot p : PlotMain.getPlots(plr.getWorld()).values()) { Flag price = FlagManager.getPlotFlag(p, "price"); @@ -85,7 +88,7 @@ public class list extends SubCommand { 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")); + string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "Includes").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1 ? "plot" : "plots")); PlayerFunctions.sendMessage(plr, string.toString()); return true; } 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 d108a613b..df4819f5f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -58,6 +58,7 @@ public enum C { INVALID_INBOX("&cThat is not a valid inbox.\n&6Accepted values: %s"), NO_PERM_INBOX("&cYou do not have permission to read that inbox."), COMMENT_REMOVED("&aSuccessfully deleted %s."), + COMMENT_ADDED("&aA comment has been left"), /* * Console */ @@ -85,6 +86,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"), + CANNOT_BUY_OWN("&cYou cannot buy your own plot"), 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"), diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index 60fe21d5f..4c2e76f64 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -214,7 +214,7 @@ public class DBFunc { /** * @param plot */ - public static ArrayList getCommenst(final String world, final Plot plot, final int tier) { + public static ArrayList getComments(final String world, final Plot plot, final int tier) { return dbManager.getComments(world, plot, tier); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 9cf9736ad..336010446 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -982,7 +982,7 @@ public class SQLManager implements AbstractDB { public ArrayList getComments(final String world, final Plot plot, final int tier) { final ArrayList comments = new ArrayList(); try { - final PreparedStatement statement = this.connection.prepareStatement("SELECT `*` FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` = ?"); + final PreparedStatement statement = this.connection.prepareStatement("SELECT `*` FROM `" + this.prefix + "plot_comments` WHERE `plot_plot_id` = ? AND `tier` <= ?"); statement.setInt(1, getId(plot.getWorld().getName(), plot.id)); statement.setInt(2, tier); final ResultSet set = statement.executeQuery();