diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index 5aee193ad..f0b363208 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -62,7 +62,7 @@ public class Clear extends SubCommand { Runnable runnable = new Runnable() { @Override public void run() { - MainUtil.clear(world, plot, plot.owner == null, null); + MainUtil.clear(world, plot, plot.owner_ == null, null); PlotSquared.log("Plot " + plot.getId().toString() + " cleared."); } }; @@ -110,7 +110,7 @@ public class Clear extends SubCommand { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; @@ -122,7 +122,7 @@ public class Clear extends SubCommand { @Override public void run() { final long start = System.currentTimeMillis(); - final boolean result = MainUtil.clearAsPlayer(plot, plot.owner == null, new Runnable() { + final boolean result = MainUtil.clearAsPlayer(plot, plot.owner_ == null, new Runnable() { @Override public void run() { MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 89a5ee654..3613a7e26 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -129,9 +129,9 @@ public class Cluster extends SubCommand { // Add any existing plots to the current cluster for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { final PlotCluster current = ClusterManager.getCluster(plot); - if (cluster.equals(current) && !cluster.hasRights(plot.owner)) { - cluster.invited.add(plot.owner); - DBFunc.setInvited(world, cluster, plot.owner); + if (cluster.equals(current) && !cluster.hasRights(plot.owner_)) { + cluster.invited.add(plot.owner_); + DBFunc.setInvited(world, cluster, plot.owner_); } } if (!PlotSquared.isPlotWorld(world)) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index 76b92e195..d7ec5885c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -123,7 +123,7 @@ public class DebugClaimTest extends SubCommand { } if (uuid != null) { MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); - plot.owner = uuid; + plot.owner_ = uuid; plot.hasChanged = true; plots.add(plot); } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java index 509106be0..2883c198c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -85,7 +85,7 @@ public class DebugClear extends SubCommand { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return sendMessage(plr, C.UNLINK_REQUIRED); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) { return sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 83f52878f..71d46599a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -97,7 +97,7 @@ public class DebugExec extends SubCommand { for (final Entry entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) { final Plot plot = entry.getKey(); final Long stamp = entry.getValue(); - MainUtil.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner) + " : " + stamp); + MainUtil.sendMessage(null, " - " + plot.world + ";" + plot.id.x + ";" + plot.id.y + ";" + UUIDHandler.getName(plot.owner_) + " : " + stamp); } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index a4a844b7b..541d5ee5a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -50,7 +50,7 @@ public class Delete extends SubCommand { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) { + if ((((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; @@ -62,7 +62,7 @@ public class Delete extends SubCommand { Runnable runnable = new Runnable() { @Override public void run() { - if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) { + if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.isOwner(UUIDHandler.getUUID(plr))) { final double c = pWorld.SELL_PRICE; if (c > 0d) { EconHandler.depositPlayer(plr, c); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index 168b6b8a7..9fbe31017 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -53,7 +53,7 @@ public class Denied extends SubCommand { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.denied")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.denied")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } @@ -69,7 +69,7 @@ public class Denied extends SubCommand { return false; } if (!plot.denied.contains(uuid)) { - if (plot.owner.equals(uuid)) { + if (plot.isOwner(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 3f3b6573c..b1d5c880d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -52,7 +52,7 @@ public class Helpers extends SubCommand { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.helpers")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.helpers")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } @@ -68,7 +68,7 @@ public class Helpers extends SubCommand { return false; } if (!plot.helpers.contains(uuid)) { - if (plot.owner.equals(uuid)) { + if (plot.isOwner(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java index 6a3e13d11..838ea3b0c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -63,7 +63,7 @@ public class Home extends SubCommand { Plot temp; if ((temp = isAlias(args[0])) != null) { if (temp.hasOwner()) { - if (temp.getOwner().equals(UUIDHandler.getUUID(plr))) { + if (temp.isOwner(plr.getUUID())) { MainUtil.teleportPlayer(plr, plr.getLocation(), temp); return true; } 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 144da8cbb..544219a82 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -59,10 +59,10 @@ public class Inbox extends SubCommand { return false; } Integer tier; - final UUID uuid = UUIDHandler.getUUID(plr); + final UUID uuid = plr.getUUID(); if (Permissions.hasPermission(plr, "plots.comment.admin")) { tier = 0; - } else if ((plot != null) && plot.owner.equals(uuid)) { + } else if ((plot != null) && plot.isOwner(uuid)) { tier = 1; } else if ((plot != null) && plot.helpers.contains(uuid)) { tier = 2; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 7e0268e0f..fb0b65a29 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -21,6 +21,9 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; import java.util.UUID; import org.apache.commons.lang.StringUtils; @@ -110,11 +113,11 @@ public class Info extends SubCommand { return true; } String owner = "none"; - if (plot.owner != null) { - owner = UUIDHandler.getName(plot.owner); + if (plot.owner_ == null) { + owner = "unowned"; } - if (owner == null) { - owner = plot.owner.toString(); + else { + owner = getPlayerList(plot.getOwners()); } String info = C.PLOT_INFO.s(); if (args.length == 1) { @@ -170,11 +173,11 @@ public class Info extends SubCommand { final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none"); final boolean build = (player == null) || plot.isAdded(player.getUUID()); String owner = "none"; - if (plot.owner != null) { - owner = UUIDHandler.getName(plot.owner); + if (plot.owner_ == null) { + owner = "unowned"; } - if (owner == null) { - owner = plot.owner.toString(); + else { + owner = getPlayerList(plot.getOwners()); } info = info.replaceAll("%alias%", alias); info = info.replaceAll("%id%", id.toString()); @@ -192,7 +195,8 @@ public class Info extends SubCommand { return info; } - private String getPlayerList(final ArrayList l) { + private String getPlayerList(final Collection uuids) { + ArrayList l = new ArrayList<>(uuids); if ((l == null) || (l.size() < 1)) { return " none"; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 0540bf88e..3de39de9f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -42,7 +42,7 @@ public class Kick extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index f8dbdf2a7..0b9504469 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -85,7 +85,7 @@ public class Merge extends SubCommand { return false; } final boolean admin = Permissions.hasPermission(plr, "plots.admin.command.merge"); - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) { + if (!plot.isOwner(plr.getUUID()) && !admin) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -138,10 +138,10 @@ public class Merge extends SubCommand { boolean multiMerge = false; final HashSet multiUUID = new HashSet(); HashSet multiPlots = new HashSet<>(); - final UUID u1 = plot.getOwner(); + final UUID u1 = plot.owner_; for (final PlotId myid : plots) { final Plot myplot = PlotSquared.getPlots(world).get(myid); - UUID u2 = myplot.getOwner(); + UUID u2 = myplot.owner_; if (myplot == null || u2 == null) { MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; @@ -190,7 +190,7 @@ public class Merge extends SubCommand { } MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot); MainUtil.update(loc); } MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED); @@ -219,7 +219,7 @@ public class Merge extends SubCommand { } MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.mergePlots(world, plots, true); - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot); MainUtil.update(loc); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index 2fd574adc..e6327b99b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -120,8 +120,8 @@ public class Purge extends SubCommand { final Collection plots = PlotSquared.getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { - if (plot.owner != null) { - final String name = UUIDHandler.getName(plot.owner); + if (plot.owner_ != null) { + final String name = UUIDHandler.getName(plot.owner_); if (name == null) { ids.add(plot.id); } @@ -138,7 +138,7 @@ public class Purge extends SubCommand { final Collection plots = PlotSquared.getPlots(worldname).values(); final Set ids = new HashSet<>(); for (final Plot plot : plots) { - if (plot.owner == null) { + if (plot.owner_ == null) { ids.add(plot.id); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 6073c9fae..9b46e38f3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -52,7 +52,7 @@ public class Rate extends SubCommand { sendMessage(plr, C.RATING_NOT_OWNED); return true; } - if (plot.getOwner().equals(UUIDHandler.getUUID(plr))) { + if (plot.isOwner(plr.getUUID())) { sendMessage(plr, C.RATING_NOT_YOUR_OWN); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index 0524b48e0..913806733 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -222,7 +222,7 @@ public class SchematicCmd extends SubCommand { } final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter]; final CompoundTag sch = SchematicHandler.manager.getCompoundTag(worldname, plot.id); - final String o = UUIDHandler.getName(plot.owner); + final String o = UUIDHandler.getName(plot.owner_); final String owner = o == null ? "unknown" : o; if (sch == null) { MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); @@ -303,7 +303,7 @@ public class SchematicCmd extends SubCommand { } final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter]; final CompoundTag sch = SchematicHandler.manager.getCompoundTag(world, plot.id); - final String o = UUIDHandler.getName(plot.owner); + final String o = UUIDHandler.getName(plot.owner_); final String owner = o == null ? "unknown" : o; if (sch == null) { MainUtil.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 2c8449666..0f5c4e2bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -52,7 +52,7 @@ public class SetOwner extends SubCommand { public boolean execute(final PlotPlayer plr, final String... args) { final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); - if ((plot == null) || (plot.owner == null)) { + if ((plot == null) || (plot.owner_ == null)) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return false; } @@ -60,7 +60,7 @@ public class SetOwner extends SubCommand { MainUtil.sendMessage(plr, C.NEED_USER); return false; } - if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.setowner")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.setowner")) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner"); return false; } @@ -75,9 +75,9 @@ public class SetOwner extends SubCommand { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } - current.owner = uuid; + current.owner_ = uuid; PlotSquared.updatePlot(current); - DBFunc.setOwner(current, current.owner); + DBFunc.setOwner(current, current.owner_); } MainUtil.setSign(args[0], plot); MainUtil.sendMessage(plr, C.SET_OWNER); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index 424923313..aa6f2b435 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -52,7 +52,7 @@ public class Swap extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -66,7 +66,7 @@ public class Swap extends SubCommand { try { plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); final Plot plot2 = PlotSquared.getPlots(world).get(plotid); - if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { + if (((plot2 == null) || !plot2.hasOwner() || !(plot2.owner_.equals(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) { MainUtil.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString()); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index 38ebc32aa..04a6f78e6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -53,7 +53,7 @@ public class Trusted extends SubCommand { MainUtil.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.trusted")) { + if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.trusted")) { MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); return true; } @@ -69,7 +69,7 @@ public class Trusted extends SubCommand { return false; } if (!plot.trusted.contains(uuid)) { - if (plot.owner.equals(uuid)) { + if (plot.isOwner(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_OWNER); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java index 71af1cc06..f4a468829 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -47,7 +47,7 @@ public class Unclaim extends SubCommand { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { return !sendMessage(plr, C.UNLINK_REQUIRED); } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) { + if ((((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) { return !sendMessage(plr, C.NO_PLOT_PERMS); } assert plot != null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index e827ef7a7..fffb7226a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -56,7 +56,7 @@ public class Unlink extends SubCommand { if (plot == null) { return !sendMessage(plr, C.NOT_IN_PLOT); } - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { + if (((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) { return sendMessage(plr, C.NO_PLOT_PERMS); } if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { @@ -124,14 +124,14 @@ public class Unlink extends SubCommand { if (ly) { manager.createRoadSouth(plotworld, p); } - MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); + MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot); } } manager.finishPlotUnlink(plotworld, ids); for (final PlotId id : ids) { final Plot myPlot = MainUtil.getPlot(world, id); if (plot.hasOwner()) { - final String name = UUIDHandler.getName(myPlot.owner); + final String name = UUIDHandler.getName(myPlot.owner_); if (name != null) { MainUtil.setSign(name, myPlot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index facfbad9a..1fe36383e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -39,7 +39,7 @@ public class Visit extends SubCommand { public List getPlots(final UUID uuid) { final List plots = new ArrayList<>(); for (final Plot p : PlotSquared.getPlots()) { - if (p.hasOwner() && p.owner.equals(uuid)) { + if (p.hasOwner() && p.isOwner(uuid)) { plots.add(p); } } 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 d563738d9..d41bb5fec 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -151,7 +151,7 @@ public class list extends SubCommand { case "unowned": { plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { - if (plot.owner == null) { + if (plot.owner_ == null) { plots.add(plot); } } @@ -160,10 +160,10 @@ public class list extends SubCommand { case "unknown": { plots = new HashSet<>(); for (Plot plot : PlotSquared.getPlots()) { - if (plot.owner == null) { + if (plot.owner_ == null) { continue; } - if (UUIDHandler.getName(plot.owner) == null) { + if (UUIDHandler.getName(plot.owner_) == null) { plots.add(plot); } } @@ -219,7 +219,7 @@ public class list extends SubCommand { // This might work xD for (int x = (page * 12); x < max; x++) { p = (Plot) plots.toArray()[x]; - string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n"); + string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner_))).append("\n"); } string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", plots.size() + "").replaceAll("%plot%", plots.size() == 1 ? "plot" : "plots")); MainUtil.sendMessage(player, string.toString()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 7d9fb2641..d495d29e8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -138,6 +138,18 @@ public class Plot implements Cloneable { public boolean hasOwner() { return this.owner_ != null; } + + public boolean isOwner(UUID uuid) { + return PlotHandler.isOwner(this, uuid); + } + + /** + * Get a list of owner UUIDs for a plot (supports multi-owner mega-plots) + * @return + */ + public HashSet getOwners() { + return PlotHandler.getOwners(this); + } /** * Check if the player is either the owner or on the helpers list @@ -147,21 +159,7 @@ public class Plot implements Cloneable { * @return true if the player is added as a helper or is the owner */ public boolean isAdded(final UUID uuid) { - if (this.owner_ == null) { - return false; - } - if (this.denied.contains(uuid)) { - return false; - } - if (this.helpers.contains(uuid) || this.helpers.contains(DBFunc.everyone)) { - return true; - } - if (this.trusted.contains(uuid) || this.trusted.contains(DBFunc.everyone)) { - if (PlotHandler.isOnline(this)) { - return true; - } - } - return PlotHandler.isOwner(this, uuid); + return PlotHandler.isAdded(this, uuid); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java index 329daff22..057a4a2c2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotHandler.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.UUID; +import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -73,4 +74,22 @@ public class PlotHandler { owners.retainAll(getOwners(plot2)); return owners.size() > 0; } + + public static boolean isAdded(Plot plot, final UUID uuid) { + if (plot.owner_ == null) { + return false; + } + if (plot.denied.contains(uuid)) { + return false; + } + if (plot.helpers.contains(uuid) || plot.helpers.contains(DBFunc.everyone)) { + return true; + } + if (plot.trusted.contains(uuid) || plot.trusted.contains(DBFunc.everyone)) { + if (PlotHandler.isOnline(plot)) { + return true; + } + } + return PlotHandler.isOwner(plot, uuid); + } }