Skip to content
PheonixVX edited this page Aug 5, 2020 · 6 revisions

Player Join Event

The PlayerJoinEvent is a listening event that activates when a Player join's the server.
To register an event, instantiate the event class, and register it through BeaconEventManager like so:

PlayerJoinedEvent playerJoinedEvent = new PlayerJoinedEvent();
BeaconEventManager.registerListener(playerJoinedEvent);

In this code example, PlayerJoinedEvent implements BeaconEventListener and uses @BeaconEventHandler annotation to feed code into the Event. To say a message on Player join, consider the following example:
public class PlayerJoinedEvent implements BeaconEventListener {

    @BeaconEventHandler(value = BeaconPlayerJoinEvent.class)
    public static void PlayerJoinEvent(ClientConnection clientConnection, ServerPlayerEntity playerEntity, CallbackInfo callbackInfo) {
        LiteralText text = new LiteralText("Welcome " + playerEntity.getName() + " to the server!").formatted(Formatting.AQUA);
        playerEntity.sendMessage(text, false);
    }
}

See ya in the next tutorial 👍!

Clone this wiki locally