use of fr.xephi.authme.data.limbo.LimboPlayer in project AuthMeReloaded by AuthMe.
the class IndividualFilesPersistenceHandlerTest method shouldSavePlayerData.
@Test
public void shouldSavePlayerData() {
// given
Player player = mock(Player.class);
UUID uuid = UUID.nameUUIDFromBytes("New player".getBytes());
given(player.getUniqueId()).willReturn(uuid);
World world = mock(World.class);
given(world.getName()).willReturn("player-world");
Location location = new Location(world, 0.2, 102.25, -89.28, 3.02f, 90.13f);
String group = "primary-grp";
LimboPlayer limbo = new LimboPlayer(location, true, group, true, 1.2f, 0.8f);
// when
handler.saveLimboPlayer(player, limbo);
// then
File playerFile = new File(dataFolder, FileUtils.makePath("playerdata", uuid.toString(), "data.json"));
assertThat(playerFile.exists(), equalTo(true));
// TODO ljacqu 20160711: Check contents of file
}
use of fr.xephi.authme.data.limbo.LimboPlayer in project AuthMeReloaded by AuthMe.
the class LimboPersistenceTest method shouldDelegateToHandler.
@Test
public void shouldDelegateToHandler() {
// given
Player player = mock(Player.class);
LimboPersistenceHandler handler = getHandler();
LimboPlayer limbo = mock(LimboPlayer.class);
given(handler.getLimboPlayer(player)).willReturn(limbo);
// when
LimboPlayer result = limboPersistence.getLimboPlayer(player);
limboPersistence.saveLimboPlayer(player, mock(LimboPlayer.class));
limboPersistence.removeLimboPlayer(mock(Player.class));
// then
assertThat(result, equalTo(limbo));
verify(handler).getLimboPlayer(player);
verify(handler).saveLimboPlayer(eq(player), argThat(notNullAndDifferentFrom(limbo)));
verify(handler).removeLimboPlayer(argThat(notNullAndDifferentFrom(player)));
}
use of fr.xephi.authme.data.limbo.LimboPlayer in project AuthMeReloaded by AuthMe.
the class TeleportationServiceTest method shouldTeleportAccordingToPlayerAuthAndPlayerWorldAsFallback.
@Test
public void shouldTeleportAccordingToPlayerAuthAndPlayerWorldAsFallback() {
// given
given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(true);
given(settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)).willReturn(true);
PlayerAuth auth = createAuthWithLocation();
auth.setWorld("myWorld");
given(bukkitService.getWorld("myWorld")).willReturn(null);
Player player = mock(Player.class);
given(player.isOnline()).willReturn(true);
World world = mock(World.class);
given(player.getWorld()).willReturn(world);
LimboPlayer limbo = mock(LimboPlayer.class);
Location limboLocation = mockLocation();
given(limbo.getLocation()).willReturn(limboLocation);
// when
teleportationService.teleportOnLogin(player, auth, limbo);
runSyncDelayedTask(bukkitService);
// then
ArgumentCaptor<Location> locationCaptor = ArgumentCaptor.forClass(Location.class);
verify(player).teleport(locationCaptor.capture());
assertCorrectLocation(locationCaptor.getValue(), auth, world);
}
use of fr.xephi.authme.data.limbo.LimboPlayer in project AuthMeReloaded by AuthMe.
the class TeleportationServiceTest method shouldNotTeleportToSpawnForOtherCaseInWorld.
@Test
public // Check that the worlds for "force spawn loc after login" are case-sensitive
void shouldNotTeleportToSpawnForOtherCaseInWorld() {
// given
given(settings.getProperty(RestrictionSettings.FORCE_SPAWN_LOCATION_AFTER_LOGIN)).willReturn(true);
given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(false);
Player player = mock(Player.class);
Location spawn = mockLocation();
PlayerAuth auth = mock(PlayerAuth.class);
LimboPlayer limbo = mock(LimboPlayer.class);
Location limboLocation = mockLocation();
// different case
given(limboLocation.getWorld().getName()).willReturn("Forced1");
given(limbo.getLocation()).willReturn(limboLocation);
// when
teleportationService.teleportOnLogin(player, auth, limbo);
// then
verify(player, never()).teleport(spawn);
verifyZeroInteractions(bukkitService, spawnLoader);
}
use of fr.xephi.authme.data.limbo.LimboPlayer in project AuthMeReloaded by AuthMe.
the class TeleportationServiceTest method shouldTeleportWithLimboPlayerIfSaveQuitLocIsDisabled.
@Test
public void shouldTeleportWithLimboPlayerIfSaveQuitLocIsDisabled() {
// given
given(settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)).willReturn(true);
given(settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)).willReturn(false);
PlayerAuth auth = createAuthWithLocation();
Player player = mock(Player.class);
given(player.isOnline()).willReturn(true);
LimboPlayer limbo = mock(LimboPlayer.class);
Location location = mockLocation();
given(limbo.getLocation()).willReturn(location);
// when
teleportationService.teleportOnLogin(player, auth, limbo);
runSyncDelayedTask(bukkitService);
// then
verify(player).teleport(location);
}
Aggregations