public static Location findSpawnLocation(Location startLocation, boolean createPortals) {
WorldServer ws = CommonNMS.getNative(startLocation.getWorld());
// Use a new travel agent to designate a proper position
CraftTravelAgent travelAgent = new CraftTravelAgent(ws);
travelAgent.setCanCreatePortal(createPortals);
Location exit = travelAgent.findOrCreate(startLocation);
// Adjust the exit to make it suitable for players
// Note: this will raise an NPE while trying to fire the PortalExit event
// This is expected behavior
try {
travelAgent.adjustExit((Entity) findSpawnDummyEntity, exit, new Vector(0, 0, 0));