mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Fixed fwhitelist when linked account with identical names are online
1. I join as a linked user (happens to be the same java/bedrock username) 2. If I try to fwhitelist myself, it'll fail as I'm not a bedrock player Co-authored-by: chris <github@onechris.mozmail.com>
This commit is contained in:
@@ -72,7 +72,7 @@ public class HandshakeDataImpl implements HandshakeData {
|
||||
linkedPlayer = connection.linkedPlayer();
|
||||
|
||||
javaUsername = connection.javaUsername();
|
||||
javaUniqueId = Utils.getJavaUuid(bedrockData.getXuid());
|
||||
javaUniqueId = Utils.toFloodgateUniqueId(bedrockData.getXuid());
|
||||
this.ip = bedrockData.getIp();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,10 +89,6 @@ public class SimpleFloodgateApi implements GeyserApiBase {
|
||||
return connectionManager.connectionByXuid(xuid);
|
||||
}
|
||||
|
||||
public boolean isFloodgateId(UUID uuid) {
|
||||
return uuid.getMostSignificantBits() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendForm(@NonNull UUID uuid, @NonNull Form form) {
|
||||
return pluginMessageManager.get().getChannel(FormChannel.class).sendForm(uuid, form);
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.geysermc.floodgate.core.connection.FloodgateConnection;
|
||||
import org.geysermc.floodgate.core.http.xbox.GetGamertagResult;
|
||||
import org.geysermc.floodgate.core.http.xbox.GetXuidResult;
|
||||
import org.geysermc.floodgate.core.http.xbox.XboxClient;
|
||||
import org.geysermc.floodgate.core.util.Utils;
|
||||
|
||||
@Singleton
|
||||
public final class LegacyApiWrapper implements FloodgateApi {
|
||||
@@ -86,7 +87,7 @@ public final class LegacyApiWrapper implements FloodgateApi {
|
||||
|
||||
@Override
|
||||
public boolean isFloodgateId(UUID uuid) {
|
||||
return uuid.getMostSignificantBits() == 0;
|
||||
return Utils.isFloodgateUniqueId(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TestCommand implements FloodgateCommand {
|
||||
|
||||
public void execute(CommandContext<ConsoleAudience> context) {
|
||||
try {
|
||||
link.addLink(context.get("uuid"), context.get("name"), Utils.getJavaUuid(context.get("xuid"))).get();
|
||||
link.addLink(context.get("uuid"), context.get("name"), Utils.toFloodgateUniqueId(context.get("xuid"))).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.geysermc.floodgate.core.platform.command.CommandUtil;
|
||||
import org.geysermc.floodgate.core.platform.command.FloodgateCommand;
|
||||
import org.geysermc.floodgate.core.platform.command.MessageType;
|
||||
import org.geysermc.floodgate.core.platform.command.TranslatableMessage;
|
||||
import org.geysermc.floodgate.core.util.Utils;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
@@ -83,7 +84,7 @@ public class WhitelistCommand implements FloodgateCommand {
|
||||
}
|
||||
|
||||
if (uuid != null) {
|
||||
if (uuid.getMostSignificantBits() != 0) { // TODO
|
||||
if (!Utils.isFloodgateUniqueId(uuid)) {
|
||||
sender.sendMessage(Message.INVALID_USERNAME);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public final class FloodgateDataHandler {
|
||||
if (!link.isEnabled() || connection.isLinked()) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
return link.fetchLink(Utils.getJavaUuid(connection.xuid()))
|
||||
return link.fetchLink(Utils.toFloodgateUniqueId(connection.xuid()))
|
||||
.thenApply(link -> {
|
||||
if (link == null) {
|
||||
return null;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class StandaloneFloodgateConnectionBuilder {
|
||||
|
||||
public FloodgateConnection build() {
|
||||
// todo add an option to use identity instead of xuid
|
||||
UUID javaUniqueId = Utils.getJavaUuid(xuid);
|
||||
UUID javaUniqueId = Utils.toFloodgateUniqueId(xuid);
|
||||
|
||||
return new StandaloneFloodgateConnection(
|
||||
version,
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class ProfileFetcher {
|
||||
if (xuid == null) {
|
||||
return null;
|
||||
}
|
||||
return new ProfileAudience(Utils.getJavaUuid(xuid), gamertag);
|
||||
return new ProfileAudience(Utils.toFloodgateUniqueId(xuid), gamertag);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class ProfileFetcher {
|
||||
if (gamertag == null) {
|
||||
return null;
|
||||
}
|
||||
return new ProfileAudience(Utils.getJavaUuid(xuid), gamertag);
|
||||
return new ProfileAudience(Utils.toFloodgateUniqueId(xuid), gamertag);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -34,16 +34,12 @@ import org.geysermc.floodgate.core.util.Utils;
|
||||
@Serdeable
|
||||
public record LinkedPlayer(
|
||||
@JsonbProperty("bedrock_id")
|
||||
@Nullable
|
||||
Long xuid,
|
||||
@Nullable
|
||||
String gamertag,
|
||||
@Nullable Long xuid,
|
||||
@Nullable String gamertag,
|
||||
@JsonbProperty("java_id")
|
||||
@Nullable
|
||||
UUID uuid,
|
||||
@Nullable UUID uuid,
|
||||
@JsonbProperty("java_name")
|
||||
@Nullable
|
||||
String username
|
||||
@Nullable String username
|
||||
) {
|
||||
public boolean isLinked() {
|
||||
// everything will be null when the player is not linked, since we return an empty object.
|
||||
@@ -56,6 +52,6 @@ public record LinkedPlayer(
|
||||
return null;
|
||||
}
|
||||
|
||||
return new org.geysermc.floodgate.core.database.entity.LinkedPlayer(Utils.getJavaUuid(xuid), uuid, username);
|
||||
return new org.geysermc.floodgate.core.database.entity.LinkedPlayer(Utils.toFloodgateUniqueId(xuid), uuid, username);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public abstract class CommandUtil {
|
||||
return player;
|
||||
}
|
||||
if (filter == ONLY_BEDROCK || filter == ONLY_JAVA) {
|
||||
if (api.isBedrockPlayer(getUuidFromSource(player)) == (filter == ONLY_BEDROCK)) {
|
||||
if (Utils.isFloodgateUniqueId(getUuidFromSource(player)) == (filter == ONLY_BEDROCK)) {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public abstract class CommandUtil {
|
||||
* Defaults to false when this platform doesn't support whitelisting.
|
||||
*/
|
||||
public boolean whitelistPlayer(long xuid, String username) {
|
||||
UUID uuid = Utils.getJavaUuid(xuid);
|
||||
UUID uuid = Utils.toFloodgateUniqueId(xuid);
|
||||
return whitelistPlayer(uuid, username);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public abstract class CommandUtil {
|
||||
* whitelisted. Defaults to false when this platform doesn't support whitelisting.
|
||||
*/
|
||||
public boolean removePlayerFromWhitelist(long xuid, String username) {
|
||||
UUID uuid = Utils.getJavaUuid(xuid);
|
||||
UUID uuid = Utils.toFloodgateUniqueId(xuid);
|
||||
return removePlayerFromWhitelist(uuid, username);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,12 +85,16 @@ public class Utils {
|
||||
return locale.getLanguage() + "_" + locale.getCountry();
|
||||
}
|
||||
|
||||
public static UUID getJavaUuid(long xuid) {
|
||||
public static boolean isFloodgateUniqueId(UUID uuid) {
|
||||
return uuid.getMostSignificantBits() == 0;
|
||||
}
|
||||
|
||||
public static UUID toFloodgateUniqueId(long xuid) {
|
||||
return new UUID(0, xuid);
|
||||
}
|
||||
|
||||
public static UUID getJavaUuid(String xuid) {
|
||||
return getJavaUuid(Long.parseLong(xuid));
|
||||
public static UUID toFloodgateUniqueId(String xuid) {
|
||||
return toFloodgateUniqueId(Long.parseLong(xuid));
|
||||
}
|
||||
|
||||
public static UUID fromShortUniqueId(String uuid) {
|
||||
|
||||
Reference in New Issue
Block a user