Merge pull request #2888 from HaHaWTH/upstream/fix/y0-teleport

Fix y = 0 teleportUnAuthedToSpawn bug
This commit is contained in:
Gabriele C. 2024-10-21 21:03:34 +02:00 committed by GitHub
commit 46cb7178c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 27 deletions

View File

@ -90,6 +90,11 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
} }
final PlayerAuth auth = playerCache.getAuth(name); final PlayerAuth auth = playerCache.getAuth(name);
if (isFirstLogin) { // Save quit location before login teleport
auth.setQuitLocation(player.getLocation());
}
teleportationService.teleportOnLogin(player, auth, limbo); teleportationService.teleportOnLogin(player, auth, limbo);
// We can now display the join message (if delayed) // We can now display the join message (if delayed)

View File

@ -140,7 +140,7 @@ public class TeleportationService implements Reloadable {
logger.debug("Teleporting `{0}` to spawn because of 'force-spawn after login'", player.getName()); logger.debug("Teleporting `{0}` to spawn because of 'force-spawn after login'", player.getName());
teleportToSpawn(player, true); teleportToSpawn(player, true);
} else if (settings.getProperty(TELEPORT_UNAUTHED_TO_SPAWN)) { } else if (settings.getProperty(TELEPORT_UNAUTHED_TO_SPAWN)) {
if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION) && auth.getQuitLocY() != 0) { if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
Location location = buildLocationFromAuth(player, auth); Location location = buildLocationFromAuth(player, auth);
logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName()); logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName());
teleportBackFromSpawn(player, location); teleportBackFromSpawn(player, location);

View File

@ -22,10 +22,9 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.util.Arrays; import java.util.Arrays;
import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask; import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -328,30 +327,6 @@ public class TeleportationServiceTest {
assertCorrectLocation(locationCaptor.getValue(), auth, world); assertCorrectLocation(locationCaptor.getValue(), auth, world);
} }
@Test
public void shouldTeleportWithLimboPlayerIfAuthYCoordIsNotSet() {
// given
given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(true);
given(settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)).willReturn(true);
PlayerAuth auth = createAuthWithLocation();
auth.setQuitLocY(0.0);
auth.setWorld("authWorld");
Player player = mock(Player.class);
given(player.isOnline()).willReturn(true);
LimboPlayer limbo = mock(LimboPlayer.class);
Location location = mockLocation();
given(limbo.getLocation()).willReturn(location);
setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService);
// when
teleportationService.teleportOnLogin(player, auth, limbo);
// then
verify(player).teleport(location);
verify(bukkitService, never()).getWorld(anyString());
}
@Test @Test
public void shouldTeleportWithLimboPlayerIfSaveQuitLocIsDisabled() { public void shouldTeleportWithLimboPlayerIfSaveQuitLocIsDisabled() {
// given // given