mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-23 10:45:23 +01:00
Teleportation needs to be scheduled in sync
- Revert removal of sync scheduled task for teleportation
- Add back listener properties from 5d6f3e1
since they don't interfere
This commit is contained in:
parent
306160e675
commit
8002ef45fd
@ -193,7 +193,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
teleportationService.teleportNewPlayerToFirstSpawn(player);
|
||||
@ -206,7 +206,7 @@ public class PlayerListener implements Listener {
|
||||
// event caused by "logged in from another location". The nicer way, but only for Spigot, would be
|
||||
// to check in the AsyncPlayerPreLoginEvent. To support all servers, we use the less nice way.
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final String name = player.getName();
|
||||
|
@ -158,10 +158,15 @@ public class TeleportationService implements Reloadable {
|
||||
* @param event the event to emit and according to which to teleport
|
||||
*/
|
||||
private void performTeleportation(final Player player, final AbstractTeleportEvent event) {
|
||||
bukkitService.callEvent(event);
|
||||
if (player.isOnline() && isEventValid(event)) {
|
||||
player.teleport(event.getTo());
|
||||
}
|
||||
bukkitService.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bukkitService.callEvent(event);
|
||||
if (player.isOnline() && isEventValid(event)) {
|
||||
player.teleport(event.getTo());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean isEventValid(AbstractTeleportEvent event) {
|
||||
|
@ -23,6 +23,7 @@ import org.mockito.stubbing.Answer;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static fr.xephi.authme.TestHelper.runSyncDelayedTask;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
@ -93,6 +94,7 @@ public class TeleportationServiceTest {
|
||||
|
||||
// when
|
||||
teleportationService.teleportNewPlayerToFirstSpawn(player);
|
||||
runSyncDelayedTask(bukkitService);
|
||||
|
||||
// then
|
||||
verify(player).teleport(firstSpawn);
|
||||
@ -112,6 +114,7 @@ public class TeleportationServiceTest {
|
||||
|
||||
// when
|
||||
teleportationService.teleportOnJoin(player);
|
||||
runSyncDelayedTask(bukkitService);
|
||||
|
||||
// then
|
||||
verify(player).teleport(spawn);
|
||||
@ -190,6 +193,7 @@ public class TeleportationServiceTest {
|
||||
|
||||
// when
|
||||
teleportationService.teleportOnJoin(player);
|
||||
runSyncDelayedTask(bukkitService);
|
||||
|
||||
// then
|
||||
verify(bukkitService).callEvent(any(SpawnTeleportEvent.class));
|
||||
@ -215,6 +219,7 @@ public class TeleportationServiceTest {
|
||||
|
||||
// when
|
||||
teleportationService.teleportOnJoin(player);
|
||||
runSyncDelayedTask(bukkitService);
|
||||
|
||||
// then
|
||||
verify(bukkitService).callEvent(any(SpawnTeleportEvent.class));
|
||||
@ -255,6 +260,7 @@ public class TeleportationServiceTest {
|
||||
|
||||
// when
|
||||
teleportationService.teleportOnLogin(player, auth, limbo);
|
||||
runSyncDelayedTask(bukkitService);
|
||||
|
||||
// then
|
||||
verify(player).teleport(spawn);
|
||||
@ -304,6 +310,7 @@ public class TeleportationServiceTest {
|
||||
|
||||
// when
|
||||
teleportationService.teleportOnLogin(player, auth, limbo);
|
||||
runSyncDelayedTask(bukkitService);
|
||||
|
||||
// then
|
||||
ArgumentCaptor<Location> locationCaptor = ArgumentCaptor.forClass(Location.class);
|
||||
@ -332,6 +339,7 @@ public class TeleportationServiceTest {
|
||||
|
||||
// when
|
||||
teleportationService.teleportOnLogin(player, auth, limbo);
|
||||
runSyncDelayedTask(bukkitService);
|
||||
|
||||
// then
|
||||
ArgumentCaptor<Location> locationCaptor = ArgumentCaptor.forClass(Location.class);
|
||||
@ -359,6 +367,7 @@ public class TeleportationServiceTest {
|
||||
|
||||
// when
|
||||
teleportationService.teleportOnLogin(player, auth, limbo);
|
||||
runSyncDelayedTask(bukkitService);
|
||||
|
||||
// then
|
||||
verify(player).teleport(location);
|
||||
@ -383,6 +392,7 @@ public class TeleportationServiceTest {
|
||||
|
||||
// when
|
||||
teleportationService.teleportOnLogin(player, auth, limbo);
|
||||
runSyncDelayedTask(bukkitService);
|
||||
|
||||
// then
|
||||
verify(player).teleport(location);
|
||||
|
Loading…
Reference in New Issue
Block a user