diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PS.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PS.java index ffc188ba7..393f4e140 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PS.java @@ -70,6 +70,7 @@ public class PS { * @param imp_class */ protected PS(final IPlotMain imp_class) { + instance = this; SetupUtils.generators = new HashMap<>(); IMP = imp_class; try { @@ -529,7 +530,11 @@ public class PS { if (callEvent) { EventUtil.manager.callDelete(world, id); } - Plot plot = plots.get(world).remove(id); + HashMap allPlots = plots.get(world); + if (allPlots == null) { + return false; + } + Plot plot = allPlots.remove(id); if (MainUtil.lastPlot.containsKey(world)) { final PlotId last = MainUtil.lastPlot.get(world); final int last_max = Math.max(last.x, last.y); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java index f4b4e0b28..16f72d916 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Add.java @@ -67,34 +67,29 @@ public class Add extends SubCommand { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } - if (!plot.members.contains(uuid)) { - if (plot.isOwner(uuid)) { - MainUtil.sendMessage(plr, C.ALREADY_OWNER); - return false; - } - if (plot.trusted.contains(uuid)) { - plot.trusted.remove(uuid); - DBFunc.removeTrusted(loc.getWorld(), plot, uuid); - } - if (plot.denied.contains(uuid)) { - if (plot.members.size() + plot.trusted.size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { - MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); - return false; - } - plot.denied.remove(uuid); - DBFunc.removeDenied(loc.getWorld(), plot, uuid); - } - plot.addMember(uuid); - DBFunc.setMember(loc.getWorld(), plot, uuid); - EventUtil.manager.callMember(plr, plot, uuid, true); - } else { + if (plot.isOwner(uuid)) { + MainUtil.sendMessage(plr, C.ALREADY_OWNER); + return false; + } + + if (plot.members.contains(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; } - if (plot.members.size() + plot.trusted.size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { - MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); - return false; + if (plot.removeTrusted(uuid)) { + plot.addMember(uuid); } + else { + if (plot.members.size() + plot.trusted.size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { + MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); + return false; + } + if (plot.denied.contains(uuid)) { + plot.removeDenied(uuid); + } + plot.addMember(uuid); + } + EventUtil.manager.callMember(plr, plot, uuid, true); MainUtil.sendMessage(plr, C.MEMBER_ADDED); return true; } 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 c644ddbd4..581c5be17 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(plot, plot.owner == null, null); PS.log("Plot " + plot.getId().toString() + " cleared."); } }; 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 11e2dc2cb..11401ccc2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -187,7 +187,7 @@ public class Cluster extends SubCommand { } } for (final Plot plot : toRemove) { - DBFunc.delete(plot.world, plot); + plot.unclaim(); } } DBFunc.delete(cluster); @@ -361,11 +361,11 @@ public class Cluster extends SubCommand { if (player != null) { MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); } - for (final Plot plot : PS.get().getPlots(plr.getLocation().getWorld(), uuid)) { + for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) { final PlotCluster current = ClusterManager.getCluster(plot); if ((current != null) && current.equals(cluster)) { final String world = plr.getLocation().getWorld(); - DBFunc.delete(world, plot); + plot.unclaim(); } } MainUtil.sendMessage(plr, C.CLUSTER_KICKED_USER); @@ -411,11 +411,11 @@ public class Cluster extends SubCommand { cluster.invited.remove(uuid); DBFunc.removeInvited(cluster, uuid); MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName()); - for (final Plot plot : PS.get().getPlots(plr.getLocation().getWorld(), uuid)) { + for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) { final PlotCluster current = ClusterManager.getCluster(plot); if ((current != null) && current.equals(cluster)) { final String world = plr.getLocation().getWorld(); - DBFunc.delete(world, plot); + plot.unclaim(); } } return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java index 0c13dce78..cfb3fd5a6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -66,7 +66,7 @@ public class DebugFixFlags extends SubCommand { } } if (changed) { - DBFunc.setFlags(plot.world, plot, plot.settings.flags.values()); + DBFunc.setFlags(plot, plot.settings.flags.values()); } } MainUtil.sendMessage(plr, "&aDone!"); 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 7524181bc..44d5fd086 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -76,7 +76,7 @@ public class Delete extends SubCommand { if (!result) { MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); } - DBFunc.delete(loc.getWorld(), plot); + DBFunc.delete(plot); } }; if (Settings.CONFIRM_DELETE && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java index e75319229..bd71ff3c0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Deny.java @@ -67,26 +67,19 @@ public class Deny extends SubCommand { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } - if (!plot.denied.contains(uuid)) { - if (plot.isOwner(uuid)) { - MainUtil.sendMessage(plr, C.ALREADY_OWNER); - return false; - } - if (plot.trusted.contains(uuid)) { - plot.trusted.remove(uuid); - DBFunc.removeTrusted(loc.getWorld(), plot, uuid); - } - if (plot.members.contains(uuid)) { - plot.members.remove(uuid); - DBFunc.removeMember(loc.getWorld(), plot, uuid); - } - plot.addDenied(uuid); - DBFunc.setDenied(loc.getWorld(), plot, uuid); - EventUtil.manager.callDenied(plr, plot, uuid, true); - } else { + if (plot.isOwner(uuid)) { + MainUtil.sendMessage(plr, C.ALREADY_OWNER); + return false; + } + + if (plot.denied.contains(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; } + plot.removeMember(uuid); + plot.removeTrusted(uuid); + plot.addDenied(uuid); + EventUtil.manager.callDenied(plr, plot, uuid, true); MainUtil.sendMessage(plr, C.DENIED_ADDED); if (!uuid.equals(DBFunc.everyone)) { PS.get().IMP.handleKick(uuid, C.YOU_GOT_DENIED); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index 51a37fb77..0a2c21549 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -159,7 +159,7 @@ public class FlagCmd extends SubCommand { if ((args.length == 3) && flag.getAbstractFlag().isList()) { final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); ((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value); - DBFunc.setFlags(plot.world, plot, plot.settings.flags.values()); + DBFunc.setFlags(plot, plot.settings.flags.values()); } else { final boolean result = FlagManager.removePlotFlag(plot, flag.getKey()); if (!result) { @@ -206,7 +206,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(player, C.FLAG_NOT_ADDED); return false; } - DBFunc.setFlags(plot.world, plot, plot.settings.flags.values()); + DBFunc.setFlags(plot, plot.settings.flags.values()); MainUtil.sendMessage(player, C.FLAG_ADDED); APlotListener.manager.plotEntry(player, plot); return true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Remove.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Remove.java index 5d27bb929..4c33ca3ed 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Remove.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Remove.java @@ -20,6 +20,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.UUID; @@ -58,74 +60,56 @@ public class Remove extends SubCommand { } int count = 0; if (args[0].equals("unknown")) { - Iterator i = plot.members.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); + ArrayList toRemove = new ArrayList<>(); + HashSet all = new HashSet<>(); + all.addAll(plot.members); + all.addAll(plot.trusted); + all.addAll(plot.denied); + for (UUID uuid : all) { if (UUIDHandler.getName(uuid) == null) { - DBFunc.removeMember(plot.world, plot, uuid); - i.remove(); + toRemove.add(uuid); count++; } } - i = plot.trusted.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); - if (UUIDHandler.getName(uuid) == null) { - DBFunc.removeTrusted(plot.world, plot, uuid); - i.remove(); - count++; - } - } - i = plot.denied.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); - if (UUIDHandler.getName(uuid) == null) { - DBFunc.removeDenied(plot.world, plot, uuid); - i.remove(); - count++; - } + for (UUID uuid : toRemove) { + plot.removeDenied(uuid); + plot.removeTrusted(uuid); + plot.removeMember(uuid); } } else if (args[0].equals("*")){ - Iterator i = plot.members.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); - DBFunc.removeMember(plot.world, plot, uuid); - i.remove(); + ArrayList toRemove = new ArrayList<>(); + HashSet all = new HashSet<>(); + all.addAll(plot.members); + all.addAll(plot.trusted); + all.addAll(plot.denied); + for (UUID uuid : all) { + toRemove.add(uuid); count++; } - i = plot.trusted.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); - DBFunc.removeTrusted(plot.world, plot, uuid); - i.remove(); - count++; - } - i = plot.denied.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); - DBFunc.removeDenied(plot.world, plot, uuid); - i.remove(); - count++; + for (UUID uuid : toRemove) { + plot.removeDenied(uuid); + plot.removeTrusted(uuid); + plot.removeMember(uuid); } } else { UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { if (plot.trusted.contains(uuid)) { - DBFunc.removeTrusted(plot.world, plot, uuid); - plot.trusted.remove(uuid); - count++; + if (plot.removeTrusted(uuid)) { + count++; + } } else if (plot.members.contains(uuid)) { - DBFunc.removeMember(plot.world, plot, uuid); - plot.members.remove(uuid); - count++; + if (plot.removeMember(uuid)) { + count++; + } } else if (plot.denied.contains(uuid)) { - DBFunc.removeDenied(plot.world, plot, uuid); - plot.denied.remove(uuid); - count++; + if (plot.removeDenied(uuid)) { + count++; + } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index f3f6376c1..77c06b5d0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -141,8 +141,7 @@ public class Set extends SubCommand { } if (args.length > 1) { if (args[1].equalsIgnoreCase("none")) { - plot.settings.setPosition(null); - DBFunc.setPosition(loc.getWorld(), plot, ""); + plot.setHome(null); return true; } return MainUtil.sendMessage(plr, C.HOME_ARGUMENT); @@ -153,8 +152,7 @@ public class Set extends SubCommand { base.setY(0); final Location relative = plr.getLocation().subtract(base.getX(), base.getY(), base.getZ()); final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ(), relative.getYaw(), relative.getPitch()); - plot.settings.setPosition(blockloc); - DBFunc.setPosition(loc.getWorld(), plot, blockloc.toString()); + plot.setHome(blockloc); return MainUtil.sendMessage(plr, C.POSITION_SET); } if (args[0].equalsIgnoreCase("alias")) { @@ -181,7 +179,7 @@ public class Set extends SubCommand { return false; } } - DBFunc.setAlias(loc.getWorld(), plot, alias); + plot.setAlias(alias); MainUtil.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias)); return true; } @@ -211,7 +209,7 @@ public class Set extends SubCommand { MainUtil.sendMessage(plr, getBiomeList(BlockManager.manager.getBiomeList())); return true; } - MainUtil.setBiome(plr.getLocation().getWorld(), plot, args[1].toUpperCase()); + plot.setBiome(args[1].toUpperCase()); MainUtil.sendMessage(plr, C.BIOME_SET_TO.s() + args[1].toLowerCase()); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trust.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trust.java index 36dc9cb47..2a6ba88b1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trust.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trust.java @@ -67,34 +67,29 @@ public class Trust extends SubCommand { MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]); return false; } - if (!plot.trusted.contains(uuid)) { - if (plot.isOwner(uuid)) { - MainUtil.sendMessage(plr, C.ALREADY_OWNER); - return false; - } - if (plot.members.contains(uuid)) { - plot.members.remove(uuid); - DBFunc.removeMember(loc.getWorld(), plot, uuid); - } - if (plot.denied.contains(uuid)) { - if (plot.members.size() + plot.trusted.size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { - MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); - return false; - } - plot.denied.remove(uuid); - DBFunc.removeDenied(loc.getWorld(), plot, uuid); - } - plot.addTrusted(uuid); - DBFunc.setTrusted(loc.getWorld(), plot, uuid); - EventUtil.manager.callTrusted(plr, plot, uuid, true); - } else { + if (plot.isOwner(uuid)) { + MainUtil.sendMessage(plr, C.ALREADY_OWNER); + return false; + } + + if (plot.trusted.contains(uuid)) { MainUtil.sendMessage(plr, C.ALREADY_ADDED); return false; } - if (plot.members.size() + plot.trusted.size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { - MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); - return false; + if (plot.removeMember(uuid)) { + plot.addTrusted(uuid); } + else { + if (plot.members.size() + plot.trusted.size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { + MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); + return false; + } + if (plot.denied.contains(uuid)) { + plot.removeDenied(uuid); + } + plot.addTrusted(uuid); + } + EventUtil.manager.callTrusted(plr, plot, uuid, true); MainUtil.sendMessage(plr, C.TRUSTED_ADDED); return true; } 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 5d425313f..b924478dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Unclaim.java @@ -60,10 +60,7 @@ public class Unclaim extends SubCommand { } final boolean result = PS.get().removePlot(loc.getWorld(), plot.id, true); if (result) { - final String worldname = plr.getLocation().getWorld(); - PS.get().getPlotManager(worldname).unclaimPlot(pWorld, plot); - DBFunc.delete(worldname, plot); - // TODO set wall block + plot.unclaim(); } else { MainUtil.sendMessage(plr, "Plot removal has been denied."); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java index 50114be7c..33678044b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java @@ -20,6 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; import java.util.Iterator; import java.util.UUID; @@ -58,33 +59,28 @@ public class Undeny extends SubCommand { } int count = 0; if (args[0].equals("unknown")) { - Iterator i = plot.denied.iterator(); - i = plot.denied.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); + ArrayList toRemove = new ArrayList<>(); + for (UUID uuid : plot.denied) { if (UUIDHandler.getName(uuid) == null) { - DBFunc.removeDenied(plot.world, plot, uuid); - i.remove(); - count++; + toRemove.add(uuid); } } + for (UUID uuid : toRemove) { + plot.removeDenied(uuid); + count++; + } } else if (args[0].equals("*")){ - Iterator i = plot.denied.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); - DBFunc.removeDenied(plot.world, plot, uuid); - i.remove(); + for (UUID uuid : new ArrayList<>(plot.denied)) { + plot.removeDenied(uuid); count++; } } else { UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { - if (plot.denied.contains(uuid)) { - DBFunc.removeDenied(plot.world, plot, uuid); - plot.denied.remove(uuid); - count++; + if (plot.removeDenied(uuid)) { + count++; } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Untrust.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Untrust.java index 1a6872275..ad552683d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Untrust.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Untrust.java @@ -20,6 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; import java.util.Iterator; import java.util.UUID; @@ -58,33 +59,28 @@ public class Untrust extends SubCommand { } int count = 0; if (args[0].equals("unknown")) { - Iterator i = plot.trusted.iterator(); - i = plot.trusted.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); + ArrayList toRemove = new ArrayList<>(); + for (UUID uuid : plot.trusted) { if (UUIDHandler.getName(uuid) == null) { - DBFunc.removeTrusted(plot.world, plot, uuid); - i.remove(); - count++; + toRemove.add(uuid); } } + for (UUID uuid : toRemove) { + plot.removeTrusted(uuid); + count++; + } } else if (args[0].equals("*")){ - Iterator i = plot.trusted.iterator(); - while (i.hasNext()) { - UUID uuid = i.next(); - DBFunc.removeTrusted(plot.world, plot, uuid); - i.remove(); + for (UUID uuid : new ArrayList<>(plot.trusted)) { + plot.removeTrusted(uuid); count++; } } else { UUID uuid = UUIDHandler.getUUID(args[0]); if (uuid != null) { - if (plot.trusted.contains(uuid)) { - DBFunc.removeTrusted(plot.world, plot, uuid); - plot.trusted.remove(uuid); - count++; + if (plot.removeTrusted(uuid)) { + count++; } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 64a27b90e..cfda18743 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -84,7 +84,7 @@ public interface AbstractDB { * * @param plot Plot that should be deleted */ - public void delete(final String world, final Plot plot); + public void delete(final Plot plot); public void delete(final PlotCluster cluster); @@ -133,7 +133,7 @@ public interface AbstractDB { * @param plot Plot Object * @param merged boolean[] */ - public void setMerged(final String world, final Plot plot, final boolean[] merged); + public void setMerged(final Plot plot, final boolean[] merged); /** * Swap the settings, helpers etc. of two plots @@ -149,7 +149,7 @@ public interface AbstractDB { * @param plot Plot Object * @param flags flags to set (flag[]) */ - public void setFlags(final String world, final Plot plot, final Collection flags); + public void setFlags(final Plot plot, final Collection flags); /** * Set cluster flags @@ -170,7 +170,7 @@ public interface AbstractDB { * @param plot Plot for which the alias should be set * @param alias Plot Alias */ - public void setAlias(final String world, final Plot plot, final String alias); + public void setAlias(final Plot plot, final String alias); /** * Purgle a plot @@ -193,7 +193,7 @@ public interface AbstractDB { * @param plot Plot Object * @param position Plot Home Position */ - public void setPosition(final String world, final Plot plot, final String position); + public void setPosition(final Plot plot, final String position); /** * @@ -220,7 +220,7 @@ public interface AbstractDB { * @param plot Plot Object * @param uuid Player that should be removed */ - public void removeTrusted(final String world, final Plot plot, final UUID uuid); + public void removeTrusted(final Plot plot, final UUID uuid); /** * @param cluster PlotCluster Object @@ -232,7 +232,7 @@ public interface AbstractDB { * @param plot Plot Object * @param uuid Player that should be removed */ - public void removeMember(final String world, final Plot plot, final UUID uuid); + public void removeMember(final Plot plot, final UUID uuid); /** * @@ -245,7 +245,7 @@ public interface AbstractDB { * @param plot Plot Object * @param uuid Player that should be removed */ - public void setTrusted(final String world, final Plot plot, final UUID uuid); + public void setTrusted(final Plot plot, final UUID uuid); /** * @param cluster PlotCluster Object @@ -257,7 +257,7 @@ public interface AbstractDB { * @param plot Plot Object * @param uuid Player that should be added */ - public void setMember(final String world, final Plot plot, final UUID uuid); + public void setMember(final Plot plot, final UUID uuid); /** * @@ -265,19 +265,19 @@ public interface AbstractDB { * @param cluster * @param uuid */ - public void setInvited(final String world, final PlotCluster cluster, final UUID uuid); + public void setInvited(final PlotCluster cluster, final UUID uuid); /** * @param plot Plot Object * @param uuid Player uuid */ - public void removeDenied(final String world, final Plot plot, final UUID uuid); + public void removeDenied(final Plot plot, final UUID uuid); /** * @param plot Plot Object * @param uuid Player uuid that should be added */ - public void setDenied(final String world, final Plot plot, final UUID uuid); + public void setDenied(final Plot plot, final UUID uuid); /** * Get Plots ratings @@ -303,7 +303,7 @@ public interface AbstractDB { * @param plot Plot Object * @param comment Comment to remove */ - public void removeComment(final String world, final Plot plot, final PlotComment comment); + public void removeComment(final Plot plot, final PlotComment comment); /** * Clear an inbox @@ -319,7 +319,7 @@ public interface AbstractDB { * @param plot Plot Object * @param comment Comment to add */ - public void setComment(final String world, final Plot plot, final PlotComment comment); + public void setComment(final Plot plot, final PlotComment comment); /** * Get Plot Comments @@ -330,7 +330,7 @@ public interface AbstractDB { * * @return Plot Comments within the specified tier */ - public void getComments(final String world, final Plot plot, final String inbox, RunnableVal whenDone); + public void getComments(final Plot plot, final String inbox, RunnableVal whenDone); public void createPlotAndSettings(Plot plot); 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 f67ad781a..c1af50f85 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -56,6 +56,9 @@ public class DBFunc { public static AbstractDB dbManager; public static void movePlot(final Plot originalPlot, final Plot newPlot) { + if (originalPlot.temp || newPlot.temp) { + return; + } dbManager.movePlot(originalPlot, newPlot); } /** @@ -87,6 +90,9 @@ public class DBFunc { * @param uuid New Owner */ public static void setOwner(final Plot plot, final UUID uuid) { + if (plot.temp) { + return; + } dbManager.setOwner(plot, uuid); } @@ -105,6 +111,9 @@ public class DBFunc { * @param plot Plot to create */ public static void createPlot(final Plot plot) { + if (plot.temp) { + return; + } dbManager.createPlot(plot); } @@ -114,6 +123,9 @@ public class DBFunc { * @param plot Plot to create */ public static void createPlotAndSettings(final Plot plot) { + if (plot.temp) { + return; + } dbManager.createPlotAndSettings(plot); } @@ -131,8 +143,11 @@ public class DBFunc { * * @param plot Plot to delete */ - public static void delete(final String world, final Plot plot) { - dbManager.delete(world, plot); + public static void delete(final Plot plot) { + if (plot.temp) { + return; + } + dbManager.delete(plot); } public static void delete(final PlotCluster toDelete) { @@ -146,6 +161,9 @@ public class DBFunc { * @param plot Plot Object */ public static void createPlotSettings(final int id, final Plot plot) { + if (plot.temp) { + return; + } dbManager.createPlotSettings(id, plot); } @@ -158,7 +176,7 @@ public class DBFunc { * @return ID */ /* - * public static int getId(String world, PlotId id2) { Statement stmt = + * public static int getId(String plotId id2) { Statement stmt = * null; try { stmt = connection.createStatement(); ResultSet r = * stmt.executeQuery("SELECT `id` FROM `plot` WHERE `plot_id_x` = '" + id2.x * + "' AND `plot_id_z` = '" + id2.y + "' AND `world` = '" + world + @@ -178,12 +196,18 @@ public class DBFunc { return dbManager.getPlots(); } - public static void setMerged(final String world, final Plot plot, final boolean[] merged) { - dbManager.setMerged(world, plot, merged); + public static void setMerged(final Plot plot, final boolean[] merged) { + if (plot.temp) { + return; + } + dbManager.setMerged(plot, merged); } - public static void setFlags(final String world, final Plot plot, final Collection flags) { - dbManager.setFlags(world, plot, flags); + public static void setFlags(final Plot plot, final Collection flags) { + if (plot.temp) { + return; + } + dbManager.setFlags(plot, flags); } public static void setFlags(final PlotCluster cluster, final Collection flags) { @@ -194,8 +218,11 @@ public class DBFunc { * @param plot * @param alias */ - public static void setAlias(final String world, final Plot plot, final String alias) { - dbManager.setAlias(world, plot, alias); + public static void setAlias(final Plot plot, final String alias) { + if (plot.temp) { + return; + } + dbManager.setAlias(plot, alias); } public static void purgeIds(final String world, final Set uniqueIds) { @@ -210,8 +237,11 @@ public class DBFunc { * @param plot * @param position */ - public static void setPosition(final String world, final Plot plot, final String position) { - dbManager.setPosition(world, plot, position); + public static void setPosition(final Plot plot, final String position) { + if (plot.temp) { + return; + } + dbManager.setPosition(plot, position); } /** @@ -227,11 +257,17 @@ public class DBFunc { * @param plot * @param comment */ - public static void removeComment(final String world, final Plot plot, final PlotComment comment) { - dbManager.removeComment(world, plot, comment); + public static void removeComment(final Plot plot, final PlotComment comment) { + if (plot.temp) { + return; + } + dbManager.removeComment(plot, comment); } public static void clearInbox(final Plot plot, final String inbox) { + if (plot.temp) { + return; + } dbManager.clearInbox(plot, inbox); } @@ -239,23 +275,32 @@ public class DBFunc { * @param plot * @param comment */ - public static void setComment(final String world, final Plot plot, final PlotComment comment) { - dbManager.setComment(world, plot, comment); + public static void setComment(final Plot plot, final PlotComment comment) { + if (plot.temp) { + return; + } + dbManager.setComment(plot, comment); } /** * @param plot */ - public static void getComments(final String world, final Plot plot, final String inbox, RunnableVal whenDone) { - dbManager.getComments(world, plot, inbox, whenDone); + public static void getComments(final Plot plot, final String inbox, RunnableVal whenDone) { + if (plot.temp) { + return; + } + dbManager.getComments(plot, inbox, whenDone); } /** * @param plot * @param uuid */ - public static void removeTrusted(final String world, final Plot plot, final UUID uuid) { - dbManager.removeTrusted(world, plot, uuid); + public static void removeTrusted(final Plot plot, final UUID uuid) { + if (plot.temp) { + return; + } + dbManager.removeTrusted(plot, uuid); } /** @@ -286,8 +331,11 @@ public class DBFunc { * @param plot * @param uuid */ - public static void removeMember(final String world, final Plot plot, final UUID uuid) { - dbManager.removeMember(world, plot, uuid); + public static void removeMember(final Plot plot, final UUID uuid) { + if (plot.temp) { + return; + } + dbManager.removeMember(plot, uuid); } /** @@ -304,8 +352,11 @@ public class DBFunc { * @param plot * @param uuid */ - public static void setTrusted(final String world, final Plot plot, final UUID uuid) { - dbManager.setTrusted(world, plot, uuid); + public static void setTrusted(final Plot plot, final UUID uuid) { + if (plot.temp) { + return; + } + dbManager.setTrusted(plot, uuid); } public static void setHelper(final PlotCluster cluster, final UUID uuid) { @@ -317,12 +368,15 @@ public class DBFunc { * @param plot * @param uuid */ - public static void setMember(final String world, final Plot plot, final UUID uuid) { - dbManager.setMember(world, plot, uuid); + public static void setMember(final Plot plot, final UUID uuid) { + if (plot.temp) { + return; + } + dbManager.setMember(plot, uuid); } public static void setInvited(final String world, final PlotCluster cluster, final UUID uuid) { - dbManager.setInvited(world, cluster, uuid); + dbManager.setInvited(cluster, uuid); } /** @@ -330,8 +384,11 @@ public class DBFunc { * @param plot * @param uuid */ - public static void removeDenied(final String world, final Plot plot, final UUID uuid) { - dbManager.removeDenied(world, plot, uuid); + public static void removeDenied(final Plot plot, final UUID uuid) { + if (plot.temp) { + return; + } + dbManager.removeDenied(plot, uuid); } /** @@ -339,8 +396,11 @@ public class DBFunc { * @param plot * @param uuid */ - public static void setDenied(final String world, final Plot plot, final UUID uuid) { - dbManager.setDenied(world, plot, uuid); + public static void setDenied(final Plot plot, final UUID uuid) { + if (plot.temp) { + return; + } + dbManager.setDenied(plot, uuid); } public static HashMap getRatings(final Plot plot) { @@ -348,6 +408,9 @@ public class DBFunc { } public static void setRating(Plot plot, UUID rater, int value) { + if (plot.temp) { + return; + } dbManager.setRating(plot, rater, value); } 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 78d6aa6b4..ab578ec52 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -683,13 +683,13 @@ public class SQLManager implements AbstractDB { * @param plot */ @Override - public void delete(final String world, final Plot plot) { - PS.get().removePlot(world, plot.id, false); + public void delete(final Plot plot) { + PS.get().removePlot(plot.world, plot.id, false); TaskManager.runTaskAsync(new Runnable() { @Override public void run() { PreparedStatement stmt = null; - final int id = getId(world, plot.id); + final int id = getId(plot.world, plot.id); try { stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_settings` WHERE `plot_plot_id` = ?"); stmt.setInt(1, id); @@ -708,7 +708,7 @@ public class SQLManager implements AbstractDB { stmt.executeUpdate(); stmt.close(); stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_comments` WHERE `world` = ? AND `hashcode` = ?"); - stmt.setString(1, world); + stmt.setString(1, plot.world); stmt.setInt(2, plot.hashCode()); stmt.executeUpdate(); stmt = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot` WHERE `id` = ?"); @@ -1039,7 +1039,7 @@ public class SQLManager implements AbstractDB { } @Override - public void setMerged(final String world, final Plot plot, final boolean[] merged) { + public void setMerged(final Plot plot, final boolean[] merged) { plot.settings.setMerged(merged); TaskManager.runTaskAsync(new Runnable() { @Override @@ -1051,7 +1051,7 @@ public class SQLManager implements AbstractDB { } final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?"); stmt.setInt(1, n); - stmt.setInt(2, getId(world, plot.id)); + stmt.setInt(2, getId(plot.world, plot.id)); stmt.execute(); stmt.close(); } catch (final SQLException e) { @@ -1118,7 +1118,7 @@ public class SQLManager implements AbstractDB { } @Override - public void setFlags(final String world, final Plot plot, final Collection flags) { + public void setFlags(final Plot plot, final Collection flags) { final StringBuilder flag_string = new StringBuilder(); int i = 0; for (final Flag flag : flags) { @@ -1134,7 +1134,7 @@ public class SQLManager implements AbstractDB { try { final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?"); stmt.setString(1, flag_string.toString()); - stmt.setInt(2, getId(world, plot.id)); + stmt.setInt(2, getId(plot.world, plot.id)); stmt.execute(); stmt.close(); } catch (final SQLException e) { @@ -1165,8 +1165,7 @@ public class SQLManager implements AbstractDB { } @Override - public void setAlias(final String world, final Plot plot, final String alias) { - plot.settings.setAlias(alias); + public void setAlias(final Plot plot, final String alias) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -1174,7 +1173,7 @@ public class SQLManager implements AbstractDB { try { stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?"); stmt.setString(1, alias); - stmt.setInt(2, getId(world, plot.id)); + stmt.setInt(2, getId(plot.world, plot.id)); stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { @@ -1259,7 +1258,7 @@ public class SQLManager implements AbstractDB { } @Override - public void setPosition(final String world, final Plot plot, final String position) { + public void setPosition(final Plot plot, final String position) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -1267,7 +1266,7 @@ public class SQLManager implements AbstractDB { try { stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?"); stmt.setString(1, position); - stmt.setInt(2, getId(world, plot.id)); + stmt.setInt(2, getId(plot.world, plot.id)); stmt.executeUpdate(); stmt.close(); } catch (final SQLException e) { @@ -1327,7 +1326,7 @@ public class SQLManager implements AbstractDB { } @Override - public void removeComment(final String world, final Plot plot, final PlotComment comment) { + public void removeComment(final Plot plot, final PlotComment comment) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -1383,7 +1382,7 @@ public class SQLManager implements AbstractDB { } @Override - public void getComments(final String world, final Plot plot, final String inbox, final RunnableVal whenDone) { + public void getComments(final Plot plot, final String inbox, final RunnableVal whenDone) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -1429,7 +1428,7 @@ public class SQLManager implements AbstractDB { } @Override - public void setComment(final String world, final Plot plot, final PlotComment comment) { + public void setComment(final Plot plot, final PlotComment comment) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -1452,13 +1451,13 @@ public class SQLManager implements AbstractDB { } @Override - public void removeTrusted(final String world, final Plot plot, final UUID uuid) { + public void removeTrusted(final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); - statement.setInt(1, getId(world, plot.id)); + statement.setInt(1, getId(plot.world, plot.id)); statement.setString(2, uuid.toString()); statement.executeUpdate(); statement.close(); @@ -1471,13 +1470,13 @@ public class SQLManager implements AbstractDB { } @Override - public void removeMember(final String world, final Plot plot, final UUID uuid) { + public void removeMember(final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); - statement.setInt(1, getId(world, plot.id)); + statement.setInt(1, getId(plot.world, plot.id)); statement.setString(2, uuid.toString()); statement.executeUpdate(); statement.close(); @@ -1490,13 +1489,13 @@ public class SQLManager implements AbstractDB { } @Override - public void setTrusted(final String world, final Plot plot, final UUID uuid) { + public void setTrusted(final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); - statement.setInt(1, getId(world, plot.id)); + statement.setInt(1, getId(plot.world, plot.id)); statement.setString(2, uuid.toString()); statement.executeUpdate(); statement.close(); @@ -1527,13 +1526,13 @@ public class SQLManager implements AbstractDB { } @Override - public void setMember(final String world, final Plot plot, final UUID uuid) { + public void setMember(final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); - statement.setInt(1, getId(world, plot.id)); + statement.setInt(1, getId(plot.world, plot.id)); statement.setString(2, uuid.toString()); statement.executeUpdate(); statement.close(); @@ -1546,13 +1545,13 @@ public class SQLManager implements AbstractDB { } @Override - public void removeDenied(final String world, final Plot plot, final UUID uuid) { + public void removeDenied(final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { final PreparedStatement statement = SQLManager.this.connection.prepareStatement("DELETE FROM `" + SQLManager.this.prefix + "plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); - statement.setInt(1, getId(world, plot.id)); + statement.setInt(1, getId(plot.world, plot.id)); statement.setString(2, uuid.toString()); statement.executeUpdate(); statement.close(); @@ -1565,13 +1564,13 @@ public class SQLManager implements AbstractDB { } @Override - public void setDenied(final String world, final Plot plot, final UUID uuid) { + public void setDenied(final Plot plot, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { try { final PreparedStatement statement = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); - statement.setInt(1, getId(world, plot.id)); + statement.setInt(1, getId(plot.world, plot.id)); statement.setString(2, uuid.toString()); statement.executeUpdate(); statement.close(); @@ -2098,7 +2097,7 @@ public class SQLManager implements AbstractDB { } @Override - public void setInvited(final String world, final PlotCluster cluster, final UUID uuid) { + public void setInvited(final PlotCluster cluster, final UUID uuid) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java index 2cdfeaf79..580d96d23 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java @@ -175,7 +175,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { else { UUIDHandler.add(new StringWrapper(name), owner); } - final Plot plot = new Plot(id, owner, new ArrayList(), new ArrayList(), world); + final Plot plot = new Plot(world, id, owner); plots.get(world).put(id, plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index b2288daf2..d24b80558 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -196,7 +196,7 @@ public class FlagManager { return false; } plot.settings.flags.put(flag.getKey(), flag); - DBFunc.setFlags(plot.world, plot, plot.settings.flags.values()); + DBFunc.setFlags(plot, plot.settings.flags.values()); return true; } @@ -249,7 +249,7 @@ public class FlagManager { plot.settings.flags.put(id, flag); return false; } - DBFunc.setFlags(plot.world, plot, plot.settings.flags.values()); + DBFunc.setFlags(plot, plot.settings.flags.values()); return true; } @@ -280,7 +280,7 @@ public class FlagManager { else { plot.settings.flags.clear(); } - DBFunc.setFlags(plot.world, plot, plot.settings.flags.values()); + DBFunc.setFlags(plot, plot.settings.flags.values()); } public static void setClusterFlags(final PlotCluster cluster, final Set flags) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index f7f37e667..ec0f7e021 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -1132,10 +1132,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { final Collection plots = PS.get().getPlots(pp.getName()).values(); for (final Plot plot : plots) { - final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); - final PlotManager manager = PS.get().getPlotManager(plot.world); - manager.clearPlot(plotworld, plot, true, null); - DBFunc.delete(plot.world, plot); + plot.delete(); PS.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); } } 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 93bee189f..dd520d0ba 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -27,8 +27,11 @@ import java.util.HashSet; import java.util.Set; import java.util.UUID; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MainUtil; /** * The plot class @@ -50,10 +53,6 @@ public class Plot implements Cloneable { * plot owner */ public UUID owner; - /** - * Deny Entry - */ - public boolean deny_entry; /** * List of trusted (with plot permissions) */ @@ -70,40 +69,56 @@ public class Plot implements Cloneable { * External settings class */ public PlotSettings settings; - /** - * Delete on next save cycle? - */ - public boolean delete; /** * Has the plot changed since the last save cycle? */ public boolean hasChanged = false; public boolean countsTowardsMax = true; + + /** + * If this plot is temporary i.e. not stored in the DB + */ + public final boolean temp; /** - * Primary constructor - * + * Constructor for a new plot + * + * @param world * @param id * @param owner - * @param trusted - * @param denied */ - public Plot(final PlotId id, final UUID owner, final ArrayList trusted, final ArrayList denied, final String world) { - this.id = id; - this.settings = new PlotSettings(this); - this.owner = owner; - this.deny_entry = this.owner == null; - this.trusted = trusted; - this.denied = denied; - this.members = new ArrayList<>(); - this.settings.setAlias(""); - this.delete = false; - this.settings.flags = new HashMap<>(); + public Plot(String world, PlotId id, UUID owner) { this.world = world; + this.id = id; + this.owner = owner; + this.settings = new PlotSettings(this); + this.trusted = new ArrayList<>(); + this.members = new ArrayList<>(); + this.denied = new ArrayList<>(); + this.temp = false; } - + /** - * Constructor for saved plots + * Constructor for a temporary plot + * + * @param world + * @param id + * @param owner + * @param temp + */ + public Plot(String world, PlotId id, UUID owner, boolean temp) { + this.world = world; + this.id = id; + this.owner = owner; + this.settings = new PlotSettings(this); + this.trusted = new ArrayList<>(); + this.members = new ArrayList<>(); + this.denied = new ArrayList<>(); + this.temp = temp; + } + + /** + * Constructor for a saved plots * * @param id * @param owner @@ -115,21 +130,19 @@ public class Plot implements Cloneable { this.id = id; this.settings = new PlotSettings(this); this.owner = owner; - this.deny_entry = this.owner != null; this.members = members; this.trusted = trusted; this.denied = denied; this.settings.setAlias(alias); this.settings.setPosition(position); this.settings.setMerged(merged); - this.delete = false; - this.settings.flags = new HashMap<>(); if (flags != null) { for (Flag flag : flags) { this.settings.flags.put(flag.getKey(), flag); } } this.world = world; + this.temp = false; } /** @@ -202,7 +215,7 @@ public class Plot implements Cloneable { * @param uuid */ public void addDenied(final UUID uuid) { - this.denied.add(uuid); + if (this.denied.add(uuid)) DBFunc.setDenied(this, uuid); } /** @@ -211,7 +224,7 @@ public class Plot implements Cloneable { * @param uuid */ public void addTrusted(final UUID uuid) { - this.trusted.add(uuid); + if (this.trusted.add(uuid)) DBFunc.setTrusted(this, uuid); } /** @@ -220,9 +233,223 @@ public class Plot implements Cloneable { * @param uuid */ public void addMember(final UUID uuid) { - this.members.add(uuid); + if (this.members.add(uuid)) DBFunc.setMember(this, uuid); } - + + /** + * Set the plot owner + * @param owner + */ + public void setOwner(final UUID owner) { + if (!this.owner.equals(owner)) { + this.owner = owner; + DBFunc.setOwner(this, owner); + } + } + + /** + * Clear a plot + * @see MainUtil#clear(Plot, boolean, Runnable) + * @see MainUtil#clearAsPlayer(Plot, boolean, Runnable) + * @see #delete() to clear and delete a plot + * @param whenDone A runnable to execute when clearing finishes, or null + */ + public void clear(Runnable whenDone) { + MainUtil.clear(this, false, whenDone); + } + + /** + * Delete a plot + * @see PS#removePlot(String, PlotId, boolean) + * @see #clear(Runnable) to simply clear a plot + */ + public void delete() { + MainUtil.removeSign(this); + MainUtil.clear(this, true, new Runnable() { + @Override + public void run() { + if (PS.get().removePlot(world, id, true)) { + DBFunc.delete(Plot.this); + } + } + }); + } + + public void unclaim() { + if (PS.get().removePlot(world, id, true)) { + DBFunc.delete(Plot.this); + } + } + + /** + * Unlink a plot and remove the roads + * @see MainUtil#unlinkPlot(Plot) + * @return true if plot was linked + */ + public boolean unlink() { + return MainUtil.unlinkPlot(this); + } + + /** + * Return the home location for the plot + * @see MainUtil#getPlotHome(Plot) + * @return Home location + */ + public Location getHome() { + return MainUtil.getPlotHome(this); + } + + /** + * Set the home location + * @param loc + */ + public void setHome(BlockLoc loc) { + BlockLoc pos = this.settings.getPosition(); + if ((pos == null && loc == null) || (pos != null && pos.equals(loc))) { + return; + } + this.settings.setPosition(loc); + if (this.settings.getPosition() == null) { + DBFunc.setPosition(this, ""); + } + else { + DBFunc.setPosition(this, this.settings.getPosition().toString()); + } + } + + /** + * Set the plot alias + * @param alias + */ + public void setAlias(String alias) { + String name = this.settings.getAlias(); + if (alias == null) { + alias = ""; + } + if (name.equals(alias)) { + return; + } + this.settings.setAlias(alias); + DBFunc.setAlias(this, alias); + } + + /** + * Resend all chunks inside the plot to nearby players
+ * This should not need to be called + * @see MainUtil#update(Plot) + */ + public void refreshChunks() { + MainUtil.update(this); + } + + /** + * Remove the plot sign if it is set + */ + public void removeSign() { + MainUtil.removeSign(this); + } + + /** + * Set the plot sign if plot signs are enabled + */ + public void setSign() { + MainUtil.setSign(this); + } + + /** + * Register a plot and create it in the database
+ * - The plot will not be created if the owner is null
+ * - This will not save any trusted etc in the DB, those should be set after plot creation + * @return true if plot was created successfully + */ + public boolean create() { + return MainUtil.createPlot(owner, this); + } + + /** + * Auto merge the plot with any adjacent plots of the same owner + * @see MainUtil#autoMerge(Plot, UUID) to specify the owner + */ + public void autoMerge() { + MainUtil.autoMerge(this, owner); + } + + /** + * Set the plot biome + */ + public void setBiome(String biome) { + MainUtil.setBiome(this, biome); + } + + /** + * Return the top location for the plot + * @return + */ + public Location getTop() { + return MainUtil.getPlotTopLoc(world, id); + } + + /** + * Return the bottom location for the plot + * @return + */ + public Location getBottom() { + return MainUtil.getPlotBottomLoc(world, id); + } + + /** + * Get the top plot, or this plot if it is not part of a mega plot + * @return The bottom plot + */ + public Plot getTopPlot() { + return MainUtil.getTopPlot(this); + } + + /** + * Get the bottom plot, or this plot if it is not part of a mega plot + * @return The bottom plot + */ + public Plot getBottomPlot() { + return MainUtil.getBottomPlot(this); + } + + /** + * Swap the plot contents and settings with another location
+ * - The destination must correspond to a valid plot of equal dimensions + * @see ChunkManager#swap(String, bot1, top1, bot2, top2) to swap terrain + * @see MainUtil#getPlotSelectionIds(PlotId, PlotId) to get the plots inside a selection + * @see MainUtil#swapData(String, PlotId, PlotId, Runnable) to swap plot settings + * @param other The other plot id to swap with + * @param whenDone A task to run when finished, or null + * @see MainUtil#swapData(String, PlotId, PlotId, Runnable) + * @return boolean if swap was successful + */ + public boolean swap(PlotId destination, Runnable whenDone) { + return MainUtil.swap(world, id, destination, whenDone); + } + + /** + * Move the plot to an empty location
+ * - The location must be empty + * @param destination Where to move the plot + * @param whenDone A task to run when done, or null + * @return if the move was successful + */ + public boolean move(Plot destination, Runnable whenDone) { + return MainUtil.move(this, destination, whenDone); + } + + /** + * Copy the plot contents and settings to another location
+ * - The destination must correspond to an empty location + * @param destination The location to copy to + * @param whenDone The task to run when done + * @return If the copy was successful + */ + public boolean copy(PlotId destination, Runnable whenDone) { + return MainUtil.copy(world, id, destination, whenDone); + } + /** * Get plot display name * @@ -241,8 +468,12 @@ public class Plot implements Cloneable { * * @param uuid */ - public void removeDenied(final UUID uuid) { - this.denied.remove(uuid); + public boolean removeDenied(final UUID uuid) { + if (this.denied.remove(uuid)) { + DBFunc.removeDenied(this, uuid); + return true; + } + return false; } /** @@ -250,8 +481,12 @@ public class Plot implements Cloneable { * * @param uuid */ - public void removeHelper(final UUID uuid) { - this.trusted.remove(uuid); + public boolean removeTrusted(final UUID uuid) { + if (this.trusted.remove(uuid)) { + DBFunc.removeTrusted(this, uuid); + return true; + } + return false; } /** @@ -259,8 +494,12 @@ public class Plot implements Cloneable { * * @param uuid */ - public void removeTrusted(final UUID uuid) { - this.members.remove(uuid); + public boolean removeMember(final UUID uuid) { + if (this.members.remove(uuid)) { + DBFunc.removeMember(this, uuid); + return true; + } + return false; } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index c544d7343..35bb3e3a8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -79,6 +79,7 @@ public class PlotSettings { public PlotSettings(final Plot plot) { this.alias = ""; this.plot = plot; + this.flags = new HashMap<>(); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java index af17285ad..34ebf02a7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxOwner.java @@ -47,7 +47,7 @@ public class InboxOwner extends CommentInbox { TaskManager.runTask(whenDone); return true; } - DBFunc.getComments(plot.world, plot, toString(), new RunnableVal() { + DBFunc.getComments(plot, toString(), new RunnableVal() { @Override public void run() { whenDone.value = value; @@ -68,7 +68,7 @@ public class InboxOwner extends CommentInbox { return false; } plot.settings.addComment(comment); - DBFunc.setComment(plot.world, plot, comment); + DBFunc.setComment(plot, comment); return true; } @@ -82,7 +82,7 @@ public class InboxOwner extends CommentInbox { if (plot == null || plot.owner == null) { return false; } - DBFunc.removeComment(plot.world, plot, comment); + DBFunc.removeComment(plot, comment); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java index d2668271e..77c924ab1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxPublic.java @@ -47,7 +47,7 @@ public class InboxPublic extends CommentInbox { TaskManager.runTask(whenDone); return true; } - DBFunc.getComments(plot.world, plot, toString(), new RunnableVal() { + DBFunc.getComments(plot, toString(), new RunnableVal() { @Override public void run() { whenDone.value = value; @@ -68,7 +68,7 @@ public class InboxPublic extends CommentInbox { return false; } plot.settings.addComment(comment); - DBFunc.setComment(plot.world, plot, comment); + DBFunc.setComment(plot, comment); return true; } @@ -82,7 +82,7 @@ public class InboxPublic extends CommentInbox { if (plot == null || plot.owner == null) { return false; } - DBFunc.removeComment(plot.world, plot, comment); + DBFunc.removeComment(plot, comment); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java index e80e1f31a..d0e8f8179 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/InboxReport.java @@ -36,7 +36,7 @@ public class InboxReport extends CommentInbox { @Override public boolean getComments(final Plot plot, final RunnableVal whenDone) { - DBFunc.getComments(null, null, toString(), new RunnableVal() { + DBFunc.getComments(null, toString(), new RunnableVal() { @Override public void run() { whenDone.value = value; @@ -51,7 +51,7 @@ public class InboxReport extends CommentInbox { if (plot == null || plot.owner == null) { return false; } - DBFunc.setComment(plot.world, plot, comment); + DBFunc.setComment(plot, comment); return true; } @@ -65,7 +65,7 @@ public class InboxReport extends CommentInbox { if (plot == null || plot.owner == null) { return false; } - DBFunc.removeComment(plot.world, plot, comment); + DBFunc.removeComment(plot, comment); return false; } 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 a7a5c19e9..0e1adec49 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -132,10 +132,7 @@ public class ExpireManager { if (plot.settings.isMerged()) { MainUtil.unlinkPlot(plot); } - manager.clearPlot(plotworld, plot, false, null); - MainUtil.removeSign(plot); - DBFunc.delete(world, plot); - PS.get().removePlot(world, plot.id, false); + plot.delete(); expiredPlots.get(world).remove(plot); PS.log("&7[&5Expire&dManager&7] &cDeleted expired plot: " + plot.id + (changed != -1 ? " (changed " + value + ")" : "")); PS.log("&3 - World: " + plot.world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 93fee36f3..dd19e8e54 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -175,9 +175,8 @@ public class MainUtil { if (plot.denied != null) { myplot.denied = plot.denied; } - myplot.deny_entry = plot.deny_entry; myplot.settings.setMerged(new boolean[] { false, false, false, false }); - DBFunc.setMerged(world, myplot, myplot.settings.getMerged()); + DBFunc.setMerged(myplot, myplot.settings.getMerged()); } if (plotworld.TERRAIN != 3) { for (int x = pos1.x; x <= pos2.x; x++) { @@ -345,7 +344,7 @@ public class MainUtil { if (result) { final Location location; if (PS.get().getPlotWorld(plot.world).HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) { - location = MainUtil.getPlotHome(bot.world, bot); + location = MainUtil.getPlotHome(bot); } else { location = getDefaultHome(plot); @@ -532,7 +531,7 @@ public class MainUtil { for (int y = pos1.y; y <= pos2.y; y++) { final PlotId id = new PlotId(x, y); final Plot plot = PS.get().getPlots(world).get(id); - DBFunc.setMerged(world, plot, plot.settings.getMerged()); + DBFunc.setMerged(plot, plot.settings.getMerged()); } } manager.finishPlotMerge(plotworld, plotIds); @@ -633,6 +632,14 @@ public class MainUtil { final Location loc = manager.getSignLoc(plotworld, p); BlockManager.setBlocks(world, new int[] { loc.getX() }, new int[] { loc.getY() }, new int[] { loc.getZ() }, new int[] { 0 }, new byte[] { 0 }); } + + public static void setSign(final Plot p) { + if (p.owner == null) { + setSign(null, p); + return; + } + setSign(UUIDHandler.getName(p.owner), p); + } public static void setSign(String name, final Plot p) { if (name == null) { @@ -655,7 +662,7 @@ public class MainUtil { return string; } - public static void autoMerge(final String world, final Plot plot, final UUID uuid) { + public static void autoMerge(final Plot plot, final UUID uuid) { if (plot == null) { return; } @@ -676,32 +683,32 @@ public class MainUtil { final PlotId bot = getBottomPlot(plot).id; final PlotId top = getTopPlot(plot).id; plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); - if (ownsPlots(world, plots, uuid, 0)) { - final boolean result = mergePlots(world, plots, true); + if (ownsPlots(plot.world, plots, uuid, 0)) { + final boolean result = mergePlots(plot.world, plots, true); if (result) { merge = true; continue; } } plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); - if (ownsPlots(world, plots, uuid, 1)) { - final boolean result = mergePlots(world, plots, true); + if (ownsPlots(plot.world, plots, uuid, 1)) { + final boolean result = mergePlots(plot.world, plots, true); if (result) { merge = true; continue; } } plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); - if (ownsPlots(world, plots, uuid, 2)) { - final boolean result = mergePlots(world, plots, true); + if (ownsPlots(plot.world, plots, uuid, 2)) { + final boolean result = mergePlots(plot.world, plots, true); if (result) { merge = true; continue; } } plots = getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); - if (ownsPlots(world, plots, uuid, 3)) { - final boolean result = mergePlots(world, plots, true); + if (ownsPlots(plot.world, plots, uuid, 3)) { + final boolean result = mergePlots(plot.world, plots, true); if (result) { merge = true; continue; @@ -757,9 +764,12 @@ public class MainUtil { updateWorldBorder(plot); } final Plot p = createPlotAbs(uuid, plot); + if (p == null) { + return false; + } final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); if (plotworld.AUTO_MERGE) { - autoMerge(plot.world, p, uuid); + autoMerge(p, uuid); } return true; } @@ -769,7 +779,15 @@ public class MainUtil { */ public static Plot createPlotAbs(final UUID uuid, final Plot plot) { final String w = plot.world; - final Plot p = new Plot(plot.id, uuid, new ArrayList(), new ArrayList(), w); + HashMap plots = PS.get().getPlots(plot.world); + Plot p = plots.get(plot.id); + if (p != null) { + return p; + } + p = new Plot(w, plot.id, uuid); + if (p.owner == null) { + return null; + } PS.get().updatePlot(p); DBFunc.createPlotAndSettings(p); return p; @@ -803,24 +821,24 @@ public class MainUtil { return false; } ChunkManager.manager.clearAllEntities(plot); - clear(plot.world, plot, isDelete, whenDone); + clear(plot, isDelete, whenDone); removeSign(plot); return true; } - public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) { - final PlotManager manager = PS.get().getPlotManager(world); - final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); + public static void clear(final Plot plot, final boolean isDelete, final Runnable whenDone) { + final PlotManager manager = PS.get().getPlotManager(plot.world); + final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); final int prime = 31; int h = 1; h = (prime * h) + pos1.getX(); h = (prime * h) + pos1.getZ(); state = h; System.currentTimeMillis(); - final PlotWorld plotworld = PS.get().getPlotWorld(world); + final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); runners.put(plot, 1); if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) { - final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); + final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { @Override public void run() { @@ -919,12 +937,12 @@ public class MainUtil { } } - public static void setBiome(final String world, final Plot plot, final String biome) { - final int bottomX = getPlotBottomLoc(world, plot.id).getX() + 1; - final int topX = getPlotTopLoc(world, plot.id).getX(); - final int bottomZ = getPlotBottomLoc(world, plot.id).getZ() + 1; - final int topZ = getPlotTopLoc(world, plot.id).getZ(); - BukkitUtil.setBiome(world, bottomX, bottomZ, topX, topZ, biome); + public static void setBiome(final Plot plot, final String biome) { + final int bottomX = getPlotBottomLoc(plot.world, plot.id).getX() + 1; + final int topX = getPlotTopLoc(plot.world, plot.id).getX(); + final int bottomZ = getPlotBottomLoc(plot.world, plot.id).getZ() + 1; + final int topZ = getPlotTopLoc(plot.world, plot.id).getZ(); + BukkitUtil.setBiome(plot.world, bottomX, bottomZ, topX, topZ, biome); update(plot); } @@ -967,8 +985,8 @@ public class MainUtil { * * @see #getPlotHome(String, Plot) */ - public static Location getPlotHome(final String w, final Plot plot) { - return getPlotHome(w, plot.id); + public static Location getPlotHome(final Plot plot) { + return getPlotHome(plot.world, plot.id); } /** @@ -1160,7 +1178,7 @@ public class MainUtil { } final Plot pos1 = getBottomPlot(plot1); final Plot pos2 = getTopPlot(plot1); - final PlotId size = MainUtil.getSize(plot1.world, plot1); + final PlotId size = MainUtil.getSize(plot1); if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) { TaskManager.runTaskLater(whenDone, 1); return false; @@ -1190,7 +1208,7 @@ public class MainUtil { } final Plot pos1 = getBottomPlot(plot1); final Plot pos2 = getTopPlot(plot1); - final PlotId size = MainUtil.getSize(plot1.world, plot1); + final PlotId size = MainUtil.getSize(plot1); if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) { return false; } @@ -1230,7 +1248,7 @@ public class MainUtil { } final Plot pos1 = getBottomPlot(currentPlot); final Plot pos2 = getTopPlot(currentPlot); - final PlotId size = MainUtil.getSize(world, currentPlot); + final PlotId size = MainUtil.getSize(currentPlot); if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) { TaskManager.runTaskLater(whenDone, 1); return false; @@ -1244,28 +1262,28 @@ public class MainUtil { Plot plot = createPlotAbs(currentPlot.owner, getPlot(world, new PlotId(x, y))); if (currentPlot.settings.flags != null && currentPlot.settings.flags.size() > 0) { plot.settings.flags = currentPlot.settings.flags; - DBFunc.setFlags(world, plot, currentPlot.settings.flags.values()); + DBFunc.setFlags(plot, currentPlot.settings.flags.values()); } if (currentPlot.settings.isMerged()) { plot.settings.setMerged(currentPlot.settings.getMerged()); - DBFunc.setMerged(world, plot, currentPlot.settings.getMerged()); + DBFunc.setMerged(plot, currentPlot.settings.getMerged()); } if (currentPlot.members != null && currentPlot.members.size() > 0) { plot.members = currentPlot.members; for (UUID member : plot.members) { - DBFunc.setMember(world, plot, member); + DBFunc.setMember(plot, member); } } if (currentPlot.trusted != null && currentPlot.trusted.size() > 0) { plot.members = currentPlot.trusted; for (UUID trusted : plot.trusted) { - DBFunc.setTrusted(world, plot, trusted); + DBFunc.setTrusted(plot, trusted); } } if (currentPlot.denied != null && currentPlot.denied.size() > 0) { plot.members = currentPlot.denied; for (UUID denied : plot.denied) { - DBFunc.setDenied(world, plot, denied); + DBFunc.setDenied(plot, denied); } } PS.get().getPlots(world).put(plot.id, plot); @@ -1470,7 +1488,7 @@ public class MainUtil { } - public static PlotId getSize(final String world, final Plot plot) { + public static PlotId getSize(final Plot plot) { final PlotSettings settings = plot.settings; if (!settings.isMerged()) { return new PlotId(1, 1); @@ -1490,7 +1508,7 @@ public class MainUtil { if (PS.get().getPlots(world).containsKey(id)) { return PS.get().getPlots(world).get(id); } - return new Plot(id, null, new ArrayList(), new ArrayList(), world); + return new Plot(world, id, null); } /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index 2a9d8c82c..c9bd8f08a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -121,7 +121,7 @@ public class BukkitPlayerFunctions { if (PS.get().getPlots(world).containsKey(id)) { return PS.get().getPlots(world).get(id); } - return new Plot(id, null, new ArrayList(), new ArrayList(), world); + return new Plot(world, id, null); } /**