Merge pull request #2548 from IntellectualSites/flag_fix

Flag fixes and others 🐮
This commit is contained in:
Alexander Söderberg 2019-10-27 16:13:22 +01:00 committed by GitHub
commit d1115d62a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 131 additions and 66 deletions

View File

@ -163,6 +163,11 @@ public class FlagCmd extends SubCommand {
MainUtil.sendMessage(player, "&c" + flag.getValueDescription()); MainUtil.sendMessage(player, "&c" + flag.getValueDescription());
return false; return false;
} }
if (flag instanceof ListFlag) {
if (!(parsed instanceof Collection) || ((Collection) parsed).isEmpty()) {
return !MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
}
}
boolean result = plot.setFlag(flag, parsed); boolean result = plot.setFlag(flag, parsed);
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED); MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
@ -197,25 +202,26 @@ public class FlagCmd extends SubCommand {
} }
if (args.length == 3 && flag instanceof ListFlag) { if (args.length == 3 && flag instanceof ListFlag) {
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " "); String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
Optional<? extends Collection> flag1 = final ListFlag<? extends Collection> listFlag = (ListFlag<? extends Collection>) flag;
plot.getFlag((Flag<? extends Collection<?>>) flag); final Optional<? extends Collection> collectionOptional = plot.getFlag(listFlag);
if (flag1.isPresent()) { if (collectionOptional.isPresent()) {
boolean o = flag1.get().removeAll((Collection) flag.parseValue(value)); final Collection parsedCollection = (Collection) flag.parseValue(value);
if (o) { if (parsedCollection.isEmpty()) {
if (flag1.get().isEmpty()) { return !MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
final boolean result = plot.removeFlag(flag); }
if (result) { final Collection flagCollection = collectionOptional.get();
MainUtil.sendMessage(player, Captions.FLAG_REMOVED); if (flagCollection.removeAll(parsedCollection)) {
if (flagCollection.isEmpty()) {
if (plot.removeFlag(flag)) {
return MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
} else { } else {
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); return !MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
} }
return true;
} else { } else {
MainUtil.sendMessage(player, Captions.FLAG_REMOVED); MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
} }
} else { } else {
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED); return !MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
return false;
} }
} }
DBFunc.setFlags(plot, plot.getFlags()); DBFunc.setFlags(plot, plot.getFlags());
@ -259,16 +265,19 @@ public class FlagCmd extends SubCommand {
} }
Object val = parsed; Object val = parsed;
if (flag instanceof ListFlag) { if (flag instanceof ListFlag) {
Optional<? extends Collection> flag1 = final Collection parsedCollection = (Collection<?>) parsed;
plot.getFlag((Flag<? extends Collection<?>>) flag); if (parsedCollection.isEmpty()) {
if (flag1.isPresent()) { return !MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
boolean o = flag1.get().addAll((Collection) parsed); }
if (o) { final ListFlag<? extends Collection> listFlag = (ListFlag<? extends Collection>) flag;
final Optional<? extends Collection> collectionOptional = plot.getFlag(listFlag);
if (collectionOptional.isPresent()) {
final Collection flagCollection = collectionOptional.get();
if (flagCollection.addAll(parsedCollection)) {
MainUtil.sendMessage(player, Captions.FLAG_ADDED); MainUtil.sendMessage(player, Captions.FLAG_ADDED);
val = flag1.get(); val = flagCollection;
} else { } else {
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED); return !MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
return false;
} }
} }
} }
@ -289,21 +298,26 @@ public class FlagCmd extends SubCommand {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag list"); MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag list");
return false; return false;
} }
HashMap<String, ArrayList<String>> flags = new HashMap<>(); final Map<String, ArrayList<String>> flags = new HashMap<>();
for (Flag<?> flag1 : Flags.getFlags()) { for (Flag<?> flag1 : Flags.getFlags()) {
String type = flag1.getClass().getSimpleName(); final String category = flag1.getCategoryCaption();
flags.computeIfAbsent(type, k -> new ArrayList<>()); final Collection<String> flagList =
flags.get(type).add(flag1.getName()); flags.computeIfAbsent(category, k -> new ArrayList<>());
flagList.add(flag1.getName());
} }
StringBuilder message = new StringBuilder();
String prefix = ""; final StringBuilder message = new StringBuilder();
for (Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) { final Iterator<Map.Entry<String, ArrayList<String>>> iterator =
String category = entry.getKey(); flags.entrySet().iterator();
List<String> flagNames = entry.getValue(); while (iterator.hasNext()) {
final Map.Entry<String, ArrayList<String>> flagsEntry = iterator.next();
final List<String> flagNames = flagsEntry.getValue();
Collections.sort(flagNames); Collections.sort(flagNames);
message.append(prefix).append("&6").append(category).append(": &7") message.append(String.format(Captions.FLAG_LIST_ENTRY.formatted(),
.append(StringMan.join(flagNames, ", ")); flagsEntry.getKey(), StringMan.join(flagNames, ", ")));
prefix = "\n"; if (iterator.hasNext()) {
message.append("\n");
}
} }
MainUtil.sendMessage(player, message.toString()); MainUtil.sendMessage(player, message.toString());
return true; return true;

