fix ServerConfigurator

This commit is contained in:
CrazyDev22
2024-04-26 18:14:40 +02:00
parent fc1761a55b
commit a5f687fd76
@@ -69,7 +69,7 @@ public class ServerConfigurator {
} }
private static void increaseKeepAliveSpigot() throws IOException, InvalidConfigurationException { private static void increaseKeepAliveSpigot() throws IOException, InvalidConfigurationException {
File spigotConfig = new File("config/spigot.yml"); File spigotConfig = new File("spigot.yml");
FileConfiguration f = new YamlConfiguration(); FileConfiguration f = new YamlConfiguration();
f.load(spigotConfig); f.load(spigotConfig);
long tt = f.getLong("settings.timeout-time"); long tt = f.getLong("settings.timeout-time");
@@ -101,16 +101,27 @@ public class ServerConfigurator {
} }
KList<File> worlds = new KList<>(); KList<File> worlds = new KList<>();
Bukkit.getServer().getWorlds().forEach(w -> worlds.add(new File(w.getWorldFolder(), "datapacks"))); Bukkit.getServer().getWorlds().forEach(w -> worlds.add(new File(w.getWorldFolder(), "datapacks")));
if (worlds.isEmpty()) {
worlds.add(new File(getMainWorldFolder(), "datapacks"));
}
return worlds; return worlds;
} }
private static boolean postVerifyDataPacks(boolean fast) { private static File getMainWorldFolder() {
try { try {
Properties prop = new Properties(); Properties prop = new Properties();
prop.load(new FileInputStream("server.properties")); prop.load(new FileInputStream("server.properties"));
String world = prop.getProperty("level-name"); String world = prop.getProperty("level-name");
File worldFolder = new File(Bukkit.getWorldContainer(), world); return new File(Bukkit.getWorldContainer(), world);
File datapacksFolder = new File(worldFolder, "datapacks"); } catch (Exception e) {
e.printStackTrace();
}
return null;
}
private static boolean postVerifyDataPacks(boolean fast) {
try {
File datapacksFolder = new File(getMainWorldFolder(), "datapacks");
File IrisDatapacks = new File(datapacksFolder, "iris"); File IrisDatapacks = new File(datapacksFolder, "iris");
if (!datapacksFolder.exists() || !IrisDatapacks.exists()) { if (!datapacksFolder.exists() || !IrisDatapacks.exists()) {
return (true); return (true);