Remove unused classes

This commit is contained in:
Alexander Söderberg 2020-02-18 13:42:49 +01:00
parent 00c435e29b
commit eeb814fb8f
13 changed files with 0 additions and 430 deletions

View File

@ -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<Set<BlockType>> {
public BlockStateListFlag(String name) {
super(Captions.FLAG_CATEGORY_BLOCK_LIST, name);
}
@Override public String valueToString(Object value) {
return StringMan.join((Set<BlockType>) value, ",");
}
@Override public Set<BlockType> 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());
}
}

View File

@ -1,27 +0,0 @@
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(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();
}
}

View File

@ -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<String> {
private final HashSet<String> 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);
}
}

View File

@ -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<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
* register it with PlotSquared.
*
* @param name the flag name
*/
public Flag(String name) {
this(null, name);
}
public Flag<V> 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();
}
}

View File

@ -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<GameMode> {
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();
}
}

View File

@ -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<Integer> {
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;
}
}

View File

@ -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<IntervalFlag.Interval> {
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);
}
}
}

View File

@ -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<Set<ItemType>> {
public ItemTypeListFlag(String name) {
super(Captions.FLAG_CATEGORY_BLOCK_LIST, name);
}
@Override public String valueToString(Object value) {
return StringMan.join((Set<ItemType>) value, ",");
}
@Override public Set<ItemType> 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();
}
}

View File

@ -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<V extends Collection<?>> extends Flag<V> {
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);
}
}

View File

@ -1,26 +0,0 @@
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(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();
}
}

View File

@ -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<List<String>> {
public StringListFlag(String name) {
super(Captions.FLAG_CATEGORY_STRING_LIST, name);
}
@Override public String valueToString(Object value) {
return StringMan.join((List<String>) value, ",");
}
@Override public List<String> parseValue(String value) {
return new ArrayList<>(Arrays.asList(value.split(",")));
}
@Override public String getValueDescription() {
return Captions.FLAG_ERROR_STRINGLIST.getTranslated();
}
}

View File

@ -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");
}
}

View File

@ -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.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; 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.Flag;
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag; import com.github.intellectualsites.plotsquared.plot.flags.implementations.DescriptionFlag;