diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCommand.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCommand.java index d4dd80b29..c17d85bd7 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCommand.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCommand.java @@ -266,10 +266,10 @@ import java.util.Map; final Plot plot = player.getLocation().getPlotAbs(); if (args.length == 2 && flag instanceof ListFlag) { String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " "); - final ListFlag listFlag = (ListFlag) flag; - final List list = + final ListFlag listFlag = (ListFlag) flag; + final List list = plot.getFlag((Class>) listFlag.getClass()); - final PlotFlag, ?> parsedFlag; + final PlotFlag parsedFlag; try { parsedFlag = listFlag.parse(value); } catch (final FlagParseException e) { @@ -277,11 +277,11 @@ import java.util.Map; .send(player, e.getFlag().getName(), e.getValue(), e.getErrorMessage()); return; } - if (parsedFlag.getValue().isEmpty()) { + if (((List) parsedFlag.getValue()).isEmpty()) { MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); return; } - if (list.removeAll(parsedFlag.getValue())) { + if (list.removeAll((List) parsedFlag.getValue())) { if (list.isEmpty()) { if (plot.removeFlag(flag)) { MainUtil.sendMessage(player, Captions.FLAG_REMOVED); @@ -291,14 +291,19 @@ import java.util.Map; return; } } else { - MainUtil.sendMessage(player, Captions.FLAG_REMOVED); + // MainUtil.sendMessage(player, Captions.FLAG_REMOVED); + if (plot.setFlag(parsedFlag.createFlagInstance(list))) { + MainUtil.sendMessage(player, Captions.FLAG_PARTIALLY_REMOVED); + return; + } else { + MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); + return; + } } } else { MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); return; } - // TODO reimplement somewhere else: DBFunc.setFlags(plot, plot.getFlags()); - return; } else { boolean result = plot.removeFlag(flag); if (!result) { @@ -306,12 +311,6 @@ import java.util.Map; return; } } - /* TODO reimplement, maybe handle it with events? - if (flag == Flags.TIME) { - player.setTime(Long.MAX_VALUE); - } else if (flag == Flags.WEATHER) { - player.setWeather(PlotWeather.RESET); - }*/ MainUtil.sendMessage(player, Captions.FLAG_REMOVED); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java index 2d06f5724..b7a98b8f2 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java @@ -529,6 +529,7 @@ public enum Captions implements Caption { FLAG_NOT_REMOVED("$2The flag could not be removed", "Flag"), FLAG_NOT_ADDED("$2The flag could not be added", "Flag"), FLAG_REMOVED("$4Successfully removed flag", "Flag"), + FLAG_PARTIALLY_REMOVED("$4Successfully removed flag value(s)", "Flag"), FLAG_ADDED("$4Successfully added flag", "Flag"), FLAG_TUTORIAL_USAGE("$1Have an admin set the flag: $2%s", "CommandConfig"), FLAG_LIST_ENTRY("$2%s: $1%s", "Flag"),