Lazy initialization

This commit is contained in:
boy0001 2015-07-22 04:31:12 +10:00
parent 59c672d9a8
commit 95ad199f52
37 changed files with 263 additions and 207 deletions

View File

@ -72,7 +72,7 @@ public class Add extends SubCommand {
return false; return false;
} }
if (plot.members.contains(uuid)) { if (plot.getMembers().contains(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_ADDED); MainUtil.sendMessage(plr, C.ALREADY_ADDED);
return false; return false;
} }
@ -80,11 +80,11 @@ public class Add extends SubCommand {
plot.addMember(uuid); plot.addMember(uuid);
} }
else { else {
if (plot.members.size() + plot.trusted.size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { if (plot.getMembers().size() + plot.getTrusted().size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
return false; return false;
} }
if (plot.denied.contains(uuid)) { if (plot.getDenied().contains(uuid)) {
plot.removeDenied(uuid); plot.removeDenied(uuid);
} }
plot.addMember(uuid); plot.addMember(uuid);

View File

@ -176,7 +176,7 @@ public class Auto extends SubCommand {
for (int i = 0; i <= max; i++) { for (int i = 0; i <= max; i++) {
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y); final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
final Plot current = MainUtil.getPlot(worldname, currentId); final Plot current = MainUtil.getPlot(worldname, currentId);
if (MainUtil.canClaim(plr, current) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) { if (MainUtil.canClaim(plr, current) && (current.getSettings().isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
Claim.claimPlot(plr, current, true, true); Claim.claimPlot(plr, current, true, true);
return true; return true;
} }

View File

@ -47,7 +47,7 @@ public class Claim extends SubCommand {
} }
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) { public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport, final String schematic, final boolean auto) {
if (plot.hasOwner() || plot.settings.isMerged()) { if (plot.hasOwner() || plot.getSettings().isMerged()) {
return false; return false;
} }
final boolean result = EventUtil.manager.callClaim(player, plot, false); final boolean result = EventUtil.manager.callClaim(player, plot, false);

View File

@ -56,7 +56,7 @@ public class DebugFixFlags extends SubCommand {
} }
MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---"); MainUtil.sendMessage(plr, "&8--- &6Starting task &8 ---");
for (final Plot plot : PS.get().getPlots(world).values()) { for (final Plot plot : PS.get().getPlots(world).values()) {
final HashMap<String, Flag> flags = plot.settings.flags; final HashMap<String, Flag> flags = plot.getSettings().flags;
Iterator<Entry<String, Flag>> i = flags.entrySet().iterator(); Iterator<Entry<String, Flag>> i = flags.entrySet().iterator();
boolean changed = false; boolean changed = false;
while (i.hasNext()) { while (i.hasNext()) {
@ -66,7 +66,7 @@ public class DebugFixFlags extends SubCommand {
} }
} }
if (changed) { if (changed) {
DBFunc.setFlags(plot, plot.settings.flags.values()); DBFunc.setFlags(plot, plot.getSettings().flags.values());
} }
} }
MainUtil.sendMessage(plr, "&aDone!"); MainUtil.sendMessage(plr, "&aDone!");

View File

@ -221,9 +221,9 @@ public class DebugUUID extends SubCommand {
if (value != null) { if (value != null) {
plot.owner = value; plot.owner = value;
} }
plot.trusted = new HashSet<>(); plot.getTrusted().clear();
plot.members = new HashSet<>(); plot.getMembers().clear();
plot.denied = new HashSet<>(); plot.getDenied().clear();
} }
MainUtil.sendConsoleMessage("&7 - Deleting database"); MainUtil.sendConsoleMessage("&7 - Deleting database");

View File

@ -75,7 +75,7 @@ public class Deny extends SubCommand {
return false; return false;
} }
if (plot.denied.contains(uuid)) { if (plot.getDenied().contains(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_ADDED); MainUtil.sendMessage(plr, C.ALREADY_ADDED);
return false; return false;
} }

View File

@ -158,7 +158,7 @@ public class FlagCmd extends SubCommand {
if ((args.length == 3) && flag.getAbstractFlag().isList()) { if ((args.length == 3) && flag.getAbstractFlag().isList()) {
final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value); ((FlagValue.ListValue) flag.getAbstractFlag().value).remove(flag.getValue(), value);
DBFunc.setFlags(plot, plot.settings.flags.values()); DBFunc.setFlags(plot, plot.getSettings().flags.values());
} else { } else {
final boolean result = FlagManager.removePlotFlag(plot, flag.getKey()); final boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
if (!result) { if (!result) {
@ -204,7 +204,7 @@ public class FlagCmd extends SubCommand {
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED); MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
return false; return false;
} }
DBFunc.setFlags(plot, plot.settings.flags.values()); DBFunc.setFlags(plot, plot.getSettings().flags.values());
MainUtil.sendMessage(player, C.FLAG_ADDED); MainUtil.sendMessage(player, C.FLAG_ADDED);
return true; return true;
} }

View File

@ -38,7 +38,7 @@ public class Home extends SubCommand {
private Plot isAlias(final String a) { private Plot isAlias(final String a) {
for (final Plot p : PS.get().getPlots()) { for (final Plot p : PS.get().getPlots()) {
if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { if ((p.getSettings().getAlias().length() > 0) && p.getSettings().getAlias().equalsIgnoreCase(a)) {
return p; return p;
} }
} }

View File

@ -156,7 +156,7 @@ public class Inbox extends SubCommand {
} }
PlotComment comment = comments.get(index - 1); PlotComment comment = comments.get(index - 1);
inbox.removeComment(plot, comment); inbox.removeComment(plot, comment);
plot.settings.removeComment(comment); plot.getSettings().removeComment(comment);
MainUtil.sendMessage(player, C.COMMENT_REMOVED, comment.comment); MainUtil.sendMessage(player, C.COMMENT_REMOVED, comment.comment);
} }
})) { })) {
@ -170,9 +170,9 @@ public class Inbox extends SubCommand {
sendMessage(player, C.NO_PERM_INBOX_MODIFY); sendMessage(player, C.NO_PERM_INBOX_MODIFY);
} }
inbox.clearInbox(plot); inbox.clearInbox(plot);
ArrayList<PlotComment> comments = plot.settings.getComments(inbox.toString()); ArrayList<PlotComment> comments = plot.getSettings().getComments(inbox.toString());
if (comments != null) { if (comments != null) {
plot.settings.removeComments(comments); plot.getSettings().removeComments(comments);
} }
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*"); MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
return true; return true;

View File

@ -144,8 +144,8 @@ public class Info extends SubCommand {
boolean trustedEveryone; boolean trustedEveryone;
// Wildcard player {added} // Wildcard player {added}
{ {
containsEveryone = (plot.trusted != null) && plot.trusted.contains(DBFunc.everyone); containsEveryone = (plot.getTrusted() != null) && plot.getTrusted().contains(DBFunc.everyone);
trustedEveryone = (plot.members != null) && plot.members.contains(DBFunc.everyone); trustedEveryone = (plot.getMembers() != null) && plot.getMembers().contains(DBFunc.everyone);
} }
// Unclaimed? // Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) { if (!hasOwner && !containsEveryone && !trustedEveryone) {
@ -198,18 +198,18 @@ public class Info extends SubCommand {
final PlotId id = plot.id; final PlotId id = plot.id;
final PlotId id2 = MainUtil.getTopPlot(plot).id; final PlotId id2 = MainUtil.getTopPlot(plot).id;
final int num = MainUtil.getPlotSelectionIds(id, id2).size(); final int num = MainUtil.getPlotSelectionIds(id, id2).size();
final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : C.NONE.s(); final String alias = plot.getSettings().getAlias().length() > 0 ? plot.getSettings().getAlias() : C.NONE.s();
Location top = MainUtil.getPlotTopLoc(world, plot.id); Location top = MainUtil.getPlotTopLoc(world, plot.id);
Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
final String biome = BlockManager.manager.getBiome(bot.add((top.getX() - bot.getX()) / 2, 0, (top.getX() - bot.getX()) / 2)); final String biome = BlockManager.manager.getBiome(bot.add((top.getX() - bot.getX()) / 2, 0, (top.getX() - bot.getX()) / 2));
final String trusted = getPlayerList(plot.trusted); final String trusted = getPlayerList(plot.getTrusted());
final String members = getPlayerList(plot.members); final String members = getPlayerList(plot.getMembers());
final String denied = getPlayerList(plot.denied); final String denied = getPlayerList(plot.getDenied());
Flag descriptionFlag = FlagManager.getPlotFlag(plot, "description"); Flag descriptionFlag = FlagManager.getPlotFlag(plot, "description");
final String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString(); final String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
final String flags = StringMan.replaceFromMap("$2" + (StringUtils.join(FlagManager.getPlotFlags(plot.world, plot.settings, true).values(), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot.world, plot.settings, true).values(), "$1, $2") : C.NONE.s()), C.replacements); final String flags = StringMan.replaceFromMap("$2" + (StringUtils.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true).values(), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true).values(), "$1, $2") : C.NONE.s()), C.replacements);
final boolean build = (player == null) || plot.isAdded(player.getUUID()); final boolean build = (player == null) || plot.isAdded(player.getUUID());
String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners()); String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());

