diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 21982e5eec..29439d86d9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.io.BaseEncoding; import com.mojang.authlib.GameProfile; +import com.mojang.datafixers.util.Pair; import io.netty.buffer.Unpooled; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -11,6 +12,7 @@ import java.lang.ref.WeakReference; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -41,6 +43,7 @@ import net.minecraft.network.protocol.game.PacketPlayOutBlockChange; import net.minecraft.network.protocol.game.PacketPlayOutChat; import net.minecraft.network.protocol.game.PacketPlayOutCustomPayload; import net.minecraft.network.protocol.game.PacketPlayOutCustomSoundEffect; +import net.minecraft.network.protocol.game.PacketPlayOutEntityEquipment; import net.minecraft.network.protocol.game.PacketPlayOutExperience; import net.minecraft.network.protocol.game.PacketPlayOutMap; import net.minecraft.network.protocol.game.PacketPlayOutNamedSoundEffect; @@ -61,6 +64,7 @@ import net.minecraft.server.network.PlayerConnection; import net.minecraft.server.players.WhiteListEntry; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityLiving; +import net.minecraft.world.entity.EnumItemSlot; import net.minecraft.world.entity.ai.attributes.AttributeMapBase; import net.minecraft.world.entity.ai.attributes.AttributeModifiable; import net.minecraft.world.entity.ai.attributes.GenericAttributes; @@ -97,6 +101,7 @@ import org.bukkit.conversations.Conversation; import org.bukkit.conversations.ConversationAbandonedEvent; import org.bukkit.conversations.ManuallyAbandonedConversationCanceller; import org.bukkit.craftbukkit.CraftEffect; +import org.bukkit.craftbukkit.CraftEquipmentSlot; import org.bukkit.craftbukkit.CraftOfflinePlayer; import org.bukkit.craftbukkit.CraftParticle; import org.bukkit.craftbukkit.CraftServer; @@ -108,6 +113,7 @@ import org.bukkit.craftbukkit.advancement.CraftAdvancementProgress; import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.conversations.ConversationTracker; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.map.CraftMapView; import org.bukkit.craftbukkit.map.RenderData; import org.bukkit.craftbukkit.scoreboard.CraftScoreboard; @@ -115,10 +121,12 @@ import org.bukkit.craftbukkit.util.CraftChatMessage; import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerRegisterChannelEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerUnregisterChannelEvent; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.InventoryView.Property; import org.bukkit.inventory.ItemStack; import org.bukkit.map.MapCursor; @@ -615,6 +623,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().connection.send(sign.getUpdatePacket()); } + @Override + public void sendEquipmentChange(LivingEntity entity, EquipmentSlot slot, ItemStack item) { + Preconditions.checkArgument(entity != null, "entity must not be null"); + Preconditions.checkArgument(slot != null, "slot must not be null"); + Preconditions.checkArgument(item != null, "item must not be null"); + + if (getHandle().connection == null) return; + + List> equipment = Arrays.asList( + new Pair<>(CraftEquipmentSlot.getNMS(slot), CraftItemStack.asNMSCopy(item)) + ); + + getHandle().connection.send(new PacketPlayOutEntityEquipment(entity.getEntityId(), equipment)); + } + @Override public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) { if (getHandle().connection == null) return false;