From 970efe2cd78f57e61266a4956ce2ba6d44f91c2e Mon Sep 17 00:00:00 2001 From: Allink Date: Fri, 20 May 2022 11:20:25 +0100 Subject: [PATCH] Limit random spawn to half a million blocks, which should hopefully fix the OOB error --- .../kaboom/extras/modules/player/PlayerConnection.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java index d1fbed8..3208eac 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java @@ -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); } }