From eeb814fb8f02e26126e25b653603fb1c63982e66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Tue, 18 Feb 2020 13:42:49 +0100 Subject: [PATCH] Remove unused classes --- .../plot/flag/BlockStateListFlag.java | 37 --------- .../plotsquared/plot/flag/DoubleFlag.java | 27 ------- .../plotsquared/plot/flag/EnumFlag.java | 33 -------- .../plotsquared/plot/flag/Flag.java | 75 ------------------- .../plotsquared/plot/flag/GameModeFlag.java | 42 ----------- .../plotsquared/plot/flag/IntegerFlag.java | 42 ----------- .../plotsquared/plot/flag/IntervalFlag.java | 57 -------------- .../plot/flag/ItemTypeListFlag.java | 31 -------- .../plotsquared/plot/flag/ListFlag.java | 22 ------ .../plotsquared/plot/flag/LongFlag.java | 26 ------- .../plotsquared/plot/flag/StringListFlag.java | 27 ------- .../plot/flag/TeleportDenyFlag.java | 10 --- .../plotsquared/plot/util/MainUtil.java | 1 - 13 files changed, 430 deletions(-) delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BlockStateListFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ItemTypeListFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ListFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/TeleportDenyFlag.java 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 deleted file mode 100644 index 6f4f05b11..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BlockStateListFlag.java +++ /dev/null @@ -1,37 +0,0 @@ -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.StringMan; -import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil; -import com.sk89q.worldedit.world.block.BlockState; -import com.sk89q.worldedit.world.block.BlockType; - -import java.util.Arrays; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -public class BlockStateListFlag extends ListFlag> { - - public BlockStateListFlag(String name) { - super(Captions.FLAG_CATEGORY_BLOCK_LIST, name); - } - - @Override public String valueToString(Object value) { - return StringMan.join((Set) value, ","); - } - - @Override public Set parseValue(final String value) { - return Arrays.stream(BlockUtil.parse(value)).filter(Objects::nonNull) - .map(BlockState::getBlockType).collect(Collectors.toSet()); - } - - @Override public String getValueDescription() { - return Captions.FLAG_ERROR_PLOTBLOCKLIST.getTranslated(); - } - - public boolean contains(Plot plot, BlockState value) { - return contains(plot, value.getBlockType()); - } -} 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 deleted file mode 100644 index ab2c86c45..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.github.intellectualsites.plotsquared.plot.flag; - -import com.github.intellectualsites.plotsquared.plot.config.Captions; - -public class DoubleFlag extends Flag { - - public DoubleFlag(String name) { - super(Captions.FLAG_CATEGORY_DECIMAL, name); - } - - @Override public String valueToString(Object value) { - return value.toString(); - } - - @Override public Double parseValue(String value) { - try { - return Double.parseDouble(value); - } catch (NumberFormatException ignored) { - return null; - } - - } - - @Override public String getValueDescription() { - return Captions.FLAG_ERROR_BOOLEAN.getTranslated(); - } -} 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 deleted file mode 100644 index 06936d4df..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java +++ /dev/null @@ -1,33 +0,0 @@ -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 { - - private final HashSet values; - - public EnumFlag(String name, String... values) { - super(Captions.FLAG_CATEGORY_ENUM, name); - this.values = new HashSet<>(Arrays.asList(values)); - } - - @Override public String valueToString(Object value) { - return value.toString(); - } - - @Override public String parseValue(String value) { - value = value.toLowerCase(); - if (values.contains(value)) { - return value; - } - return null; - } - - @Override public String getValueDescription() { - return Captions.FLAG_ERROR_ENUM.getTranslated() + StringMan.getString(values); - } -} 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 deleted file mode 100644 index 4051ce138..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flag.java +++ /dev/null @@ -1,75 +0,0 @@ -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 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 - * register it with PlotSquared. - * - * @param name the flag name - */ - public Flag(String name) { - this(null, name); - } - - public Flag reserve() { - this.reserved = true; - return this; - } - - public boolean isReserved() { - return this.reserved; - } - - public void unreserve() { - this.reserved = false; - } - - public void register() { - Flags.registerFlag(this); - } - - public abstract String valueToString(Object value); - - @Override public final String toString() { - return "Flag { name='" + getName() + "'}"; - } - - public abstract V parseValue(String value); - - public abstract String getValueDescription(); - - public final String getName() { - return this.name; - } - - public boolean isSet(Plot plot) { - return FlagManager.getPlotFlagRaw(plot, this) != null; - } - - @Override public String getComparableString() { - return getName(); - } - - public String getCategoryCaption() { - return this.typeCaption == null ? - getClass().getSimpleName() : - this.typeCaption.getTranslated(); - } - -} 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 deleted file mode 100644 index 0c4ca07a1..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.github.intellectualsites.plotsquared.plot.flag; - -import com.github.intellectualsites.plotsquared.plot.config.Captions; -import com.sk89q.worldedit.world.gamemode.GameMode; -import com.sk89q.worldedit.world.gamemode.GameModes; - -public class GameModeFlag extends Flag { - - public GameModeFlag(String name) { - super(Captions.FLAG_CATEGORY_GAMEMODE, name); - } - - @Override public String valueToString(Object value) { - return ((GameMode) value).getName(); - } - - @Override public GameMode 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": - default: - return GameModes.SURVIVAL; - } - } - - @Override public String getValueDescription() { - return Captions.FLAG_ERROR_GAMEMODE.getTranslated(); - } -} 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 deleted file mode 100644 index 8b527c46a..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java +++ /dev/null @@ -1,42 +0,0 @@ -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 { - - public IntegerFlag(String name) { - super(Captions.FLAG_CATEGORY_INTEGERS, name); - } - - @Override public String getValueDescription() { - return Captions.FLAG_ERROR_INTEGER.getTranslated(); - } - - @Override public String valueToString(Object value) { - return value.toString(); - } - - @Override public Integer parseValue(String value) { - try { - return Integer.parseInt(value); - } catch (NumberFormatException ignored) { - return null; - } - } - - public boolean isEqual(Plot plot, int value) { - Integer existing = FlagManager.getPlotFlagRaw(plot, this); - return existing != null && existing == value; - } - - public boolean isMore(Plot plot, int value) { - Integer existing = FlagManager.getPlotFlagRaw(plot, this); - return existing != null && existing > value; - } - - public boolean isLess(Plot plot, int value) { - Integer existing = FlagManager.getPlotFlagRaw(plot, this); - return existing != null && existing < 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 deleted file mode 100644 index 7b6b64d47..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.github.intellectualsites.plotsquared.plot.flag; - -import com.github.intellectualsites.plotsquared.plot.config.Captions; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -public class IntervalFlag extends Flag { - - public IntervalFlag(String name) { - super(Captions.FLAG_CATEGORY_INTERVALS, name); - } - - @Override public String valueToString(Object value) { - return value.toString(); - } - - @Override public Interval parseValue(String value) { - int seconds; - int amount; - String[] values = value.split(" "); - if (values.length < 2) { - seconds = 1; - try { - amount = Integer.parseInt(values[0]); - } catch (NumberFormatException ignored) { - return null; - } - } else if (values.length == 2) { - try { - amount = Integer.parseInt(values[0]); - seconds = Integer.parseInt(values[1]); - } catch (NumberFormatException ignored) { - return null; - } - } else { - return null; - } - return new Interval(amount, seconds); - } - - @Override public String getValueDescription() { - return Captions.FLAG_ERROR_INTERVAL.getTranslated(); - } - - @EqualsAndHashCode @RequiredArgsConstructor @Getter public static final class Interval { - - private final int val1; - private final int val2; - - public String toString() { - return String.format("%d %d", this.val1, this.val2); - } - - } - -} 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 deleted file mode 100644 index 5812588c2..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ItemTypeListFlag.java +++ /dev/null @@ -1,31 +0,0 @@ -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.world.ItemUtil; -import com.sk89q.worldedit.world.item.ItemType; - -import java.util.Arrays; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -public class ItemTypeListFlag extends ListFlag> { - - public ItemTypeListFlag(String name) { - super(Captions.FLAG_CATEGORY_BLOCK_LIST, name); - } - - @Override public String valueToString(Object value) { - return StringMan.join((Set) value, ","); - } - - @Override public Set parseValue(final String value) { - return Arrays.stream(ItemUtil.parse(value)).filter(Objects::nonNull) - .collect(Collectors.toSet()); - } - - @Override public String getValueDescription() { - return Captions.FLAG_ERROR_PLOTBLOCKLIST.getTranslated(); - } -} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ListFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ListFlag.java deleted file mode 100644 index 3085288b1..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/ListFlag.java +++ /dev/null @@ -1,22 +0,0 @@ -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> extends Flag { - - public ListFlag(Captions typeCaption, String name) { - super(typeCaption, name); - } - - public ListFlag(String name) { - super(name); - } - - public boolean contains(Plot plot, Object value) { - V existing = plot.getFlag(this, null); - return existing != null && existing.contains(value); - } -} 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 deleted file mode 100644 index 1d8846701..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.github.intellectualsites.plotsquared.plot.flag; - -import com.github.intellectualsites.plotsquared.plot.config.Captions; - -public class LongFlag extends Flag { - - public LongFlag(String name) { - super(Captions.FLAG_CATEGORY_INTEGERS, name); - } - - @Override public Long parseValue(String value) { - try { - return Long.parseLong(value); - } catch (IllegalArgumentException ignored) { - return null; - } - } - - @Override public String valueToString(Object value) { - return value.toString(); - } - - @Override public String getValueDescription() { - return Captions.FLAG_ERROR_LONG.getTranslated(); - } -} 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 deleted file mode 100644 index eb76ec8c1..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java +++ /dev/null @@ -1,27 +0,0 @@ -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; -import java.util.Arrays; -import java.util.List; - -public class StringListFlag extends ListFlag> { - - public StringListFlag(String name) { - super(Captions.FLAG_CATEGORY_STRING_LIST, name); - } - - @Override public String valueToString(Object value) { - return StringMan.join((List) value, ","); - } - - @Override public List parseValue(String value) { - return new ArrayList<>(Arrays.asList(value.split(","))); - } - - @Override public String getValueDescription() { - return Captions.FLAG_ERROR_STRINGLIST.getTranslated(); - } -} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/TeleportDenyFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/TeleportDenyFlag.java deleted file mode 100644 index 1a8e7c694..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/TeleportDenyFlag.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.github.intellectualsites.plotsquared.plot.flag; - -public class TeleportDenyFlag extends EnumFlag { - - public TeleportDenyFlag(String name) { - super(name, "trusted", "members", "nonmembers", "nontrusted", "nonowners"); - } - - -} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java index e96be74ff..5e2110abc 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java @@ -8,7 +8,6 @@ import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility; import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.database.DBFunc; -import com.github.intellectualsites.plotsquared.plot.flag.DoubleFlag; import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;