mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-12-23 16:48:16 +01:00
Fixes #2462 by making flag categories translatable. This reflects (somewhat) recent changes to command categories.
This commit is contained in:
parent
a601739fbd
commit
01eee306f1
@ -293,11 +293,12 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag list");
|
||||
return false;
|
||||
}
|
||||
HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
||||
final Map<String, ArrayList<String>> flags = new HashMap<>();
|
||||
for (Flag<?> flag1 : Flags.getFlags()) {
|
||||
String type = flag1.getClass().getSimpleName();
|
||||
flags.computeIfAbsent(type, k -> new ArrayList<>());
|
||||
flags.get(type).add(flag1.getName());
|
||||
final String category = flag1.getCategoryCaption();
|
||||
final Collection<String> flagList =
|
||||
flags.computeIfAbsent(category, k -> new ArrayList<>());
|
||||
flagList.add(flag1.getName());
|
||||
}
|
||||
StringBuilder message = new StringBuilder();
|
||||
String prefix = "";
|
||||
|
@ -567,9 +567,7 @@ public enum Captions {
|
||||
//</editor-fold>
|
||||
BUCKET_ENTRIES_IGNORED("$2Total bucket values add up to 1 or more. Blocks without a specified chance will be ignored","Generator_Bucket"),
|
||||
|
||||
/**
|
||||
* Command Categories
|
||||
*/
|
||||
//<editor-fold desc="Command Categories">
|
||||
COMMAND_CATEGORY_CLAIMING("Claiming", "Category"),
|
||||
COMMAND_CATEGORY_TELEPORT("Teleport", "Category"),
|
||||
COMMAND_CATEGORY_SETTINGS("Protection", "Category"),
|
||||
@ -579,6 +577,7 @@ public enum Captions {
|
||||
COMMAND_CATEGORY_INFO("Info", "Category"),
|
||||
COMMAND_CATEGORY_DEBUG("Debug", "Category"),
|
||||
COMMAND_CATEGORY_ADMINISTRATION("Admin", "Category"),
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold desc="Grants">
|
||||
GRANTED_PLOTS("$1Result: $2%s $1grants left", "Grants"),
|
||||
@ -586,6 +585,22 @@ public enum Captions {
|
||||
GRANTED_PLOT_FAILED("$1Grant failed: $2%s", "Grants"),
|
||||
//</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>
|
||||
|
||||
/**
|
||||
* Legacy Configuration Conversion
|
||||
*/
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
|
||||
public class BooleanFlag extends Flag<Boolean> {
|
||||
|
||||
public BooleanFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_BOOLEAN, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
|
||||
public class DoubleFlag extends Flag<Double> {
|
||||
|
||||
public DoubleFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_DECIMAL, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
|
@ -1,15 +1,17 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class EnumFlag extends Flag<String> {
|
||||
|
||||
private final HashSet<String> values;
|
||||
|
||||
public EnumFlag(String name, String... values) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_ENUM, name);
|
||||
this.values = new HashSet<>(Arrays.asList(values));
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,21 @@
|
||||
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.util.StringComparison;
|
||||
import lombok.Getter;
|
||||
|
||||
public abstract class Flag<V> implements StringComparison.StringComparable {
|
||||
|
||||
@Getter private final Captions typeCaption;
|
||||
private final String name;
|
||||
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
|
||||
* 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
|
||||
*/
|
||||
public Flag(String name) {
|
||||
this.name = name;
|
||||
this(null, name);
|
||||
}
|
||||
|
||||
public Flag<V> reserve() {
|
||||
@ -57,4 +65,11 @@ public abstract class Flag<V> implements StringComparison.StringComparable {
|
||||
@Override public String getComparableString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public String getCategoryCaption() {
|
||||
return this.typeCaption == null ?
|
||||
getClass().getSimpleName() :
|
||||
this.typeCaption.getTranslated();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
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.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
@ -95,7 +96,7 @@ public final class Flags {
|
||||
public static final IntegerFlag ANIMAL_CAP = new IntegerFlag("animal-cap");
|
||||
public static final IntegerFlag HOSTILE_CAP = new IntegerFlag("hostile-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) {
|
||||
return value.toString();
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
||||
|
||||
public class GameModeFlag extends Flag<PlotGameMode> {
|
||||
|
||||
public GameModeFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_GAMEMODE, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
|
||||
public class IntegerFlag extends Flag<Integer> {
|
||||
|
||||
public IntegerFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_INTEGERS, name);
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -9,7 +10,7 @@ import java.util.List;
|
||||
public class IntegerListFlag extends ListFlag<List<Integer>> {
|
||||
|
||||
public IntegerListFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_INTEGER_LIST, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -7,7 +8,7 @@ import lombok.RequiredArgsConstructor;
|
||||
public class IntervalFlag extends Flag<IntervalFlag.Interval> {
|
||||
|
||||
public IntervalFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_INTERVALS, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
|
@ -1,11 +1,16 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class ListFlag<V extends Collection<?>> extends Flag<V> {
|
||||
|
||||
public ListFlag(Captions typeCaption, String name) {
|
||||
super(typeCaption, name);
|
||||
}
|
||||
|
||||
public ListFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
|
||||
public class LongFlag extends Flag<Long> {
|
||||
|
||||
public LongFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_INTEGERS, name);
|
||||
}
|
||||
|
||||
@Override public Long parseValue(String value) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
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.util.LegacyMappings;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
@ -14,7 +15,7 @@ import java.util.stream.Collectors;
|
||||
public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
|
||||
|
||||
public PlotBlockListFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_BLOCK_LIST, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||
|
||||
public class PlotWeatherFlag extends Flag<PlotWeather> {
|
||||
|
||||
public PlotWeatherFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_WEATHER, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
|
||||
public class StringFlag extends Flag<String> {
|
||||
|
||||
public StringFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_STRING, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -9,7 +10,7 @@ import java.util.List;
|
||||
public class StringListFlag extends ListFlag<List<String>> {
|
||||
|
||||
public StringListFlag(String name) {
|
||||
super(name);
|
||||
super(Captions.FLAG_CATEGORY_STRING_LIST, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
|
@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
|
||||
public class TeleportDenyFlag extends EnumFlag {
|
||||
|
||||
public TeleportDenyFlag(String name) {
|
||||
super(name, "trusted", "members", "nonmembers", "nontrusted", "nonowners");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user