Minestom/src/main/java/net/minestom/server/event/player/PlayerSpawnEvent.java

47 lines
1.2 KiB
Java
Raw Normal View History

package net.minestom.server.event.player;
2019-08-25 20:03:43 +02: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;
import org.jetbrains.annotations.NotNull;
2019-09-01 06:18:41 +02:00
2020-05-30 22:32:12 +02: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;
private final Instance spawnInstance;
private final boolean firstSpawn;
public PlayerSpawnEvent(@NotNull Player player, @NotNull Instance spawnInstance, boolean firstSpawn) {
2021-06-02 07:09:15 +02:00
this.player = player;
this.spawnInstance = spawnInstance;
this.firstSpawn = firstSpawn;
}
/**
* Gets the entity new instance.
*
* @return the instance
*/
@NotNull
public Instance getSpawnInstance() {
return spawnInstance;
}
/**
* '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
*/
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
}