Fixed more stuff

This commit is contained in:
NickAcPT 2018-07-21 18:17:54 +01:00
parent 09f013532a
commit 7dd5837dd0

View File

@ -1,4 +1,4 @@
From 95e357f7dd549b278714a9ea76bf6d11d6c2b5fd Mon Sep 17 00:00:00 2001
From 8a9ff94f0db13f56873de8e6f555bc7893cffc31 Mon Sep 17 00:00:00 2001
From: NickAcPT <32451103+NickAcPT@users.noreply.github.com>
Date: Sat, 21 Jul 2018 01:30:30 +0100
Subject: [PATCH] Extend player profile API to support skin changes
@ -6,18 +6,10 @@ Subject: [PATCH] Extend player profile API to support skin changes
Added code that refreshes the player's skin by sending packets with a special order, telling the client to respawn the player and re-apply the game profile
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 6cbf429f..57f17120 100644
index 6cbf429f..01335b6b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -55,6 +55,7 @@ import org.bukkit.craftbukkit.CraftStatistic;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.advancement.CraftAdvancement;
import org.bukkit.craftbukkit.advancement.CraftAdvancementProgress;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.map.CraftMapView;
import org.bukkit.craftbukkit.map.RenderData;
import org.bukkit.craftbukkit.scoreboard.CraftScoreboard;
@@ -1176,10 +1177,41 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -1176,10 +1176,38 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
for (EntityPlayer player : players) {
player.getBukkitEntity().reregisterPlayer(self);
}
@ -30,20 +22,17 @@ index 6cbf429f..57f17120 100644
+ private void refreshPlayer() {
+ EntityPlayer entityplayer = getHandle();
+
+ Packet respawn = new PacketPlayOutRespawn(entityplayer.dimension, entityplayer.world.getDifficulty(), entityplayer.world.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode());
+ Location l = getLocation();
+ Packet pos = new PacketPlayOutPosition(l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch(), new HashSet<>(), 0);
+ Packet slot = new PacketPlayOutHeldItemSlot(getInventory().getHeldItemSlot());
+ Location loc = getLocation();
+
+ EntityPlayer handle = getHandle();
+ PlayerConnection playerCon = handle.playerConnection;
+ PlayerConnection connection = handle.playerConnection;
+ reregisterPlayer(handle);
+
+ //Respawn the player then update their position and selected slot
+ playerCon.sendPacket(respawn);
+ connection.sendPacket(new PacketPlayOutRespawn(entityplayer.dimension, entityplayer.world.getDifficulty(), entityplayer.world.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode()));
+ handle.updateAbilities();
+ playerCon.sendPacket(pos);
+ playerCon.sendPacket(slot);
+ connection.sendPacket(new PacketPlayOutPosition(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), new HashSet<>(), 0));
+ connection.sendPacket(new PacketPlayOutHeldItemSlot(getInventory().getHeldItemSlot()));
+
+ updateScaledHealth();
+ this.updateInventory();