Redo File Search and War ID

This commit is contained in:
Aubri Seebauer committed 2023-04-02 23:43:40 -04:00
1 parent 388c600ce5
commit 471a03bb7b
2 files changed
+12 -5

No files matched your search

@@ -4,6 +4,7 @@ import java.util.ArrayList;
public class War {
private String name;
private final int id;
private String side1;
private String side2;
private ArrayList<String> side1Players;
@@ -11,12 +12,13 @@ public class War {
private ArrayList<String> side1Mercs;
private ArrayList<String> side2Mercs;
public War(final String name, final String side1, final String side2) {
public War(final String name, final int id, final String side1, final String side2) {
side1Players = new ArrayList<String>();
side2Players = new ArrayList<String>();
side1Mercs = new ArrayList<String>();
side2Mercs = new ArrayList<String>();
this.name = name;
this.id = id;
this.side1 = side1;
this.side2 = side2;
side1Players.add("Placeholder1");
@@ -74,6 +76,10 @@ public class War {
}
}
}
public int getId() {
return this.id;
}
public String getName() {
return this.name;
@@ -19,6 +19,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -50,8 +51,6 @@ public class WarData
this.configFile = new File(this.plugin.getDataFolder(), "wars.yml");
}
//Gather all war files in this
warsData.clear();
Stream<Path> stream = null;
@@ -62,7 +61,10 @@ public class WarData
.map(Path::toFile)
.filter(file -> {
if (file.getName().split(".").length > 1) {
if (file.getName().split(".")[1].equalsIgnoreCase("yml")) {
String[] parse = file.getName().split(".");
int extensionCheck = Arrays.binarySearch(parse, "yml");
// -1 if search fail
if (extensionCheck >= 0) {
return true;
}
}
@@ -75,7 +77,6 @@ public class WarData
throw new RuntimeException(e);
}
int i = 0;
for(File file : warsFiles) {
this.warsData.add(i, new Pair(YamlConfiguration.loadConfiguration(file), file));