mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 12:45:57 +01:00
Fixing PLayerListener kick message/tests
This commit is contained in:
parent
55b6f67550
commit
048a47ce6e
@ -105,7 +105,7 @@ public class PlayerListener implements Listener {
|
||||
final Player player = event.getPlayer();
|
||||
if (!quickCommandsProtectionManager.isAllowed(player.getName())) {
|
||||
event.setCancelled(true);
|
||||
player.kickPlayer(m.retrieveSingle(MessageKey.QUICK_COMMAND_PROTECTION_KICK));
|
||||
player.kickPlayer(m.retrieveSingle(player, MessageKey.QUICK_COMMAND_PROTECTION_KICK));
|
||||
return;
|
||||
}
|
||||
if (listenerService.shouldCancelEvent(player)) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import fr.xephi.authme.TestHelper;
|
||||
import fr.xephi.authme.data.QuickCommandsProtectionManager;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
@ -110,6 +111,8 @@ public class PlayerListenerTest {
|
||||
private ValidationService validationService;
|
||||
@Mock
|
||||
private JoinMessageService joinMessageService;
|
||||
@Mock
|
||||
private QuickCommandsProtectionManager quickCommandsProtectionManager;
|
||||
|
||||
/**
|
||||
* #831: If a player is kicked because of "logged in from another location", the kick
|
||||
@ -219,6 +222,7 @@ public class PlayerListenerTest {
|
||||
// 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);
|
||||
given(quickCommandsProtectionManager.isAllowed(player.getName())).willReturn(true);
|
||||
|
||||
// when
|
||||
listener.onPlayerCommandPreprocess(event);
|
||||
@ -238,6 +242,7 @@ public class PlayerListenerTest {
|
||||
Player player = playerWithMockedServer();
|
||||
PlayerCommandPreprocessEvent event = spy(new PlayerCommandPreprocessEvent(player, "/hub"));
|
||||
given(listenerService.shouldCancelEvent(player)).willReturn(true);
|
||||
given(quickCommandsProtectionManager.isAllowed(player.getName())).willReturn(true);
|
||||
|
||||
// when
|
||||
listener.onPlayerCommandPreprocess(event);
|
||||
@ -248,6 +253,23 @@ public class PlayerListenerTest {
|
||||
verify(messages).send(player, MessageKey.DENIED_COMMAND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCancelCommandFastCommandEvent() {
|
||||
// given
|
||||
given(settings.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)).willReturn(false);
|
||||
given(settings.getProperty(RestrictionSettings.ALLOW_COMMANDS)).willReturn(Arrays.asList("/spawn", "/help"));
|
||||
Player player = playerWithMockedServer();
|
||||
PlayerCommandPreprocessEvent event = spy(new PlayerCommandPreprocessEvent(player, "/hub"));
|
||||
given(quickCommandsProtectionManager.isAllowed(player.getName())).willReturn(false);
|
||||
|
||||
// when
|
||||
listener.onPlayerCommandPreprocess(event);
|
||||
|
||||
// then
|
||||
verify(event).setCancelled(true);
|
||||
verify(player).kickPlayer(messages.retrieveSingle(player, MessageKey.QUICK_COMMAND_PROTECTION_KICK));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldAllowChat() {
|
||||
// given
|
||||
|
Loading…
Reference in New Issue
Block a user