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