# PlayerJoin

`com.jsmacrosce.jsmacros.client.api.event.impl.world.EventPlayerJoin`

**Since:** 1.2.7

**Cancellable:** No. Calling `event.cancel()` throws `UnsupportedOperationException`.

Fired when a player-list entry is first added to the client player list.  
```js
JsMacros.on("PlayerJoin", JavaWrapper.methodToJava(function (event) {
  const name = event.player.getName();  
  Chat.log(`${name === null ? event.UUID : name} joined, ping ${event.player.getPing()} ms`);  
}))
```

## Constructors

### new EventPlayerJoin {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventPlayerJoin_constructor-UUID-PlayerInfo-}

```js
new EventPlayerJoin(UUID uuid, PlayerInfo playerInfo)
```

Wraps a player-list entry in a join event; it does not add the entry or dispatch the event.  
The supplied UUID is converted to a string independently of the profile in `playerInfo`.  
A null UUID causes a [NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) before the player entry is wrapped.  
`playerInfo` is required to be non-null but is not eagerly checked; passing `null`
despite that precondition creates a wrapper around null and causes a downstream [NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html).

**Parameters:**
- `uuid`: non-null identifier whose string form is stored in [UUID](#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventPlayerJoin_UUID)
- `playerInfo`: non-null player-list entry to wrap

## Fields

### player {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventPlayerJoin_player}

```js
player: PlayerListEntryHelper
```

The added player-list entry. Its name may be `null` when the profile has no name.

### UUID {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventPlayerJoin_UUID}

```js
UUID: String
```

UUID of the added player's profile; the same value returned by
[PlayerListEntryHelper.getUUID()](../../../../../../../../../classes/com/jsmacrosce/jsmacros/client/api/helper/world/PlayerListEntryHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.PlayerListEntryHelper_getUUID-) on [player](#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventPlayerJoin_player).

## Methods

### toString {#com.jsmacrosce.jsmacros.client.api.event.impl.world.EventPlayerJoin_toString-}

```js
toString(): String
```

Returns an event-name-prefixed diagnostic containing the current player-helper representation, not a full entry snapshot.  
If `playerInfo` was `null` despite the constructor's non-null precondition, the non-null helper contains a null raw entry; formatting then causes a [NullPointerException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/NullPointerException.html) through `helper.getUUID()` and `base.getProfile()`.

**Returns:** diagnostic string in the form `eventName:{"player": playerRepresentation}`
