mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Convert GameProfileData to record; remove confusing skin log
`Registering bedrock skin for PLAYERNAME` is now just confusing as it implies something to do with Floodgate's skin system when it's just for Bedrock <-> Bedrock players.
This commit is contained in:
parent
7d176cd669
commit
7f4d3def58
3 changed files with 13 additions and 18 deletions
|
@ -30,8 +30,6 @@ import com.github.steveice10.mc.auth.data.GameProfile;
|
||||||
import com.nukkitx.protocol.bedrock.data.skin.ImageData;
|
import com.nukkitx.protocol.bedrock.data.skin.ImageData;
|
||||||
import com.nukkitx.protocol.bedrock.data.skin.SerializedSkin;
|
import com.nukkitx.protocol.bedrock.data.skin.SerializedSkin;
|
||||||
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
|
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.common.AuthType;
|
import org.geysermc.connector.common.AuthType;
|
||||||
import org.geysermc.connector.entity.player.PlayerEntity;
|
import org.geysermc.connector.entity.player.PlayerEntity;
|
||||||
|
@ -52,10 +50,10 @@ public class SkinManager {
|
||||||
*/
|
*/
|
||||||
public static PlayerListPacket.Entry buildCachedEntry(GeyserSession session, PlayerEntity playerEntity) {
|
public static PlayerListPacket.Entry buildCachedEntry(GeyserSession session, PlayerEntity playerEntity) {
|
||||||
GameProfileData data = GameProfileData.from(playerEntity.getProfile());
|
GameProfileData data = GameProfileData.from(playerEntity.getProfile());
|
||||||
SkinProvider.Cape cape = SkinProvider.getCachedCape(data.getCapeUrl());
|
SkinProvider.Cape cape = SkinProvider.getCachedCape(data.capeUrl());
|
||||||
SkinProvider.SkinGeometry geometry = SkinProvider.SkinGeometry.getLegacy(data.isAlex());
|
SkinProvider.SkinGeometry geometry = SkinProvider.SkinGeometry.getLegacy(data.isAlex());
|
||||||
|
|
||||||
SkinProvider.Skin skin = SkinProvider.getCachedSkin(data.getSkinUrl());
|
SkinProvider.Skin skin = SkinProvider.getCachedSkin(data.skinUrl());
|
||||||
if (skin == null) {
|
if (skin == null) {
|
||||||
skin = SkinProvider.EMPTY_SKIN;
|
skin = SkinProvider.EMPTY_SKIN;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +116,7 @@ public class SkinManager {
|
||||||
Consumer<SkinProvider.SkinAndCape> skinAndCapeConsumer) {
|
Consumer<SkinProvider.SkinAndCape> skinAndCapeConsumer) {
|
||||||
GameProfileData data = GameProfileData.from(entity.getProfile());
|
GameProfileData data = GameProfileData.from(entity.getProfile());
|
||||||
|
|
||||||
SkinProvider.requestSkinAndCape(entity.getUuid(), data.getSkinUrl(), data.getCapeUrl())
|
SkinProvider.requestSkinAndCape(entity.getUuid(), data.skinUrl(), data.capeUrl())
|
||||||
.whenCompleteAsync((skinAndCape, throwable) -> {
|
.whenCompleteAsync((skinAndCape, throwable) -> {
|
||||||
try {
|
try {
|
||||||
SkinProvider.Skin skin = skinAndCape.getSkin();
|
SkinProvider.Skin skin = skinAndCape.getSkin();
|
||||||
|
@ -206,7 +204,10 @@ public class SkinManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleBedrockSkin(PlayerEntity playerEntity, BedrockClientData clientData) {
|
public static void handleBedrockSkin(PlayerEntity playerEntity, BedrockClientData clientData) {
|
||||||
GeyserConnector.getInstance().getLogger().info(LanguageUtils.getLocaleStringLog("geyser.skin.bedrock.register", playerEntity.getUsername(), playerEntity.getUuid()));
|
GeyserConnector connector = GeyserConnector.getInstance();
|
||||||
|
if (connector.getConfig().isDebugMode()) {
|
||||||
|
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.skin.bedrock.register", playerEntity.getUsername(), playerEntity.getUuid()));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] skinBytes = Base64.getDecoder().decode(clientData.getSkinData().getBytes(StandardCharsets.UTF_8));
|
byte[] skinBytes = Base64.getDecoder().decode(clientData.getSkinData().getBytes(StandardCharsets.UTF_8));
|
||||||
|
@ -218,9 +219,9 @@ public class SkinManager {
|
||||||
if (skinBytes.length <= (128 * 128 * 4) && !clientData.isPersonaSkin()) {
|
if (skinBytes.length <= (128 * 128 * 4) && !clientData.isPersonaSkin()) {
|
||||||
SkinProvider.storeBedrockSkin(playerEntity.getUuid(), clientData.getSkinId(), skinBytes);
|
SkinProvider.storeBedrockSkin(playerEntity.getUuid(), clientData.getSkinId(), skinBytes);
|
||||||
SkinProvider.storeBedrockGeometry(playerEntity.getUuid(), geometryNameBytes, geometryBytes);
|
SkinProvider.storeBedrockGeometry(playerEntity.getUuid(), geometryNameBytes, geometryBytes);
|
||||||
} else {
|
} else if (connector.getConfig().isDebugMode()) {
|
||||||
GeyserConnector.getInstance().getLogger().info(LanguageUtils.getLocaleStringLog("geyser.skin.bedrock.fail", playerEntity.getUsername()));
|
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.skin.bedrock.fail", playerEntity.getUsername()));
|
||||||
GeyserConnector.getInstance().getLogger().debug("The size of '" + playerEntity.getUsername() + "' skin is: " + clientData.getSkinImageWidth() + "x" + clientData.getSkinImageHeight());
|
connector.getLogger().debug("The size of '" + playerEntity.getUsername() + "' skin is: " + clientData.getSkinImageWidth() + "x" + clientData.getSkinImageHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!clientData.getCapeId().equals("")) {
|
if (!clientData.getCapeId().equals("")) {
|
||||||
|
@ -231,13 +232,7 @@ public class SkinManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
public record GameProfileData(String skinUrl, String capeUrl, boolean isAlex) {
|
||||||
@Getter
|
|
||||||
public static class GameProfileData {
|
|
||||||
private final String skinUrl;
|
|
||||||
private final String capeUrl;
|
|
||||||
private final boolean alex;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the GameProfileData from the given GameProfile
|
* Generate the GameProfileData from the given GameProfile
|
||||||
*
|
*
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class SkinProvider {
|
||||||
public static final Skin EMPTY_SKIN = new Skin(-1, "steve", STEVE_SKIN);
|
public static final Skin EMPTY_SKIN = new Skin(-1, "steve", STEVE_SKIN);
|
||||||
public static final byte[] ALEX_SKIN = new ProvidedSkin("bedrock/skin/skin_alex.png").getSkin();
|
public static final byte[] ALEX_SKIN = new ProvidedSkin("bedrock/skin/skin_alex.png").getSkin();
|
||||||
public static final Skin EMPTY_SKIN_ALEX = new Skin(-1, "alex", ALEX_SKIN);
|
public static final Skin EMPTY_SKIN_ALEX = new Skin(-1, "alex", ALEX_SKIN);
|
||||||
private static final Map<String, Skin> permanentSkins = new HashMap<String, Skin>() {{
|
private static final Map<String, Skin> permanentSkins = new HashMap<>() {{
|
||||||
put("steve", EMPTY_SKIN);
|
put("steve", EMPTY_SKIN);
|
||||||
put("alex", EMPTY_SKIN_ALEX);
|
put("alex", EMPTY_SKIN_ALEX);
|
||||||
}};
|
}};
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class SkullSkinManager extends SkinManager {
|
||||||
Consumer<SkinProvider.Skin> skinConsumer) {
|
Consumer<SkinProvider.Skin> skinConsumer) {
|
||||||
GameProfileData data = GameProfileData.from(entity.getProfile());
|
GameProfileData data = GameProfileData.from(entity.getProfile());
|
||||||
|
|
||||||
SkinProvider.requestSkin(entity.getUuid(), data.getSkinUrl(), true)
|
SkinProvider.requestSkin(entity.getUuid(), data.skinUrl(), true)
|
||||||
.whenCompleteAsync((skin, throwable) -> {
|
.whenCompleteAsync((skin, throwable) -> {
|
||||||
try {
|
try {
|
||||||
if (session.getUpstream().isInitialized()) {
|
if (session.getUpstream().isInitialized()) {
|
||||||
|
|
Loading…
Reference in a new issue