View File

@ -63,12 +63,12 @@ public class Rate extends SubCommand {
public int compare(Plot p1, Plot p2) { public int compare(Plot p1, Plot p2) {
double v1 = 0; double v1 = 0;
double v2 = 0; double v2 = 0;
if (p1.settings.ratings != null) { if (p1.getSettings().ratings != null) {
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) { for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
v1 -= 11 - entry.getValue().getAverageRating(); v1 -= 11 - entry.getValue().getAverageRating();
} }
} }
if (p2.settings.ratings != null) { if (p2.getSettings().ratings != null) {
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) { for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
v2 -= 11 - entry.getValue().getAverageRating(); v2 -= 11 - entry.getValue().getAverageRating();
} }
@ -78,7 +78,7 @@ public class Rate extends SubCommand {
}); });
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
for (Plot p : plots) { for (Plot p : plots) {
if ((p.settings.ratings == null || !p.settings.ratings.containsKey(uuid)) && !p.isAdded(uuid)) { if ((p.getSettings().ratings == null || !p.getSettings().ratings.containsKey(uuid)) && !p.isAdded(uuid)) {
MainUtil.teleportPlayer(player, player.getLocation(), p); MainUtil.teleportPlayer(player, player.getLocation(), p);
MainUtil.sendMessage(player, C.RATE_THIS); MainUtil.sendMessage(player, C.RATE_THIS);
return true; return true;
@ -105,7 +105,7 @@ public class Rate extends SubCommand {
final Runnable run = new Runnable() { final Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
if (plot.settings.ratings.containsKey(player.getUUID())) { if (plot.getSettings().ratings.containsKey(player.getUUID())) {
sendMessage(player, C.RATING_ALREADY_EXISTS, plot.getId().toString()); sendMessage(player, C.RATING_ALREADY_EXISTS, plot.getId().toString());
return; return;
} }
@ -127,7 +127,7 @@ public class Rate extends SubCommand {
// get new rating // get new rating
rV = rateEvent.getRating(); rV = rateEvent.getRating();
// set rating // set rating
plot.settings.ratings.put(player.getUUID(), rV); plot.getSettings().ratings.put(player.getUUID(), rV);
DBFunc.setRating(plot, player.getUUID(), rV); DBFunc.setRating(plot, player.getUUID(), rV);
sendMessage(player, C.RATING_APPLIED, plot.getId().toString()); sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
sendMessage(player, C.RATING_APPLIED, plot.getId().toString()); sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
@ -149,11 +149,11 @@ public class Rate extends SubCommand {
inventory.openInventory(); inventory.openInventory();
} }
}; };
if (plot.settings.ratings == null) { if (plot.getSettings().ratings == null) {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
plot.settings.ratings = DBFunc.getRatings(plot); plot.getSettings().ratings = DBFunc.getRatings(plot);
run.run(); run.run();
} }
}); });
@ -187,20 +187,20 @@ public class Rate extends SubCommand {
final Runnable run = new Runnable() { final Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
if (plot.settings.ratings.containsKey(uuid)) { if (plot.getSettings().ratings.containsKey(uuid)) {
sendMessage(player, C.RATING_ALREADY_EXISTS, plot.getId().toString()); sendMessage(player, C.RATING_ALREADY_EXISTS, plot.getId().toString());
return; return;
} }
plot.settings.ratings.put(uuid, rating); plot.getSettings().ratings.put(uuid, rating);
DBFunc.setRating(plot, uuid, rating); DBFunc.setRating(plot, uuid, rating);
sendMessage(player, C.RATING_APPLIED, plot.getId().toString()); sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
} }
}; };
if (plot.settings.ratings == null) { if (plot.getSettings().ratings == null) {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
plot.settings.ratings = DBFunc.getRatings(plot); plot.getSettings().ratings = DBFunc.getRatings(plot);
run.run(); run.run();
} }
}); });

View File

