Fixed errors.

This commit is contained in:
boy0001 2015-03-20 14:00:02 +11:00
parent bdbebfa29d
commit fbaca34218
25 changed files with 92 additions and 71 deletions

View File

@ -62,7 +62,7 @@ public class Clear extends SubCommand {
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { 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."); PlotSquared.log("Plot " + plot.getId().toString() + " cleared.");
} }
}; };
@ -110,7 +110,7 @@ public class Clear extends SubCommand {
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
return sendMessage(plr, C.UNLINK_REQUIRED); 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); return sendMessage(plr, C.NO_PLOT_PERMS);
} }
assert plot != null; assert plot != null;
@ -122,7 +122,7 @@ public class Clear extends SubCommand {
@Override @Override
public void run() { public void run() {
final long start = System.currentTimeMillis(); 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 @Override
public void run() { public void run() {
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));

View File

@ -129,9 +129,9 @@ public class Cluster extends SubCommand {
// Add any existing plots to the current cluster // Add any existing plots to the current cluster
for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) { for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) {
final PlotCluster current = ClusterManager.getCluster(plot); final PlotCluster current = ClusterManager.getCluster(plot);
if (cluster.equals(current) && !cluster.hasRights(plot.owner)) { if (cluster.equals(current) && !cluster.hasRights(plot.owner_)) {
cluster.invited.add(plot.owner); cluster.invited.add(plot.owner_);
DBFunc.setInvited(world, cluster, plot.owner); DBFunc.setInvited(world, cluster, plot.owner_);
} }
} }
if (!PlotSquared.isPlotWorld(world)) { if (!PlotSquared.isPlotWorld(world)) {

View File

@ -123,7 +123,7 @@ public class DebugClaimTest extends SubCommand {
} }
if (uuid != null) { if (uuid != null) {
MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line); MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line);
plot.owner = uuid; plot.owner_ = uuid;
plot.hasChanged = true; plot.hasChanged = true;
plots.add(plot); plots.add(plot);
} else { } else {

View File

@ -85,7 +85,7 @@ public class DebugClear extends SubCommand {
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
return sendMessage(plr, C.UNLINK_REQUIRED); 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); return sendMessage(plr, C.NO_PLOT_PERMS);
} }
assert plot != null; assert plot != null;

View File

@ -97,7 +97,7 @@ public class DebugExec extends SubCommand {
for (final Entry<Plot, Long> entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) { for (final Entry<Plot, Long> entry : ExpireManager.expiredPlots.get(args[1]).entrySet()) {
final Plot plot = entry.getKey(); final Plot plot = entry.getKey();
final Long stamp = entry.getValue(); 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; return true;
} }

View File

@ -50,7 +50,7 @@ public class Delete extends SubCommand {
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
return !sendMessage(plr, C.UNLINK_REQUIRED); 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); return !sendMessage(plr, C.NO_PLOT_PERMS);
} }
assert plot != null; assert plot != null;
@ -62,7 +62,7 @@ public class Delete extends SubCommand {
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { 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; final double c = pWorld.SELL_PRICE;
if (c > 0d) { if (c > 0d) {
EconHandler.depositPlayer(plr, c); EconHandler.depositPlayer(plr, c);

View File

@ -53,7 +53,7 @@ public class Denied extends SubCommand {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
return false; 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); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return true; return true;
} }
@ -69,7 +69,7 @@ public class Denied extends SubCommand {
return false; return false;
} }
if (!plot.denied.contains(uuid)) { if (!plot.denied.contains(uuid)) {
if (plot.owner.equals(uuid)) { if (plot.isOwner(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_OWNER); MainUtil.sendMessage(plr, C.ALREADY_OWNER);
return false; return false;
} }

View File

@ -52,7 +52,7 @@ public class Helpers extends SubCommand {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
return false; 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); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return true; return true;
} }
@ -68,7 +68,7 @@ public class Helpers extends SubCommand {
return false; return false;
} }
if (!plot.helpers.contains(uuid)) { if (!plot.helpers.contains(uuid)) {
if (plot.owner.equals(uuid)) { if (plot.isOwner(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_OWNER); MainUtil.sendMessage(plr, C.ALREADY_OWNER);
return false; return false;
} }

View File

@ -63,7 +63,7 @@ public class Home extends SubCommand {
Plot temp; Plot temp;
if ((temp = isAlias(args[0])) != null) { if ((temp = isAlias(args[0])) != null) {
if (temp.hasOwner()) { if (temp.hasOwner()) {
if (temp.getOwner().equals(UUIDHandler.getUUID(plr))) { if (temp.isOwner(plr.getUUID())) {
MainUtil.teleportPlayer(plr, plr.getLocation(), temp); MainUtil.teleportPlayer(plr, plr.getLocation(), temp);
return true; return true;
} }

View File

@ -59,10 +59,10 @@ public class Inbox extends SubCommand {
return false; return false;
} }
Integer tier; Integer tier;
final UUID uuid = UUIDHandler.getUUID(plr); final UUID uuid = plr.getUUID();
if (Permissions.hasPermission(plr, "plots.comment.admin")) { if (Permissions.hasPermission(plr, "plots.comment.admin")) {
tier = 0; tier = 0;
} else if ((plot != null) && plot.owner.equals(uuid)) { } else if ((plot != null) && plot.isOwner(uuid)) {
tier = 1; tier = 1;
} else if ((plot != null) && plot.helpers.contains(uuid)) { } else if ((plot != null) && plot.helpers.contains(uuid)) {
tier = 2; tier = 2;

View File

@ -21,6 +21,9 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -110,11 +113,11 @@ public class Info extends SubCommand {
return true; return true;
} }
String owner = "none"; String owner = "none";
if (plot.owner != null) { if (plot.owner_ == null) {
owner = UUIDHandler.getName(plot.owner); owner = "unowned";
} }
if (owner == null) { else {
owner = plot.owner.toString(); owner = getPlayerList(plot.getOwners());
} }
String info = C.PLOT_INFO.s(); String info = C.PLOT_INFO.s();
if (args.length == 1) { 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 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()); final boolean build = (player == null) || plot.isAdded(player.getUUID());
String owner = "none"; String owner = "none";
if (plot.owner != null) { if (plot.owner_ == null) {
owner = UUIDHandler.getName(plot.owner); owner = "unowned";
} }
if (owner == null) { else {
owner = plot.owner.toString(); owner = getPlayerList(plot.getOwners());
} }
info = info.replaceAll("%alias%", alias); info = info.replaceAll("%alias%", alias);
info = info.replaceAll("%id%", id.toString()); info = info.replaceAll("%id%", id.toString());
@ -192,7 +195,8 @@ public class Info extends SubCommand {
return info; return info;
} }
private String getPlayerList(final ArrayList<UUID> l) { private String getPlayerList(final Collection<UUID> uuids) {
ArrayList<UUID> l = new ArrayList<>(uuids);
if ((l == null) || (l.size() < 1)) { if ((l == null) || (l.size() < 1)) {
return " none"; return " none";
} }

View File

@ -42,7 +42,7 @@ public class Kick extends SubCommand {
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); 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); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -85,7 +85,7 @@ public class Merge extends SubCommand {
return false; return false;
} }
final boolean admin = Permissions.hasPermission(plr, "plots.admin.command.merge"); 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); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }
@ -138,10 +138,10 @@ public class Merge extends SubCommand {
boolean multiMerge = false; boolean multiMerge = false;
final HashSet<UUID> multiUUID = new HashSet<UUID>(); final HashSet<UUID> multiUUID = new HashSet<UUID>();
HashSet<PlotId> multiPlots = new HashSet<>(); HashSet<PlotId> multiPlots = new HashSet<>();
final UUID u1 = plot.getOwner(); final UUID u1 = plot.owner_;
for (final PlotId myid : plots) { for (final PlotId myid : plots) {
final Plot myplot = PlotSquared.getPlots(world).get(myid); final Plot myplot = PlotSquared.getPlots(world).get(myid);
UUID u2 = myplot.getOwner(); UUID u2 = myplot.owner_;
if (myplot == null || u2 == null) { if (myplot == null || u2 == null) {
MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
return false; return false;
@ -190,7 +190,7 @@ public class Merge extends SubCommand {
} }
MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
MainUtil.mergePlots(world, plots, true); MainUtil.mergePlots(world, plots, true);
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot);
MainUtil.update(loc); MainUtil.update(loc);
} }
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED); MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
@ -219,7 +219,7 @@ public class Merge extends SubCommand {
} }
MainUtil.sendMessage(plr, C.SUCCESS_MERGE); MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
MainUtil.mergePlots(world, plots, true); MainUtil.mergePlots(world, plots, true);
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot);
MainUtil.update(loc); MainUtil.update(loc);
return true; return true;
} }

View File

@ -120,8 +120,8 @@ public class Purge extends SubCommand {
final Collection<Plot> plots = PlotSquared.getPlots(worldname).values(); final Collection<Plot> plots = PlotSquared.getPlots(worldname).values();
final Set<PlotId> ids = new HashSet<>(); final Set<PlotId> ids = new HashSet<>();
for (final Plot plot : plots) { for (final Plot plot : plots) {
if (plot.owner != null) { if (plot.owner_ != null) {
final String name = UUIDHandler.getName(plot.owner); final String name = UUIDHandler.getName(plot.owner_);
if (name == null) { if (name == null) {
ids.add(plot.id); ids.add(plot.id);
} }
@ -138,7 +138,7 @@ public class Purge extends SubCommand {
final Collection<Plot> plots = PlotSquared.getPlots(worldname).values(); final Collection<Plot> plots = PlotSquared.getPlots(worldname).values();
final Set<PlotId> ids = new HashSet<>(); final Set<PlotId> ids = new HashSet<>();
for (final Plot plot : plots) { for (final Plot plot : plots) {
if (plot.owner == null) { if (plot.owner_ == null) {
ids.add(plot.id); ids.add(plot.id);
} }
} }

View File

@ -52,7 +52,7 @@ public class Rate extends SubCommand {
sendMessage(plr, C.RATING_NOT_OWNED); sendMessage(plr, C.RATING_NOT_OWNED);
return true; return true;
} }
if (plot.getOwner().equals(UUIDHandler.getUUID(plr))) { if (plot.isOwner(plr.getUUID())) {
sendMessage(plr, C.RATING_NOT_YOUR_OWN); sendMessage(plr, C.RATING_NOT_YOUR_OWN);
return true; return true;
} }

View File

@ -222,7 +222,7 @@ public class SchematicCmd extends SubCommand {
} }
final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter]; final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter];
final CompoundTag sch = SchematicHandler.manager.getCompoundTag(worldname, plot.id); 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; final String owner = o == null ? "unknown" : o;
if (sch == null) { if (sch == null) {
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); 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 Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter];
final CompoundTag sch = SchematicHandler.manager.getCompoundTag(world, plot.id); 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; final String owner = o == null ? "unknown" : o;
if (sch == null) { if (sch == null) {
MainUtil.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); MainUtil.sendMessage(plr, "&7 - Skipped plot &c" + plot.id);

View File

@ -52,7 +52,7 @@ public class SetOwner extends SubCommand {
public boolean execute(final PlotPlayer plr, final String... args) { public boolean execute(final PlotPlayer plr, final String... args) {
final Location loc = plr.getLocation(); final Location loc = plr.getLocation();
final Plot plot = MainUtil.getPlot(loc); 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); MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
return false; return false;
} }
@ -60,7 +60,7 @@ public class SetOwner extends SubCommand {
MainUtil.sendMessage(plr, C.NEED_USER); MainUtil.sendMessage(plr, C.NEED_USER);
return false; 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"); MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner");
return false; return false;
} }
@ -75,9 +75,9 @@ public class SetOwner extends SubCommand {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
return false; return false;
} }
current.owner = uuid; current.owner_ = uuid;
PlotSquared.updatePlot(current); PlotSquared.updatePlot(current);
DBFunc.setOwner(current, current.owner); DBFunc.setOwner(current, current.owner_);
} }
MainUtil.setSign(args[0], plot); MainUtil.setSign(args[0], plot);
MainUtil.sendMessage(plr, C.SET_OWNER); MainUtil.sendMessage(plr, C.SET_OWNER);

