diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommand.java index acfc59be0..340cd7a24 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommand.java @@ -20,7 +20,7 @@ public void runCommand(Player player, List arguments) { if (spawnLoader.getFirstSpawn() == null) { player.sendMessage("[AuthMe] First spawn has failed, please try to define the first spawn"); } else { - player.teleport(spawnLoader.getFirstSpawn()); + player.teleportAsync(spawnLoader.getFirstSpawn()); } } } diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/SpawnCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/SpawnCommand.java index 3c011e6da..22f37ea93 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/SpawnCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/SpawnCommand.java @@ -17,7 +17,7 @@ public void runCommand(Player player, List arguments) { if (spawnLoader.getSpawn() == null) { player.sendMessage("[AuthMe] Spawn has failed, please try to define the spawn"); } else { - player.teleport(spawnLoader.getSpawn()); + player.teleportAsync(spawnLoader.getSpawn()); } } } diff --git a/src/main/java/fr/xephi/authme/listener/PlayerListener.java b/src/main/java/fr/xephi/authme/listener/PlayerListener.java index f49ce0e84..a2540b61d 100644 --- a/src/main/java/fr/xephi/authme/listener/PlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/PlayerListener.java @@ -357,9 +357,9 @@ public void onPlayerMove(PlayerMoveEvent event) { Location spawn = spawnLoader.getSpawnLocation(player); if (spawn != null && spawn.getWorld() != null) { if (!player.getWorld().equals(spawn.getWorld())) { - player.teleport(spawn); + player.teleportAsync(spawn); } else if (spawn.distance(player.getLocation()) > settings.getProperty(ALLOWED_MOVEMENT_RADIUS)) { - player.teleport(spawn); + player.teleportAsync(spawn); } } } diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommandTest.java index 4b1af2b97..6b7929b4f 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/FirstSpawnCommandTest.java @@ -43,7 +43,7 @@ public void shouldTeleportToFirstSpawn() { command.executeCommand(player, Collections.emptyList()); // then - verify(player).teleport(firstSpawn); + verify(player).teleportAsync(firstSpawn); verify(spawnLoader, atLeastOnce()).getFirstSpawn(); } @@ -58,6 +58,6 @@ public void shouldHandleMissingFirstSpawn() { // then verify(player).sendMessage(argThat(containsString("spawn has failed"))); - verify(player, never()).teleport(any(Location.class)); + verify(player, never()).teleportAsync(any(Location.class)); } } diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/SpawnCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/SpawnCommandTest.java index b9566c98b..957c9c8d3 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/SpawnCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/SpawnCommandTest.java @@ -44,7 +44,7 @@ public void shouldTeleportToSpawn() { command.executeCommand(player, Collections.emptyList()); // then - verify(player).teleport(spawn); + verify(player).teleportAsync(spawn); verify(spawnLoader, atLeastOnce()).getSpawn(); } @@ -59,6 +59,6 @@ public void shouldHandleMissingSpawn() { // then verify(player).sendMessage(argThat(containsString("Spawn has failed"))); - verify(player, never()).teleport(any(Location.class)); + verify(player, never()).teleportAsync(any(Location.class)); } } diff --git a/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java b/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java index 6ea299732..a228b1ed3 100644 --- a/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java +++ b/src/test/java/fr/xephi/authme/listener/PlayerListenerTest.java @@ -478,7 +478,7 @@ public void shouldTeleportPlayerInDifferentWorldToSpawn() { // then verify(listenerService).shouldCancelEvent(player); - verify(player).teleport(spawn); + verify(player).teleportAsync(spawn); verify(spawnLoader).getSpawnLocation(player); verifyNoModifyingCalls(event); } @@ -506,7 +506,7 @@ public void shouldAllowMovementWithinRadius() { // then verify(listenerService).shouldCancelEvent(player); - verify(player, never()).teleport(any(Location.class)); + verify(player, never()).teleportAsync(any(Location.class)); verify(spawnLoader).getSpawnLocation(player); verifyNoModifyingCalls(event); } @@ -534,7 +534,7 @@ public void shouldRejectMovementOutsideOfRadius() { // then verify(listenerService).shouldCancelEvent(player); - verify(player).teleport(spawn); + verify(player).teleportAsync(spawn); verify(spawnLoader).getSpawnLocation(player); verifyNoModifyingCalls(event); } diff --git a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java index 46db5e05c..758b4bc6a 100644 --- a/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java +++ b/src/test/java/fr/xephi/authme/service/TeleportationServiceTest.java @@ -95,7 +95,7 @@ public void shouldTeleportPlayerToFirstSpawn() { teleportationService.teleportNewPlayerToFirstSpawn(player); // then - verify(player).teleport(firstSpawn); + verify(player).teleportAsync(firstSpawn); verify(bukkitService).callEvent(any(FirstSpawnTeleportEvent.class)); verify(spawnLoader).getFirstSpawn(); verify(spawnLoader, never()).getSpawnLocation(any(Player.class)); @@ -115,7 +115,7 @@ public void shouldTeleportPlayerToSpawn() { teleportationService.teleportOnJoin(player); // then - verify(player).teleport(spawn); + verify(player).teleportAsync(spawn); verify(bukkitService).callEvent(any(SpawnTeleportEvent.class)); verify(spawnLoader).getSpawnLocation(player); } @@ -131,7 +131,7 @@ public void shouldNotTeleportNewPlayer() { teleportationService.teleportNewPlayerToFirstSpawn(player); // then - verify(player, never()).teleport(any(Location.class)); + verify(player, never()).teleportAsync(any(Location.class)); verify(spawnLoader).getFirstSpawn(); verify(spawnLoader, never()).getSpawnLocation(any(Player.class)); verifyNoInteractions(bukkitService); @@ -147,7 +147,7 @@ public void shouldNotTeleportPlayerToFirstSpawnIfNoTeleportEnabled() { teleportationService.teleportNewPlayerToFirstSpawn(player); // then - verify(player, never()).teleport(any(Location.class)); + verify(player, never()).teleportAsync(any(Location.class)); verifyNoInteractions(bukkitService); } @@ -161,7 +161,7 @@ public void shouldNotTeleportNotNewPlayerToFirstSpawn() { teleportationService.teleportNewPlayerToFirstSpawn(player); // then - verify(player, never()).teleport(any(Location.class)); + verify(player, never()).teleportAsync(any(Location.class)); verifyNoInteractions(bukkitService); } @@ -185,7 +185,7 @@ public void shouldNotTeleportPlayerForRemovedLocationInEvent() { // then verify(bukkitService).callEvent(any(SpawnTeleportEvent.class)); - verify(player, never()).teleport(any(Location.class)); + verify(player, never()).teleportAsync(any(Location.class)); } @Test @@ -208,7 +208,7 @@ public void shouldNotTeleportPlayerForCanceledEvent() { // then verify(bukkitService).callEvent(any(SpawnTeleportEvent.class)); - verify(player, never()).teleport(any(Location.class)); + verify(player, never()).teleportAsync(any(Location.class)); } // --------- @@ -248,7 +248,7 @@ public void shouldTeleportPlayerToSpawnAfterLogin() { teleportationService.teleportOnLogin(player, auth, limbo); // then - verify(player).teleport(spawn); + verify(player).teleportAsync(spawn); } @Test @@ -269,7 +269,7 @@ public void shouldNotTeleportToSpawnForOtherCaseInWorld() { teleportationService.teleportOnLogin(player, auth, limbo); // then - verify(player, never()).teleport(spawn); + verify(player, never()).teleportAsync(spawn); verifyNoInteractions(bukkitService, spawnLoader); } @@ -296,7 +296,7 @@ public void shouldTeleportBackToPlayerAuthLocation() { // then ArgumentCaptor locationCaptor = ArgumentCaptor.forClass(Location.class); - verify(player).teleport(locationCaptor.capture()); + verify(player).teleportAsync(locationCaptor.capture()); assertCorrectLocation(locationCaptor.getValue(), auth, world); } @@ -324,7 +324,7 @@ public void shouldTeleportAccordingToPlayerAuthAndPlayerWorldAsFallback() { // then ArgumentCaptor locationCaptor = ArgumentCaptor.forClass(Location.class); - verify(player).teleport(locationCaptor.capture()); + verify(player).teleportAsync(locationCaptor.capture()); assertCorrectLocation(locationCaptor.getValue(), auth, world); } @@ -348,7 +348,7 @@ public void shouldTeleportWithLimboPlayerIfAuthYCoordIsNotSet() { teleportationService.teleportOnLogin(player, auth, limbo); // then - verify(player).teleport(location); + verify(player).teleportAsync(location); verify(bukkitService, never()).getWorld(anyString()); } @@ -370,7 +370,7 @@ public void shouldTeleportWithLimboPlayerIfSaveQuitLocIsDisabled() { teleportationService.teleportOnLogin(player, auth, limbo); // then - verify(player).teleport(location); + verify(player).teleportAsync(location); } @Test