diff --git a/pom.xml b/pom.xml
index 4166141..47aca72 100644
--- a/pom.xml
+++ b/pom.xml
@@ -283,11 +283,6 @@
command
2.0.11
-
- com.syntaxphoenix.syntaxapi
- version
- 2.0.10
-
com.syntaxphoenix.syntaxapi
reflection
diff --git a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/annotation/MCVersionEnumGenerator.java b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/annotation/MCVersionEnumGenerator.java
index 9fd6b9b..36c8341 100644
--- a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/annotation/MCVersionEnumGenerator.java
+++ b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/annotation/MCVersionEnumGenerator.java
@@ -8,6 +8,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
@@ -21,13 +22,15 @@
import javax.tools.Diagnostic.Kind;
import javax.tools.JavaFileObject;
+import org.bukkit.Bukkit;
import org.jboss.forge.roaster.Roaster;
import org.jboss.forge.roaster.model.source.EnumConstantSource;
import org.jboss.forge.roaster.model.source.JavaEnumSource;
-import com.syntaxphoenix.syntaxapi.version.DefaultVersion;
-import com.syntaxphoenix.syntaxapi.version.Version;
-import com.syntaxphoenix.syntaxapi.version.VersionAnalyzer;
+import com.syntaxphoenix.spigot.smoothtimber.version.Version;
+import com.syntaxphoenix.spigot.smoothtimber.version.VersionManager;
+import com.syntaxphoenix.spigot.smoothtimber.version.VersionManager.VersionState;
+import com.syntaxphoenix.spigot.smoothtimber.version.manager.VersionChanger;
public final class MCVersionEnumGenerator extends AbstractProcessor {
@@ -58,7 +61,6 @@ public boolean process(final Set extends TypeElement> annotations, final Round
final HashMap> map = new HashMap<>();
final ArrayList types = new ArrayList<>();
- final VersionAnalyzer analyzer = new DefaultVersion().getAnalyzer();
for (final Element element : roundEnv.getElementsAnnotatedWith(SupportedVersions.class)) {
if (element.getKind() != ElementKind.CLASS) {
continue;
@@ -72,12 +74,12 @@ public boolean process(final Set extends TypeElement> annotations, final Round
final ArrayList versions = new ArrayList<>();
map.put(typeName, versions);
for (final String supported : versionsSupported.value()) {
- final Version version = analyzer.analyze(supported);
- if (version.getMajor() == 0) {
+ final Version version = Version.fromString(supported);
+ if (version.major() == 0) {
messager.printMessage(Kind.WARNING, format("Failed to parse version '%s' of type '%s'", supported, typeName), element);
continue;
}
- versions.add(analyzer.analyze(supported));
+ versions.add(version);
}
}
@@ -94,21 +96,37 @@ public boolean process(final Set extends TypeElement> annotations, final Round
final JavaEnumSource source = Roaster.create(JavaEnumSource.class);
source.setName("MCVersion");
source.setPackage("com.syntaxphoenix.spigot.smoothtimber.version.manager.gen");
- source.addImport("com.syntaxphoenix.spigot.smoothtimber.version.manager.VersionChanger");
- source.addImport("com.syntaxphoenix.syntaxapi.version.DefaultVersion");
- source.addImport("com.syntaxphoenix.syntaxapi.version.Version");
- source.addImport("com.syntaxphoenix.syntaxapi.version.VersionAnalyzer");
- source.addImport("com.syntaxphoenix.syntaxapi.version.VersionManager");
- source.addImport("com.syntaxphoenix.syntaxapi.version.VersionState");
- source.addImport("java.util.ArrayList");
- source.addImport("org.bukkit.Bukkit");
- source.addNestedType(join("\n", "private static interface ChangerBuilder {", " public VersionChanger create();", "}"));
- source.addNestedType(join("\n", "public static final class MCVersionResult {", " private final MCVersion version;",
- " private final VersionState state;", " private MCVersionResult(MCVersion version, VersionState state) {",
- " this.version = version;", " this.state = state;", " }", " public MCVersion version() { return version; }",
- " public VersionState state() { return state; }", "}"));
- source.addMethod(join("\n", "MCVersion(DefaultVersion[] versions, ChangerBuilder builder) {", " this.builder = builder;",
- " versionManager.setAll(VersionState.SUPPORTED, versions);", "}")).setConstructor(true);
+ source.addImport(Version.class);
+ source.addImport(VersionManager.class);
+ source.addImport(VersionState.class);
+ source.addImport(VersionChanger.class);
+ source.addImport(ArrayList.class);
+ source.addImport(Collections.class);
+ source.addImport(List.class);
+ source.addImport(Bukkit.class);
+ source.addNestedType(join("\n", new String[] {
+ "private static interface ChangerBuilder {",
+ " public VersionChanger create();",
+ "}"
+ }));
+ source.addNestedType(join("\n", new String[] {
+ "public static final class MCVersionResult {",
+ " private final MCVersion version;",
+ " private final VersionState state;",
+ " private MCVersionResult(MCVersion version, VersionState state) {",
+ " this.version = version;",
+ " this.state = state;",
+ " }",
+ " public MCVersion version() { return version; }",
+ " public VersionState state() { return state; }",
+ "}"
+ }));
+ source.addMethod(join("\n", new String[] {
+ "MCVersion(Version[] versions, ChangerBuilder builder) {",
+ " this.builder = builder;",
+ " versionManager.set(VersionState.SUPPORTED, versions);",
+ "}"
+ })).setConstructor(true);
for (int index = 0; index < types.size(); index++) {
final String type = types.get(index);
final ArrayList versions = map.get(type);
@@ -119,50 +137,95 @@ public boolean process(final Set extends TypeElement> annotations, final Round
final String versionName = getVersionFromName(typeName);
final EnumConstantSource enumSource = source.addEnumConstant(versionName);
- final StringBuilder versionArray = new StringBuilder("new DefaultVersion[] {");
+ final StringBuilder versionArray = new StringBuilder("new Version[] {");
for (final Version version : versions) {
- versionArray.append("new DefaultVersion(");
- versionArray.append(version.getMajor()).append(", ").append(version.getMinor()).append(", ").append(version.getPatch());
+ versionArray.append("new Version(");
+ versionArray.append(version.major()).append(", ").append(version.minor()).append(", ").append(version.patch());
versionArray.append("),");
}
enumSource.setConstructorArguments(versionArray.append("}").toString(), format("() -> new %s()", typeName));
}
- source.addField("private static final VersionAnalyzer ANALYZER = new DefaultVersion().getAnalyzer();");
source.addField("private static final MCVersion[] ALL_VERSIONS = MCVersion.values();");
- source.addField("private static DefaultVersion minecraftVersion;");
+ source.addField("private static Version minecraftVersion;");
source.addField("private static MCVersionResult coreVersionResult;");
source.addField(
- "private final VersionManager versionManager = new VersionManager(VersionState.NOT_COMPATIBLE, VersionState.NOT_TESTED, VersionState.NOT_COMPATIBLE);");
+ "private final VersionManager versionManager = new VersionManager();");
source.addField("private final ChangerBuilder builder;");
- source.addMethod(join("\n", "public VersionChanger create() {", " return builder.create();", "}"));
-
- source.addMethod(
- join("\n", "public VersionState getState(DefaultVersion version) {", " return versionManager.getState(version);", "}"));
-
- source.addMethod(join("\n", "public ArrayList getKnownSupported() {",
- " return versionManager.getVersions(VersionState.SUPPORTED);", "}"));
-
- source.addMethod(join("\n", "public static ArrayList getAllKnownSupported() {",
- " ArrayList list = new ArrayList<>();", " for (MCVersion version : ALL_VERSIONS) {",
- " list.addAll(version.getKnownSupported());", " }", " return list;", "}"));
- source.addMethod(join("\n", "public static DefaultVersion getMinecraftVersion() {", " if (minecraftVersion != null) {",
- " return minecraftVersion;", " }", " String versionStr = Bukkit.getVersion().split(\" \")[2].replace(\")\", \"\");",
- " Version version = ANALYZER.analyze(versionStr);",
- " if (version == null || version.getMajor() == 0 || !(version instanceof DefaultVersion)) {",
- " throw new IllegalStateException(String.format(\"Minecraft version is invalid: '%s'\", versionStr));", " }",
- " return (minecraftVersion = (DefaultVersion) version);", "}"));
- source.addMethod(join("\n", "public static MCVersion getCoreVersion() {", " return getCoreVersionResult().version();", "}"));
- source.addMethod(join("\n", "public static MCVersionResult getCoreVersionResult() {", " if (coreVersionResult != null) {",
- " return coreVersionResult;", " }", " return (coreVersionResult = detectCoreVersion(getMinecraftVersion()));", "}"));
- source.addMethod(join("\n", "public static MCVersionResult detectCoreVersion(DefaultVersion version) {",
- " if (ALL_VERSIONS.length == 0) {", " throw new IllegalStateException(\"No core version available\");", " }",
- " MCVersion selected = ALL_VERSIONS[0];", " VersionState selectedState = VersionState.NOT_COMPATIBLE;",
- " for (MCVersion current : ALL_VERSIONS) {", " VersionState state = current.getState(version);",
- " if (state == VersionState.NOT_COMPATIBLE) {", " break;", " }", " selected = current;",
- " if ((selectedState = state) == VersionState.SUPPORTED || state == VersionState.NOT_SUPPORTED) {", " break;",
- " }", " }", " return new MCVersionResult(selected, selectedState);", "}"));
+ source.addMethod(join("\n", new String[] {
+ "public VersionChanger create() {",
+ " return builder.create();",
+ "}"
+ }));
+
+ source.addMethod(join("\n", new String[] {
+ "public VersionState getState(Version version) {",
+ " return versionManager.state(version);",
+ "}"
+ }));
+
+ source.addMethod(join("\n", new String[] {
+ "public List getKnownSupported() {",
+ " return versionManager.get(VersionState.SUPPORTED);",
+ "}"
+ }));
+
+ source.addMethod(join("\n", new String[] {
+ "public static List getAllKnownSupported() {",
+ " ArrayList list = new ArrayList<>();",
+ " for (MCVersion version : ALL_VERSIONS) {",
+ " list.addAll(version.getKnownSupported());",
+ " }",
+ " return Collections.unmodifiableList(list);",
+ "}"
+ }));
+ source.addMethod(join("\n", new String[] {
+ "public static Version getMinecraftVersion() {",
+ " if (minecraftVersion != null) {",
+ " return minecraftVersion;",
+ " }",
+ " String versionStr = Bukkit.getVersion().split(\" \")[2].replace(\")\", \"\");",
+ " Version version = Version.fromString(versionStr);",
+ " if (version == null || version.major() == 0) {",
+ " throw new IllegalStateException(String.format(\"Minecraft version is invalid: '%s'\", versionStr));",
+ " }",
+ " return (minecraftVersion = version);",
+ "}"
+ }));
+ source.addMethod(join("\n", new String[] {
+ "public static MCVersion getCoreVersion() {",
+ " return getCoreVersionResult().version();",
+ "}"
+ }));
+ source.addMethod(join("\n", new String[] {
+ "public static MCVersionResult getCoreVersionResult() {",
+ " if (coreVersionResult != null) {",
+ " return coreVersionResult;",
+ " }",
+ " return (coreVersionResult = detectCoreVersion(getMinecraftVersion()));",
+ "}"
+ }));
+ source.addMethod(join("\n", new String[] {
+ "public static MCVersionResult detectCoreVersion(Version version) {",
+ " if (ALL_VERSIONS.length == 0) {",
+ " throw new IllegalStateException(\"No core version available\");",
+ " }",
+ " MCVersion selected = ALL_VERSIONS[0];",
+ " VersionState selectedState = VersionState.UNSUPPORTED;",
+ " for (MCVersion current : ALL_VERSIONS) {",
+ " VersionState state = current.getState(version);",
+ " if (state == VersionState.INCOMPATIBLE) {",
+ " break;",
+ " }",
+ " selected = current;",
+ " if ((selectedState = state) == VersionState.SUPPORTED || state == VersionState.UNSUPPORTED) {",
+ " break;",
+ " }",
+ " }",
+ " return new MCVersionResult(selected, selectedState);",
+ "}"
+ }));
try {
final JavaFileObject file = processingEnv.getFiler().createSourceFile(source.getPackage() + '.' + source.getName());
diff --git a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/compatibility/blockylog/BlockyLog.java b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/compatibility/blockylog/BlockyLog.java
index deb92e0..cf47048 100644
--- a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/compatibility/blockylog/BlockyLog.java
+++ b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/compatibility/blockylog/BlockyLog.java
@@ -13,7 +13,7 @@ public class BlockyLog extends CompatibilityAddon {
@Override
public void onEnable(final PluginPackage pluginPackage, final SmoothTimber smoothTimber) throws Exception {
- switch (pluginPackage.getVersion().getMajor()) {
+ switch (pluginPackage.getVersion().major()) {
case 1:
resolver = new BlockyLogResolver_v1_x();
break;
diff --git a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/compatibility/jobsreborn/JobsReborn.java b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/compatibility/jobsreborn/JobsReborn.java
index 2e92454..c47d764 100644
--- a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/compatibility/jobsreborn/JobsReborn.java
+++ b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/compatibility/jobsreborn/JobsReborn.java
@@ -10,7 +10,7 @@
import com.syntaxphoenix.spigot.smoothtimber.compatibility.jobsreborn.adapter.AdapterLegacy4_17;
import com.syntaxphoenix.spigot.smoothtimber.utilities.Container;
import com.syntaxphoenix.spigot.smoothtimber.utilities.plugin.PluginPackage;
-import com.syntaxphoenix.syntaxapi.version.Version;
+import com.syntaxphoenix.spigot.smoothtimber.version.Version;
public class JobsReborn extends CompatibilityAddon {
@@ -30,7 +30,7 @@ public void onEnable(final PluginPackage pluginPackage, final SmoothTimber smoot
private JobAdapter getAdapter(final PluginPackage pluginPackage) {
final Version version = pluginPackage.getVersion();
- if (version.getMajor() < 4 || version.getMajor() == 4 && version.getMinor() <= 16) {
+ if (version.major() < 4 || version.major() == 4 && version.minor() <= 16) {
return new AdapterLegacy4_16();
}
return new AdapterLegacy4_17();
diff --git a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/utilities/plugin/PluginPackage.java b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/utilities/plugin/PluginPackage.java
index cde2326..d097cc0 100644
--- a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/utilities/plugin/PluginPackage.java
+++ b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/utilities/plugin/PluginPackage.java
@@ -2,15 +2,11 @@
import org.bukkit.plugin.Plugin;
+import com.syntaxphoenix.spigot.smoothtimber.version.Version;
import com.syntaxphoenix.syntaxapi.reflection.ReflectCache;
-import com.syntaxphoenix.syntaxapi.version.DefaultVersion;
-import com.syntaxphoenix.syntaxapi.version.Version;
-import com.syntaxphoenix.syntaxapi.version.VersionAnalyzer;
public class PluginPackage {
- public static final VersionAnalyzer ANALYZER = new DefaultVersion().getAnalyzer();
-
private ReflectCache cache = new ReflectCache();
private Version version;
@@ -38,7 +34,7 @@ final void update(final Plugin plugin) {
this.plugin = plugin;
this.name = plugin.getName();
this.versionRaw = plugin.getDescription().getVersion();
- this.version = ANALYZER.analyze(versionRaw.contains("[") ? versionRaw.split("\\[")[0] : versionRaw);
+ this.version = Version.fromString(versionRaw.contains("[") ? versionRaw.split("\\[")[0] : versionRaw);
}
/*
diff --git a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/Version.java b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/Version.java
new file mode 100644
index 0000000..105e008
--- /dev/null
+++ b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/Version.java
@@ -0,0 +1,132 @@
+package com.syntaxphoenix.spigot.smoothtimber.version;
+
+import java.util.Objects;
+
+public final class Version implements Comparable {
+
+ public static final Version ZERO = new Version(0, 0, 0);
+
+ public static Version fromString(String string) {
+ if (string.isBlank()) {
+ return ZERO;
+ }
+ String[] parts = string.contains(".") ? string.split("\\.")
+ : new String[] {
+ string
+ };
+ int major = 0;
+ int minor = 0;
+ int patch = 0;
+ try {
+ major = Integer.parseInt(parts[0]);
+ if (parts.length >= 2) {
+ minor = Integer.parseInt(parts[1]);
+ if (parts.length >= 3) {
+ patch = Integer.parseInt(parts[2]);
+ }
+ }
+ } catch (NumberFormatException nfe) {
+ }
+ if (major == 0 && minor == 0 && patch == 0) {
+ return ZERO;
+ }
+ return new Version(major, minor, patch);
+ }
+
+ private final int major, minor, patch;
+
+ public Version(int major) {
+ this(major, 0, 0);
+ }
+
+ public Version(int major, int minor) {
+ this(major, minor, 0);
+ }
+
+ public Version(int major, int minor, int patch) {
+ this.major = major;
+ this.minor = minor;
+ this.patch = patch;
+ }
+
+ public int major() {
+ return major;
+ }
+
+ public Version major(int major) {
+ return new Version(major, minor, patch);
+ }
+
+ public int minor() {
+ return minor;
+ }
+
+ public Version minor(int minor) {
+ return new Version(major, minor, patch);
+ }
+
+ public int patch() {
+ return patch;
+ }
+
+ public Version patch(int patch) {
+ return new Version(major, minor, patch);
+ }
+
+ public boolean isLower(Version version) {
+ return compareTo(version) < 0;
+ }
+
+ public boolean isHigher(Version version) {
+ return compareTo(version) > 0;
+ }
+
+ public boolean isSimilar(Version version) {
+ return version != null && (this == version || (major == version.major && minor == version.minor && patch == version.patch));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(major, minor, patch);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(major).append('.').append(minor);
+ if (patch != 0) {
+ builder.append('.').append(patch);
+ }
+ return builder.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || !(obj instanceof Version)) {
+ return false;
+ }
+ return isSimilar((Version) obj);
+ }
+
+ @Override
+ public int compareTo(Version o) {
+ if (this == o) {
+ return 0;
+ } else if (o == null) {
+ return -1;
+ }
+ int comp = Integer.compare(major, o.major);
+ if (comp != 0) {
+ return comp;
+ }
+ comp = Integer.compare(minor, o.minor);
+ if (comp != 0) {
+ return comp;
+ }
+ return Integer.compare(patch, o.patch);
+ }
+
+}
diff --git a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/VersionManager.java b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/VersionManager.java
new file mode 100644
index 0000000..40a7a45
--- /dev/null
+++ b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/VersionManager.java
@@ -0,0 +1,190 @@
+package com.syntaxphoenix.spigot.smoothtimber.version;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Objects;
+
+public final class VersionManager {
+
+ private static final VersionState[] STATES = VersionState.values();
+
+ public static enum VersionState {
+
+ SUPPORTED,
+ UNTESTED,
+ UNSUPPORTED,
+ INCOMPATIBLE;
+
+ }
+
+ private final EnumMap> map = new EnumMap<>(VersionState.class);
+
+ public VersionManager() {
+ for (VersionState state : STATES) {
+ map.put(state, new ArrayList<>());
+ }
+ }
+
+ public void clear() {
+ for (VersionState state : STATES) {
+ clear(state);
+ }
+ }
+
+ public void clear(VersionState state) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ map.get(state).clear();
+ }
+
+ public void sort() {
+ for (VersionState state : STATES) {
+ sort(state);
+ }
+ }
+
+ public void sort(VersionState state) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ ArrayList list = map.get(state);
+ if (list.size() < 2) {
+ return;
+ }
+ Collections.sort(list);
+ }
+
+ public VersionState state(Version version) {
+ VersionState exactState = exactState(version);
+ if (exactState != null) {
+ return exactState;
+ }
+ Version lowest = getLowest(VersionState.SUPPORTED, VersionState.UNTESTED);
+ if (lowest != null && version.isLower(lowest)) {
+ return VersionState.INCOMPATIBLE;
+ }
+ Version highest = getHighest(VersionState.SUPPORTED, VersionState.UNTESTED);
+ if (highest != null && version.isHigher(highest)) {
+ return VersionState.UNTESTED;
+ }
+ return VersionState.UNSUPPORTED;
+ }
+
+ public VersionState exactState(Version version) {
+ for (VersionState state : STATES) {
+ if (has(state, version)) {
+ return state;
+ }
+ }
+ return null;
+ }
+
+ public boolean has(VersionState state, Version version) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ return map.get(state).contains(version);
+ }
+
+ public List get(VersionState state) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ return Collections.unmodifiableList(map.get(state));
+ }
+
+ public Version getLowest(VersionState state) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ ArrayList list = map.get(state);
+ if (list.isEmpty()) {
+ return null;
+ }
+ return list.get(0);
+ }
+
+ public Version getLowest(VersionState... states) {
+ Objects.requireNonNull(states, "VersionState[] can't be null");
+ Version lowest = null;
+ for (VersionState state : states) {
+ Version current = getHighest(state);
+ if (current == null || (lowest != null && !current.isLower(lowest))) {
+ continue;
+ }
+ lowest = current;
+ }
+ return lowest;
+ }
+
+ public Version getHighest(VersionState state) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ ArrayList list = map.get(state);
+ if (list.isEmpty()) {
+ return null;
+ }
+ return list.get(list.size() - 1);
+ }
+
+ public Version getHighest(VersionState... states) {
+ Objects.requireNonNull(states, "VersionState[] can't be null");
+ Version highest = null;
+ for (VersionState state : states) {
+ Version current = getHighest(state);
+ if (current == null || (highest != null && !current.isHigher(highest))) {
+ continue;
+ }
+ highest = current;
+ }
+ return highest;
+ }
+
+ public void set(VersionState state, Version version) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ ArrayList list = map.get(state);
+ list.clear();
+ list.add(version);
+ }
+
+ public void set(VersionState state, Version... versions) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ ArrayList list = map.get(state);
+ list.clear();
+ for (Version version : versions) {
+ if (list.contains(version)) {
+ continue;
+ }
+ list.add(version);
+ }
+ sort(state);
+ }
+
+ public void add(VersionState state, Version version) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ ArrayList list = map.get(state);
+ if (list.contains(version)) {
+ return;
+ }
+ list.add(version);
+ sort(state);
+ }
+
+ public void add(VersionState state, Version... versions) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ ArrayList list = map.get(state);
+ for (Version version : versions) {
+ if (list.contains(version)) {
+ continue;
+ }
+ list.add(version);
+ }
+ sort(state);
+ }
+
+ public void remove(VersionState state, Version version) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ map.get(state).remove(version);
+ }
+
+ public void remove(VersionState state, Version... versions) {
+ Objects.requireNonNull(state, "VersionState can't be null");
+ ArrayList list = map.get(state);
+ for (Version version : versions) {
+ list.remove(version);
+ }
+ }
+
+}
diff --git a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/manager/VersionExchanger.java b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/manager/VersionExchanger.java
index 7b4cb52..47400c9 100644
--- a/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/manager/VersionExchanger.java
+++ b/src/main/java/com/syntaxphoenix/spigot/smoothtimber/version/manager/VersionExchanger.java
@@ -7,10 +7,10 @@
import com.syntaxphoenix.spigot.smoothtimber.config.Message;
import com.syntaxphoenix.spigot.smoothtimber.utilities.PluginUtils;
+import com.syntaxphoenix.spigot.smoothtimber.version.Version;
import com.syntaxphoenix.spigot.smoothtimber.version.changer.NOPChanger;
import com.syntaxphoenix.spigot.smoothtimber.version.manager.gen.MCVersion;
import com.syntaxphoenix.spigot.smoothtimber.version.manager.gen.MCVersion.MCVersionResult;
-import com.syntaxphoenix.syntaxapi.version.DefaultVersion;
public final class VersionExchanger {
@@ -22,7 +22,7 @@ public static VersionChanger getVersionChanger() {
}
final MCVersionResult result = MCVersion.getCoreVersionResult();
switch (result.state()) {
- case NOT_TESTED:
+ case UNTESTED:
PluginUtils.sendConsoleMessage(false,
Message.GLOBAL_PREFIX.colored() + ' ' + Message.STARTUP_VERSION_UNTESTED_MSG.colored(new String[][] {
{
@@ -38,7 +38,7 @@ public static VersionChanger getVersionChanger() {
Message.GLOBAL_PREFIX.colored() + ' ' + Message.STARTUP_VERSION_UNTESTED_VERSIONS.colored(new String[][] {
{
"%versions%",
- result.version().getKnownSupported().stream().map(DefaultVersion::toString)
+ result.version().getKnownSupported().stream().map(Version::toString)
.collect(Collectors.joining(Message.GLOBAL_LIST222SPLIT.message()))
}
}));
@@ -68,7 +68,7 @@ public static VersionChanger getVersionChanger() {
PluginUtils.sendConsoleMessage(false,
Message.GLOBAL_PREFIX.colored() + ' ' + Message.STARTUP_VERSION_VERSIONS.colored(new String[] {
"%versions%",
- MCVersion.getAllKnownSupported().stream().map(DefaultVersion::toString)
+ MCVersion.getAllKnownSupported().stream().map(Version::toString)
.collect(Collectors.joining(Message.GLOBAL_LIST222SPLIT.message()))
}));
Bukkit.getPluginManager().disablePlugin(PluginUtils.MAIN);