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;
}
if (plot.members.contains(uuid)) {
if (plot.getMembers().contains(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_ADDED);
return false;
}
@ -80,11 +80,11 @@ public class Add extends SubCommand {
plot.addMember(uuid);
}
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);
return false;
}
if (plot.denied.contains(uuid)) {
if (plot.getDenied().contains(uuid)) {
plot.removeDenied(uuid);
}
plot.addMember(uuid);

View File

@ -176,7 +176,7 @@ public class Auto extends SubCommand {
for (int i = 0; i <= max; i++) {
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
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);
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) {
if (plot.hasOwner() || plot.settings.isMerged()) {
if (plot.hasOwner() || plot.getSettings().isMerged()) {
return 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 ---");
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();
boolean changed = false;
while (i.hasNext()) {
@ -66,7 +66,7 @@ public class DebugFixFlags extends SubCommand {
}
}
if (changed) {
DBFunc.setFlags(plot, plot.settings.flags.values());
DBFunc.setFlags(plot, plot.getSettings().flags.values());
}
}
MainUtil.sendMessage(plr, "&aDone!");

View File

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

View File

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

View File

@ -158,7 +158,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, plot.settings.flags.values());
DBFunc.setFlags(plot, plot.getSettings().flags.values());
} else {
final boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
if (!result) {
@ -204,7 +204,7 @@ public class FlagCmd extends SubCommand {
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
return false;
}
DBFunc.setFlags(plot, plot.settings.flags.values());
DBFunc.setFlags(plot, plot.getSettings().flags.values());
MainUtil.sendMessage(player, C.FLAG_ADDED);
return true;
}

View File

@ -38,7 +38,7 @@ public class Home extends SubCommand {
private Plot isAlias(final String a) {
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;
}
}

View File

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

View File

@ -144,8 +144,8 @@ public class Info extends SubCommand {
boolean trustedEveryone;
// Wildcard player {added}
{
containsEveryone = (plot.trusted != null) && plot.trusted.contains(DBFunc.everyone);
trustedEveryone = (plot.members != null) && plot.members.contains(DBFunc.everyone);
containsEveryone = (plot.getTrusted() != null) && plot.getTrusted().contains(DBFunc.everyone);
trustedEveryone = (plot.getMembers() != null) && plot.getMembers().contains(DBFunc.everyone);
}
// Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) {
@ -198,18 +198,18 @@ public class Info extends SubCommand {
final PlotId id = plot.id;
final PlotId id2 = MainUtil.getTopPlot(plot).id;
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 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 trusted = getPlayerList(plot.trusted);
final String members = getPlayerList(plot.members);
final String denied = getPlayerList(plot.denied);
final String trusted = getPlayerList(plot.getTrusted());
final String members = getPlayerList(plot.getMembers());
final String denied = getPlayerList(plot.getDenied());
Flag descriptionFlag = FlagManager.getPlotFlag(plot, "description");
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());
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) {
double v1 = 0;
double v2 = 0;
if (p1.settings.ratings != null) {
if (p1.getSettings().ratings != null) {
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
v1 -= 11 - entry.getValue().getAverageRating();
}
}
if (p2.settings.ratings != null) {
if (p2.getSettings().ratings != null) {
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
v2 -= 11 - entry.getValue().getAverageRating();
}
@ -78,7 +78,7 @@ public class Rate extends SubCommand {
});
UUID uuid = player.getUUID();
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.sendMessage(player, C.RATE_THIS);
return true;
@ -105,7 +105,7 @@ public class Rate extends SubCommand {
final Runnable run = new Runnable() {
@Override
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());
return;
}
@ -127,7 +127,7 @@ public class Rate extends SubCommand {
// get new rating
rV = rateEvent.getRating();
// set rating
plot.settings.ratings.put(player.getUUID(), rV);
plot.getSettings().ratings.put(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());
@ -149,11 +149,11 @@ public class Rate extends SubCommand {
inventory.openInventory();
}
};
if (plot.settings.ratings == null) {
if (plot.getSettings().ratings == null) {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
plot.settings.ratings = DBFunc.getRatings(plot);
plot.getSettings().ratings = DBFunc.getRatings(plot);
run.run();
}
});
@ -187,20 +187,20 @@ public class Rate extends SubCommand {
final Runnable run = new Runnable() {
@Override
public void run() {
if (plot.settings.ratings.containsKey(uuid)) {
if (plot.getSettings().ratings.containsKey(uuid)) {
sendMessage(player, C.RATING_ALREADY_EXISTS, plot.getId().toString());
return;
}
plot.settings.ratings.put(uuid, rating);
plot.getSettings().ratings.put(uuid, rating);
DBFunc.setRating(plot, uuid, rating);
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
}
};
if (plot.settings.ratings == null) {
if (plot.getSettings().ratings == null) {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
plot.settings.ratings = DBFunc.getRatings(plot);
plot.getSettings().ratings = DBFunc.getRatings(plot);
run.run();
}
});

View File

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

View File

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

View File

@ -207,7 +207,7 @@ public class Set extends SubCommand {
return false;
}
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);
return false;
}

View File

@ -94,7 +94,7 @@ public class TP extends SubCommand {
return null;
}
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;
}
}

View File

@ -72,7 +72,7 @@ public class Trust extends SubCommand {
return false;
}
if (plot.trusted.contains(uuid)) {
if (plot.getTrusted().contains(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_ADDED);
return false;
}
@ -80,11 +80,11 @@ public class Trust extends SubCommand {
plot.addTrusted(uuid);
}
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);
return false;
}
if (plot.denied.contains(uuid)) {
if (plot.getDenied().contains(uuid)) {
plot.removeDenied(uuid);
}
plot.addTrusted(uuid);

View File

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

View File

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

View File

@ -171,7 +171,7 @@ public class list extends SubCommand {
}
plots = new ArrayList<Plot>();
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);
}
}
@ -208,9 +208,9 @@ public class list extends SubCommand {
public int compare(Plot p1, Plot p2) {
double v1 = 0;
double v2 = 0;
int p1s = p1.settings.ratings != null ? p1.settings.ratings.size() : 0;
int p2s = p2.settings.ratings != null ? p2.settings.ratings.size() : 0;
if (p1.settings.ratings != null && p1s > 0) {
int p1s = p1.getSettings().ratings != null ? p1.getSettings().ratings.size() : 0;
int p2s = p2.getSettings().ratings != null ? p2.getSettings().ratings.size() : 0;
if (p1.getSettings().ratings != null && p1s > 0) {
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
double av = entry.getValue().getAverageRating();
v1 += av * av;
@ -218,7 +218,7 @@ public class list extends SubCommand {
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()) {
double av = entry.getValue().getAverageRating();
v2 += av * av;
@ -353,7 +353,7 @@ public class list extends SubCommand {
int i = page * pageSize;
for (Plot plot : subList) {
if (plot.settings.isMerged()) {
if (plot.getSettings().isMerged()) {
if (!MainUtil.getBottomPlot(plot).equals(plot)) {
continue;
}
@ -380,16 +380,16 @@ public class list extends SubCommand {
new FancyMessage(
ChatColor.stripColor(
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);
FancyMessage members =
new FancyMessage(
ChatColor.stripColor(
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);
String strFlags = StringUtils.join(plot.settings.flags.values(), ",");
String strFlags = StringUtils.join(plot.getSettings().flags.values(), ",");
if (strFlags.length() == 0) {
strFlags = C.NONE.s();
}

View File

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

View File

@ -131,7 +131,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
HashMap<PlotId, Plot> newplots = plots.get(world);
Plot plot = newplots.get(entry2.getKey());
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)) {
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)) {
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);
if (mergeMap != null) {
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;
}
UUID denied = UUID.fromString(r.getString("player"));
plot.denied.add(denied);
plot.getDenied().add(denied);
}
MainUtil.sendConsoleMessage(" - " + plugin + "core_allowed");
@ -165,7 +165,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
continue;
}
UUID allowed = UUID.fromString(r.getString("player"));
plot.trusted.add(allowed);
plot.getTrusted().add(allowed);
}
r.close();
stmt.close();

View File

@ -104,7 +104,7 @@ public class FlagManager {
}
if (PS.get().getAllPlotsRaw() != null) {
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) {
flag.setKey(af);
}
@ -151,7 +151,10 @@ public class FlagManager {
* @return 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) {
@ -183,7 +186,7 @@ public class FlagManager {
* @return 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) {
@ -203,9 +206,9 @@ public class FlagManager {
if (!result) {
return false;
}
plot.settings.flags.put(flag.getKey(), flag);
plot.getSettings().flags.put(flag.getKey(), flag);
MainUtil.reEnterPlot(plot);
DBFunc.setFlags(plot, plot.settings.flags.values());
DBFunc.setFlags(plot, plot.getSettings().flags.values());
return true;
}
@ -214,7 +217,7 @@ public class FlagManager {
if (!result) {
return false;
}
plot.settings.flags.put(flag.getKey(), flag);
plot.getSettings().flags.put(flag.getKey(), flag);
return true;
}
@ -232,7 +235,10 @@ public class FlagManager {
* @return set of flags
*/
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) {
@ -260,17 +266,17 @@ public class FlagManager {
}
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) {
return false;
}
final boolean result = EventUtil.manager.callFlagRemove(flag, plot);
if (!result) {
plot.settings.flags.put(id, flag);
plot.getSettings().flags.put(id, flag);
return false;
}
MainUtil.reEnterPlot(plot);
DBFunc.setFlags(plot, plot.settings.flags.values());
DBFunc.setFlags(plot, plot.getSettings().flags.values());
return true;
}
@ -290,19 +296,19 @@ public class FlagManager {
public static void setPlotFlags(final Plot plot, final Set<Flag> flags) {
if (flags != null && flags.size() != 0) {
plot.settings.flags.clear();
plot.getSettings().flags.clear();
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;
}
else {
plot.settings.flags.clear();
plot.getSettings().flags.clear();
}
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) {

View File

@ -101,13 +101,13 @@ public abstract class HybridUtils {
if (result) {
if (id1 != null) {
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;
}
}
if ((id2 != null) && !toCheck) {
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;
}
}

View File

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

View File

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

View File

@ -207,6 +207,9 @@ public class PlotPlusListener extends PlotListener implements Listener {
public void onPlotLeave(final PlayerLeavePlotEvent event) {
final Player leaver = event.getPlayer();
final Plot plot = event.getPlot();
if (!plot.hasOwner()) {
return;
}
if (FlagManager.getPlotFlag(plot, "farewell") != null) {
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<>();
UUID uuid = player.getUUID();
for (Plot plot : PS.get().getPlots(player.getLocation().getWorld()).values()) {
if (!plot.settings.getMerged(0) && !plot.settings.getMerged(3)) {
if (Settings.WE_ALLOW_HELPER ? plot.isAdded(uuid) : (plot.isOwner(uuid) || plot.trusted.contains(uuid))) {
if (!plot.getMerged(0) && !plot.getMerged(3)) {
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 pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
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() {
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 trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.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 denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.denied.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 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.getTrusted().size(), "&8Click to view a list of the trusted users");
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.getDenied().size(), "&8Click to view a list of denied players");
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(3, trusted);
this.inventory.setItem(4, members);

View File

@ -92,10 +92,6 @@ public class Plot implements Cloneable {
this.world = world;
this.id = id;
this.owner = owner;
this.settings = new PlotSettings(this);
this.trusted = new HashSet<>();
this.members = new HashSet<>();
this.denied = new HashSet<>();
this.temp = false;
}
@ -111,10 +107,6 @@ public class Plot implements Cloneable {
this.world = world;
this.id = id;
this.owner = owner;
this.settings = new PlotSettings(this);
this.trusted = new HashSet<>();
this.members = new HashSet<>();
this.denied = new HashSet<>();
this.temp = temp;
}
@ -186,7 +178,7 @@ public class Plot implements Cloneable {
* @return boolean false if the player is allowed to enter
*/
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)));
}
/**
@ -195,6 +187,69 @@ public class Plot implements Cloneable {
public PlotId getId() {
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
@ -216,7 +271,7 @@ public class Plot implements Cloneable {
* @param 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
*/
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
*/
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() {
HashMap<UUID, Rating> map = new HashMap<UUID, Rating>();
if (settings.ratings == null) {
if (getSettings().ratings == null) {
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()));
}
return map;
@ -346,16 +401,16 @@ public class Plot implements Cloneable {
* @param 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))) {
return;
}
this.settings.setPosition(loc);
if (this.settings.getPosition() == null) {
this.getSettings().setPosition(loc);
if (this.getSettings().getPosition() == null) {
DBFunc.setPosition(this, "");
}
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
*/
public void setAlias(String alias) {
String name = this.settings.getAlias();
String name = this.getSettings().getAlias();
if (alias == null) {
alias = "";
}
if (name.equals(alias)) {
return;
}
this.settings.setAlias(alias);
this.getSettings().setAlias(alias);
DBFunc.setAlias(this, alias);
}
@ -499,7 +554,7 @@ public class Plot implements Cloneable {
*/
@Override
public String toString() {
if (this.settings.getAlias().length() > 1) {
if (this.settings != null && this.settings.getAlias().length() > 1) {
return this.settings.getAlias();
}
return this.world + ";" + this.getId().x + ";" + this.getId().y;
@ -511,7 +566,7 @@ public class Plot implements Cloneable {
* @param uuid
*/
public boolean removeDenied(final UUID uuid) {
if (this.denied.remove(uuid)) {
if (this.getDenied().remove(uuid)) {
DBFunc.removeDenied(this, uuid);
return true;
}
@ -524,7 +579,7 @@ public class Plot implements Cloneable {
* @param uuid
*/
public boolean removeTrusted(final UUID uuid) {
if (this.trusted.remove(uuid)) {
if (this.getTrusted().remove(uuid)) {
DBFunc.removeTrusted(this, uuid);
return true;
}
@ -537,7 +592,7 @@ public class Plot implements Cloneable {
* @param uuid
*/
public boolean removeMember(final UUID uuid) {
if (this.members.remove(uuid)) {
if (this.getMembers().remove(uuid)) {
DBFunc.removeMember(this, uuid);
return true;
}

View File

@ -105,7 +105,7 @@ public class PlotAnalysis {
PS.log(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
while (iter.hasNext()) {
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();
}
else {
@ -147,7 +147,7 @@ public class PlotAnalysis {
for (;mi.intValue() < plots.size(); mi.increment()) {
int i = mi.intValue();
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]));
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -96,17 +96,11 @@ public class UUIDHandler {
public static HashSet<UUID> getAllUUIDS() {
HashSet<UUID> uuids = new HashSet<UUID>();
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) {
uuids.add(plot.owner);
uuids.addAll(plot.getTrusted());
uuids.addAll(plot.getMembers());
uuids.addAll(plot.getDenied());
}
}
return uuids;