Skip to content

Commit

Permalink
Merge #1357 into v5 (Get skin from profile properties by property name)
Browse files Browse the repository at this point in the history
  • Loading branch information
NEZNAMY committed Aug 20, 2024
1 parent 6164dd8 commit f488f18
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ public TabList.Skin getSkin() {
LoginResult loginResult = ((InitialHandler)getPlayer().getPendingConnection()).getLoginProfile();
if (loginResult == null) return null;
Property[] properties = loginResult.getProperties();
if (properties == null || properties.length == 0) return null; //Offline mode
return new TabList.Skin(properties[0].getValue(), properties[0].getSignature());
if (properties == null) return null; //Offline mode
for (Property property : properties) {
if (property.getName().equals(TabList.TEXTURES_PROPERTY)) {
return new TabList.Skin(property.getValue(), property.getSignature());
}
}
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ public boolean isDisguised() {
public TabList.Skin getSkin() {
List<ProfileProperty> list = getPlayer().profile().properties();
if (list.isEmpty()) return null; // Offline mode
return new TabList.Skin(list.get(0).value(), list.get(0).signature().orElse(null));
for (ProfileProperty property : list) {
if (property.name().equals(TabList.TEXTURES_PROPERTY)) {
return new TabList.Skin(property.value(), property.signature().orElse(null));
}
}
return null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ public void sendMessage(@NotNull TabComponent message) {
public TabList.Skin getSkin() {
List<GameProfile.Property> properties = getPlayer().getGameProfile().getProperties();
if (properties.isEmpty()) return null; //Offline mode
return new TabList.Skin(properties.get(0).getValue(), properties.get(0).getSignature());
for (GameProfile.Property property : properties) {
if (property.getName().equals(TabList.TEXTURES_PROPERTY)) {
return new TabList.Skin(property.getValue(), property.getSignature());
}
}
return null;
}

@Override
Expand Down

0 comments on commit f488f18

Please sign in to comment.