Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
Bedrock <-> Bedrock skin display fix (#1195)
* Implement partial bedrock skin fix * Fix equals method * Fix ViaVersion Co-authored-by: DoctorMacc <toy.fighter1@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
62d984da61
Commit
7f2b2e0913
@ -33,6 +33,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
@ -42,13 +43,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class SkinProvider {
|
||||
@ -157,10 +152,21 @@ public class SkinProvider {
|
||||
public static CompletableFuture<SkinAndCape> requestSkinAndCape(UUID playerId, String skinUrl, String capeUrl) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
long time = System.currentTimeMillis();
|
||||
String newSkinUrl = skinUrl;
|
||||
|
||||
if ("steve".equals(skinUrl) || "alex".equals(skinUrl)) {
|
||||
// TODO: Don't have a for loop for this? Have a proper map?
|
||||
for (GeyserSession session : GeyserConnector.getInstance().getPlayers()) {
|
||||
if (session.getPlayerEntity().getUuid().equals(playerId)) {
|
||||
newSkinUrl = session.getClientData().getSkinId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CapeProvider provider = capeUrl != null ? CapeProvider.MINECRAFT : null;
|
||||
SkinAndCape skinAndCape = new SkinAndCape(
|
||||
getOrDefault(requestSkin(playerId, skinUrl, false), EMPTY_SKIN, 5),
|
||||
getOrDefault(requestSkin(playerId, newSkinUrl, false), EMPTY_SKIN, 5),
|
||||
getOrDefault(requestCape(capeUrl, provider, false), EMPTY_CAPE, 5)
|
||||
);
|
||||
|
||||
|
@ -251,6 +251,7 @@ public class SkinUtils {
|
||||
try {
|
||||
GameProfile.Property skinProperty = profile.getProperty("textures");
|
||||
|
||||
// TODO: Remove try/catch here
|
||||
JsonNode skinObject = new ObjectMapper().readTree(new String(Base64.getDecoder().decode(skinProperty.getValue()), StandardCharsets.UTF_8));
|
||||
JsonNode textures = skinObject.get("textures");
|
||||
|
||||
@ -271,7 +272,16 @@ public class SkinUtils {
|
||||
GeyserConnector.getInstance().getLogger().debug("Got invalid texture data for " + profile.getName() + " " + exception.getMessage());
|
||||
}
|
||||
// return default skin with default cape when texture data is invalid
|
||||
return new GameProfileData((isAlex ? SkinProvider.EMPTY_SKIN_ALEX.getTextureUrl() : SkinProvider.EMPTY_SKIN.getTextureUrl()), SkinProvider.EMPTY_CAPE.getTextureUrl(), isAlex);
|
||||
String skinUrl = isAlex ? SkinProvider.EMPTY_SKIN_ALEX.getTextureUrl() : SkinProvider.EMPTY_SKIN.getTextureUrl();
|
||||
if ("steve".equals(skinUrl) || "alex".equals(skinUrl)) {
|
||||
for (GeyserSession session : GeyserConnector.getInstance().getPlayers()) {
|
||||
if (session.getPlayerEntity().getUuid().equals(profile.getId())) {
|
||||
skinUrl = session.getClientData().getSkinId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new GameProfileData(skinUrl, SkinProvider.EMPTY_CAPE.getTextureUrl(), isAlex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren