Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix y = 0 teleportUnAuthedToSpawn bug #2888

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public void processPlayerLogin(Player player, boolean isFirstLogin, List<String>
}

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void teleportOnLogin(final Player player, PlayerAuth auth, LimboPlayer li
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
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;
Expand Down Expand Up @@ -328,30 +327,6 @@ public void shouldTeleportAccordingToPlayerAuthAndPlayerWorldAsFallback() {
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
Expand Down
Loading