From fd823d2910e532691a93dfb1940c0e4799e9b5f0 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 23 Sep 2014 19:54:06 +1000 Subject: [PATCH] Fixed getPlots() causing NPE --- PlotSquared/src/com/intellectualcrafters/plot/C.java | 2 +- .../src/com/intellectualcrafters/plot/Flag.java | 3 +++ .../com/intellectualcrafters/plot/PlotHelper.java | 1 - .../src/com/intellectualcrafters/plot/PlotMain.java | 12 ++++++++---- .../intellectualcrafters/plot/commands/Claim.java | 2 +- .../com/intellectualcrafters/plot/commands/Set.java | 2 +- .../intellectualcrafters/plot/database/DBFunc.java | 9 +++++++-- 7 files changed, 21 insertions(+), 10 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/C.java b/PlotSquared/src/com/intellectualcrafters/plot/C.java index 37ef64d60..190a37ead 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/C.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/C.java @@ -192,7 +192,7 @@ public enum C { /* * Flag */ - NEED_KEY("&cYou need to specify a flag"), + NEED_KEY("&cPossible values: &6%values%"), NOT_VALID_FLAG("&cThat is not a valid flag"), NOT_VALID_VALUE("&cFlag values must be alphanumerical"), FLAG_NOT_IN_PLOT("&cThe plot does not have that flag"), diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Flag.java b/PlotSquared/src/com/intellectualcrafters/plot/Flag.java index c967d18e3..d8ea16439 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Flag.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Flag.java @@ -24,6 +24,9 @@ public class Flag { } @Override public String toString() { + if (this.value.equals("")) { + return this.key; + } return this.key+":"+this.value; } @Override diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java index 6123f15dc..8a5791162 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java @@ -62,7 +62,6 @@ public class PlotHelper { sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); - System.out.print(10); sign.update(true); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index 6aa9b65df..be5a9fb0c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -170,8 +170,10 @@ public class PlotMain extends JavaPlugin { ArrayList myplots = new ArrayList(); for (HashMap world:plots.values()) { for (Plot plot:world.values()) { - if (plot.getOwner().equals(uuid)) { - myplots.add(plot); + if (plot.hasOwner()) { + if (plot.getOwner().equals(uuid)) { + myplots.add(plot); + } } } } @@ -187,8 +189,10 @@ public class PlotMain extends JavaPlugin { UUID uuid = player.getUniqueId(); ArrayList myplots = new ArrayList(); for (Plot plot:getPlots(world).values()) { - if (plot.getOwner().equals(uuid)) { - myplots.add(plot); + if (plot.hasOwner()) { + if (plot.getOwner().equals(uuid)) { + myplots.add(plot); + } } } return new HashSet(myplots); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java index cc3d39dbf..d426eeeb3 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java @@ -42,7 +42,7 @@ public class Claim extends SubCommand{ return false; } boolean result = claimPlot(plr, plot, false); - if (!result) { + if (result) { PlayerFunctions.sendMessage(plr, C.PLOT_NOT_CLAIMED); return false; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java index fe59e3c0c..682c707ea 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java @@ -84,7 +84,7 @@ public class Set extends SubCommand{ if(args[0].equalsIgnoreCase("flag")) { if(args.length < 2) { - PlayerFunctions.sendMessage(plr, C.NEED_KEY); + PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", StringUtils.join(PlotMain.getFlags(),"&c, &6"))); return false; } if (!PlotMain.isRegisteredFlag(args[1])) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java index 8bc3cb7b6..d1a57fd39 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java @@ -293,8 +293,13 @@ public class DBFunc { flags_string = ((String) settings.get("flags")).split(","); Flag[] flags = new Flag[flags_string.length]; for (int i = 0; i helpers = plotHelpers(id);