From 48257e20287af2df81546b21ffd4b04d13f260cb Mon Sep 17 00:00:00 2001 From: ineanto Date: Mon, 3 Jul 2023 17:51:37 +0200 Subject: [PATCH] fix: flying after respawn --- .../xyz/atnrch/nicko/disguise/AppearanceManager.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java b/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java index e85359e..16bb8d7 100644 --- a/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java +++ b/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java @@ -95,18 +95,13 @@ public class AppearanceManager { public ActionResult updatePlayer(boolean skinChange, boolean reset) { final String displayName = profile.getName() == null ? player.getName() : profile.getName(); - final WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player).withName(displayName); final ActionResult result = updateGameProfileSkin(gameProfile, skinChange, reset); - final boolean wasFlying = player.isFlying(); if (!result.isError()) { updateMetadata(); updateTabList(gameProfile, displayName); respawnPlayer(); updateOthers(); - player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); - player.setFlying(wasFlying); - player.updateInventory(); } return result; } @@ -163,6 +158,7 @@ public class AppearanceManager { private void respawnPlayer() { final World world = player.getWorld(); + final boolean wasFlying = player.isFlying(); final WrapperPlayServerRespawn respawn = new WrapperPlayServerRespawn(); respawn.setDimension(world); respawn.setSeed(world.getSeed()); @@ -171,6 +167,9 @@ public class AppearanceManager { respawn.setDifficulty(world.getDifficulty()); respawn.setCopyMetadata(true); respawn.sendPacket(player); + player.setFlying(wasFlying); + player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); + player.updateInventory(); } @SuppressWarnings("deprecation")