From fc011dcbaf1bd9d6f6086b5007d22d454b567768 Mon Sep 17 00:00:00 2001 From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> Date: Sun, 20 Oct 2024 23:56:50 +0800 Subject: [PATCH 1/2] Fix y = 0 teleport bug --- .../xephi/authme/process/login/ProcessSyncPlayerLogin.java | 5 +++++ .../java/fr/xephi/authme/service/TeleportationService.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java index 74946039a..8d1b18540 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java @@ -90,6 +90,11 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess { } final PlayerAuth auth = playerCache.getAuth(name); + + if (isFirstLogin) { // Save quit location before login teleport + auth.setQuitLocation(player.getLocation()); + } + teleportationService.teleportOnLogin(player, auth, limbo); // We can now display the join message (if delayed) diff --git a/src/main/java/fr/xephi/authme/service/TeleportationService.java b/src/main/java/fr/xephi/authme/service/TeleportationService.java index f0eb7f851..881062547 100644 --- a/src/main/java/fr/xephi/authme/service/TeleportationService.java +++ b/src/main/java/fr/xephi/authme/service/TeleportationService.java @@ -140,7 +140,7 @@ public class TeleportationService implements Reloadable { logger.debug("Teleporting `{0}` to spawn because of 'force-spawn after login'", player.getName()); teleportToSpawn(player, true); } 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); logger.debug("Teleporting `{0}` after login, based on the player auth", player.getName()); teleportBackFromSpawn(player, location); From 8ee60e67802229d1dad1b840dd3d4d9128a9722e Mon Sep 17 00:00:00 2001 From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com> Date: Mon, 21 Oct 2024 00:24:57 +0800 Subject: [PATCH 2/2] Remove validation test since y coordinate is always set --- .../service/TeleportationServiceTest.java | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java index 7041a1e3e..4028cdf73 100644 --- a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java @@ -22,10 +22,9 @@ import org.mockito.junit.MockitoJUnitRunner; import java.util.Arrays; import static fr.xephi.authme.service.BukkitServiceTestHelper.setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask; -import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; @@ -328,30 +327,6 @@ public class TeleportationServiceTest { 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 public void shouldTeleportWithLimboPlayerIfSaveQuitLocIsDisabled() { // given