View File

@ -52,7 +52,7 @@ public class Swap extends SubCommand {
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); 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); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }
@ -66,7 +66,7 @@ public class Swap extends SubCommand {
try { try {
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
final Plot plot2 = PlotSquared.getPlots(world).get(plotid); 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()); MainUtil.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString());
return false; return false;
} }

View File

@ -53,7 +53,7 @@ public class Trusted extends SubCommand {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED); MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
return false; 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); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return true; return true;
} }
@ -69,7 +69,7 @@ public class Trusted extends SubCommand {
return false; return false;
} }
if (!plot.trusted.contains(uuid)) { if (!plot.trusted.contains(uuid)) {
if (plot.owner.equals(uuid)) { if (plot.isOwner(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_OWNER); MainUtil.sendMessage(plr, C.ALREADY_OWNER);
return false; return false;
} }

View File

@ -47,7 +47,7 @@ public class Unclaim extends SubCommand {
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
return !sendMessage(plr, C.UNLINK_REQUIRED); 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); return !sendMessage(plr, C.NO_PLOT_PERMS);
} }
assert plot != null; assert plot != null;

View File

@ -56,7 +56,7 @@ public class Unlink extends SubCommand {
if (plot == null) { if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); 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); return sendMessage(plr, C.NO_PLOT_PERMS);
} }
if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) { if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
@ -124,14 +124,14 @@ public class Unlink extends SubCommand {
if (ly) { if (ly) {
manager.createRoadSouth(plotworld, p); manager.createRoadSouth(plotworld, p);
} }
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot); MainUtil.setSign(UUIDHandler.getName(plot.owner_), plot);
} }
} }
manager.finishPlotUnlink(plotworld, ids); manager.finishPlotUnlink(plotworld, ids);
for (final PlotId id : ids) { for (final PlotId id : ids) {
final Plot myPlot = MainUtil.getPlot(world, id); final Plot myPlot = MainUtil.getPlot(world, id);
if (plot.hasOwner()) { if (plot.hasOwner()) {
final String name = UUIDHandler.getName(myPlot.owner); final String name = UUIDHandler.getName(myPlot.owner_);
if (name != null) { if (name != null) {
MainUtil.setSign(name, myPlot); MainUtil.setSign(name, myPlot);
} }

View File

@ -39,7 +39,7 @@ public class Visit extends SubCommand {
public List<Plot> getPlots(final UUID uuid) { public List<Plot> getPlots(final UUID uuid) {
final List<Plot> plots = new ArrayList<>(); final List<Plot> plots = new ArrayList<>();
for (final Plot p : PlotSquared.getPlots()) { for (final Plot p : PlotSquared.getPlots()) {
if (p.hasOwner() && p.owner.equals(uuid)) { if (p.hasOwner() && p.isOwner(uuid)) {
plots.add(p); plots.add(p);
} }
} }

View File

@ -151,7 +151,7 @@ public class list extends SubCommand {
case "unowned": { case "unowned": {
plots = new HashSet<>(); plots = new HashSet<>();
for (Plot plot : PlotSquared.getPlots()) { for (Plot plot : PlotSquared.getPlots()) {
if (plot.owner == null) { if (plot.owner_ == null) {
plots.add(plot); plots.add(plot);
} }
} }
@ -160,10 +160,10 @@ public class list extends SubCommand {
case "unknown": { case "unknown": {
plots = new HashSet<>(); plots = new HashSet<>();
for (Plot plot : PlotSquared.getPlots()) { for (Plot plot : PlotSquared.getPlots()) {
if (plot.owner == null) { if (plot.owner_ == null) {
continue; continue;
} }
if (UUIDHandler.getName(plot.owner) == null) { if (UUIDHandler.getName(plot.owner_) == null) {
plots.add(plot); plots.add(plot);
} }
} }
@ -219,7 +219,7 @@ public class list extends SubCommand {
// This might work xD // This might work xD
for (int x = (page * 12); x < max; x++) { for (int x = (page * 12); x < max; x++) {
p = (Plot) plots.toArray()[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")); 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()); MainUtil.sendMessage(player, string.toString());

View File

@ -138,6 +138,18 @@ public class Plot implements Cloneable {
public boolean hasOwner() { public boolean hasOwner() {
return this.owner_ != null; 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<UUID> getOwners() {
return PlotHandler.getOwners(this);
}
/** /**
* Check if the player is either the owner or on the helpers list * 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 * @return true if the player is added as a helper or is the owner
*/ */
public boolean isAdded(final UUID uuid) { public boolean isAdded(final UUID uuid) {
if (this.owner_ == null) { return PlotHandler.isAdded(this, uuid);
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);
} }
/** /**

View File

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
@ -73,4 +74,22 @@ public class PlotHandler {
owners.retainAll(getOwners(plot2)); owners.retainAll(getOwners(plot2));
return owners.size() > 0; 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);
}
} }