Throw exception on world create while being ticked

There are no plans to support creating worlds while worlds are
being ticked themselvess.
This commit is contained in:
Jake Potrebic
2022-03-22 12:44:30 -07:00
parent 4c16855bdd
commit 6a51d13dbf
2 changed files with 75 additions and 60 deletions

View File

@ -919,6 +919,11 @@ public final class CraftServer implements Server {
return new ArrayList<World>(this.worlds.values());
}
@Override
public boolean isTickingWorlds() {
return console.isIteratingOverLevels;
}
public DedicatedPlayerList getHandle() {
return this.playerList;
}
@ -1182,6 +1187,7 @@ public final class CraftServer implements Server {
@Override
public World createWorld(WorldCreator creator) {
Preconditions.checkState(this.console.getAllLevels().iterator().hasNext(), "Cannot create additional worlds on STARTUP");
//Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot create a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes.
Preconditions.checkArgument(creator != null, "WorldCreator cannot be null");
String name = creator.name();
@ -1358,6 +1364,7 @@ public final class CraftServer implements Server {
@Override
public boolean unloadWorld(World world, boolean save) {
//Preconditions.checkState(!this.console.isIteratingOverLevels, "Cannot unload a world while worlds are being ticked"); // Paper - Cat - Temp disable. We'll see how this goes.
if (world == null) {
return false;
}