@ -60,9 +60,9 @@ public class Remove extends SubCommand {
if (args[0].equals("unknown")) { if (args[0].equals("unknown")) {
ArrayList<UUID> toRemove = new ArrayList<>(); ArrayList<UUID> toRemove = new ArrayList<>();
HashSet<UUID> all = new HashSet<>(); HashSet<UUID> all = new HashSet<>();
all.addAll(plot.members); all.addAll(plot.getMembers());
all.addAll(plot.trusted); all.addAll(plot.getTrusted());
all.addAll(plot.denied); all.addAll(plot.getDenied());
for (UUID uuid : all) { for (UUID uuid : all) {
if (UUIDHandler.getName(uuid) == null) { if (UUIDHandler.getName(uuid) == null) {
toRemove.add(uuid); toRemove.add(uuid);
@ -78,9 +78,9 @@ public class Remove extends SubCommand {
else if (args[0].equals("*")){ else if (args[0].equals("*")){
ArrayList<UUID> toRemove = new ArrayList<>(); ArrayList<UUID> toRemove = new ArrayList<>();
HashSet<UUID> all = new HashSet<>(); HashSet<UUID> all = new HashSet<>();
all.addAll(plot.members); all.addAll(plot.getMembers());
all.addAll(plot.trusted); all.addAll(plot.getTrusted());
all.addAll(plot.denied); all.addAll(plot.getDenied());
for (UUID uuid : all) { for (UUID uuid : all) {
toRemove.add(uuid); toRemove.add(uuid);
count++; count++;
@ -94,17 +94,17 @@ public class Remove extends SubCommand {
else { else {
UUID uuid = UUIDHandler.getUUID(args[0]); UUID uuid = UUIDHandler.getUUID(args[0]);
if (uuid != null) { if (uuid != null) {
if (plot.trusted.contains(uuid)) { if (plot.getTrusted().contains(uuid)) {
if (plot.removeTrusted(uuid)) { if (plot.removeTrusted(uuid)) {
count++; count++;
} }
} }
else if (plot.members.contains(uuid)) { else if (plot.getMembers().contains(uuid)) {
if (plot.removeMember(uuid)) { if (plot.removeMember(uuid)) {
count++; count++;
} }
} }
else if (plot.denied.contains(uuid)) { else if (plot.getDenied().contains(uuid)) {
if (plot.removeDenied(uuid)) { if (plot.removeDenied(uuid)) {
count++; count++;
} }

View File

@ -123,10 +123,9 @@ public class SchematicCmd extends SubCommand {
if (!(schematic.getSchematicDimension().getY() == BukkitUtil.getMaxHeight(loc.getWorld()))) { if (!(schematic.getSchematicDimension().getY() == BukkitUtil.getMaxHeight(loc.getWorld()))) {
l1 = bot.add(0, sy - 1, 0); l1 = bot.add(0, sy - 1, 0);
} }
else { else {
l1 = bot; l1 = bot;
} }
final int blen = b.length - 1; final int blen = b.length - 1;
SchematicCmd.this.task = TaskManager.runTaskRepeat(new Runnable() { SchematicCmd.this.task = TaskManager.runTaskRepeat(new Runnable() {
@Override @Override

View File

@ -207,7 +207,7 @@ public class Set extends SubCommand {
return false; return false;
} }
for (final Plot p : PS.get().getPlots(plr.getLocation().getWorld()).values()) { for (final Plot p : PS.get().getPlots(plr.getLocation().getWorld()).values()) {
if (p.settings.getAlias().equalsIgnoreCase(alias)) { if (p.getSettings().getAlias().equalsIgnoreCase(alias)) {
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN); MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
return false; return false;
} }

View File

@ -94,7 +94,7 @@ public class TP extends SubCommand {
return null; return null;
} }
for (final Plot p : PS.get().getPlots(world).values()) { for (final Plot p : PS.get().getPlots(world).values()) {
if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { if ((p.getSettings().getAlias().length() > 0) && p.getSettings().getAlias().equalsIgnoreCase(a)) {
return p; return p;
} }
} }

View File

@ -72,7 +72,7 @@ public class Trust extends SubCommand {
return false; return false;
} }
if (plot.trusted.contains(uuid)) { if (plot.getTrusted().contains(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_ADDED); MainUtil.sendMessage(plr, C.ALREADY_ADDED);
return false; return false;
} }
@ -80,11 +80,11 @@ public class Trust extends SubCommand {
plot.addTrusted(uuid); plot.addTrusted(uuid);
} }
else { else {
if (plot.members.size() + plot.trusted.size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) { if (plot.getMembers().size() + plot.getTrusted().size() >= PS.get().getPlotWorld(plot.world).MAX_PLOT_MEMBERS) {
MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS); MainUtil.sendMessage(plr, C.PLOT_MAX_MEMBERS);
return false; return false;
} }
if (plot.denied.contains(uuid)) { if (plot.getDenied().contains(uuid)) {
plot.removeDenied(uuid); plot.removeDenied(uuid);
} }
plot.addTrusted(uuid); plot.addTrusted(uuid);

View File

@ -58,7 +58,7 @@ public class Undeny extends SubCommand {
int count = 0; int count = 0;
if (args[0].equals("unknown")) { if (args[0].equals("unknown")) {
ArrayList<UUID> toRemove = new ArrayList<>(); ArrayList<UUID> toRemove = new ArrayList<>();
for (UUID uuid : plot.denied) { for (UUID uuid : plot.getDenied()) {
if (UUIDHandler.getName(uuid) == null) { if (UUIDHandler.getName(uuid) == null) {
toRemove.add(uuid); toRemove.add(uuid);
} }
@ -69,7 +69,7 @@ public class Undeny extends SubCommand {
} }
} }
else if (args[0].equals("*")){ else if (args[0].equals("*")){
for (UUID uuid : new ArrayList<>(plot.denied)) { for (UUID uuid : new ArrayList<>(plot.getDenied())) {
plot.removeDenied(uuid); plot.removeDenied(uuid);
count++; count++;
} }

View File

@ -58,7 +58,7 @@ public class Untrust extends SubCommand {
int count = 0; int count = 0;
if (args[0].equals("unknown")) { if (args[0].equals("unknown")) {
ArrayList<UUID> toRemove = new ArrayList<>(); ArrayList<UUID> toRemove = new ArrayList<>();
for (UUID uuid : plot.trusted) { for (UUID uuid : plot.getTrusted()) {
if (UUIDHandler.getName(uuid) == null) { if (UUIDHandler.getName(uuid) == null) {
toRemove.add(uuid); toRemove.add(uuid);
} }
@ -69,7 +69,7 @@ public class Untrust extends SubCommand {
} }
} }
else if (args[0].equals("*")){ else if (args[0].equals("*")){
for (UUID uuid : new ArrayList<>(plot.trusted)) { for (UUID uuid : new ArrayList<>(plot.getTrusted())) {
plot.removeTrusted(uuid); plot.removeTrusted(uuid);
count++; count++;
} }

View File

@ -171,7 +171,7 @@ public class list extends SubCommand {
} }
plots = new ArrayList<Plot>(); plots = new ArrayList<Plot>();
for (Plot plot : PS.get().getPlots()) { for (Plot plot : PS.get().getPlots()) {
if (plot.trusted.contains(plr.getUUID()) || plot.members.contains(plr.getUUID())) { if (plot.getTrusted().contains(plr.getUUID()) || plot.getMembers().contains(plr.getUUID())) {
plots.add(plot); plots.add(plot);
} }
} }
@ -208,9 +208,9 @@ public class list extends SubCommand {
public int compare(Plot p1, Plot p2) { public int compare(Plot p1, Plot p2) {
double v1 = 0; double v1 = 0;
double v2 = 0; double v2 = 0;
int p1s = p1.settings.ratings != null ? p1.settings.ratings.size() : 0; int p1s = p1.getSettings().ratings != null ? p1.getSettings().ratings.size() : 0;
int p2s = p2.settings.ratings != null ? p2.settings.ratings.size() : 0; int p2s = p2.getSettings().ratings != null ? p2.getSettings().ratings.size() : 0;
if (p1.settings.ratings != null && p1s > 0) { if (p1.getSettings().ratings != null && p1s > 0) {
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) { for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
double av = entry.getValue().getAverageRating(); double av = entry.getValue().getAverageRating();
v1 += av * av; v1 += av * av;
@ -218,7 +218,7 @@ public class list extends SubCommand {
v1 /= p1s; v1 /= p1s;
v1 += p1s; v1 += p1s;
} }
if (p2.settings.ratings != null && p2s > 0) { if (p2.getSettings().ratings != null && p2s > 0) {
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) { for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
double av = entry.getValue().getAverageRating(); double av = entry.getValue().getAverageRating();
v2 += av * av; v2 += av * av;
@ -353,7 +353,7 @@ public class list extends SubCommand {
int i = page * pageSize; int i = page * pageSize;
for (Plot plot : subList) { for (Plot plot : subList) {
if (plot.settings.isMerged()) { if (plot.getSettings().isMerged()) {
if (!MainUtil.getBottomPlot(plot).equals(plot)) { if (!MainUtil.getBottomPlot(plot).equals(plot)) {
continue; continue;
} }
@ -380,16 +380,16 @@ public class list extends SubCommand {
new FancyMessage( new FancyMessage(
ChatColor.stripColor( ChatColor.stripColor(
ChatColor.translateAlternateColorCodes('&', ChatColor.translateAlternateColorCodes('&',
C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", Info.getPlayerList(plot.trusted))))) C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", Info.getPlayerList(plot.getTrusted())))))
.color(ChatColor.GOLD); .color(ChatColor.GOLD);
FancyMessage members = FancyMessage members =
new FancyMessage( new FancyMessage(
ChatColor.stripColor( ChatColor.stripColor(
ChatColor.translateAlternateColorCodes('&', ChatColor.translateAlternateColorCodes('&',
C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", Info.getPlayerList(plot.members))))) C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", Info.getPlayerList(plot.getMembers())))))
.color(ChatColor.GOLD); .color(ChatColor.GOLD);
String strFlags = StringUtils.join(plot.settings.flags.values(), ","); String strFlags = StringUtils.join(plot.getSettings().flags.values(), ",");
if (strFlags.length() == 0) { if (strFlags.length() == 0) {
strFlags = C.NONE.s(); strFlags = C.NONE.s();
} }

View File

@ -173,19 +173,19 @@ public class SQLManager implements AbstractDB {
PlotId plotId = new PlotId(x, y); PlotId plotId = new PlotId(x, y);
Plot plot = plotMap.get(plotId); Plot plot = plotMap.get(plotId);
if (plot != null) { if (plot != null) {
settings.add(new SettingsPair(id, plot.settings)); settings.add(new SettingsPair(id, plot.getSettings()));
if (plot.denied != null) { if (plot.getDenied() != null) {
for (UUID uuid : plot.denied) { for (UUID uuid : plot.getDenied()) {
denied.add(new UUIDPair(id, uuid)); denied.add(new UUIDPair(id, uuid));
} }
} }
if (plot.members != null) { if (plot.getMembers() != null) {
for (UUID uuid : plot.members) { for (UUID uuid : plot.getMembers()) {
trusted.add(new UUIDPair(id, uuid)); trusted.add(new UUIDPair(id, uuid));
} }
} }
if (plot.trusted != null) { if (plot.getTrusted() != null) {
for (UUID uuid : plot.trusted) { for (UUID uuid : plot.getTrusted()) {
helpers.add(new UUIDPair(id, uuid)); helpers.add(new UUIDPair(id, uuid));
} }
} }
@ -950,10 +950,10 @@ public class SQLManager implements AbstractDB {
} }
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
if (plot.settings.ratings == null) { if (plot.getSettings().ratings == null) {
plot.settings.ratings = new HashMap<UUID, Integer>(); plot.getSettings().ratings = new HashMap<UUID, Integer>();
} }
plot.settings.ratings.put(user, r.getInt("rating")); plot.getSettings().ratings.put(user, r.getInt("rating"));
} else { } else {
PS.log("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry."); PS.log("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry.");
} }
@ -974,7 +974,7 @@ public class SQLManager implements AbstractDB {
} }
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.trusted.add(user); plot.getTrusted().add(user);
} else { } else {
PS.log("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry."); PS.log("&cPLOT " + id + " in plot_helpers does not exist. Please create the plot or remove this entry.");
} }
@ -994,7 +994,7 @@ public class SQLManager implements AbstractDB {
} }
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.members.add(user); plot.getMembers().add(user);
} else { } else {
PS.log("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry."); PS.log("&cPLOT " + id + " in plot_trusted does not exist. Please create the plot or remove this entry.");
} }
@ -1014,7 +1014,7 @@ public class SQLManager implements AbstractDB {
} }
final Plot plot = plots.get(id); final Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.denied.add(user); plot.getDenied().add(user);
} else { } else {
PS.log("&cPLOT " + id + " in plot_denied does not exist. Please create the plot or remove this entry."); PS.log("&cPLOT " + id + " in plot_denied does not exist. Please create the plot or remove this entry.");
} }
@ -1040,7 +1040,7 @@ public class SQLManager implements AbstractDB {
} }
final String alias = r.getString("alias"); final String alias = r.getString("alias");
if (alias != null) { if (alias != null) {
plot.settings.setAlias(alias); plot.getSettings().setAlias(alias);
} }
final String pos = r.getString("position"); final String pos = r.getString("position");
switch (pos.toLowerCase()) { switch (pos.toLowerCase()) {
@ -1051,7 +1051,7 @@ public class SQLManager implements AbstractDB {
break; break;
default: default:
try { try {
plot.settings.setPosition(BlockLoc.fromString(pos)); plot.getSettings().setPosition(BlockLoc.fromString(pos));
} catch (final Exception e) { } catch (final Exception e) {
} }
} }
@ -1061,9 +1061,9 @@ public class SQLManager implements AbstractDB {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
merged[3 - i] = ((m) & (1 << i)) != 0; merged[3 - i] = ((m) & (1 << i)) != 0;
} }
plot.settings.setMerged(merged); plot.getSettings().setMerged(merged);
} else { } else {
plot.settings.setMerged(new boolean[]{false, false, false, false}); plot.getSettings().setMerged(new boolean[]{false, false, false, false});
} }
String[] flags_string; String[] flags_string;
final String myflags = r.getString("flags"); final String myflags = r.getString("flags");
@ -1104,7 +1104,7 @@ public class SQLManager implements AbstractDB {
PS.log("&c" + myflags); PS.log("&c" + myflags);
setFlags(id, flags.values()); setFlags(id, flags.values());
} }
plot.settings.flags = flags; plot.getSettings().flags = flags;
} else { } else {
PS.log("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry."); PS.log("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry.");
} }
@ -1132,7 +1132,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void setMerged(final Plot plot, final boolean[] merged) { public void setMerged(final Plot plot, final boolean[] merged) {
plot.settings.setMerged(merged); plot.getSettings().setMerged(merged);
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -131,7 +131,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
HashMap<PlotId, Plot> newplots = plots.get(world); HashMap<PlotId, Plot> newplots = plots.get(world);
Plot plot = newplots.get(entry2.getKey()); Plot plot = newplots.get(entry2.getKey());
if (plot != null) { if (plot != null) {
plot.settings.setMerged(entry2.getValue()); plot.getSettings().setMerged(entry2.getValue());
} }
} }
} }
@ -159,7 +159,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
} }
} }
if (plots.get(world).containsKey(id)) { if (plots.get(world).containsKey(id)) {
plots.get(world).get(id).denied.add(denied); plots.get(world).get(id).getDenied().add(denied);
} }
} }
@ -180,7 +180,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
} }
} }
if (plots.get(world).containsKey(id)) { if (plots.get(world).containsKey(id)) {
plots.get(world).get(id).trusted.add(helper); plots.get(world).get(id).getTrusted().add(helper);
} }
} }

View File

@ -131,7 +131,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.world); HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.world);
if (mergeMap != null) { if (mergeMap != null) {
if (mergeMap.containsKey(plot.id)) { if (mergeMap.containsKey(plot.id)) {
plot.settings.setMerged(mergeMap.get(plot.id)); plot.getSettings().setMerged(mergeMap.get(plot.id));
} }
} }
} }
@ -150,7 +150,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
continue; continue;
} }
UUID denied = UUID.fromString(r.getString("player")); UUID denied = UUID.fromString(r.getString("player"));
plot.denied.add(denied); plot.getDenied().add(denied);
} }
MainUtil.sendConsoleMessage(" - " + plugin + "core_allowed"); MainUtil.sendConsoleMessage(" - " + plugin + "core_allowed");
@ -165,7 +165,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
continue; continue;
} }
UUID allowed = UUID.fromString(r.getString("player")); UUID allowed = UUID.fromString(r.getString("player"));
plot.trusted.add(allowed); plot.getTrusted().add(allowed);
} }
r.close(); r.close();
stmt.close(); stmt.close();

View File

@ -104,7 +104,7 @@ public class FlagManager {
} }
if (PS.get().getAllPlotsRaw() != null) { if (PS.get().getAllPlotsRaw() != null) {
for (final Plot plot : PS.get().getPlotsRaw()) { for (final Plot plot : PS.get().getPlotsRaw()) {
Flag flag = plot.settings.flags.get(af.getKey()); Flag flag = plot.getSettings().flags.get(af.getKey());
if (flag != null) { if (flag != null) {
flag.setKey(af); flag.setKey(af);
} }
@ -151,7 +151,10 @@ public class FlagManager {
* @return Flag * @return Flag
*/ */
public static Flag getPlotFlag(final Plot plot, final String flag) { public static Flag getPlotFlag(final Plot plot, final String flag) {
return getSettingFlag(plot.world, plot.settings, flag); if (!plot.hasOwner()) {
return null;
}
return getSettingFlag(plot.world, plot.getSettings(), flag);
} }
public static boolean isPlotFlagTrue(final Plot plot, final String strFlag) { public static boolean isPlotFlagTrue(final Plot plot, final String strFlag) {
@ -183,7 +186,7 @@ public class FlagManager {
* @return Flag * @return Flag
*/ */
public static Flag getPlotFlagAbs(final Plot plot, final String flag) { public static Flag getPlotFlagAbs(final Plot plot, final String flag) {
return getSettingFlagAbs(plot.settings, flag); return getSettingFlagAbs(plot.getSettings(), flag);
} }
public static Flag getSettingFlagAbs(final PlotSettings settings, final String flag) { public static Flag getSettingFlagAbs(final PlotSettings settings, final String flag) {
@ -203,9 +206,9 @@ public class FlagManager {
if (!result) { if (!result) {
return false; return false;
} }
plot.settings.flags.put(flag.getKey(), flag); plot.getSettings().flags.put(flag.getKey(), flag);
MainUtil.reEnterPlot(plot); MainUtil.reEnterPlot(plot);
DBFunc.setFlags(plot, plot.settings.flags.values()); DBFunc.setFlags(plot, plot.getSettings().flags.values());
return true; return true;
} }
@ -214,7 +217,7 @@ public class FlagManager {
if (!result) { if (!result) {
return false; return false;
} }
plot.settings.flags.put(flag.getKey(), flag); plot.getSettings().flags.put(flag.getKey(), flag);
return true; return true;
} }
@ -232,7 +235,10 @@ public class FlagManager {
* @return set of flags * @return set of flags
*/ */
public static HashMap<String, Flag> getPlotFlags(final Plot plot) { public static HashMap<String, Flag> getPlotFlags(final Plot plot) {
return getSettingFlags(plot.world, plot.settings); if (!plot.hasOwner()) {
return null;
}
return getSettingFlags(plot.world, plot.getSettings());
} }
public static HashMap<String, Flag> getPlotFlags(final String world, final PlotSettings settings, final boolean ignorePluginflags) { public static HashMap<String, Flag> getPlotFlags(final String world, final PlotSettings settings, final boolean ignorePluginflags) {
@ -260,17 +266,17 @@ public class FlagManager {
} }
public static boolean removePlotFlag(final Plot plot, final String id) { public static boolean removePlotFlag(final Plot plot, final String id) {
Flag flag = plot.settings.flags.remove(id); Flag flag = plot.getSettings().flags.remove(id);
if (flag == null) { if (flag == null) {
return false; return false;
} }
final boolean result = EventUtil.manager.callFlagRemove(flag, plot); final boolean result = EventUtil.manager.callFlagRemove(flag, plot);
if (!result) { if (!result) {
plot.settings.flags.put(id, flag); plot.getSettings().flags.put(id, flag);
return false; return false;
} }
MainUtil.reEnterPlot(plot); MainUtil.reEnterPlot(plot);
DBFunc.setFlags(plot, plot.settings.flags.values()); DBFunc.setFlags(plot, plot.getSettings().flags.values());
return true; return true;
} }
@ -290,19 +296,19 @@ public class FlagManager {
public static void setPlotFlags(final Plot plot, final Set<Flag> flags) { public static void setPlotFlags(final Plot plot, final Set<Flag> flags) {
if (flags != null && flags.size() != 0) { if (flags != null && flags.size() != 0) {
plot.settings.flags.clear(); plot.getSettings().flags.clear();
for (Flag flag : flags) { for (Flag flag : flags) {
plot.settings.flags.put(flag.getKey(), flag); plot.getSettings().flags.put(flag.getKey(), flag);
} }
} }
else if (plot.settings.flags.size() == 0) { else if (plot.getSettings().flags.size() == 0) {
return; return;
} }
else { else {
plot.settings.flags.clear(); plot.getSettings().flags.clear();
} }
MainUtil.reEnterPlot(plot); MainUtil.reEnterPlot(plot);
DBFunc.setFlags(plot, plot.settings.flags.values()); DBFunc.setFlags(plot, plot.getSettings().flags.values());
} }
public static void setClusterFlags(final PlotCluster cluster, final Set<Flag> flags) { public static void setClusterFlags(final PlotCluster cluster, final Set<Flag> flags) {

View File

@ -101,13 +101,13 @@ public abstract class HybridUtils {
if (result) { if (result) {
if (id1 != null) { if (id1 != null) {
final Plot p1 = MainUtil.getPlot(world, id1); final Plot p1 = MainUtil.getPlot(world, id1);
if ((p1 != null) && p1.hasOwner() && p1.settings.isMerged()) { if ((p1 != null) && p1.hasOwner() && p1.getSettings().isMerged()) {
toCheck = true; toCheck = true;
} }
} }
if ((id2 != null) && !toCheck) { if ((id2 != null) && !toCheck) {
final Plot p2 = MainUtil.getPlot(world, id2); final Plot p2 = MainUtil.getPlot(world, id2);
if ((p2 != null) && p2.hasOwner() && p2.settings.isMerged()) { if ((p2 != null) && p2.hasOwner() && p2.getSettings().isMerged()) {
toCheck = true; toCheck = true;
} }
} }

View File

@ -130,7 +130,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
if (plot == null) { if (plot == null) {
return null; return null;
} }
if ((plot.settings.getMerged(0) && plot.settings.getMerged(3))) { if ((plot.getMerged(0) && plot.getMerged(3))) {
return MainUtil.getBottomPlot(plot).id; return MainUtil.getBottomPlot(plot).id;
} }
return null; return null;
@ -143,7 +143,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
if (plot == null) { if (plot == null) {
return null; return null;
} }
if (plot.settings.getMerged(0)) { if (plot.getMerged(0)) {
return MainUtil.getBottomPlot(plot).id; return MainUtil.getBottomPlot(plot).id;
} }
return null; return null;
@ -156,7 +156,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
if (plot == null) { if (plot == null) {
return null; return null;
} }
if (plot.settings.getMerged(3)) { if (plot.getMerged(3)) {
return MainUtil.getBottomPlot(plot).id; return MainUtil.getBottomPlot(plot).id;
} }
return null; return null;

View File

@ -160,13 +160,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
Plot plot = MainUtil.getPlot(loc); Plot plot = MainUtil.getPlot(loc);
if (plot == null) { if (plot == null || !plot.hasOwner()) {
return; return;
} }
if (Settings.REDSTONE_DISABLER) { if (Settings.REDSTONE_DISABLER) {
if (UUIDHandler.getPlayer(plot.owner) == null) { if (UUIDHandler.getPlayer(plot.owner) == null) {
boolean disable = true; boolean disable = true;
for (UUID trusted : plot.trusted) { for (UUID trusted : plot.getTrusted()) {
if (UUIDHandler.getPlayer(trusted) != null) { if (UUIDHandler.getPlayer(trusted) != null) {
disable = false; disable = false;
break; break;

View File

@ -207,6 +207,9 @@ public class PlotPlusListener extends PlotListener implements Listener {
public void onPlotLeave(final PlayerLeavePlotEvent event) { public void onPlotLeave(final PlayerLeavePlotEvent event) {
final Player leaver = event.getPlayer(); final Player leaver = event.getPlayer();
final Plot plot = event.getPlot(); final Plot plot = event.getPlot();
if (!plot.hasOwner()) {
return;
}
if (FlagManager.getPlotFlag(plot, "farewell") != null) { if (FlagManager.getPlotFlag(plot, "farewell") != null) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "farewell").getValueString())); event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "farewell").getValueString()));
} }

View File

@ -27,8 +27,8 @@ public class WEManager {
HashSet<RegionWrapper> regions = new HashSet<>(); HashSet<RegionWrapper> regions = new HashSet<>();
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
for (Plot plot : PS.get().getPlots(player.getLocation().getWorld()).values()) { for (Plot plot : PS.get().getPlots(player.getLocation().getWorld()).values()) {
if (!plot.settings.getMerged(0) && !plot.settings.getMerged(3)) { if (!plot.getMerged(0) && !plot.getMerged(3)) {
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.trusted.contains(uuid))) { if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ())); regions.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()));

View File

@ -52,11 +52,11 @@ public class InfoInventory implements InventoryHolder {
public InfoInventory build() { public InfoInventory build() {
final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(this.player)); final UUID uuid = UUIDHandler.getUUID(BukkitUtil.getPlayer(this.player));
final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.owner), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid)); final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.owner), "&cAlias: &6" + this.plot.getSettings().getAlias(), "&cBiome: &6" + this.plot.getSettings().getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.isAdded(uuid), "&cIs Denied: &6" + this.plot.isDenied(uuid));
final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of the trusted users"); final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.getTrusted().size(), "&8Click to view a list of the trusted users");
final ItemStack members = getItem(Material.EMERALD, "&cMembers", "&cAmount: &6" + this.plot.members.size(), "&8Click to view a list of plot members"); final ItemStack members = getItem(Material.EMERALD, "&cMembers", "&cAmount: &6" + this.plot.getMembers().size(), "&8Click to view a list of plot members");
final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.denied.size(), "&8Click to view a list of denied players"); final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.getDenied().size(), "&8Click to view a list of denied players");
final ItemStack flags = getItem(Material.EMERALD, "&cFlags", "&cAmount: &6" + this.plot.settings.flags.size(), "&8Click to view a list of plot flags"); final ItemStack flags = getItem(Material.EMERALD, "&cFlags", "&cAmount: &6" + this.plot.getSettings().flags.size(), "&8Click to view a list of plot flags");
this.inventory.setItem(2, generalInfo); this.inventory.setItem(2, generalInfo);
this.inventory.setItem(3, trusted); this.inventory.setItem(3, trusted);
this.inventory.setItem(4, members); this.inventory.setItem(4, members);

View File

@ -92,10 +92,6 @@ public class Plot implements Cloneable {
this.world = world; this.world = world;
this.id = id; this.id = id;
this.owner = owner; this.owner = owner;
this.settings = new PlotSettings(this);
this.trusted = new HashSet<>();
this.members = new HashSet<>();
this.denied = new HashSet<>();
this.temp = false; this.temp = false;
} }
@ -111,10 +107,6 @@ public class Plot implements Cloneable {
this.world = world; this.world = world;
this.id = id; this.id = id;
this.owner = owner; this.owner = owner;
this.settings = new PlotSettings(this);
this.trusted = new HashSet<>();
this.members = new HashSet<>();
this.denied = new HashSet<>();
this.temp = temp; this.temp = temp;
} }
@ -186,7 +178,7 @@ public class Plot implements Cloneable {
* @return boolean false if the player is allowed to enter * @return boolean false if the player is allowed to enter
*/ */
public boolean isDenied(final UUID uuid) { public boolean isDenied(final UUID uuid) {
return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid))); return (this.getDenied() != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid)));
} }
/** /**
@ -196,6 +188,69 @@ public class Plot implements Cloneable {
return this.id; return this.id;
} }
/**
* Get or create plot settings
* @return PlotSettings
*/
public PlotSettings getSettings() {
if (settings == null) {
settings = new PlotSettings(this);
}
return settings;
}
public boolean isMerged() {
if (settings == null) {
return false;
}
return settings.getMerged(0) || settings.getMerged(2) || settings.getMerged(1) || settings.getMerged(3);
}
/**
* Get if the plot is merged in a direction
* @param direction
* @return
*/
public boolean getMerged(int direction) {
if (settings == null) {
return false;
}
return settings.getMerged(direction);
}
/**
* Get the denied users
* @return
*/
public HashSet<UUID> getDenied() {
if (this.denied == null) {
this.denied = new HashSet<>();
}
return this.denied;
}
/**
* Get the trusted users
* @return
*/
public HashSet<UUID> getTrusted() {
if (this.trusted == null) {
this.trusted = new HashSet<>();
}
return this.trusted;
}
/**
* Get the members
* @return
*/
public HashSet<UUID> getMembers() {
if (this.members == null) {
this.members = new HashSet<>();
}
return this.members;
}
/** /**
* Get a clone of the plot * Get a clone of the plot
* *
@ -216,7 +271,7 @@ public class Plot implements Cloneable {
* @param uuid * @param uuid
*/ */
public void addDenied(final UUID uuid) { public void addDenied(final UUID uuid) {
if (this.denied.add(uuid)) DBFunc.setDenied(this, uuid); if (this.getDenied().add(uuid)) DBFunc.setDenied(this, uuid);
} }
/** /**
@ -225,7 +280,7 @@ public class Plot implements Cloneable {
* @param uuid * @param uuid
*/ */
public void addTrusted(final UUID uuid) { public void addTrusted(final UUID uuid) {
if (this.trusted.add(uuid)) DBFunc.setTrusted(this, uuid); if (this.getTrusted().add(uuid)) DBFunc.setTrusted(this, uuid);
} }
/** /**
@ -234,7 +289,7 @@ public class Plot implements Cloneable {
* @param uuid * @param uuid
*/ */
public void addMember(final UUID uuid) { public void addMember(final UUID uuid) {
if (this.members.add(uuid)) DBFunc.setMember(this, uuid); if (this.getMembers().add(uuid)) DBFunc.setMember(this, uuid);
} }
/** /**
@ -332,10 +387,10 @@ public class Plot implements Cloneable {
*/ */
public HashMap<UUID, Rating> getRatings() { public HashMap<UUID, Rating> getRatings() {
HashMap<UUID, Rating> map = new HashMap<UUID, Rating>(); HashMap<UUID, Rating> map = new HashMap<UUID, Rating>();
if (settings.ratings == null) { if (getSettings().ratings == null) {
return map; return map;
} }
for (Entry<UUID, Integer> entry : settings.ratings.entrySet()) { for (Entry<UUID, Integer> entry : getSettings().ratings.entrySet()) {
map.put(entry.getKey(), new Rating(entry.getValue())); map.put(entry.getKey(), new Rating(entry.getValue()));
} }
return map; return map;
@ -346,16 +401,16 @@ public class Plot implements Cloneable {
* @param loc * @param loc
*/ */
public void setHome(BlockLoc loc) { public void setHome(BlockLoc loc) {
BlockLoc pos = this.settings.getPosition(); BlockLoc pos = this.getSettings().getPosition();
if ((pos == null && loc == null) || (pos != null && pos.equals(loc))) { if ((pos == null && loc == null) || (pos != null && pos.equals(loc))) {
return; return;
} }
this.settings.setPosition(loc); this.getSettings().setPosition(loc);
if (this.settings.getPosition() == null) { if (this.getSettings().getPosition() == null) {
DBFunc.setPosition(this, ""); DBFunc.setPosition(this, "");
} }
else { else {
DBFunc.setPosition(this, this.settings.getPosition().toString()); DBFunc.setPosition(this, this.getSettings().getPosition().toString());
} }
} }
@ -364,14 +419,14 @@ public class Plot implements Cloneable {
* @param alias * @param alias
*/ */
public void setAlias(String alias) { public void setAlias(String alias) {
String name = this.settings.getAlias(); String name = this.getSettings().getAlias();
if (alias == null) { if (alias == null) {
alias = ""; alias = "";
} }
if (name.equals(alias)) { if (name.equals(alias)) {
return; return;
} }
this.settings.setAlias(alias); this.getSettings().setAlias(alias);
DBFunc.setAlias(this, alias); DBFunc.setAlias(this, alias);
} }
@ -499,7 +554,7 @@ public class Plot implements Cloneable {
*/ */
@Override @Override
public String toString() { public String toString() {
if (this.settings.getAlias().length() > 1) { if (this.settings != null && this.settings.getAlias().length() > 1) {
return this.settings.getAlias(); return this.settings.getAlias();
} }
return this.world + ";" + this.getId().x + ";" + this.getId().y; return this.world + ";" + this.getId().x + ";" + this.getId().y;
@ -511,7 +566,7 @@ public class Plot implements Cloneable {
* @param uuid * @param uuid
*/ */
public boolean removeDenied(final UUID uuid) { public boolean removeDenied(final UUID uuid) {
if (this.denied.remove(uuid)) { if (this.getDenied().remove(uuid)) {
DBFunc.removeDenied(this, uuid); DBFunc.removeDenied(this, uuid);
return true; return true;
} }
@ -524,7 +579,7 @@ public class Plot implements Cloneable {
* @param uuid * @param uuid
*/ */
public boolean removeTrusted(final UUID uuid) { public boolean removeTrusted(final UUID uuid) {
if (this.trusted.remove(uuid)) { if (this.getTrusted().remove(uuid)) {
DBFunc.removeTrusted(this, uuid); DBFunc.removeTrusted(this, uuid);
return true; return true;
} }
@ -537,7 +592,7 @@ public class Plot implements Cloneable {
* @param uuid * @param uuid
*/ */
public boolean removeMember(final UUID uuid) { public boolean removeMember(final UUID uuid) {
if (this.members.remove(uuid)) { if (this.getMembers().remove(uuid)) {
DBFunc.removeMember(this, uuid); DBFunc.removeMember(this, uuid);
return true; return true;
} }

View File

@ -105,7 +105,7 @@ public class PlotAnalysis {
PS.log(" - $1Reducing " + plots.size() + " plots to those with sufficient data"); PS.log(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
while (iter.hasNext()) { while (iter.hasNext()) {
Plot plot = iter.next(); Plot plot = iter.next();
if (plot.settings.ratings == null || plot.settings.ratings.size() == 0) { if (plot.getSettings().ratings == null || plot.getSettings().ratings.size() == 0) {
iter.remove(); iter.remove();
} }
else { else {
@ -147,7 +147,7 @@ public class PlotAnalysis {
for (;mi.intValue() < plots.size(); mi.increment()) { for (;mi.intValue() < plots.size(); mi.increment()) {
int i = mi.intValue(); int i = mi.intValue();
Plot plot = plots.get(i); Plot plot = plots.get(i);
ratings[i] = (int) ((plot.getAverageRating() + plot.settings.ratings.size()) * 100); ratings[i] = (int) ((plot.getAverageRating() + plot.getSettings().ratings.size()) * 100);
PS.log(" | " + plot + " (rating) " + (ratings[i])); PS.log(" | " + plot + " (rating) " + (ratings[i]));
} }
} }

View File

@ -14,7 +14,7 @@ public class PlotHandler {
if (plot.owner == null) { if (plot.owner == null) {
return new HashSet<UUID>(); return new HashSet<UUID>();
} }
if (plot.settings.isMerged()) { if (plot.isMerged()) {
HashSet<UUID> owners = new HashSet<UUID>(); HashSet<UUID> owners = new HashSet<UUID>();
Plot top = MainUtil.getTopPlot(plot); Plot top = MainUtil.getTopPlot(plot);
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id); ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id);
@ -33,7 +33,7 @@ public class PlotHandler {
if (plot.owner == null) { if (plot.owner == null) {
return false; return false;
} }
if (plot.settings.isMerged()) { if (plot.isMerged()) {
Plot top = MainUtil.getTopPlot(plot); Plot top = MainUtil.getTopPlot(plot);
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id); ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id);
for (PlotId id : ids) { for (PlotId id : ids) {
@ -50,7 +50,7 @@ public class PlotHandler {
if (plot.owner == null) { if (plot.owner == null) {
return false; return false;
} }
if (plot.settings.isMerged()) { if (plot.isMerged()) {
Plot top = MainUtil.getTopPlot(plot); Plot top = MainUtil.getTopPlot(plot);
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id); ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(plot.id, top.id);
for (PlotId id : ids) { for (PlotId id : ids) {
@ -82,13 +82,13 @@ public class PlotHandler {
if (isOwner(plot, uuid)) { if (isOwner(plot, uuid)) {
return true; return true;
} }
if (plot.denied.contains(uuid)) { if (plot.getDenied().contains(uuid)) {
return false; return false;
} }
if (plot.trusted.contains(uuid) || plot.trusted.contains(DBFunc.everyone)) { if (plot.getTrusted().contains(uuid) || plot.getTrusted().contains(DBFunc.everyone)) {
return true; return true;
} }
if (plot.members.contains(uuid) || plot.members.contains(DBFunc.everyone)) { if (plot.getMembers().contains(uuid) || plot.getMembers().contains(DBFunc.everyone)) {
if (PlotHandler.isOnline(plot)) { if (PlotHandler.isOnline(plot)) {
return true; return true;
} }

View File

@ -41,7 +41,7 @@ public class InboxOwner extends CommentInbox {
if (plot == null || plot.owner == null) { if (plot == null || plot.owner == null) {
return false; return false;
} }
ArrayList<PlotComment> comments = plot.settings.getComments(toString()); ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
if (comments != null) { if (comments != null) {
whenDone.value = comments; whenDone.value = comments;
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -53,7 +53,7 @@ public class InboxOwner extends CommentInbox {
whenDone.value = value; whenDone.value = value;
if (value != null) { if (value != null) {
for (PlotComment comment : (ArrayList<PlotComment>) value) { for (PlotComment comment : (ArrayList<PlotComment>) value) {
plot.settings.addComment(comment); plot.getSettings().addComment(comment);
} }
} }
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -67,7 +67,7 @@ public class InboxOwner extends CommentInbox {
if (plot == null || plot.owner == null) { if (plot == null || plot.owner == null) {
return false; return false;
} }
plot.settings.addComment(comment); plot.getSettings().addComment(comment);
DBFunc.setComment(plot, comment); DBFunc.setComment(plot, comment);
return true; return true;
} }

View File

@ -41,7 +41,7 @@ public class InboxPublic extends CommentInbox {
if (plot == null || plot.owner == null) { if (plot == null || plot.owner == null) {
return false; return false;
} }
ArrayList<PlotComment> comments = plot.settings.getComments(toString()); ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
if (comments != null) { if (comments != null) {
whenDone.value = comments; whenDone.value = comments;
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -53,7 +53,7 @@ public class InboxPublic extends CommentInbox {
whenDone.value = value; whenDone.value = value;
if (value != null) { if (value != null) {
for (PlotComment comment : (ArrayList<PlotComment>) value) { for (PlotComment comment : (ArrayList<PlotComment>) value) {
plot.settings.addComment(comment); plot.getSettings().addComment(comment);
} }
} }
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -67,7 +67,7 @@ public class InboxPublic extends CommentInbox {
if (plot == null || plot.owner == null) { if (plot == null || plot.owner == null) {
return false; return false;
} }
plot.settings.addComment(comment); plot.getSettings().addComment(comment);
DBFunc.setComment(plot, comment); DBFunc.setComment(plot, comment);
return true; return true;
} }

View File

@ -99,13 +99,13 @@ public class ExpireManager {
PS.log("$2[&5Expire&dManager$2] &bSkipping no longer expired: " + plot); PS.log("$2[&5Expire&dManager$2] &bSkipping no longer expired: " + plot);
return; return;
} }
for (final UUID helper : plot.trusted) { for (final UUID helper : plot.getTrusted()) {
final PlotPlayer player = UUIDHandler.getPlayer(helper); final PlotPlayer player = UUIDHandler.getPlayer(helper);
if (player != null) { if (player != null) {
MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.id.toString()); MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.id.toString());
} }
} }
for (final UUID helper : plot.members) { for (final UUID helper : plot.getMembers()) {
final PlotPlayer player = UUIDHandler.getPlayer(helper); final PlotPlayer player = UUIDHandler.getPlayer(helper);
if (player != null) { if (player != null) {
MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.id.toString()); MainUtil.sendMessage(player, C.PLOT_REMOVED_USER, plot.id.toString());
@ -130,7 +130,7 @@ public class ExpireManager {
return; return;
} }
} }
if (plot.settings.isMerged()) { if (plot.isMerged()) {
MainUtil.unlinkPlot(plot); MainUtil.unlinkPlot(plot);
} }
plot.delete(); plot.delete();

View File

@ -160,7 +160,7 @@ public class MainUtil {
if (world != null && plot.world.equals(world)) { if (world != null && plot.world.equals(world)) {
count++; count++;
} }
if (alias != null && alias.equals(plot.settings.getAlias())) { if (alias != null && alias.equals(plot.getSettings().getAlias())) {
count+=2; count+=2;
} }
if (count != 0) { if (count != 0) {
@ -207,7 +207,7 @@ public class MainUtil {
worldname = PS.get().getPlotWorlds().iterator().next(); worldname = PS.get().getPlotWorlds().iterator().next();
} }
for (Plot p : PS.get().getPlots(worldname).values()) { for (Plot p : PS.get().getPlots(worldname).values()) {
String name = p.settings.getAlias(); String name = p.getSettings().getAlias();
if (name.length() != 0 && name.equalsIgnoreCase(arg)) { if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
return p; return p;
} }
@ -215,7 +215,7 @@ public class MainUtil {
for (String world : PS.get().getPlotWorlds()) { for (String world : PS.get().getPlotWorlds()) {
if (!world.endsWith(worldname)) { if (!world.endsWith(worldname)) {
for (Plot p : PS.get().getPlots(world).values()) { for (Plot p : PS.get().getPlots(world).values()) {
String name = p.settings.getAlias(); String name = p.getSettings().getAlias();
if (name.length() != 0 && name.equalsIgnoreCase(arg)) { if (name.length() != 0 && name.equalsIgnoreCase(arg)) {
return p; return p;
} }
@ -281,8 +281,8 @@ public class MainUtil {
if (plot.denied != null) { if (plot.denied != null) {
myplot.denied = plot.denied; myplot.denied = plot.denied;
} }
myplot.settings.setMerged(new boolean[] { false, false, false, false }); myplot.getSettings().setMerged(new boolean[] { false, false, false, false });
DBFunc.setMerged(myplot, myplot.settings.getMerged()); DBFunc.setMerged(myplot, myplot.getSettings().getMerged());
} }
if (plotworld.TERRAIN != 3) { if (plotworld.TERRAIN != 3) {
for (int x = pos1.x; x <= pos2.x; x++) { for (int x = pos1.x; x <= pos2.x; x++) {
@ -610,25 +610,25 @@ public class MainUtil {
} }
if (lx) { if (lx) {
if (ly) { if (ly) {
if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) { if (!plot.getSettings().getMerged(1) || !plot.getSettings().getMerged(2)) {
if (removeRoads) { if (removeRoads) {
MainUtil.removeRoadSouthEast(plotworld, plot); MainUtil.removeRoadSouthEast(plotworld, plot);
} }
} }
} }
if (!plot.settings.getMerged(1)) { if (!plot.getSettings().getMerged(1)) {
plot2 = PS.get().getPlots(world).get(new PlotId(x + 1, y)); plot2 = PS.get().getPlots(world).get(new PlotId(x + 1, y));
mergePlot(world, plot, plot2, removeRoads); mergePlot(world, plot, plot2, removeRoads);
plot.settings.setMerged(1, true); plot.getSettings().setMerged(1, true);
plot2.settings.setMerged(3, true); plot2.getSettings().setMerged(3, true);
} }
} }
if (ly) { if (ly) {
if (!plot.settings.getMerged(2)) { if (!plot.getSettings().getMerged(2)) {
plot2 = PS.get().getPlots(world).get(new PlotId(x, y + 1)); plot2 = PS.get().getPlots(world).get(new PlotId(x, y + 1));
mergePlot(world, plot, plot2, removeRoads); mergePlot(world, plot, plot2, removeRoads);
plot.settings.setMerged(2, true); plot.getSettings().setMerged(2, true);
plot2.settings.setMerged(0, true); plot2.getSettings().setMerged(0, true);
} }
} }
} }
@ -637,7 +637,7 @@ public class MainUtil {
for (int y = pos1.y; y <= pos2.y; y++) { for (int y = pos1.y; y <= pos2.y; y++) {
final PlotId id = new PlotId(x, y); final PlotId id = new PlotId(x, y);
final Plot plot = PS.get().getPlots(world).get(id); final Plot plot = PS.get().getPlots(world).get(id);
DBFunc.setMerged(plot, plot.settings.getMerged()); DBFunc.setMerged(plot, plot.getSettings().getMerged());
} }
} }
manager.finishPlotMerge(plotworld, plotIds); manager.finishPlotMerge(plotworld, plotIds);
@ -710,17 +710,17 @@ public class MainUtil {
public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) { public static void mergePlot(final String world, final Plot lesserPlot, final Plot greaterPlot, final boolean removeRoads) {
final PlotWorld plotworld = PS.get().getPlotWorld(world); final PlotWorld plotworld = PS.get().getPlotWorld(world);
if (lesserPlot.id.x.equals(greaterPlot.id.x)) { if (lesserPlot.id.x.equals(greaterPlot.id.x)) {
if (!lesserPlot.settings.getMerged(2)) { if (!lesserPlot.getSettings().getMerged(2)) {
lesserPlot.settings.setMerged(2, true); lesserPlot.getSettings().setMerged(2, true);
greaterPlot.settings.setMerged(0, true); greaterPlot.getSettings().setMerged(0, true);
if (removeRoads) { if (removeRoads) {
MainUtil.removeRoadSouth(plotworld, lesserPlot); MainUtil.removeRoadSouth(plotworld, lesserPlot);
} }
} }
} else { } else {
if (!lesserPlot.settings.getMerged(1)) { if (!lesserPlot.getSettings().getMerged(1)) {
lesserPlot.settings.setMerged(1, true); lesserPlot.getSettings().setMerged(1, true);
greaterPlot.settings.setMerged(3, true); greaterPlot.getSettings().setMerged(3, true);
if (removeRoads) { if (removeRoads) {
MainUtil.removeRoadEast(plotworld, lesserPlot); MainUtil.removeRoadEast(plotworld, lesserPlot);
} }
@ -1070,7 +1070,7 @@ public class MainUtil {
*/ */
public static Location getPlotHome(final String w, final PlotId plotid) { public static Location getPlotHome(final String w, final PlotId plotid) {
final Plot plot = getPlot(w, plotid); final Plot plot = getPlot(w, plotid);
final BlockLoc home = plot.settings.getPosition(); final BlockLoc home = plot.getSettings().getPosition();
final Location bot = getPlotBottomLoc(w, plotid); final Location bot = getPlotBottomLoc(w, plotid);
final PlotManager manager = PS.get().getPlotManager(w); final PlotManager manager = PS.get().getPlotManager(w);
if ((home == null) || ((home.x == 0) && (home.z == 0))) { if ((home == null) || ((home.x == 0) && (home.z == 0))) {
@ -1368,13 +1368,13 @@ public class MainUtil {
int x = id.x + offset_x; int x = id.x + offset_x;
int y = id.y + offset_y; int y = id.y + offset_y;
Plot plot = createPlotAbs(currentPlot.owner, getPlot(world, new PlotId(x, y))); Plot plot = createPlotAbs(currentPlot.owner, getPlot(world, new PlotId(x, y)));
if (currentPlot.settings.flags != null && currentPlot.settings.flags.size() > 0) { if (currentPlot.getSettings().flags != null && currentPlot.getSettings().flags.size() > 0) {
plot.settings.flags = currentPlot.settings.flags; plot.getSettings().flags = currentPlot.getSettings().flags;
DBFunc.setFlags(plot, currentPlot.settings.flags.values()); DBFunc.setFlags(plot, currentPlot.getSettings().flags.values());
} }
if (currentPlot.settings.isMerged()) { if (currentPlot.isMerged()) {
plot.settings.setMerged(currentPlot.settings.getMerged()); plot.getSettings().setMerged(currentPlot.getSettings().getMerged());
DBFunc.setMerged(plot, currentPlot.settings.getMerged()); DBFunc.setMerged(plot, currentPlot.getSettings().getMerged());
} }
if (currentPlot.members != null && currentPlot.members.size() > 0) { if (currentPlot.members != null && currentPlot.members.size() > 0) {
plot.members = currentPlot.members; plot.members = currentPlot.members;
@ -1383,13 +1383,13 @@ public class MainUtil {
} }
} }
if (currentPlot.trusted != null && currentPlot.trusted.size() > 0) { if (currentPlot.trusted != null && currentPlot.trusted.size() > 0) {
plot.members = currentPlot.trusted; plot.trusted = currentPlot.trusted;
for (UUID trusted : plot.trusted) { for (UUID trusted : plot.trusted) {
DBFunc.setTrusted(plot, trusted); DBFunc.setTrusted(plot, trusted);
} }
} }
if (currentPlot.denied != null && currentPlot.denied.size() > 0) { if (currentPlot.denied != null && currentPlot.denied.size() > 0) {
plot.members = currentPlot.denied; plot.denied = currentPlot.denied;
for (UUID denied : plot.denied) { for (UUID denied : plot.denied) {
DBFunc.setDenied(plot, denied); DBFunc.setDenied(plot, denied);
} }
@ -1522,14 +1522,14 @@ public class MainUtil {
} }
public static Plot getBottomPlot(final Plot plot) { public static Plot getBottomPlot(final Plot plot) {
if (plot.settings.getMerged(0)) { if (plot.getSettings().getMerged(0)) {
final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y - 1)); final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y - 1));
if (p == null) { if (p == null) {
return plot; return plot;
} }
return getBottomPlot(p); return getBottomPlot(p);
} }
if (plot.settings.getMerged(3)) { if (plot.getSettings().getMerged(3)) {
final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x - 1, plot.id.y)); final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x - 1, plot.id.y));
if (p == null) { if (p == null) {
return plot; return plot;
@ -1540,14 +1540,14 @@ public class MainUtil {
} }
public static Plot getTopPlot(final Plot plot) { public static Plot getTopPlot(final Plot plot) {
if (plot.settings.getMerged(2)) { if (plot.getSettings().getMerged(2)) {
final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1)); final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x, plot.id.y + 1));
if (p == null) { if (p == null) {
return plot; return plot;
} }
return getTopPlot(p); return getTopPlot(p);
} }
if (plot.settings.getMerged(1)) { if (plot.getSettings().getMerged(1)) {
final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y)); final Plot p = PS.get().getPlots(plot.world).get(new PlotId(plot.id.x + 1, plot.id.y));
if (p == null) { if (p == null) {
return plot; return plot;
@ -1559,8 +1559,7 @@ public class MainUtil {
} }
public static PlotId getSize(final Plot plot) { public static PlotId getSize(final Plot plot) {
final PlotSettings settings = plot.settings; if (!plot.isMerged()) {
if (!settings.isMerged()) {
return new PlotId(1, 1); return new PlotId(1, 1);
} }
final Plot top = getTopPlot(plot); final Plot top = getTopPlot(plot);
@ -1637,8 +1636,8 @@ public class MainUtil {
public static double getAverageRating(Plot plot) { public static double getAverageRating(Plot plot) {
HashMap<UUID, Integer> rating; HashMap<UUID, Integer> rating;
if (plot.settings.ratings != null) { if (plot.getSettings().ratings != null) {
rating = plot.settings.ratings; rating = plot.getSettings().ratings;
} }
else { else {
rating = DBFunc.getRatings(plot); rating = DBFunc.getRatings(plot);
@ -1667,8 +1666,8 @@ public class MainUtil {
public static double[] getAverageRatings(Plot plot) { public static double[] getAverageRatings(Plot plot) {
HashMap<UUID, Integer> rating; HashMap<UUID, Integer> rating;
if (plot.settings.ratings != null) { if (plot.getSettings().ratings != null) {
rating = plot.settings.ratings; rating = plot.getSettings().ratings;
} }
else { else {
rating = DBFunc.getRatings(plot); rating = DBFunc.getRatings(plot);

View File

@ -96,17 +96,11 @@ public class UUIDHandler {
public static HashSet<UUID> getAllUUIDS() { public static HashSet<UUID> getAllUUIDS() {
HashSet<UUID> uuids = new HashSet<UUID>(); HashSet<UUID> uuids = new HashSet<UUID>();
for (Plot plot : PS.get().getPlotsRaw()) { for (Plot plot : PS.get().getPlotsRaw()) {
for (UUID uuid : plot.trusted) {
uuids.add(uuid);
}
for (UUID uuid : plot.members) {
uuids.add(uuid);
}
for (UUID uuid : plot.denied) {
uuids.add(uuid);
}
if (plot.owner != null) { if (plot.owner != null) {
uuids.add(plot.owner); uuids.add(plot.owner);
uuids.addAll(plot.getTrusted());
uuids.addAll(plot.getMembers());
uuids.addAll(plot.getDenied());
} }
} }
return uuids; return uuids;