Search in sources :

Example 6 with PlayerJoinEvent

use of org.bukkit.event.player.PlayerJoinEvent in project AuthMeReloaded by AuthMe.

the class PlayerListenerTest method shouldRemoveJoinMessage.

@Test
public void shouldRemoveJoinMessage() {
    // given
    Player player = mock(Player.class);
    String joinMsg = "The player joined";
    PlayerJoinEvent event = new PlayerJoinEvent(player, joinMsg);
    given(settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)).willReturn(true);
    // when
    listener.onJoinMessage(event);
    // then
    assertThat(event.getJoinMessage(), nullValue());
    verifyZeroInteractions(joinMessageService);
}
Also used : PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) Player(org.bukkit.entity.Player) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 7 with PlayerJoinEvent

use of org.bukkit.event.player.PlayerJoinEvent in project AuthMeReloaded by AuthMe.

the class PlayerListenerTest method shouldUseCustomMessage.

@Test
public void shouldUseCustomMessage() {
    // given
    Player player = mock(Player.class);
    given(player.getName()).willReturn("doooew");
    given(player.getDisplayName()).willReturn("Displ");
    String joinMsg = "The player joined";
    PlayerJoinEvent event = new PlayerJoinEvent(player, joinMsg);
    given(settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)).willReturn(false);
    given(settings.getProperty(RegistrationSettings.CUSTOM_JOIN_MESSAGE)).willReturn("Hello {PLAYERNAME} (aka {DISPLAYNAME})");
    given(settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)).willReturn(false);
    // when
    listener.onJoinMessage(event);
    // then
    assertThat(event.getJoinMessage(), equalTo("Hello doooew (aka Displ)"));
    verifyZeroInteractions(joinMessageService);
}
Also used : PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent) Player(org.bukkit.entity.Player) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 8 with PlayerJoinEvent

use of org.bukkit.event.player.PlayerJoinEvent in project Essentials by drtshock.

the class FakeServer method addPlayer.

public void addPlayer(Player base1) {
    players.add(base1);
    pluginManager.callEvent(new PlayerJoinEvent(base1, null));
}
Also used : PlayerJoinEvent(org.bukkit.event.player.PlayerJoinEvent)

Aggregations

PlayerJoinEvent (org.bukkit.event.player.PlayerJoinEvent)8 Player (org.bukkit.entity.Player)6 Test (org.junit.Test)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Listener (org.bukkit.event.Listener)2 PluginManager (org.bukkit.plugin.PluginManager)2 SignBlockListener (com.earth2me.essentials.signs.SignBlockListener)1 SignEntityListener (com.earth2me.essentials.signs.SignEntityListener)1 SignPlayerListener (com.earth2me.essentials.signs.SignPlayerListener)1 Event (org.bukkit.event.Event)1 EventException (org.bukkit.event.EventException)1 EventHandler (org.bukkit.event.EventHandler)1 PlayerRespawnEvent (org.bukkit.event.player.PlayerRespawnEvent)1 EventExecutor (org.bukkit.plugin.EventExecutor)1