use of org.bukkit.event.player.PlayerJoinEvent in project AuthMeReloaded by AuthMe.
the class PlayerListenerTest method shouldNotModifyJoinMessage.
@Test
public void shouldNotModifyJoinMessage() {
// 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(false);
given(settings.getProperty(RegistrationSettings.CUSTOM_JOIN_MESSAGE)).willReturn("");
given(settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)).willReturn(false);
// when
listener.onJoinMessage(event);
// then
assertThat(event.getJoinMessage(), equalTo(joinMsg));
verifyZeroInteractions(joinMessageService);
}
use of org.bukkit.event.player.PlayerJoinEvent in project AuthMeReloaded by AuthMe.
the class PlayerListenerTest method shouldDelayJoinMessage.
@Test
public void shouldDelayJoinMessage() {
// given
Player player = mock(Player.class);
given(player.getName()).willReturn("thename0");
given(player.getDisplayName()).willReturn("(not used)");
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("{PLAYERNAME} is joining us");
given(settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)).willReturn(true);
// when
listener.onJoinMessage(event);
// then
assertThat(event.getJoinMessage(), nullValue());
verify(joinMessageService).putMessage("thename0", "thename0 is joining us");
}
use of org.bukkit.event.player.PlayerJoinEvent in project AuthMeReloaded by AuthMe.
the class PlayerListenerTest method shouldHandlePlayerJoining.
@Test
public void shouldHandlePlayerJoining() {
// given
Player player = mock(Player.class);
PlayerJoinEvent event = new PlayerJoinEvent(player, "join message");
// when
listener.onPlayerJoin(event);
// then
verify(teleportationService).teleportNewPlayerToFirstSpawn(player);
verify(management).performJoin(player);
}
use of org.bukkit.event.player.PlayerJoinEvent in project Essentials by drtshock.
the class EssentialsSpawn method onEnable.
@Override
public void onEnable() {
final PluginManager pluginManager = getServer().getPluginManager();
ess = (IEssentials) pluginManager.getPlugin("Essentials");
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
LOGGER.log(Level.WARNING, tl("versionMismatchAll"));
}
if (!ess.isEnabled()) {
this.setEnabled(false);
return;
}
spawns = new SpawnStorage(ess);
ess.addReloadListener(spawns);
final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns);
pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, ess.getSettings().getRespawnPriority(), new EventExecutor() {
@Override
public void execute(final Listener ll, final Event event) throws EventException {
((EssentialsSpawnPlayerListener) ll).onPlayerRespawn((PlayerRespawnEvent) event);
}
}, this);
pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, ess.getSettings().getRespawnPriority(), new EventExecutor() {
@Override
public void execute(final Listener ll, final Event event) throws EventException {
((EssentialsSpawnPlayerListener) ll).onPlayerJoin((PlayerJoinEvent) event);
}
}, this);
}
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);
}
Aggregations