forked from SteamWar/SteamWar
Fix version matching
This commit is contained in:
@@ -27,12 +27,13 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class GameModeConfig {
|
public class GameModeConfig {
|
||||||
|
|
||||||
private static final Pattern terminatingNumber = Pattern.compile("\\D+(\\d+)$");
|
private static final Pattern terminatingNumber = Pattern.compile("(\\d+)$");
|
||||||
|
|
||||||
public static <T extends GameModeConfig> void loadAll(Class<T> config, BiConsumer<File, T> consumer) {
|
public static <T extends GameModeConfig> void loadAll(Class<T> config, BiConsumer<File, T> consumer) {
|
||||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
||||||
@@ -70,7 +71,9 @@ public class GameModeConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ServerVersion getVersion() {
|
public ServerVersion getVersion() {
|
||||||
return ServerVersion.valueOf((getServer().isSpigot() ? "SPIGOT_" : "PAPER_") + terminatingNumber.matcher(getServer().getFolder()).group(1));
|
Matcher matcher = terminatingNumber.matcher(getServer().getFolder());
|
||||||
|
matcher.find();
|
||||||
|
return ServerVersion.valueOf((getServer().isSpigot() ? "SPIGOT_" : "PAPER_") + matcher.group(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFolder() {
|
public String getFolder() {
|
||||||
|
|||||||
Reference in New Issue
Block a user