mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-12 10:21:39 +01:00
Cleanup with the ADD_PLAYER method
This commit is contained in:
parent
7ce6f7ada1
commit
f887f21493
@ -199,9 +199,7 @@ public class Player extends LivingEntity {
|
|||||||
PlayerSkinInitEvent skinInitEvent = new PlayerSkinInitEvent(this);
|
PlayerSkinInitEvent skinInitEvent = new PlayerSkinInitEvent(this);
|
||||||
callEvent(PlayerSkinInitEvent.class, skinInitEvent);
|
callEvent(PlayerSkinInitEvent.class, skinInitEvent);
|
||||||
this.skin = skinInitEvent.getSkin();
|
this.skin = skinInitEvent.getSkin();
|
||||||
final String textures = skin == null ? "" : skin.getTextures();
|
playerConnection.sendPacket(getAddPlayerToList());
|
||||||
final String signature = skin == null ? null : skin.getSignature();
|
|
||||||
playerConnection.sendPacket(getAddPlayerToList(textures, signature));
|
|
||||||
|
|
||||||
// Commands start
|
// Commands start
|
||||||
{
|
{
|
||||||
@ -882,14 +880,11 @@ public class Player extends LivingEntity {
|
|||||||
public synchronized void setSkin(PlayerSkin skin) {
|
public synchronized void setSkin(PlayerSkin skin) {
|
||||||
this.skin = skin;
|
this.skin = skin;
|
||||||
|
|
||||||
final String textures = skin == null ? "" : skin.getTextures();
|
|
||||||
final String signature = skin == null ? null : skin.getSignature();
|
|
||||||
|
|
||||||
DestroyEntitiesPacket destroyEntitiesPacket = new DestroyEntitiesPacket();
|
DestroyEntitiesPacket destroyEntitiesPacket = new DestroyEntitiesPacket();
|
||||||
destroyEntitiesPacket.entityIds = new int[]{getEntityId()};
|
destroyEntitiesPacket.entityIds = new int[]{getEntityId()};
|
||||||
|
|
||||||
PlayerInfoPacket removePlayerPacket = getRemovePlayerToList();
|
PlayerInfoPacket removePlayerPacket = getRemovePlayerToList();
|
||||||
PlayerInfoPacket addPlayerPacket = getAddPlayerToList(textures, signature);
|
PlayerInfoPacket addPlayerPacket = getAddPlayerToList();
|
||||||
|
|
||||||
RespawnPacket respawnPacket = new RespawnPacket();
|
RespawnPacket respawnPacket = new RespawnPacket();
|
||||||
respawnPacket.dimension = getDimension();
|
respawnPacket.dimension = getDimension();
|
||||||
@ -1854,11 +1849,12 @@ public class Player extends LivingEntity {
|
|||||||
/**
|
/**
|
||||||
* Get the packet to add the player from tab-list
|
* Get the packet to add the player from tab-list
|
||||||
*
|
*
|
||||||
* @param textures the textures value
|
|
||||||
* @param signature the textures signature
|
|
||||||
* @return a {@link PlayerInfoPacket} to add the player
|
* @return a {@link PlayerInfoPacket} to add the player
|
||||||
*/
|
*/
|
||||||
protected PlayerInfoPacket getAddPlayerToList(String textures, String signature) {
|
protected PlayerInfoPacket getAddPlayerToList() {
|
||||||
|
final String textures = skin == null ? "" : skin.getTextures();
|
||||||
|
final String signature = skin == null ? null : skin.getSignature();
|
||||||
|
|
||||||
String jsonDisplayName = displayName != null ? Chat.toJsonString(Chat.fromLegacyText(displayName)) : null;
|
String jsonDisplayName = displayName != null ? Chat.toJsonString(Chat.fromLegacyText(displayName)) : null;
|
||||||
PlayerInfoPacket playerInfoPacket = new PlayerInfoPacket(PlayerInfoPacket.Action.ADD_PLAYER);
|
PlayerInfoPacket playerInfoPacket = new PlayerInfoPacket(PlayerInfoPacket.Action.ADD_PLAYER);
|
||||||
|
|
||||||
@ -1903,9 +1899,7 @@ public class Player extends LivingEntity {
|
|||||||
spawnPlayerPacket.playerUuid = getUuid();
|
spawnPlayerPacket.playerUuid = getUuid();
|
||||||
spawnPlayerPacket.position = getPosition();
|
spawnPlayerPacket.position = getPosition();
|
||||||
|
|
||||||
final String textures = skin == null ? "" : skin.getTextures();
|
connection.sendPacket(getAddPlayerToList());
|
||||||
final String signature = skin == null ? null : skin.getSignature();
|
|
||||||
connection.sendPacket(getAddPlayerToList(textures, signature));
|
|
||||||
|
|
||||||
connection.sendPacket(spawnPlayerPacket);
|
connection.sendPacket(spawnPlayerPacket);
|
||||||
connection.sendPacket(getVelocityPacket());
|
connection.sendPacket(getVelocityPacket());
|
||||||
|
Loading…
Reference in New Issue
Block a user