Stop players spawning near others when joining

This commit is contained in:
Sam 2017-02-24 23:50:37 +00:00
parent 02a2f98601
commit 605fcf90dd

View File

@ -1,5 +1,6 @@
package mineplex.gemhunters.spawn; package mineplex.gemhunters.spawn;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.WorldBorder; 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.F;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.portal.GenericServer; import mineplex.core.portal.GenericServer;
import mineplex.core.portal.Intent; import mineplex.core.portal.Intent;
@ -39,6 +41,7 @@ public class SpawnModule extends MiniPlugin
public static final int WORLD_BORDER_RADIUS = 1024; public static final int WORLD_BORDER_RADIUS = 1024;
private static final int MAX_SPAWNING_Y = 73; private static final int MAX_SPAWNING_Y = 73;
private static final int MIN_PLAYER_DISTANCE_SQUARED = 6400;
private final SafezoneModule _safezone; private final SafezoneModule _safezone;
private final WorldDataModule _worldData; private final WorldDataModule _worldData;
@ -179,6 +182,19 @@ public class SpawnModule extends MiniPlugin
return false; 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; return true;
} }