OOB Random Spawn Fix (#316)

* Add warning for "randomizeSpawn" option about the speed of chunk generation

* Limit random spawn to half a million blocks, which should hopefully fix the OOB error

* Recommend users to use Chunky for pre-world generation

* Add missing period

* Fix checkstyle violation
This commit is contained in:
Allink 2022-07-18 18:32:19 +01:00 committed by GitHub
parent 7f1057df08
commit 5780f1a4a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View file

@ -31,7 +31,6 @@ import pw.kaboom.extras.modules.server.ServerTabComplete;
public final class PlayerConnection implements Listener {
private static final FileConfiguration CONFIG = JavaPlugin.getPlugin(Main.class).getConfig();
private static final String TITLE = CONFIG.getString("playerJoinTitle");
private static final String SUBTITLE = CONFIG.getString("playerJoinSubtitle");
private static final int FADE_IN = 10;
@ -128,11 +127,16 @@ public final class PlayerConnection implements Listener {
if (RANDOMIZE_SPAWN
&& event.getPlayer().getBedSpawnLocation() != event.getSpawnLocation()) {
final World world = event.getPlayer().getWorld();
final double x = ThreadLocalRandom.current().nextInt(-300000000, 30000000) + .5;
final double y = 100;
final double z = ThreadLocalRandom.current().nextInt(-300000000, 30000000) + .5;
final ThreadLocalRandom random = ThreadLocalRandom.current();
event.setSpawnLocation(new Location(world, x, y, z));
final double teleportAmount = 500000D;
final Location location = new Location(
world,
random.nextDouble(-teleportAmount, teleportAmount),
100,
random.nextDouble(-teleportAmount, teleportAmount)
);
event.setSpawnLocation(location);
}
}

View file

@ -3,6 +3,10 @@ allowJoinOnFullServer: true
enableKick: false
enableJoinRestrictions: false
opOnJoin: true
# It's recommended to do this on a pre-generated world
# as chunk generation can be very slow in newer Minecraft
# versions.
# You can use the pre-world generation plugin "Chunky" to achieve this.
randomizeSpawn: false
maxEntitiesPerChunk: 50
maxEntitiesPerWorld: 5120