mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
Fix /plot flag remove
This commit is contained in:
parent
4dd946fba3
commit
2a84ae102e
@ -266,10 +266,10 @@ import java.util.Map;
|
|||||||
final Plot plot = player.getLocation().getPlotAbs();
|
final Plot plot = player.getLocation().getPlotAbs();
|
||||||
if (args.length == 2 && flag instanceof ListFlag) {
|
if (args.length == 2 && flag instanceof ListFlag) {
|
||||||
String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
||||||
final ListFlag<?, ?> listFlag = (ListFlag<?, ?>) flag;
|
final ListFlag listFlag = (ListFlag) flag;
|
||||||
final List<?> list =
|
final List list =
|
||||||
plot.getFlag((Class<? extends ListFlag<?, ?>>) listFlag.getClass());
|
plot.getFlag((Class<? extends ListFlag<?, ?>>) listFlag.getClass());
|
||||||
final PlotFlag<? extends List<?>, ?> parsedFlag;
|
final PlotFlag parsedFlag;
|
||||||
try {
|
try {
|
||||||
parsedFlag = listFlag.parse(value);
|
parsedFlag = listFlag.parse(value);
|
||||||
} catch (final FlagParseException e) {
|
} catch (final FlagParseException e) {
|
||||||
@ -277,11 +277,11 @@ import java.util.Map;
|
|||||||
.send(player, e.getFlag().getName(), e.getValue(), e.getErrorMessage());
|
.send(player, e.getFlag().getName(), e.getValue(), e.getErrorMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parsedFlag.getValue().isEmpty()) {
|
if (((List) parsedFlag.getValue()).isEmpty()) {
|
||||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
|
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (list.removeAll(parsedFlag.getValue())) {
|
if (list.removeAll((List) parsedFlag.getValue())) {
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
if (plot.removeFlag(flag)) {
|
if (plot.removeFlag(flag)) {
|
||||||
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
|
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
|
||||||
@ -291,14 +291,19 @@ import java.util.Map;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
|
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO reimplement somewhere else: DBFunc.setFlags(plot, plot.getFlags());
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
boolean result = plot.removeFlag(flag);
|
boolean result = plot.removeFlag(flag);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@ -306,12 +311,6 @@ import java.util.Map;
|
|||||||
return;
|
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);
|
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,6 +529,7 @@ public enum Captions implements Caption {
|
|||||||
FLAG_NOT_REMOVED("$2The flag could not be removed", "Flag"),
|
FLAG_NOT_REMOVED("$2The flag could not be removed", "Flag"),
|
||||||
FLAG_NOT_ADDED("$2The flag could not be added", "Flag"),
|
FLAG_NOT_ADDED("$2The flag could not be added", "Flag"),
|
||||||
FLAG_REMOVED("$4Successfully removed flag", "Flag"),
|
FLAG_REMOVED("$4Successfully removed flag", "Flag"),
|
||||||
|
FLAG_PARTIALLY_REMOVED("$4Successfully removed flag value(s)", "Flag"),
|
||||||
FLAG_ADDED("$4Successfully added flag", "Flag"),
|
FLAG_ADDED("$4Successfully added flag", "Flag"),
|
||||||
FLAG_TUTORIAL_USAGE("$1Have an admin set the flag: $2%s", "CommandConfig"),
|
FLAG_TUTORIAL_USAGE("$1Have an admin set the flag: $2%s", "CommandConfig"),
|
||||||
FLAG_LIST_ENTRY("$2%s: $1%s", "Flag"),
|
FLAG_LIST_ENTRY("$2%s: $1%s", "Flag"),
|
||||||
|
Loading…
Reference in New Issue
Block a user