Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/feature/playerlist-updat…
Browse files Browse the repository at this point in the history
…es-1.16' into t/bleeding

# Conflicts:
#	connector/src/main/java/org/geysermc/connector/utils/SkinUtils.java
  • Loading branch information
bundabrg committed Jun 30, 2020
2 parents 0f32251 + 6aaaee3 commit f153b95
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class PlayerEntity extends LivingEntity {
private GameProfile profile;
private UUID uuid;
private String username;
private String displayName;
private long lastSkinUpdate = -1;
private boolean playerList = true;
private final EntityEffectCache effectCache;
Expand Down Expand Up @@ -293,4 +294,12 @@ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession s
}
}
}

/**
* Returns the DisplayName if set, otherwise the Username
* @return Name of player entity
*/
public String getName() {
return displayName == null ? username : displayName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.utils.MessageUtils;
import org.geysermc.connector.utils.SkinUtils;

import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
Expand Down Expand Up @@ -81,8 +82,9 @@ public void translate(ServerPlayerListEntryPacket packet, GeyserSession session)
playerEntity.setProfile(entry.getProfile());
playerEntity.setPlayerList(true);
playerEntity.setValid(true);
playerEntity.setDisplayName(entry.getDisplayName() != null ? MessageUtils.getBedrockMessage(entry.getDisplayName()) : null);

PlayerListPacket.Entry playerListEntry = SkinUtils.buildCachedEntry(entry.getProfile(), playerEntity.getGeyserId());
PlayerListPacket.Entry playerListEntry = SkinUtils.buildCachedEntry(playerEntity);
if (self) {
// Copy the entry with our identity instead.
PlayerListPacket.Entry copy = new PlayerListPacket.Entry(session.getAuthData().getUUID());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ public Register shim(Shim shim) {
}
}

public static PlayerListPacket.Entry buildCachedEntry(GameProfile profile, long geyserId) {
GameProfileData data = GameProfileData.from(profile);
public static PlayerListPacket.Entry buildCachedEntry(PlayerEntity playerEntity) {
GameProfileData data = GameProfileData.from(playerEntity.getProfile());
SkinProvider.Cape cape = SkinProvider.getCachedCape(data.getCapeUrl());

SkinProvider.SkinGeometry geometry = SkinProvider.SkinGeometry.getLegacy(data.isAlex());

return buildEntryManually(
profile.getId(),
profile.getName(),
geyserId,
profile.getIdAsString(),
SkinProvider.getCachedSkin(profile.getId()).getSkinData(),
playerEntity.getProfile().getId(),
playerEntity.getName(),
playerEntity.getGeyserId(),
playerEntity.getProfile().getIdAsString(),
SkinProvider.getCachedSkin(playerEntity.getProfile().getId()).getSkinData(),
cape.getCapeId(),
cape.getCapeData(),
geometry.getGeometryName(),
Expand Down Expand Up @@ -218,7 +218,7 @@ public static void requestAndHandleSkinAndCape(PlayerEntity entity, GeyserSessio
if (session.getUpstream().isInitialized()) {
PlayerListPacket.Entry updatedEntry = buildEntryManually(
entity.getUuid(),
entity.getUsername(),
entity.getName(),
entity.getGeyserId(),
entity.getUuid().toString(),
skin.getSkinData(),
Expand Down

0 comments on commit f153b95

Please sign in to comment.