Implement method to check if setup is complete
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Bea 2022-08-11 21:38:49 +02:00
parent ace286c982
commit 0783505dce
2 changed files with 15 additions and 1 deletions

View File

@ -70,7 +70,7 @@ public class UhcUtils {
public static void tpSpawnAndGiveItem(Player player)
{
if(Cache.spawn == null)
if(Cache.isServerReady)
{
MessageUtils.sendLocalizedMessage(player, LocalizedMessage.ERROR_SERVER_NOT_SET_UP);
return;

View File

@ -127,6 +127,9 @@ public class FileUtils
Cache.fireworksLocations.add(new Location(plugin.getServer().getWorld(world), x, y, z));
}
// after reloading everything, check if the server is ready for gameplay.
Cache.isServerReady = isServerSetUp();
}
// Only reload the needed File.
@ -282,4 +285,15 @@ public class FileUtils
yaml = yamlConfig;
}
}
private static boolean isServerSetUp() {
if(Cache.spawn == null) return false;
if(Cache.lobbyWorlds == null || Cache.lobbyWorlds.isEmpty()) return false;
if(Cache.totalTeams <= 1) return false;
if(Cache.fireworksLocations == null) return false;
if(Cache.uhcWorlds == null || Cache.uhcWorlds.isEmpty()) return false;
return false;
}
}