From 8b7414770fe843bef63e7e224fb602f347fdaa28 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Mon, 18 Nov 2019 11:09:32 -0500 Subject: [PATCH] Fix some flag issues --- .../plot/flag/BlockStateListFlag.java | 4 +-- .../plotsquared/plot/flag/BooleanFlag.java | 4 +-- .../plotsquared/plot/flag/DoubleFlag.java | 2 +- .../plotsquared/plot/flag/EnumFlag.java | 4 +-- .../plotsquared/plot/flag/Flag.java | 2 +- .../plotsquared/plot/flag/GameModeFlag.java | 25 ++++++++++--------- .../plotsquared/plot/flag/IntegerFlag.java | 2 +- .../plot/flag/IntegerListFlag.java | 4 +-- .../plotsquared/plot/flag/IntervalFlag.java | 2 +- .../plot/flag/ItemTypeListFlag.java | 8 ++---- .../plotsquared/plot/flag/LongFlag.java | 2 +- .../plot/flag/PlotWeatherFlag.java | 2 +- .../plotsquared/plot/flag/StringFlag.java | 2 +- .../plotsquared/plot/flag/StringListFlag.java | 4 +-- .../plotsquared/plot/util/EventUtil.java | 3 --- 15 files changed, 32 insertions(+), 38 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BlockStateListFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BlockStateListFlag.java index 117551488..4cfd33258 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BlockStateListFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BlockStateListFlag.java @@ -18,8 +18,8 @@ public class BlockStateListFlag extends ListFlag> { super(Captions.FLAG_CATEGORY_BLOCK_LIST, name); } - @Override public String valueToString(Object value) { - return StringMan.join((Set) value, ","); + @Override public String valueToString(Set value) { + return StringMan.join(value, ","); } @Override public Set parseValue(final String value) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BooleanFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BooleanFlag.java index 692c0b501..5556ad1fd 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BooleanFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BooleanFlag.java @@ -9,8 +9,8 @@ public class BooleanFlag extends Flag { 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) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java index ab2c86c45..1b24d4813 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java @@ -8,7 +8,7 @@ public class DoubleFlag extends Flag { super(Captions.FLAG_CATEGORY_DECIMAL, name); } - @Override public String valueToString(Object value) { + @Override public String valueToString(Double value) { return value.toString(); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java index 06936d4df..2e1d65820 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java @@ -15,8 +15,8 @@ public class EnumFlag extends Flag { 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) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flag.java index 21047d9cd..0d01b9e7e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flag.java @@ -44,7 +44,7 @@ public abstract class Flag 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() + "'}"; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java index 023bf804a..12901fb1c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java @@ -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 { +public class GameModeFlag extends Flag { 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; } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java index 8b527c46a..93bf57610 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java @@ -13,7 +13,7 @@ public class IntegerFlag extends Flag { return Captions.FLAG_ERROR_INTEGER.getTranslated(); } - @Override public String valueToString(Object value) { + @Override public String valueToString(Integer value) { return value.toString(); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerListFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerListFlag.java index e9162000b..bfd2aa730 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerListFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerListFlag.java @@ -13,8 +13,8 @@ public class IntegerListFlag extends ListFlag> { super(Captions.FLAG_CATEGORY_INTEGER_LIST, name); } - @Override public String valueToString(Object value) { - return StringMan.join((List) value, ","); + @Override public String valueToString(List value) { + return StringMan.join(value, ","); } @Override public List parseValue(String value) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java index 7b6b64d47..470b8ed56 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java @@ -11,7 +11,7 @@ public class IntervalFlag extends Flag { super(Captions.FLAG_CATEGORY_INTERVALS, name); } - @Override public String valueToString(Object value) { + @Override public String valueToString(IntervalFlag.Interval value) { return value.toString(); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ItemTypeListFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ItemTypeListFlag.java index 2e9d80a38..fd37a65d5 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ItemTypeListFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ItemTypeListFlag.java @@ -21,8 +21,8 @@ public class ItemTypeListFlag extends ListFlag> { super(Captions.FLAG_CATEGORY_BLOCK_LIST, name); } - @Override public String valueToString(Object value) { - return StringMan.join((Set) value, ","); + @Override public String valueToString(Set value) { + return StringMan.join(value, ","); } @Override public Set parseValue(final String value) { @@ -32,8 +32,4 @@ public class ItemTypeListFlag extends ListFlag> { @Override public String getValueDescription() { return Captions.FLAG_ERROR_PLOTBLOCKLIST.getTranslated(); } - - public boolean contains(Plot plot, BlockState value) { - return contains(plot, value.getBlockType().getItemType()); - } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java index 1d8846701..538870642 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java @@ -16,7 +16,7 @@ public class LongFlag extends Flag { } } - @Override public String valueToString(Object value) { + @Override public String valueToString(Long value) { return value.toString(); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotWeatherFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotWeatherFlag.java index 1893d5370..0d5eb7481 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotWeatherFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotWeatherFlag.java @@ -9,7 +9,7 @@ public class PlotWeatherFlag extends Flag { super(Captions.FLAG_CATEGORY_WEATHER, name); } - @Override public String valueToString(Object value) { + @Override public String valueToString(PlotWeather value) { return value.toString(); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringFlag.java index 21f1690a6..ce2c739c8 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringFlag.java @@ -8,7 +8,7 @@ public class StringFlag extends Flag { super(Captions.FLAG_CATEGORY_STRING, name); } - @Override public String valueToString(Object value) { + @Override public String valueToString(String value) { return value.toString(); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java index eb76ec8c1..eae13943e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java @@ -13,8 +13,8 @@ public class StringListFlag extends ListFlag> { super(Captions.FLAG_CATEGORY_STRING_LIST, name); } - @Override public String valueToString(Object value) { - return StringMan.join((List) value, ","); + @Override public String valueToString(List value) { + return StringMan.join(value, ","); } @Override public List parseValue(String value) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java index 7af028759..a51742e24 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EventUtil.java @@ -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;