From d7aa4a0e1f7784dcb3aba7021d8efa193512f30f Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Mon, 18 Nov 2019 13:41:46 -0500 Subject: [PATCH] Revert "Fix some flag issues" This reverts commit 8b741477 --- .../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 | 37 +++++++++---------- .../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, 44 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 4cfd33258..117551488 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(Set value) { - return StringMan.join(value, ","); + @Override public String valueToString(Object value) { + return StringMan.join((Set) 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 5556ad1fd..692c0b501 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(Boolean value) { - return value.toString(); + @Override public String valueToString(Object value) { + return value + ""; } @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 1b24d4813..ab2c86c45 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(Double value) { + @Override public String valueToString(Object 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 2e1d65820..06936d4df 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(String value) { - return value; + @Override public String valueToString(Object value) { + return value.toString(); } @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 0d01b9e7e..21047d9cd 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(V value); + public abstract String valueToString(Object 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 12901fb1c..023bf804a 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,38 +2,37 @@ 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(GameMode value) { - return value.getName(); + @Override public String valueToString(Object value) { + return ((PlotGameMode) value).getName(); } - @Override public GameMode parseValue(String value) { + @Override public PlotGameMode parseValue(String value) { switch (value.toLowerCase()) { - case "creative": - case "c": - case "1": - return GameModes.CREATIVE; - case "adventure": - case "a": - case "2": - return GameModes.ADVENTURE; - case "spectator": - case "sp": - case "3": - return GameModes.SPECTATOR; case "survival": case "s": case "0": + return PlotGameMode.SURVIVAL; + case "creative": + case "c": + case "1": + return PlotGameMode.CREATIVE; + case "adventure": + case "a": + case "2": + return PlotGameMode.ADVENTURE; + case "spectator": + case "sp": + case "3": + return PlotGameMode.SPECTATOR; default: - return GameModes.SURVIVAL; + return PlotGameMode.NOT_SET; } } 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 93bf57610..8b527c46a 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(Integer value) { + @Override public String valueToString(Object 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 bfd2aa730..e9162000b 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(List value) { - return StringMan.join(value, ","); + @Override public String valueToString(Object value) { + return StringMan.join((List) 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 470b8ed56..7b6b64d47 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(IntervalFlag.Interval value) { + @Override public String valueToString(Object 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 fd37a65d5..2e9d80a38 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(Set value) { - return StringMan.join(value, ","); + @Override public String valueToString(Object value) { + return StringMan.join((Set) value, ","); } @Override public Set parseValue(final String value) { @@ -32,4 +32,8 @@ 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 538870642..1d8846701 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(Long value) { + @Override public String valueToString(Object 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 0d5eb7481..1893d5370 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(PlotWeather value) { + @Override public String valueToString(Object 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 ce2c739c8..21f1690a6 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(String value) { + @Override public String valueToString(Object 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 eae13943e..eb76ec8c1 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(List value) { - return StringMan.join(value, ","); + @Override public String valueToString(Object value) { + return StringMan.join((List) 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 a51742e24..7af028759 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,6 +14,9 @@ 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;