Fixed getPlots() causing NPE

This commit is contained in:
boy0001 2014-09-23 19:54:06 +10:00
parent f2a389f850
commit fd823d2910
7 changed files with 21 additions and 10 deletions

View File

@ -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"),

View File

@ -24,6 +24,9 @@ public class Flag {
}
@Override
public String toString() {
if (this.value.equals("")) {
return this.key;
}
return this.key+":"+this.value;
}
@Override

View File

@ -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);
}

View File

@ -170,8 +170,10 @@ public class PlotMain extends JavaPlugin {
ArrayList<Plot> myplots = new ArrayList<Plot>();
for (HashMap<PlotId, Plot> 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<Plot> myplots = new ArrayList<Plot>();
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<Plot>(myplots);

View File

@ -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;
}

View File

@ -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])) {

View File

@ -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<flags.length; i++) {
String[] split = flags_string[i].split(":");
flags[i] = new Flag(split[0], split[1]);
if (flags_string[i].contains(":")) {
String[] split = flags_string[i].split(":");
flags[i] = new Flag(split[0], split[1]);
}
else {
flags[i] = new Flag(flags_string[i], "");
}
}
ArrayList<UUID> helpers = plotHelpers(id);