mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-18 00:25:30 +01:00
Do not send gamemode related packets before the player spawn
This commit is contained in:
parent
3e532b24a8
commit
943aae7397
@ -1700,12 +1700,16 @@ public class Player extends LivingEntity implements CommandSender {
|
|||||||
public void setGameMode(@NotNull GameMode gameMode) {
|
public void setGameMode(@NotNull GameMode gameMode) {
|
||||||
Check.notNull(gameMode, "GameMode cannot be null");
|
Check.notNull(gameMode, "GameMode cannot be null");
|
||||||
this.gameMode = gameMode;
|
this.gameMode = gameMode;
|
||||||
|
|
||||||
|
// Condition to prevent sending the packets before spawning the player
|
||||||
|
if (isActive()) {
|
||||||
sendChangeGameStatePacket(ChangeGameStatePacket.Reason.CHANGE_GAMEMODE, gameMode.getId());
|
sendChangeGameStatePacket(ChangeGameStatePacket.Reason.CHANGE_GAMEMODE, gameMode.getId());
|
||||||
|
|
||||||
PlayerInfoPacket infoPacket = new PlayerInfoPacket(PlayerInfoPacket.Action.UPDATE_GAMEMODE);
|
PlayerInfoPacket infoPacket = new PlayerInfoPacket(PlayerInfoPacket.Action.UPDATE_GAMEMODE);
|
||||||
infoPacket.playerInfos.add(new PlayerInfoPacket.UpdateGamemode(getUuid(), gameMode));
|
infoPacket.playerInfos.add(new PlayerInfoPacket.UpdateGamemode(getUuid(), gameMode));
|
||||||
sendPacketToViewersAndSelf(infoPacket);
|
sendPacketToViewersAndSelf(infoPacket);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if this player is in creative. Used for code readability.
|
* Gets if this player is in creative. Used for code readability.
|
||||||
|
Loading…
Reference in New Issue
Block a user