1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-19 14:59:20 +00:00

Use the correct uuid instead of always always using the xuid

This commit is contained in:
Tim203
2021-05-04 16:16:45 +02:00
parent 34a793f41f
commit a80d0e18e1
2 changed files with 3 additions and 41 deletions

View File

@@ -213,7 +213,7 @@ public final class FloodgateHandshakeHandler {
private void correctHostname(HandshakeData handshakeData) { private void correctHostname(HandshakeData handshakeData) {
BedrockData bedrockData = handshakeData.getBedrockData(); BedrockData bedrockData = handshakeData.getBedrockData();
UUID correctUuid = Utils.getJavaUuid(bedrockData.getXuid()); UUID correctUuid = handshakeData.getCorrectUniqueId();
// replace the ip and uuid with the Bedrock client IP and an uuid based of the xuid // replace the ip and uuid with the Bedrock client IP and an uuid based of the xuid
String[] split = handshakeData.getHostname().split("\0"); String[] split = handshakeData.getHostname().split("\0");

View File

@@ -28,17 +28,14 @@ package org.geysermc.floodgate.player;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.geysermc.floodgate.api.FloodgateApi;
import org.geysermc.floodgate.api.InstanceHolder; import org.geysermc.floodgate.api.InstanceHolder;
import org.geysermc.floodgate.api.ProxyFloodgateApi; import org.geysermc.floodgate.api.ProxyFloodgateApi;
import org.geysermc.floodgate.api.SimpleFloodgateApi;
import org.geysermc.floodgate.api.handshake.HandshakeData; import org.geysermc.floodgate.api.handshake.HandshakeData;
import org.geysermc.floodgate.api.link.PlayerLink;
import org.geysermc.floodgate.api.player.FloodgatePlayer; import org.geysermc.floodgate.api.player.FloodgatePlayer;
import org.geysermc.floodgate.api.player.PropertyKey; import org.geysermc.floodgate.api.player.PropertyKey;
import org.geysermc.floodgate.api.player.PropertyKey.Result; import org.geysermc.floodgate.api.player.PropertyKey.Result;
@@ -84,7 +81,7 @@ public final class FloodgatePlayerImpl implements FloodgatePlayer {
BedrockData data, BedrockData data,
HandshakeData handshakeData) { HandshakeData handshakeData) {
SimpleFloodgateApi api = InstanceHolder.castApi(SimpleFloodgateApi.class); FloodgateApi api = InstanceHolder.getApi();
UUID javaUniqueId = Utils.getJavaUuid(data.getXuid()); UUID javaUniqueId = Utils.getJavaUuid(data.getXuid());
@@ -101,41 +98,6 @@ public final class FloodgatePlayerImpl implements FloodgatePlayer {
linkedPlayer, data.getSubscribeId(), data.getVerifyCode()); linkedPlayer, data.getSubscribeId(), data.getVerifyCode());
} }
/**
* Fetch and return the LinkedPlayer object associated to the player if the player is linked.
* Please note that this method loads the LinkedPlayer synchronously.
*
* @return LinkedPlayer or null if the player isn't linked or linking isn't enabled
* @see #fetchLinkedPlayerAsync(PlayerLink, UUID) for the asynchronously alternative
*/
public static LinkedPlayer fetchLinkedPlayer(PlayerLink link, UUID javaUniqueId) {
if (!link.isEnabled()) {
return null;
}
try {
return link.getLinkedPlayer(javaUniqueId).get();
} catch (InterruptedException | ExecutionException exception) {
exception.printStackTrace();
return null;
}
}
/**
* Fetch and return the LinkedPlayer object associated to the player if the player is linked.
*
* @return a future holding the LinkedPlayer or null if the player isn't linked or when linking
* isn't enabled
* @see #fetchLinkedPlayer(PlayerLink, UUID) for the sync version
*/
public static CompletableFuture<LinkedPlayer> fetchLinkedPlayerAsync(
PlayerLink link,
UUID javaUniqueId) {
return link.isEnabled() ?
link.getLinkedPlayer(javaUniqueId) :
CompletableFuture.completedFuture(null);
}
@Override @Override
public UUID getCorrectUniqueId() { public UUID getCorrectUniqueId() {
return linkedPlayer != null ? linkedPlayer.getJavaUniqueId() : javaUniqueId; return linkedPlayer != null ? linkedPlayer.getJavaUniqueId() : javaUniqueId;