From ffb18e5d472accc827ef93a8c88e69ec07204b29 Mon Sep 17 00:00:00 2001 From: qlow Date: Mon, 7 Dec 2020 14:30:24 +0100 Subject: [PATCH 1/9] Added IGeyserPingPassthrough#getPingInformation(InetSocketAddress) to make logging of the pinging IPs possible --- .../GeyserBungeePingPassthrough.java | 15 +++++++++------ .../spigot/GeyserSpigotPingPassthrough.java | 5 +++-- .../sponge/GeyserSpongePingPassthrough.java | 18 ++++++++++-------- .../GeyserVelocityPingPassthrough.java | 14 ++++++++------ .../network/ConnectorServerEventHandler.java | 2 +- .../ping/GeyserLegacyPingPassthrough.java | 2 +- .../connector/ping/IGeyserPingPassthrough.java | 16 +++++++++++++++- 7 files changed, 47 insertions(+), 25 deletions(-) diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePingPassthrough.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePingPassthrough.java index 15c8fa9e031..884bd7c35cf 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePingPassthrough.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePingPassthrough.java @@ -47,14 +47,12 @@ @AllArgsConstructor public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, Listener { - private static final GeyserPendingConnection PENDING_CONNECTION = new GeyserPendingConnection(); - private final ProxyServer proxyServer; @Override - public GeyserPingInfo getPingInformation() { + public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) { CompletableFuture future = new CompletableFuture<>(); - proxyServer.getPluginManager().callEvent(new ProxyPingEvent(PENDING_CONNECTION, getPingInfo(), (event, throwable) -> { + proxyServer.getPluginManager().callEvent(new ProxyPingEvent(new GeyserPendingConnection(inetSocketAddress), getPingInfo(), (event, throwable) -> { if (throwable != null) future.completeExceptionally(throwable); else future.complete(event); })); @@ -89,7 +87,12 @@ private ServerPing getPingInfo() { private static class GeyserPendingConnection implements PendingConnection { private static final UUID FAKE_UUID = UUID.nameUUIDFromBytes("geyser!internal".getBytes()); - private static final InetSocketAddress FAKE_REMOTE = new InetSocketAddress(Inet4Address.getLoopbackAddress(), 69); + + private final InetSocketAddress remote; + + public GeyserPendingConnection(InetSocketAddress remote) { + this.remote = remote; + } @Override public String getName() { @@ -143,7 +146,7 @@ public boolean isLegacy() { @Override public InetSocketAddress getAddress() { - return FAKE_REMOTE; + return remote; } @Override diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPingPassthrough.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPingPassthrough.java index 7196f4290f8..5673d85ba7b 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPingPassthrough.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPingPassthrough.java @@ -35,6 +35,7 @@ import org.geysermc.connector.ping.IGeyserPingPassthrough; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.util.Collections; import java.util.Iterator; @@ -44,9 +45,9 @@ public class GeyserSpigotPingPassthrough implements IGeyserPingPassthrough { private final GeyserSpigotLogger logger; @Override - public GeyserPingInfo getPingInformation() { + public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) { try { - ServerListPingEvent event = new GeyserPingEvent(InetAddress.getLocalHost(), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers()); + ServerListPingEvent event = new GeyserPingEvent(inetSocketAddress.getAddress(), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers()); Bukkit.getPluginManager().callEvent(event); GeyserPingInfo geyserPingInfo = new GeyserPingInfo(event.getMotd(), new GeyserPingInfo.Players(event.getMaxPlayers(), event.getNumPlayers()), diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePingPassthrough.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePingPassthrough.java index 251b9703d59..c5b6b831460 100644 --- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePingPassthrough.java +++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePingPassthrough.java @@ -38,31 +38,29 @@ import org.spongepowered.api.profile.GameProfile; import java.lang.reflect.Method; -import java.net.Inet4Address; import java.net.InetSocketAddress; import java.util.Optional; public class GeyserSpongePingPassthrough implements IGeyserPingPassthrough { - private static final GeyserStatusClient STATUS_CLIENT = new GeyserStatusClient(); private static final Cause CAUSE = Cause.of(EventContext.empty(), Sponge.getServer()); private static Method SpongeStatusResponse_create; @SuppressWarnings({"unchecked", "rawtypes"}) @Override - public GeyserPingInfo getPingInformation() { + public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) { // come on Sponge, this is in commons, why not expose it :( ClientPingServerEvent event; try { - if(SpongeStatusResponse_create == null) { + if (SpongeStatusResponse_create == null) { Class SpongeStatusResponse = Class.forName("org.spongepowered.common.network.status.SpongeStatusResponse"); Class MinecraftServer = Class.forName("net.minecraft.server.MinecraftServer"); SpongeStatusResponse_create = SpongeStatusResponse.getDeclaredMethod("create", MinecraftServer); } Object response = SpongeStatusResponse_create.invoke(null, Sponge.getServer()); - event = SpongeEventFactory.createClientPingServerEvent(CAUSE, STATUS_CLIENT, (ClientPingServerEvent.Response) response); + event = SpongeEventFactory.createClientPingServerEvent(CAUSE, new GeyserStatusClient(inetSocketAddress), (ClientPingServerEvent.Response) response); } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } @@ -76,7 +74,7 @@ public GeyserPingInfo getPingInformation() { new GeyserPingInfo.Version( event.getResponse().getVersion().getName(), MinecraftConstants.PROTOCOL_VERSION) // thanks for also not exposing this sponge - ); + ); event.getResponse().getPlayers().get().getProfiles().stream() .map(GameProfile::getName) .map(op -> op.orElseThrow(IllegalStateException::new)) @@ -87,11 +85,15 @@ public GeyserPingInfo getPingInformation() { @SuppressWarnings("NullableProblems") private static class GeyserStatusClient implements StatusClient { - private static final InetSocketAddress FAKE_REMOTE = new InetSocketAddress(Inet4Address.getLoopbackAddress(), 69); + private final InetSocketAddress remote; + + public GeyserStatusClient(InetSocketAddress remote) { + this.remote = remote; + } @Override public InetSocketAddress getAddress() { - return FAKE_REMOTE; + return this.remote; } @Override diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPingPassthrough.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPingPassthrough.java index ff8376e4b1d..9674d27ef05 100644 --- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPingPassthrough.java +++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPingPassthrough.java @@ -43,15 +43,13 @@ @AllArgsConstructor public class GeyserVelocityPingPassthrough implements IGeyserPingPassthrough { - private static final GeyserInboundConnection FAKE_INBOUND_CONNECTION = new GeyserInboundConnection(); - private final ProxyServer server; @Override - public GeyserPingInfo getPingInformation() { + public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) { ProxyPingEvent event; try { - event = server.getEventManager().fire(new ProxyPingEvent(FAKE_INBOUND_CONNECTION, ServerPing.builder() + event = server.getEventManager().fire(new ProxyPingEvent(new GeyserInboundConnection(inetSocketAddress), ServerPing.builder() .description(server.getConfiguration().getMotdComponent()).onlinePlayers(server.getPlayerCount()) .maximumPlayers(server.getConfiguration().getShowMaxPlayers()).build())).get(); } catch (ExecutionException | InterruptedException e) { @@ -74,11 +72,15 @@ public GeyserPingInfo getPingInformation() { private static class GeyserInboundConnection implements InboundConnection { - private static final InetSocketAddress FAKE_REMOTE = new InetSocketAddress(Inet4Address.getLoopbackAddress(), 69); + private final InetSocketAddress remote; + + public GeyserInboundConnection(InetSocketAddress remote) { + this.remote = remote; + } @Override public InetSocketAddress getRemoteAddress() { - return FAKE_REMOTE; + return this.remote; } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java index 150d298c76a..fade4d78a3b 100644 --- a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java @@ -63,7 +63,7 @@ public BedrockPong onQuery(InetSocketAddress inetSocketAddress) { GeyserPingInfo pingInfo = null; if (config.isPassthroughMotd() || config.isPassthroughPlayerCounts()) { IGeyserPingPassthrough pingPassthrough = connector.getBootstrap().getGeyserPingPassthrough(); - pingInfo = pingPassthrough.getPingInformation(); + pingInfo = pingPassthrough.getPingInformation(inetSocketAddress); } BedrockPong pong = new BedrockPong(); diff --git a/connector/src/main/java/org/geysermc/connector/ping/GeyserLegacyPingPassthrough.java b/connector/src/main/java/org/geysermc/connector/ping/GeyserLegacyPingPassthrough.java index 519d847dbd1..6d54cc4c2e6 100644 --- a/connector/src/main/java/org/geysermc/connector/ping/GeyserLegacyPingPassthrough.java +++ b/connector/src/main/java/org/geysermc/connector/ping/GeyserLegacyPingPassthrough.java @@ -70,7 +70,7 @@ public static IGeyserPingPassthrough init(GeyserConnector connector) { } @Override - public GeyserPingInfo getPingInformation() { + public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) { return pingInfo; } diff --git a/connector/src/main/java/org/geysermc/connector/ping/IGeyserPingPassthrough.java b/connector/src/main/java/org/geysermc/connector/ping/IGeyserPingPassthrough.java index 049f85046bd..85ef7733d33 100644 --- a/connector/src/main/java/org/geysermc/connector/ping/IGeyserPingPassthrough.java +++ b/connector/src/main/java/org/geysermc/connector/ping/IGeyserPingPassthrough.java @@ -27,15 +27,29 @@ import org.geysermc.connector.common.ping.GeyserPingInfo; +import java.net.Inet4Address; +import java.net.InetSocketAddress; + /** * Interface that retrieves ping passthrough information from the Java server */ public interface IGeyserPingPassthrough { + /** + * Get the MOTD of the server displayed on the multiplayer screen. It uses a fake remote, as the remote isn't important in this context. + * + * @return string of the MOTD + */ + default GeyserPingInfo getPingInformation() { + return this.getPingInformation(new InetSocketAddress(Inet4Address.getLoopbackAddress(), 69)); + } + /** * Get the MOTD of the server displayed on the multiplayer screen + * + * @param inetSocketAddress the ip address of the client pinging the server * @return string of the MOTD */ - GeyserPingInfo getPingInformation(); + GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress); } From b4545ae381917e230541475fd658f0d05d6f8f23 Mon Sep 17 00:00:00 2001 From: qlow Date: Wed, 9 Dec 2020 10:58:55 +0100 Subject: [PATCH 2/9] Added GeyserConnector#getPlayerByXboxUuid --- .../java/org/geysermc/connector/GeyserConnector.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index 96c7089897f..54088acdabc 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -44,6 +44,7 @@ import org.geysermc.connector.network.translators.BiomeTranslator; import org.geysermc.connector.network.translators.EntityIdentifierRegistry; import org.geysermc.connector.network.translators.PacketTranslatorRegistry; +import org.geysermc.connector.network.translators.collision.CollisionTranslator; import org.geysermc.connector.network.translators.effect.EffectRegistry; import org.geysermc.connector.network.translators.item.ItemRegistry; import org.geysermc.connector.network.translators.item.ItemTranslator; @@ -54,7 +55,6 @@ import org.geysermc.connector.network.translators.world.WorldManager; import org.geysermc.connector.network.translators.world.block.BlockTranslator; import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator; -import org.geysermc.connector.network.translators.collision.CollisionTranslator; import org.geysermc.connector.network.translators.world.block.entity.SkullBlockEntityTranslator; import org.geysermc.connector.utils.DimensionUtils; import org.geysermc.connector.utils.LanguageUtils; @@ -325,6 +325,14 @@ public void removePlayer(GeyserSession player) { players.remove(player); } + public GeyserSession getPlayerByXboxUuid(String xboxUuid) { + return players + .stream() + .filter(player -> player.getAuthData() != null && player.getAuthData().getXboxUUID().equals(xboxUuid)) + .findFirst() + .orElse(null); + } + public static GeyserConnector start(PlatformType platformType, GeyserBootstrap bootstrap) { return new GeyserConnector(platformType, bootstrap); } From d02bef3720b63260e84b3d095dc6678491276dfd Mon Sep 17 00:00:00 2001 From: qlow Date: Wed, 9 Dec 2020 12:03:29 +0100 Subject: [PATCH 3/9] Added GeyserConnector#getPlayerByUuid and added some javadocs --- .../geysermc/connector/GeyserConnector.java | 41 +++++++++++++++---- .../geysermc/connector/skin/SkinManager.java | 20 ++++----- .../geysermc/connector/skin/SkinProvider.java | 11 ++--- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index 54088acdabc..1213b0bcbac 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -67,10 +67,7 @@ import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -325,12 +322,38 @@ public void removePlayer(GeyserSession player) { players.remove(player); } + /** + * Gets a player by their current UUID + * + * @param uuid the uuid + * @return the player or null if there is no player online with this UUID + */ + public GeyserSession getPlayerByUuid(UUID uuid) { + for (GeyserSession session : players) { + if (!session.getPlayerEntity().getUuid().equals(uuid)) + continue; + + return session; + } + + return null; + } + + /** + * Gets a player by their Xbox UUID + * + * @param xboxUuid the Xbox UUID + * @return the player or null if there is no player online with this XUID + */ public GeyserSession getPlayerByXboxUuid(String xboxUuid) { - return players - .stream() - .filter(player -> player.getAuthData() != null && player.getAuthData().getXboxUUID().equals(xboxUuid)) - .findFirst() - .orElse(null); + for (GeyserSession session : players) { + if (session.getAuthData() == null || !session.getAuthData().getXboxUUID().equals(xboxUuid)) + continue; + + return session; + } + + return null; } public static GeyserConnector start(PlatformType platformType, GeyserBootstrap bootstrap) { diff --git a/connector/src/main/java/org/geysermc/connector/skin/SkinManager.java b/connector/src/main/java/org/geysermc/connector/skin/SkinManager.java index db8f25929e7..0e1499a90e5 100644 --- a/connector/src/main/java/org/geysermc/connector/skin/SkinManager.java +++ b/connector/src/main/java/org/geysermc/connector/skin/SkinManager.java @@ -81,12 +81,10 @@ public static PlayerListPacket.Entry buildEntryManually(GeyserSession session, U // This attempts to find the xuid of the player so profile images show up for xbox accounts String xuid = ""; - for (GeyserSession player : GeyserConnector.getInstance().getPlayers()) { - if (player.getPlayerEntity().getUuid().equals(uuid)) { - xuid = player.getAuthData().getXboxUUID(); - break; - } - } + GeyserSession player = GeyserConnector.getInstance().getPlayerByUuid(uuid); + + if (player != null) + xuid = player.getAuthData().getXboxUUID(); PlayerListPacket.Entry entry; @@ -268,12 +266,10 @@ public static GameProfileData from(GameProfile profile) { // return default skin with default cape when texture data is invalid 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; - } - } + GeyserSession session = GeyserConnector.getInstance().getPlayerByUuid(profile.getId()); + + if (session != null) + skinUrl = session.getClientData().getSkinId(); } return new GameProfileData(skinUrl, SkinProvider.EMPTY_CAPE.getTextureUrl(), isAlex); } diff --git a/connector/src/main/java/org/geysermc/connector/skin/SkinProvider.java b/connector/src/main/java/org/geysermc/connector/skin/SkinProvider.java index 117198685a5..dc9ff148fc1 100644 --- a/connector/src/main/java/org/geysermc/connector/skin/SkinProvider.java +++ b/connector/src/main/java/org/geysermc/connector/skin/SkinProvider.java @@ -144,13 +144,10 @@ public static CompletableFuture requestSkinAndCape(UUID playerId, S 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; - } - } + GeyserSession session = GeyserConnector.getInstance().getPlayerByUuid(playerId); + + if (session != null) + newSkinUrl = session.getClientData().getSkinId(); } CapeProvider provider = capeUrl != null ? CapeProvider.MINECRAFT : null; From 39a7c331bea6f5765e9fceb85b167bbb79a1b042 Mon Sep 17 00:00:00 2001 From: qlow <20094418+qlow@users.noreply.github.com> Date: Wed, 9 Dec 2020 12:29:56 +0100 Subject: [PATCH 4/9] Update connector/src/main/java/org/geysermc/connector/GeyserConnector.java Co-authored-by: rtm516 --- .../main/java/org/geysermc/connector/GeyserConnector.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index 1213b0bcbac..4ed1a3fc223 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -330,10 +330,9 @@ public void removePlayer(GeyserSession player) { */ public GeyserSession getPlayerByUuid(UUID uuid) { for (GeyserSession session : players) { - if (!session.getPlayerEntity().getUuid().equals(uuid)) - continue; - - return session; + if (session.getPlayerEntity().getUuid().equals(uuid)) { + return session; + } } return null; From c6638c59b442b47a499b72b8fdef688929a133eb Mon Sep 17 00:00:00 2001 From: qlow <20094418+qlow@users.noreply.github.com> Date: Wed, 9 Dec 2020 12:30:01 +0100 Subject: [PATCH 5/9] Update connector/src/main/java/org/geysermc/connector/GeyserConnector.java Co-authored-by: rtm516 --- .../main/java/org/geysermc/connector/GeyserConnector.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index 4ed1a3fc223..f33cb714ad5 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -346,10 +346,9 @@ public GeyserSession getPlayerByUuid(UUID uuid) { */ public GeyserSession getPlayerByXboxUuid(String xboxUuid) { for (GeyserSession session : players) { - if (session.getAuthData() == null || !session.getAuthData().getXboxUUID().equals(xboxUuid)) - continue; - - return session; + if (session.getAuthData() != null && session.getAuthData().getXboxUUID().equals(xboxUuid)) + return session; + } } return null; From e6d080d9564b0f8423c2a8c78546d589c374d367 Mon Sep 17 00:00:00 2001 From: qlow <20094418+qlow@users.noreply.github.com> Date: Wed, 9 Dec 2020 12:34:57 +0100 Subject: [PATCH 6/9] Update GeyserConnector.java --- .../src/main/java/org/geysermc/connector/GeyserConnector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index f33cb714ad5..1b4b6eb513c 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -346,7 +346,7 @@ public GeyserSession getPlayerByUuid(UUID uuid) { */ public GeyserSession getPlayerByXboxUuid(String xboxUuid) { for (GeyserSession session : players) { - if (session.getAuthData() != null && session.getAuthData().getXboxUUID().equals(xboxUuid)) + if (session.getAuthData() != null && session.getAuthData().getXboxUUID().equals(xboxUuid)) { return session; } } From ed03851f8aa213769a4fd3693a4bddff0ad1d564 Mon Sep 17 00:00:00 2001 From: qlow <20094418+qlow@users.noreply.github.com> Date: Wed, 9 Dec 2020 12:36:05 +0100 Subject: [PATCH 7/9] Update SkinManager.java --- .../main/java/org/geysermc/connector/skin/SkinManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/skin/SkinManager.java b/connector/src/main/java/org/geysermc/connector/skin/SkinManager.java index 0e1499a90e5..a08f567a30a 100644 --- a/connector/src/main/java/org/geysermc/connector/skin/SkinManager.java +++ b/connector/src/main/java/org/geysermc/connector/skin/SkinManager.java @@ -83,8 +83,9 @@ public static PlayerListPacket.Entry buildEntryManually(GeyserSession session, U String xuid = ""; GeyserSession player = GeyserConnector.getInstance().getPlayerByUuid(uuid); - if (player != null) + if (player != null) { xuid = player.getAuthData().getXboxUUID(); + } PlayerListPacket.Entry entry; @@ -268,8 +269,9 @@ public static GameProfileData from(GameProfile profile) { if ("steve".equals(skinUrl) || "alex".equals(skinUrl)) { GeyserSession session = GeyserConnector.getInstance().getPlayerByUuid(profile.getId()); - if (session != null) + if (session != null) { skinUrl = session.getClientData().getSkinId(); + } } return new GameProfileData(skinUrl, SkinProvider.EMPTY_CAPE.getTextureUrl(), isAlex); } From ad028694d2738696783055bbe9c8ca775169f07c Mon Sep 17 00:00:00 2001 From: qlow <20094418+qlow@users.noreply.github.com> Date: Wed, 9 Dec 2020 12:36:37 +0100 Subject: [PATCH 8/9] Update SkinProvider.java --- .../main/java/org/geysermc/connector/skin/SkinProvider.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/skin/SkinProvider.java b/connector/src/main/java/org/geysermc/connector/skin/SkinProvider.java index dc9ff148fc1..948e4b37447 100644 --- a/connector/src/main/java/org/geysermc/connector/skin/SkinProvider.java +++ b/connector/src/main/java/org/geysermc/connector/skin/SkinProvider.java @@ -146,8 +146,9 @@ public static CompletableFuture requestSkinAndCape(UUID playerId, S if ("steve".equals(skinUrl) || "alex".equals(skinUrl)) { GeyserSession session = GeyserConnector.getInstance().getPlayerByUuid(playerId); - if (session != null) + if (session != null) { newSkinUrl = session.getClientData().getSkinId(); + } } CapeProvider provider = capeUrl != null ? CapeProvider.MINECRAFT : null; From 563e72ffcc183085ffa8b623baafa014fbf15339 Mon Sep 17 00:00:00 2001 From: qlow <20094418+qlow@users.noreply.github.com> Date: Thu, 17 Dec 2020 17:36:07 +0100 Subject: [PATCH 9/9] Renamed getPlayerByXboxUuid to getPlayerByXuid --- .../java/org/geysermc/connector/GeyserConnector.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index 1b4b6eb513c..d4caf437667 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -339,14 +339,14 @@ public GeyserSession getPlayerByUuid(UUID uuid) { } /** - * Gets a player by their Xbox UUID + * Gets a player by their Xbox user identifier * - * @param xboxUuid the Xbox UUID - * @return the player or null if there is no player online with this XUID + * @param xboxUuid the Xbox user identifier + * @return the player or null if there is no player online with this xuid */ - public GeyserSession getPlayerByXboxUuid(String xboxUuid) { + public GeyserSession getPlayerByXuid(String xuid) { for (GeyserSession session : players) { - if (session.getAuthData() != null && session.getAuthData().getXboxUUID().equals(xboxUuid)) { + if (session.getAuthData() != null && session.getAuthData().getXboxUUID().equals(xuid)) { return session; } }