From 605fcf90dd79e542596e1467cb2f449cef5f7262 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 24 Feb 2017 23:50:37 +0000 Subject: [PATCH] Stop players spawning near others when joining --- .../mineplex/gemhunters/spawn/SpawnModule.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java index 61b10eaea..e2cc05ba2 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/spawn/SpawnModule.java @@ -1,5 +1,6 @@ package mineplex.gemhunters.spawn; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.WorldBorder; @@ -20,6 +21,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilServer; import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; @@ -39,7 +41,8 @@ public class SpawnModule extends MiniPlugin public static final int WORLD_BORDER_RADIUS = 1024; private static final int MAX_SPAWNING_Y = 73; - + private static final int MIN_PLAYER_DISTANCE_SQUARED = 6400; + private final SafezoneModule _safezone; private final WorldDataModule _worldData; @@ -178,6 +181,19 @@ public class SpawnModule extends MiniPlugin { return false; } + + for (Player player : Bukkit.getOnlinePlayers()) + { + if (_safezone.isInSafeZone(player.getLocation())) + { + continue; + } + + if (UtilMath.offsetSquared(player.getLocation(), block.getLocation()) < MIN_PLAYER_DISTANCE_SQUARED) + { + return false; + } + } return true; }