mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Fix some flag issues
This commit is contained in:
parent
a26ede4dae
commit
8b7414770f
@ -18,8 +18,8 @@ public class BlockStateListFlag extends ListFlag<Set<BlockType>> {
|
||||
super(Captions.FLAG_CATEGORY_BLOCK_LIST, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return StringMan.join((Set<BlockType>) value, ",");
|
||||
@Override public String valueToString(Set<BlockType> value) {
|
||||
return StringMan.join(value, ",");
|
||||
}
|
||||
|
||||
@Override public Set<BlockType> parseValue(final String value) {
|
||||
|
@ -9,8 +9,8 @@ public class BooleanFlag extends Flag<Boolean> {
|
||||
super(Captions.FLAG_CATEGORY_BOOLEAN, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return value + "";
|
||||
@Override public String valueToString(Boolean value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override public Boolean parseValue(String value) {
|
||||
|
@ -8,7 +8,7 @@ public class DoubleFlag extends Flag<Double> {
|
||||
super(Captions.FLAG_CATEGORY_DECIMAL, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
@Override public String valueToString(Double value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,8 @@ public class EnumFlag extends Flag<String> {
|
||||
this.values = new HashSet<>(Arrays.asList(values));
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return value.toString();
|
||||
@Override public String valueToString(String value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override public String parseValue(String value) {
|
||||
|
@ -44,7 +44,7 @@ public abstract class Flag<V> implements StringComparison.StringComparable {
|
||||
Flags.registerFlag(this);
|
||||
}
|
||||
|
||||
public abstract String valueToString(Object value);
|
||||
public abstract String valueToString(V value);
|
||||
|
||||
@Override public final String toString() {
|
||||
return "Flag { name='" + getName() + "'}";
|
||||
|
@ -2,37 +2,38 @@ 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.sk89q.worldedit.world.gamemode.GameMode;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
|
||||
public class GameModeFlag extends Flag<PlotGameMode> {
|
||||
public class GameModeFlag extends Flag<GameMode> {
|
||||
|
||||
public GameModeFlag(String name) {
|
||||
super(Captions.FLAG_CATEGORY_GAMEMODE, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return ((PlotGameMode) value).getName();
|
||||
@Override public String valueToString(GameMode value) {
|
||||
return value.getName();
|
||||
}
|
||||
|
||||
@Override public PlotGameMode parseValue(String value) {
|
||||
@Override public GameMode parseValue(String value) {
|
||||
switch (value.toLowerCase()) {
|
||||
case "survival":
|
||||
case "s":
|
||||
case "0":
|
||||
return PlotGameMode.SURVIVAL;
|
||||
case "creative":
|
||||
case "c":
|
||||
case "1":
|
||||
return PlotGameMode.CREATIVE;
|
||||
return GameModes.CREATIVE;
|
||||
case "adventure":
|
||||
case "a":
|
||||
case "2":
|
||||
return PlotGameMode.ADVENTURE;
|
||||
return GameModes.ADVENTURE;
|
||||
case "spectator":
|
||||
case "sp":
|
||||
case "3":
|
||||
return PlotGameMode.SPECTATOR;
|
||||
return GameModes.SPECTATOR;
|
||||
case "survival":
|
||||
case "s":
|
||||
case "0":
|
||||
default:
|
||||
return PlotGameMode.NOT_SET;
|
||||
return GameModes.SURVIVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ public class IntegerFlag extends Flag<Integer> {
|
||||
return Captions.FLAG_ERROR_INTEGER.getTranslated();
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
@Override public String valueToString(Integer value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,8 @@ public class IntegerListFlag extends ListFlag<List<Integer>> {
|
||||
super(Captions.FLAG_CATEGORY_INTEGER_LIST, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return StringMan.join((List<Integer>) value, ",");
|
||||
@Override public String valueToString(List<Integer> value) {
|
||||
return StringMan.join(value, ",");
|
||||
}
|
||||
|
||||
@Override public List<Integer> parseValue(String value) {
|
||||
|
@ -11,7 +11,7 @@ public class IntervalFlag extends Flag<IntervalFlag.Interval> {
|
||||
super(Captions.FLAG_CATEGORY_INTERVALS, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
@Override public String valueToString(IntervalFlag.Interval value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ public class ItemTypeListFlag extends ListFlag<Set<ItemType>> {
|
||||
super(Captions.FLAG_CATEGORY_BLOCK_LIST, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return StringMan.join((Set<BlockType>) value, ",");
|
||||
@Override public String valueToString(Set<ItemType> value) {
|
||||
return StringMan.join(value, ",");
|
||||
}
|
||||
|
||||
@Override public Set<ItemType> parseValue(final String value) {
|
||||
@ -32,8 +32,4 @@ public class ItemTypeListFlag extends ListFlag<Set<ItemType>> {
|
||||
@Override public String getValueDescription() {
|
||||
return Captions.FLAG_ERROR_PLOTBLOCKLIST.getTranslated();
|
||||
}
|
||||
|
||||
public boolean contains(Plot plot, BlockState value) {
|
||||
return contains(plot, value.getBlockType().getItemType());
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class LongFlag extends Flag<Long> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
@Override public String valueToString(Long value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ public class PlotWeatherFlag extends Flag<PlotWeather> {
|
||||
super(Captions.FLAG_CATEGORY_WEATHER, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
@Override public String valueToString(PlotWeather value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ public class StringFlag extends Flag<String> {
|
||||
super(Captions.FLAG_CATEGORY_STRING, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
@Override public String valueToString(String value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,8 @@ public class StringListFlag extends ListFlag<List<String>> {
|
||||
super(Captions.FLAG_CATEGORY_STRING_LIST, name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
return StringMan.join((List<String>) value, ",");
|
||||
@Override public String valueToString(List<String> value) {
|
||||
return StringMan.join(value, ",");
|
||||
}
|
||||
|
||||
@Override public List<String> parseValue(String value) {
|
||||
|
@ -14,9 +14,6 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.worlds.SinglePlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
Loading…
Reference in New Issue
Block a user