From ba568a3f60ac7a082bbde5b583d6f1e8148dbab9 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Thu, 14 Jul 2016 00:28:46 +1000 Subject: [PATCH] Recover from invalid flag value --- .../plot/flag/BooleanFlag.java | 6 +----- .../plot/flag/FlagManager.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java index 0158e6175..23e3780fe 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/BooleanFlag.java @@ -9,11 +9,7 @@ public class BooleanFlag extends Flag { } @Override public String valueToString(Object value) { - if (((boolean) value)) { - return "true"; - } else { - return "false"; - } + return value + ""; } @Override public Boolean parseValue(String value) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index bd7c1bb97..76d848749 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -112,12 +112,17 @@ public class FlagManager { StringBuilder flag_string = new StringBuilder(); int i = 0; for (Map.Entry, Object> entry : flags.entrySet()) { - Flag flag = entry.getKey(); - if (i != 0) { - flag_string.append(','); + try { + Flag flag = entry.getKey(); + if (i != 0) { + flag_string.append(','); + } + flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´")); + i++; + } catch (Exception e) { + PS.debug("Failed to parse flag: " + entry.getKey() + "->" + entry.getValue()); + e.printStackTrace(); } - flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´")); - i++; } return flag_string.toString(); }