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

This commit is contained in:
Allink 2022-05-20 11:20:25 +01:00
parent 341e8834fc
commit 970efe2cd7
No known key found for this signature in database
GPG key ID: 7F1F1B98F0FAAD13

View file

@ -30,7 +30,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;
@ -127,11 +126,11 @@ 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);
}
}