mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-04 17:59:49 +01:00
Added isFirstSpawn() to PlayerSpawnEvent
This commit is contained in:
parent
9c5c6d9161
commit
8281f1c0fd
@ -346,6 +346,7 @@ public class Player extends LivingEntity {
|
||||
if (this.instance == instance)
|
||||
throw new IllegalArgumentException("Instance should be different than the current one");
|
||||
|
||||
boolean firstSpawn = this.instance == null; // TODO: Handle player reconnections, must be false in that case too
|
||||
for (Chunk viewableChunk : viewableChunks) {
|
||||
viewableChunk.removeViewer(this);
|
||||
}
|
||||
@ -374,7 +375,7 @@ public class Player extends LivingEntity {
|
||||
if (isLast) {
|
||||
// This is the last chunk to be loaded , spawn player
|
||||
super.setInstance(instance);
|
||||
PlayerSpawnEvent spawnEvent = new PlayerSpawnEvent(instance);
|
||||
PlayerSpawnEvent spawnEvent = new PlayerSpawnEvent(instance, firstSpawn);
|
||||
callEvent(PlayerSpawnEvent.class, spawnEvent);
|
||||
updateViewPosition(chunk);
|
||||
} else {
|
||||
|
@ -4,7 +4,18 @@ import net.minestom.server.event.entity.EntitySpawnEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
||||
public class PlayerSpawnEvent extends EntitySpawnEvent {
|
||||
public PlayerSpawnEvent(Instance spawnInstance) {
|
||||
private final boolean firstSpawn;
|
||||
|
||||
public PlayerSpawnEvent(Instance spawnInstance, boolean firstSpawn) {
|
||||
super(spawnInstance);
|
||||
this.firstSpawn = firstSpawn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 'true' if the player is spawning for the first time. 'false' if this spawn event was triggered by a dimension teleport
|
||||
* @return
|
||||
*/
|
||||
public boolean isFirstSpawn() {
|
||||
return firstSpawn;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user