View File

@ -28,7 +28,6 @@ public enum Captions {
FLAG_PVP("pvp", "static.flags"), FLAG_PVP("pvp", "static.flags"),
FLAG_HANGING_PLACE("hanging-place", "static.flags"), FLAG_HANGING_PLACE("hanging-place", "static.flags"),
FLAG_HANGING_BREAK("hanging-break", "static.flags"), FLAG_HANGING_BREAK("hanging-break", "static.flags"),
FLAG_HANGING_INTERACT("hanging-interact", "static.flags"),
FLAG_MISC_INTERACT("misc-interact", "static.flags"), FLAG_MISC_INTERACT("misc-interact", "static.flags"),
FLAG_MISC_BREAK("misc-break", "static.flags"), FLAG_MISC_BREAK("misc-break", "static.flags"),
FLAG_MISC_PLACE("misc-place", "static.flags"), FLAG_MISC_PLACE("misc-place", "static.flags"),
@ -532,7 +531,24 @@ public enum Captions {
FLAG_REMOVED("$4Successfully removed flag", "Flag"), FLAG_REMOVED("$4Successfully removed flag", "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"),
//</editor-fold> //</editor-fold>
//<editor-fold desc="Flag category captions">
FLAG_CATEGORY_STRING("String Flags", "Flags"),
FLAG_CATEGORY_INTEGERS("Integer Flags", "Flags"),
FLAG_CATEGORY_TELEPORT_DENY("Teleport Deny Flag", "Flags"),
FLAG_CATEGORY_STRING_LIST("String List Flags", "Flags"),
FLAG_CATEGORY_WEATHER("Weather Flags", "Flags"),
FLAG_CATEGORY_BLOCK_LIST("Material Flags", "Flags"),
FLAG_CATEGORY_INTERVALS("Interval Flags", "Flags"),
FLAG_CATEGORY_INTEGER_LIST("Integer List Flags", "Flags"),
FLAG_CATEGORY_GAMEMODE("Game Mode Flags", "Flags"),
FLAG_CATEGORY_ENUM("Generic Enum Flags", "Flags"),
FLAG_CATEGORY_DECIMAL("Decimal Flags", "Flags"),
FLAG_CATEGORY_BOOLEAN("Boolean Flags", "Flags"),
FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"),
//</editor-fold>
//<editor-fold desc="Trusted"> //<editor-fold desc="Trusted">
TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"), TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"),
WAS_NOT_ADDED("$2That player was not trusted on this plot", "Trusted"), WAS_NOT_ADDED("$2That player was not trusted on this plot", "Trusted"),
@ -567,9 +583,7 @@ public enum Captions {
//</editor-fold> //</editor-fold>
BUCKET_ENTRIES_IGNORED("$2Total bucket values add up to 1 or more. Blocks without a specified chance will be ignored","Generator_Bucket"), BUCKET_ENTRIES_IGNORED("$2Total bucket values add up to 1 or more. Blocks without a specified chance will be ignored","Generator_Bucket"),
/** //<editor-fold desc="Command Categories">
* Command Categories
*/
COMMAND_CATEGORY_CLAIMING("Claiming", "Category"), COMMAND_CATEGORY_CLAIMING("Claiming", "Category"),
COMMAND_CATEGORY_TELEPORT("Teleport", "Category"), COMMAND_CATEGORY_TELEPORT("Teleport", "Category"),
COMMAND_CATEGORY_SETTINGS("Protection", "Category"), COMMAND_CATEGORY_SETTINGS("Protection", "Category"),
@ -579,6 +593,7 @@ public enum Captions {
COMMAND_CATEGORY_INFO("Info", "Category"), COMMAND_CATEGORY_INFO("Info", "Category"),
COMMAND_CATEGORY_DEBUG("Debug", "Category"), COMMAND_CATEGORY_DEBUG("Debug", "Category"),
COMMAND_CATEGORY_ADMINISTRATION("Admin", "Category"), COMMAND_CATEGORY_ADMINISTRATION("Admin", "Category"),
//</editor-fold>
//<editor-fold desc="Grants"> //<editor-fold desc="Grants">
GRANTED_PLOTS("$1Result: $2%s $1grants left", "Grants"), GRANTED_PLOTS("$1Result: $2%s $1grants left", "Grants"),

View File

@ -1,11 +1,12 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
public class BooleanFlag extends Flag<Boolean> { public class BooleanFlag extends Flag<Boolean> {
public BooleanFlag(String name) { public BooleanFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_BOOLEAN, name);
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {

View File

@ -1,9 +1,11 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
public class DoubleFlag extends Flag<Double> { public class DoubleFlag extends Flag<Double> {
public DoubleFlag(String name) { public DoubleFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_DECIMAL, name);
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {

View File

@ -1,15 +1,17 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
public class EnumFlag extends Flag<String> { public class EnumFlag extends Flag<String> {
private final HashSet<String> values; private final HashSet<String> values;
public EnumFlag(String name, String... values) { public EnumFlag(String name, String... values) {
super(name); super(Captions.FLAG_CATEGORY_ENUM, name);
this.values = new HashSet<>(Arrays.asList(values)); this.values = new HashSet<>(Arrays.asList(values));
} }

View File

@ -1,13 +1,21 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison; import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import lombok.Getter;
public abstract class Flag<V> implements StringComparison.StringComparable { public abstract class Flag<V> implements StringComparison.StringComparable {
@Getter private final Captions typeCaption;
private final String name; private final String name;
private boolean reserved = false; private boolean reserved = false;
public Flag(Captions typeCaption, String name) {
this.typeCaption = typeCaption;
this.name = name;
}
/** /**
* Flag object used to store basic information for a Plot. Flags are a * Flag object used to store basic information for a Plot. Flags are a
* key/value pair. For a flag to be usable by a player, you need to * key/value pair. For a flag to be usable by a player, you need to
@ -16,7 +24,7 @@ public abstract class Flag<V> implements StringComparison.StringComparable {
* @param name the flag name * @param name the flag name
*/ */
public Flag(String name) { public Flag(String name) {
this.name = name; this(null, name);
} }
public Flag<V> reserve() { public Flag<V> reserve() {
@ -57,4 +65,11 @@ public abstract class Flag<V> implements StringComparison.StringComparable {
@Override public String getComparableString() { @Override public String getComparableString() {
return getName(); return getName();
} }
public String getCategoryCaption() {
return this.typeCaption == null ?
getClass().getSimpleName() :
this.typeCaption.getTranslated();
}
} }

View File

@ -1,6 +1,7 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
@ -52,7 +53,6 @@ public final class Flags {
public static final BooleanFlag SNOW_MELT = new BooleanFlag("snow-melt"); public static final BooleanFlag SNOW_MELT = new BooleanFlag("snow-melt");
public static final BooleanFlag SNOW_FORM = new BooleanFlag("snow-form"); public static final BooleanFlag SNOW_FORM = new BooleanFlag("snow-form");
public static final BooleanFlag ICE_MELT = new BooleanFlag("ice-melt"); public static final BooleanFlag ICE_MELT = new BooleanFlag("ice-melt");
public static final BooleanFlag FIRE_SPREAD = new BooleanFlag("fire-spread");
public static final BooleanFlag BLOCK_BURN = new BooleanFlag("block-burn"); public static final BooleanFlag BLOCK_BURN = new BooleanFlag("block-burn");
public static final BooleanFlag ICE_FORM = new BooleanFlag("ice-form"); public static final BooleanFlag ICE_FORM = new BooleanFlag("ice-form");
public static final BooleanFlag BLOCK_IGNITION = new BooleanFlag("block-ignition"); public static final BooleanFlag BLOCK_IGNITION = new BooleanFlag("block-ignition");
@ -67,7 +67,6 @@ public final class Flags {
public static final BooleanFlag VEHICLE_USE = new BooleanFlag("vehicle-use"); public static final BooleanFlag VEHICLE_USE = new BooleanFlag("vehicle-use");
public static final BooleanFlag HANGING_BREAK = new BooleanFlag("hanging-break"); public static final BooleanFlag HANGING_BREAK = new BooleanFlag("hanging-break");
public static final BooleanFlag HANGING_PLACE = new BooleanFlag("hanging-place"); public static final BooleanFlag HANGING_PLACE = new BooleanFlag("hanging-place");
public static final BooleanFlag HANGING_INTERACT = new BooleanFlag("hanging-interact");
public static final BooleanFlag MISC_PLACE = new BooleanFlag("misc-place"); public static final BooleanFlag MISC_PLACE = new BooleanFlag("misc-place");
public static final BooleanFlag MISC_BREAK = new BooleanFlag("misc-break"); public static final BooleanFlag MISC_BREAK = new BooleanFlag("misc-break");
public static final BooleanFlag MISC_INTERACT = new BooleanFlag("misc-interact"); public static final BooleanFlag MISC_INTERACT = new BooleanFlag("misc-interact");
@ -95,7 +94,7 @@ public final class Flags {
public static final IntegerFlag ANIMAL_CAP = new IntegerFlag("animal-cap"); public static final IntegerFlag ANIMAL_CAP = new IntegerFlag("animal-cap");
public static final IntegerFlag HOSTILE_CAP = new IntegerFlag("hostile-cap"); public static final IntegerFlag HOSTILE_CAP = new IntegerFlag("hostile-cap");
public static final IntegerFlag VEHICLE_CAP = new IntegerFlag("vehicle-cap"); public static final IntegerFlag VEHICLE_CAP = new IntegerFlag("vehicle-cap");
public static final Flag<?> KEEP = new Flag("keep") { public static final Flag<?> KEEP = new Flag(Captions.FLAG_CATEGORY_MIXED, "keep") {
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {
return value.toString(); return value.toString();
} }
@ -115,10 +114,9 @@ public final class Flags {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must a timestamp or a boolean"; return "Flag value must be a timestamp or a boolean";
} }
}; };
public static final BooleanFlag SLEEP = new BooleanFlag("sleep");
public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("deny-teleport"); public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("deny-teleport");
public static final BooleanFlag DENY_EXIT = new BooleanFlag("deny-exit"); public static final BooleanFlag DENY_EXIT = new BooleanFlag("deny-exit");

View File

@ -1,11 +1,12 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode; import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
public class GameModeFlag extends Flag<PlotGameMode> { public class GameModeFlag extends Flag<PlotGameMode> {
public GameModeFlag(String name) { public GameModeFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_GAMEMODE, name);
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {

View File

@ -1,11 +1,12 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
public class IntegerFlag extends Flag<Integer> { public class IntegerFlag extends Flag<Integer> {
public IntegerFlag(String name) { public IntegerFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_INTEGERS, name);
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {

View File

@ -1,5 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.ArrayList; import java.util.ArrayList;
@ -9,7 +10,7 @@ import java.util.List;
public class IntegerListFlag extends ListFlag<List<Integer>> { public class IntegerListFlag extends ListFlag<List<Integer>> {
public IntegerListFlag(String name) { public IntegerListFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_INTEGER_LIST, name);
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {

View File

@ -1,5 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -7,7 +8,7 @@ import lombok.RequiredArgsConstructor;
public class IntervalFlag extends Flag<IntervalFlag.Interval> { public class IntervalFlag extends Flag<IntervalFlag.Interval> {
public IntervalFlag(String name) { public IntervalFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_INTERVALS, name);
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {

View File

@ -1,11 +1,16 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import java.util.Collection; import java.util.Collection;
public abstract class ListFlag<V extends Collection<?>> extends Flag<V> { public abstract class ListFlag<V extends Collection<?>> extends Flag<V> {
public ListFlag(Captions typeCaption, String name) {
super(typeCaption, name);
}
public ListFlag(String name) { public ListFlag(String name) {
super(name); super(name);
} }

View File

@ -1,9 +1,11 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
public class LongFlag extends Flag<Long> { public class LongFlag extends Flag<Long> {
public LongFlag(String name) { public LongFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_INTEGERS, name);
} }
@Override public Long parseValue(String value) { @Override public Long parseValue(String value) {

View File

@ -1,15 +1,21 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.util.LegacyMappings;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> { public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
public PlotBlockListFlag(String name) { public PlotBlockListFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_BLOCK_LIST, name);
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {
@ -17,14 +23,9 @@ public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
} }
@Override public HashSet<PlotBlock> parseValue(final String value) { @Override public HashSet<PlotBlock> parseValue(final String value) {
final HashSet<PlotBlock> list = new HashSet<>(); final LegacyMappings legacyMappings = PlotSquared.get().IMP.getLegacyMappings();
for (final String item : value.split(",")) { return Arrays.stream(value.split(",")).map(legacyMappings::fromAny).filter(Objects::nonNull)
final PlotBlock block = PlotSquared.get().IMP.getLegacyMappings().fromAny(item); .collect(Collectors.toCollection(HashSet::new));
if (block != null) {
list.add(block);
}
}
return list;
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {

View File

@ -1,11 +1,12 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather; import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
public class PlotWeatherFlag extends Flag<PlotWeather> { public class PlotWeatherFlag extends Flag<PlotWeather> {
public PlotWeatherFlag(String name) { public PlotWeatherFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_WEATHER, name);
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {

View File

@ -1,10 +1,12 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
public class StringFlag extends Flag<String> { public class StringFlag extends Flag<String> {
public StringFlag(String name) { public StringFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_STRING, name);
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {

View File

@ -1,5 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.flag; package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.ArrayList; import java.util.ArrayList;
@ -9,7 +10,7 @@ import java.util.List;
public class StringListFlag extends ListFlag<List<String>> { public class StringListFlag extends ListFlag<List<String>> {
public StringListFlag(String name) { public StringListFlag(String name) {
super(name); super(Captions.FLAG_CATEGORY_STRING_LIST, name);
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {

View File

@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
public class TeleportDenyFlag extends EnumFlag { public class TeleportDenyFlag extends EnumFlag {
public TeleportDenyFlag(String name) { public TeleportDenyFlag(String name) {
super(name, "trusted", "members", "nonmembers", "nontrusted", "nonowners"); super(name, "trusted", "members", "nonmembers", "nontrusted", "nonowners");
} }

View File

@ -200,7 +200,9 @@ public class PlotListener {
if (pw == null) { if (pw == null) {
return true; return true;
} }
if (Flags.DENY_EXIT.isTrue(plot) && !player.getMeta("kick", false)) { if (Flags.DENY_EXIT.isTrue(plot)
&& !Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_EXIT_DENIED)
&& !player.getMeta("kick", false)) {
if (previous != null) { if (previous != null) {
player.setMeta(PlotPlayer.META_LAST_PLOT, previous); player.setMeta(PlotPlayer.META_LAST_PLOT, previous);
} }

View File

@ -302,8 +302,7 @@ public abstract class EventUtil {
} }
return !(!notifyPerms || MainUtil return !(!notifyPerms || MainUtil
.sendMessage(player, Captions.FLAG_TUTORIAL_USAGE, .sendMessage(player, Captions.FLAG_TUTORIAL_USAGE,
Captions.FLAG_USE.getTranslated() + '/' + Captions.FLAG_HANGING_INTERACT Captions.FLAG_USE.getTranslated()));
.getTranslated()));
} }
return true; return true;
} }