refactor: cleanup internals

This commit is contained in:
aro 2023-01-22 15:17:19 +01:00
parent d7ed49f668
commit f68d962037
5 changed files with 18 additions and 88 deletions

View file

@ -4,8 +4,8 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
import net.artelnatif.nicko.NickoBukkit; import net.artelnatif.nicko.NickoBukkit;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.disguise.ActionResult; import net.artelnatif.nicko.disguise.ActionResult;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.i18n.I18NDict; import net.artelnatif.nicko.i18n.I18NDict;
import net.artelnatif.nicko.mojang.MojangAPI; import net.artelnatif.nicko.mojang.MojangAPI;
import net.artelnatif.nicko.mojang.MojangSkin; import net.artelnatif.nicko.mojang.MojangSkin;
@ -23,7 +23,6 @@ import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
@ -43,10 +42,8 @@ public class v1_17_R1 implements Internals {
false); false);
final boolean wasFlying = player.isFlying(); final boolean wasFlying = player.isFlying();
final ItemStack itemOnCursor = player.getItemOnCursor();
entityPlayer.b.sendPacket(respawn); entityPlayer.b.sendPacket(respawn);
player.setFlying(wasFlying); player.setFlying(wasFlying);
player.setItemOnCursor(itemOnCursor);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.updateInventory(); player.updateInventory();
} }
@ -57,19 +54,9 @@ public class v1_17_R1 implements Internals {
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId()); final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer); final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
/*
BIT MASKS:
0x01 Cape enabled
0x02 Jacket enabled
0x04 Left sleeve enabled
0x08 Right sleeve enabled
0x10 Left pants leg enabled
0x20 Right pants leg enabled
0x40 Hat enabled
*/
final DataWatcher dataWatcher = entityPlayer.getDataWatcher(); final DataWatcher dataWatcher = entityPlayer.getDataWatcher();
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f); // 127, all masks combined dataWatcher.set(displayedSkinPartDataWatcher, (byte) 0x7f);
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true); final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
@ -77,8 +64,8 @@ public class v1_17_R1 implements Internals {
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
onlineEntityPlayer.b.sendPacket(destroy); onlineEntityPlayer.b.sendPacket(destroy);
onlineEntityPlayer.b.sendPacket(spawn); onlineEntityPlayer.b.sendPacket(spawn);
onlineEntityPlayer.b.sendPacket(entityMetadata);
} }
onlineEntityPlayer.b.sendPacket(entityMetadata);
}); });
} }
@ -102,6 +89,7 @@ public class v1_17_R1 implements Internals {
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get())); skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
if (skin.isPresent()) { if (skin.isPresent()) {
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures");
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature())); properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
updateSelf(player); updateSelf(player);
} else { } else {
@ -121,8 +109,6 @@ public class v1_17_R1 implements Internals {
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
player.getPing(), player.getPing(),
EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); EnumGamemode.getById(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
entityPlayer.b.sendPacket(remove);
entityPlayer.b.sendPacket(add);
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();

View file

@ -4,8 +4,8 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
import net.artelnatif.nicko.NickoBukkit; import net.artelnatif.nicko.NickoBukkit;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.disguise.ActionResult; import net.artelnatif.nicko.disguise.ActionResult;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.i18n.I18NDict; import net.artelnatif.nicko.i18n.I18NDict;
import net.artelnatif.nicko.mojang.MojangAPI; import net.artelnatif.nicko.mojang.MojangAPI;
import net.artelnatif.nicko.mojang.MojangSkin; import net.artelnatif.nicko.mojang.MojangSkin;
@ -23,7 +23,6 @@ import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
@ -45,10 +44,8 @@ public class v1_18_R1 implements Internals {
false); false);
final boolean wasFlying = player.isFlying(); final boolean wasFlying = player.isFlying();
final ItemStack itemOnCursor = player.getItemOnCursor();
entityPlayer.b.a(respawn); entityPlayer.b.a(respawn);
player.setFlying(wasFlying); player.setFlying(wasFlying);
player.setItemOnCursor(itemOnCursor);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.updateInventory(); player.updateInventory();
} }
@ -59,19 +56,9 @@ public class v1_18_R1 implements Internals {
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId()); final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer); final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
/*
BIT MASKS:
0x01 Cape enabled
0x02 Jacket enabled
0x04 Left sleeve enabled
0x08 Right sleeve enabled
0x10 Left pants leg enabled
0x20 Right pants leg enabled
0x40 Hat enabled
*/
final DataWatcher dataWatcher = entityPlayer.ai(); final DataWatcher dataWatcher = entityPlayer.ai();
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f); // 127, all masks combined dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f);
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true); final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
@ -79,8 +66,8 @@ public class v1_18_R1 implements Internals {
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
onlineEntityPlayer.b.a(destroy); onlineEntityPlayer.b.a(destroy);
onlineEntityPlayer.b.a(spawn); onlineEntityPlayer.b.a(spawn);
onlineEntityPlayer.b.a(entityMetadata);
} }
onlineEntityPlayer.b.a(entityMetadata);
}); });
} }
@ -104,6 +91,7 @@ public class v1_18_R1 implements Internals {
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get())); skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
if (skin.isPresent()) { if (skin.isPresent()) {
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures");
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature())); properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
updateSelf(player); updateSelf(player);
} else { } else {
@ -123,8 +111,6 @@ public class v1_18_R1 implements Internals {
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
player.getPing(), player.getPing(),
EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
entityPlayer.b.a(remove);
entityPlayer.b.a(add);
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();

View file

@ -4,8 +4,8 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
import net.artelnatif.nicko.NickoBukkit; import net.artelnatif.nicko.NickoBukkit;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.disguise.ActionResult; import net.artelnatif.nicko.disguise.ActionResult;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.i18n.I18NDict; import net.artelnatif.nicko.i18n.I18NDict;
import net.artelnatif.nicko.mojang.MojangAPI; import net.artelnatif.nicko.mojang.MojangAPI;
import net.artelnatif.nicko.mojang.MojangSkin; import net.artelnatif.nicko.mojang.MojangSkin;
@ -24,7 +24,6 @@ import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
@ -45,10 +44,8 @@ public class v1_18_R2 implements Internals {
false); false);
final boolean wasFlying = player.isFlying(); final boolean wasFlying = player.isFlying();
final ItemStack itemOnCursor = player.getItemOnCursor();
entityPlayer.b.a(respawn); entityPlayer.b.a(respawn);
player.setFlying(wasFlying); player.setFlying(wasFlying);
player.setItemOnCursor(itemOnCursor);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.updateInventory(); player.updateInventory();
} }
@ -59,19 +56,9 @@ public class v1_18_R2 implements Internals {
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId()); final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer); final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
/*
BIT MASKS:
0x01 Cape enabled
0x02 Jacket enabled
0x04 Left sleeve enabled
0x08 Right sleeve enabled
0x10 Left pants leg enabled
0x20 Right pants leg enabled
0x40 Hat enabled
*/
final DataWatcher dataWatcher = entityPlayer.ai(); final DataWatcher dataWatcher = entityPlayer.ai();
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f); // 127, all masks combined dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f);
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true); final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
@ -79,8 +66,8 @@ public class v1_18_R2 implements Internals {
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
onlineEntityPlayer.b.a(destroy); onlineEntityPlayer.b.a(destroy);
onlineEntityPlayer.b.a(spawn); onlineEntityPlayer.b.a(spawn);
onlineEntityPlayer.b.a(entityMetadata);
} }
onlineEntityPlayer.b.a(entityMetadata);
}); });
} }
@ -104,6 +91,7 @@ public class v1_18_R2 implements Internals {
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get())); skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
if (skin.isPresent()) { if (skin.isPresent()) {
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures");
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature())); properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
updateSelf(player); updateSelf(player);
} else { } else {
@ -123,8 +111,6 @@ public class v1_18_R2 implements Internals {
add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile, add.b().add(new PacketPlayOutPlayerInfo.PlayerInfoData(gameProfile,
player.getPing(), player.getPing(),
EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName))); EnumGamemode.a(player.getGameMode().ordinal()), IChatBaseComponent.a(profileName)));
entityPlayer.b.a(remove);
entityPlayer.b.a(add);
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();

