use of org.bukkit.event.player.PlayerCommandPreprocessEvent in project AuthMeReloaded by AuthMe.
the class PlayerListenerTest method shouldNotCancelEventForAuthenticatedPlayer.
@Test
public void shouldNotCancelEventForAuthenticatedPlayer() {
// given
given(settings.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)).willReturn(false);
given(settings.getProperty(RestrictionSettings.ALLOW_COMMANDS)).willReturn(Collections.emptyList());
Player player = playerWithMockedServer();
// PlayerCommandPreprocessEvent#getPlayer is final, so create a spy instead of a mock
PlayerCommandPreprocessEvent event = spy(new PlayerCommandPreprocessEvent(player, "/hub"));
given(listenerService.shouldCancelEvent(player)).willReturn(false);
// when
listener.onPlayerCommandPreprocess(event);
// then
verify(event).getMessage();
verifyNoMoreInteractions(event);
verify(listenerService).shouldCancelEvent(player);
verifyZeroInteractions(messages);
}
Aggregations