1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2026-01-06 15:42:03 +00:00

Fixed a 1.8.8 issue and don't hide unexpected player linking errors

This commit is contained in:
Tim203
2021-09-04 21:23:30 +02:00
parent 933720660c
commit 8df1b1e03e
2 changed files with 14 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ package org.geysermc.floodgate.link;
import static org.geysermc.floodgate.util.Constants.GET_BEDROCK_LINK;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@@ -111,13 +112,14 @@ public class GlobalPlayerLinking extends CommonPlayerLink {
JsonObject data = response.getResponse().getAsJsonObject("data");
// no link if data is empty
if (data.size() == 0) {
JsonElement javaName = data.get("java_name");
// javaName will be null when the player isn't linked
if (javaName == null) {
return null;
}
return LinkedPlayer.of(
data.get("java_name").getAsString(),
javaName.getAsString(),
UUID.fromString(data.get("java_id").getAsString()),
Utils.getJavaUuid(data.get("bedrock_id").getAsLong()));
},
@@ -158,7 +160,7 @@ public class GlobalPlayerLinking extends CommonPlayerLink {
JsonObject data = response.getResponse().getAsJsonObject("data");
// no link if data is empty, otherwise the player is linked
return data.size() != 0;
return data.entrySet().size() != 0;
},
getExecutorService());
}

View File

@@ -282,7 +282,14 @@ public final class FloodgateHandshakeHandler {
return CompletableFuture.completedFuture(new ObjectObjectImmutablePair<>(data, null));
}
return api.getPlayerLink().getLinkedPlayer(Utils.getJavaUuid(data.getXuid()))
.thenApply(link -> new ObjectObjectImmutablePair<>(data, link));
.thenApply(link -> new ObjectObjectImmutablePair<>(data, link))
.handle((result, error) -> {
if (error != null) {
logger.error("The player linking implementation returned an error", error.getCause());
return new ObjectObjectImmutablePair<>(data, null);
}
return result;
});
}
public enum ResultType {