View file

@ -4,8 +4,8 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap; import com.mojang.authlib.properties.PropertyMap;
import net.artelnatif.nicko.NickoBukkit; import net.artelnatif.nicko.NickoBukkit;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.disguise.ActionResult; import net.artelnatif.nicko.disguise.ActionResult;
import net.artelnatif.nicko.disguise.NickoProfile;
import net.artelnatif.nicko.i18n.I18NDict; import net.artelnatif.nicko.i18n.I18NDict;
import net.artelnatif.nicko.mojang.MojangAPI; import net.artelnatif.nicko.mojang.MojangAPI;
import net.artelnatif.nicko.mojang.MojangSkin; import net.artelnatif.nicko.mojang.MojangSkin;
@ -20,11 +20,9 @@ import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.level.EnumGamemode; import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.level.World; import net.minecraft.world.level.World;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import java.io.IOException; import java.io.IOException;
import java.util.Optional; import java.util.Optional;
@ -35,11 +33,8 @@ public class v1_19_R1 implements Internals {
public void updateSelf(Player player) { public void updateSelf(Player player) {
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle(); final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
final ResourceKey<World> levelResourceKey = entityPlayer.x().ab(); final ResourceKey<World> levelResourceKey = entityPlayer.x().ab();
final CraftWorld world = entityPlayer.s.getWorld();
// last boolean is: "has death location" attribute, if true, the optional contains the death dimension and position.
// with the boolean being false, we don't need to provide a value, and thus we return an empty optional.
final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.x().Z(), final PacketPlayOutRespawn respawn = new PacketPlayOutRespawn(entityPlayer.x().Z(),
levelResourceKey, world.getSeed(), levelResourceKey, entityPlayer.s.getWorld().getSeed(),
entityPlayer.d.b(), entityPlayer.d.c(), entityPlayer.d.b(), entityPlayer.d.c(),
false, false,
false, false,
@ -47,10 +42,8 @@ public class v1_19_R1 implements Internals {
Optional.empty()); Optional.empty());
final boolean wasFlying = player.isFlying(); final boolean wasFlying = player.isFlying();
final ItemStack itemOnCursor = player.getItemOnCursor();
entityPlayer.b.a(respawn); entityPlayer.b.a(respawn);
player.setFlying(wasFlying); player.setFlying(wasFlying);
player.setItemOnCursor(itemOnCursor);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN); player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.updateInventory(); player.updateInventory();
} }
@ -61,19 +54,9 @@ public class v1_19_R1 implements Internals {
final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId()); final PacketPlayOutEntityDestroy destroy = new PacketPlayOutEntityDestroy(entityPlayer.getBukkitEntity().getEntityId());
final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer); final PacketPlayOutNamedEntitySpawn spawn = new PacketPlayOutNamedEntitySpawn(entityPlayer);
/*
BIT MASKS:
0x01 Cape enabled
0x02 Jacket enabled
0x04 Left sleeve enabled
0x08 Right sleeve enabled
0x10 Left pants leg enabled
0x20 Right pants leg enabled
0x40 Hat enabled
*/
final DataWatcher dataWatcher = entityPlayer.ai(); final DataWatcher dataWatcher = entityPlayer.ai();
final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a); final DataWatcherObject<Byte> displayedSkinPartDataWatcher = new DataWatcherObject<>(17, DataWatcherRegistry.a);
dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f); // 127, all masks combined dataWatcher.b(displayedSkinPartDataWatcher, (byte) 0x7f);
final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true); final PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(entityPlayer.getBukkitEntity().getEntityId(), dataWatcher, true);
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
@ -81,8 +64,8 @@ public class v1_19_R1 implements Internals {
if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) { if (onlineEntityPlayer.getBukkitEntity().getUniqueId() != player.getUniqueId()) {
onlineEntityPlayer.b.a(destroy); onlineEntityPlayer.b.a(destroy);
onlineEntityPlayer.b.a(spawn); onlineEntityPlayer.b.a(spawn);
onlineEntityPlayer.b.a(entityMetadata);
} }
onlineEntityPlayer.b.a(entityMetadata);
}); });
} }
@ -109,6 +92,7 @@ public class v1_19_R1 implements Internals {
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get())); skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
if (skin.isPresent()) { if (skin.isPresent()) {
final PropertyMap properties = gameProfile.getProperties(); final PropertyMap properties = gameProfile.getProperties();
properties.removeAll("textures");
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature())); properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
updateSelf(player); updateSelf(player);
} else { } else {
@ -132,8 +116,6 @@ public class v1_19_R1 implements Internals {
IChatBaseComponent.a(profileName), IChatBaseComponent.a(profileName),
key)); // f mojang key)); // f mojang
entityPlayer.b.a(remove);
entityPlayer.b.a(add);
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {
EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle(); EntityPlayer onlineEntityPlayer = ((CraftPlayer) online).getHandle();
onlineEntityPlayer.b.a(remove); onlineEntityPlayer.b.a(remove);

View file

@ -57,19 +57,9 @@ public class v1_19_R2 implements Internals {
final ClientboundRemoveEntitiesPacket remove = new ClientboundRemoveEntitiesPacket(serverPlayer.getBukkitEntity().getEntityId()); final ClientboundRemoveEntitiesPacket remove = new ClientboundRemoveEntitiesPacket(serverPlayer.getBukkitEntity().getEntityId());
final ClientboundAddEntityPacket add = new ClientboundAddEntityPacket(serverPlayer); final ClientboundAddEntityPacket add = new ClientboundAddEntityPacket(serverPlayer);
/*
BIT MASKS:
0x01 Cape enabled
0x02 Jacket enabled
0x04 Left sleeve enabled
0x08 Right sleeve enabled
0x10 Left pants leg enabled
0x20 Right pants leg enabled
0x40 Hat enabled
*/
final SynchedEntityData entityData = serverPlayer.getEntityData(); final SynchedEntityData entityData = serverPlayer.getEntityData();
final EntityDataAccessor<Byte> skinPartAccessor = new EntityDataAccessor<>(17, EntityDataSerializers.BYTE); final EntityDataAccessor<Byte> skinPartAccessor = new EntityDataAccessor<>(17, EntityDataSerializers.BYTE);
entityData.set(skinPartAccessor, (byte) 0x7f); // 127, all masks combined entityData.set(skinPartAccessor, (byte) 0x7f);
final ClientboundSetEntityDataPacket entityMetadata = new ClientboundSetEntityDataPacket(serverPlayer.getBukkitEntity().getEntityId(), entityData.getNonDefaultValues()); final ClientboundSetEntityDataPacket entityMetadata = new ClientboundSetEntityDataPacket(serverPlayer.getBukkitEntity().getEntityId(), entityData.getNonDefaultValues());
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {