#1280 Add NOTHING as possible flight restore type
This commit is contained in:
@@ -6,6 +6,7 @@ import org.junit.Test;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
|
||||
/**
|
||||
* Test for {@link AllowFlightRestoreType}.
|
||||
@@ -64,6 +65,42 @@ public class AllowFlightRestoreTypeTest {
|
||||
verify(player2).setAllowFlight(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotInteractWithPlayer() {
|
||||
// given
|
||||
LimboPlayer limboWithFly = newLimboWithAllowFlight(true);
|
||||
LimboPlayer limboWithoutFly = newLimboWithAllowFlight(false);
|
||||
Player player1 = mock(Player.class);
|
||||
Player player2 = mock(Player.class);
|
||||
|
||||
// when
|
||||
AllowFlightRestoreType.NOTHING.restoreAllowFlight(player1, limboWithFly);
|
||||
AllowFlightRestoreType.NOTHING.restoreAllowFlight(player2, limboWithoutFly);
|
||||
|
||||
// then
|
||||
verifyZeroInteractions(player1, player2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRemoveFlightExceptForNothingType() {
|
||||
// given
|
||||
AllowFlightRestoreType noInteractionType = AllowFlightRestoreType.NOTHING;
|
||||
|
||||
for (AllowFlightRestoreType type : AllowFlightRestoreType.values()) {
|
||||
Player player = mock(Player.class);
|
||||
|
||||
// when
|
||||
type.processPlayer(player);
|
||||
|
||||
// then
|
||||
if (type == noInteractionType) {
|
||||
verifyZeroInteractions(player);
|
||||
} else {
|
||||
verify(player).setAllowFlight(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static LimboPlayer newLimboWithAllowFlight(boolean allowFlight) {
|
||||
LimboPlayer limbo = mock(LimboPlayer.class);
|
||||
given(limbo.isCanFly()).willReturn(allowFlight);
|
||||
|
||||
@@ -84,6 +84,7 @@ public class LimboServiceTest {
|
||||
given(spawnLoader.getPlayerLocationOrSpawn(player)).willReturn(playerLoc);
|
||||
given(permissionsManager.hasGroupSupport()).willReturn(true);
|
||||
given(permissionsManager.getGroups(player)).willReturn(Collections.singletonList("permgrwp"));
|
||||
given(settings.getProperty(LimboSettings.RESTORE_ALLOW_FLIGHT)).willReturn(AllowFlightRestoreType.ENABLE);
|
||||
|
||||
// when
|
||||
limboService.createLimboPlayer(player, true);
|
||||
@@ -114,6 +115,7 @@ public class LimboServiceTest {
|
||||
Location playerLoc = mock(Location.class);
|
||||
given(spawnLoader.getPlayerLocationOrSpawn(player)).willReturn(playerLoc);
|
||||
given(permissionsManager.hasGroupSupport()).willReturn(false);
|
||||
given(settings.getProperty(LimboSettings.RESTORE_ALLOW_FLIGHT)).willReturn(AllowFlightRestoreType.RESTORE);
|
||||
|
||||
// when
|
||||
limboService.createLimboPlayer(player, false);
|
||||
@@ -143,6 +145,7 @@ public class LimboServiceTest {
|
||||
LimboPlayer existingLimbo = mock(LimboPlayer.class);
|
||||
getLimboMap().put("carlos", existingLimbo);
|
||||
Player player = newPlayer("Carlos");
|
||||
given(settings.getProperty(LimboSettings.RESTORE_ALLOW_FLIGHT)).willReturn(AllowFlightRestoreType.ENABLE);
|
||||
|
||||
// when
|
||||
limboService.createLimboPlayer(player, false);
|
||||
|
||||
Reference in New Issue
Block a user