2020-05-07 15:46:21 +02:00
|
|
|
package net.minestom.server.event.player;
|
2019-08-25 20:03:43 +02:00
|
|
|
|
2020-12-11 04:34:08 +01:00
|
|
|
import net.minestom.server.entity.Player;
|
2021-06-02 07:09:15 +02:00
|
|
|
import net.minestom.server.event.trait.PlayerEvent;
|
2020-04-24 03:25:58 +02:00
|
|
|
import net.minestom.server.instance.Instance;
|
2020-12-16 03:21:59 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2019-09-01 06:18:41 +02:00
|
|
|
|
2020-05-30 22:32:12 +02:00
|
|
|
/**
|
2020-10-31 01:38:57 +01:00
|
|
|
* Called when a new instance is set for a player.
|
2020-05-30 22:32:12 +02:00
|
|
|
*/
|
2021-06-02 08:17:03 +02:00
|
|
|
public class PlayerSpawnEvent implements PlayerEvent {
|
2020-07-24 16:11:48 +02:00
|
|
|
|
2021-06-02 07:09:15 +02:00
|
|
|
private final Player player;
|
2020-12-16 03:21:59 +01:00
|
|
|
private final Instance spawnInstance;
|
2020-05-08 18:03:39 +02:00
|
|
|
private final boolean firstSpawn;
|
|
|
|
|
2020-12-14 03:52:51 +01:00
|
|
|
public PlayerSpawnEvent(@NotNull Player player, @NotNull Instance spawnInstance, boolean firstSpawn) {
|
2021-06-02 07:09:15 +02:00
|
|
|
this.player = player;
|
2020-12-16 03:21:59 +01:00
|
|
|
this.spawnInstance = spawnInstance;
|
2020-05-08 18:03:39 +02:00
|
|
|
this.firstSpawn = firstSpawn;
|
|
|
|
}
|
|
|
|
|
2020-12-11 04:34:08 +01:00
|
|
|
/**
|
2020-12-16 03:21:59 +01:00
|
|
|
* Gets the entity new instance.
|
2020-12-11 04:34:08 +01:00
|
|
|
*
|
2020-12-16 03:21:59 +01:00
|
|
|
* @return the instance
|
2020-12-11 04:34:08 +01:00
|
|
|
*/
|
|
|
|
@NotNull
|
2020-12-16 03:21:59 +01:00
|
|
|
public Instance getSpawnInstance() {
|
|
|
|
return spawnInstance;
|
2020-12-11 04:34:08 +01:00
|
|
|
}
|
|
|
|
|
2020-05-08 18:03:39 +02:00
|
|
|
/**
|
|
|
|
* 'true' if the player is spawning for the first time. 'false' if this spawn event was triggered by a dimension teleport
|
2020-05-30 22:32:12 +02:00
|
|
|
*
|
|
|
|
* @return true if this is the first spawn, false otherwise
|
2020-05-08 18:03:39 +02:00
|
|
|
*/
|
|
|
|
public boolean isFirstSpawn() {
|
|
|
|
return firstSpawn;
|
2019-09-01 06:18:41 +02:00
|
|
|
}
|
2021-06-02 07:09:15 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public @NotNull Player getPlayer() {
|
|
|
|
return player;
|
|
|
|
}
|
2019-08-25 20:03:43 +02:00
|
|
|
}
|