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();
|
linkedPlayer = connection.linkedPlayer();
|
||||||
|
|
||||||
javaUsername = connection.javaUsername();
|
javaUsername = connection.javaUsername();
|
||||||
javaUniqueId = Utils.getJavaUuid(bedrockData.getXuid());
|
javaUniqueId = Utils.toFloodgateUniqueId(bedrockData.getXuid());
|
||||||
this.ip = bedrockData.getIp();
|
this.ip = bedrockData.getIp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,10 +89,6 @@ public class SimpleFloodgateApi implements GeyserApiBase {
|
|||||||
return connectionManager.connectionByXuid(xuid);
|
return connectionManager.connectionByXuid(xuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFloodgateId(UUID uuid) {
|
|
||||||
return uuid.getMostSignificantBits() == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sendForm(@NonNull UUID uuid, @NonNull Form form) {
|
public boolean sendForm(@NonNull UUID uuid, @NonNull Form form) {
|
||||||
return pluginMessageManager.get().getChannel(FormChannel.class).sendForm(uuid, 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.GetGamertagResult;
|
||||||
import org.geysermc.floodgate.core.http.xbox.GetXuidResult;
|
import org.geysermc.floodgate.core.http.xbox.GetXuidResult;
|
||||||
import org.geysermc.floodgate.core.http.xbox.XboxClient;
|
import org.geysermc.floodgate.core.http.xbox.XboxClient;
|
||||||
|
import org.geysermc.floodgate.core.util.Utils;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public final class LegacyApiWrapper implements FloodgateApi {
|
public final class LegacyApiWrapper implements FloodgateApi {
|
||||||
@@ -86,7 +87,7 @@ public final class LegacyApiWrapper implements FloodgateApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFloodgateId(UUID uuid) {
|
public boolean isFloodgateId(UUID uuid) {
|
||||||
return uuid.getMostSignificantBits() == 0;
|
return Utils.isFloodgateUniqueId(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class TestCommand implements FloodgateCommand {
|
|||||||
|
|
||||||
public void execute(CommandContext<ConsoleAudience> context) {
|
public void execute(CommandContext<ConsoleAudience> context) {
|
||||||
try {
|
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) {
|
} catch (InterruptedException | ExecutionException e) {
|
||||||
throw new RuntimeException(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.FloodgateCommand;
|
||||||
import org.geysermc.floodgate.core.platform.command.MessageType;
|
import org.geysermc.floodgate.core.platform.command.MessageType;
|
||||||
import org.geysermc.floodgate.core.platform.command.TranslatableMessage;
|
import org.geysermc.floodgate.core.platform.command.TranslatableMessage;
|
||||||
|
import org.geysermc.floodgate.core.util.Utils;
|
||||||
import org.incendo.cloud.Command;
|
import org.incendo.cloud.Command;
|
||||||
import org.incendo.cloud.CommandManager;
|
import org.incendo.cloud.CommandManager;
|
||||||
import org.incendo.cloud.context.CommandContext;
|
import org.incendo.cloud.context.CommandContext;
|
||||||
@@ -83,7 +84,7 @@ public class WhitelistCommand implements FloodgateCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
if (uuid.getMostSignificantBits() != 0) { // TODO
|
if (!Utils.isFloodgateUniqueId(uuid)) {
|
||||||
sender.sendMessage(Message.INVALID_USERNAME);
|
sender.sendMessage(Message.INVALID_USERNAME);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public final class FloodgateDataHandler {
|
|||||||
if (!link.isEnabled() || connection.isLinked()) {
|
if (!link.isEnabled() || connection.isLinked()) {
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
return link.fetchLink(Utils.getJavaUuid(connection.xuid()))
|
return link.fetchLink(Utils.toFloodgateUniqueId(connection.xuid()))
|
||||||
.thenApply(link -> {
|
.thenApply(link -> {
|
||||||
if (link == null) {
|
if (link == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class StandaloneFloodgateConnectionBuilder {
|
|||||||
|
|
||||||
public FloodgateConnection build() {
|
public FloodgateConnection build() {
|
||||||
// todo add an option to use identity instead of xuid
|
// todo add an option to use identity instead of xuid
|
||||||
UUID javaUniqueId = Utils.getJavaUuid(xuid);
|
UUID javaUniqueId = Utils.toFloodgateUniqueId(xuid);
|
||||||
|
|
||||||
return new StandaloneFloodgateConnection(
|
return new StandaloneFloodgateConnection(
|
||||||
version,
|
version,
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public final class ProfileFetcher {
|
|||||||
if (xuid == null) {
|
if (xuid == null) {
|
||||||
return 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) {
|
if (gamertag == null) {
|
||||||
return 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
|
@Serdeable
|
||||||
public record LinkedPlayer(
|
public record LinkedPlayer(
|
||||||
@JsonbProperty("bedrock_id")
|
@JsonbProperty("bedrock_id")
|
||||||
@Nullable
|
@Nullable Long xuid,
|
||||||
Long xuid,
|
@Nullable String gamertag,
|
||||||
@Nullable
|
|
||||||
String gamertag,
|
|
||||||
@JsonbProperty("java_id")
|
@JsonbProperty("java_id")
|
||||||
@Nullable
|
@Nullable UUID uuid,
|
||||||
UUID uuid,
|
|
||||||
@JsonbProperty("java_name")
|
@JsonbProperty("java_name")
|
||||||
@Nullable
|
@Nullable String username
|
||||||
String username
|
|
||||||
) {
|
) {
|
||||||
public boolean isLinked() {
|
public boolean isLinked() {
|
||||||
// everything will be null when the player is not linked, since we return an empty object.
|
// 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 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;
|
return player;
|
||||||
}
|
}
|
||||||
if (filter == ONLY_BEDROCK || filter == ONLY_JAVA) {
|
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;
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ public abstract class CommandUtil {
|
|||||||
* Defaults to false when this platform doesn't support whitelisting.
|
* Defaults to false when this platform doesn't support whitelisting.
|
||||||
*/
|
*/
|
||||||
public boolean whitelistPlayer(long xuid, String username) {
|
public boolean whitelistPlayer(long xuid, String username) {
|
||||||
UUID uuid = Utils.getJavaUuid(xuid);
|
UUID uuid = Utils.toFloodgateUniqueId(xuid);
|
||||||
return whitelistPlayer(uuid, username);
|
return whitelistPlayer(uuid, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ public abstract class CommandUtil {
|
|||||||
* whitelisted. Defaults to false when this platform doesn't support whitelisting.
|
* whitelisted. Defaults to false when this platform doesn't support whitelisting.
|
||||||
*/
|
*/
|
||||||
public boolean removePlayerFromWhitelist(long xuid, String username) {
|
public boolean removePlayerFromWhitelist(long xuid, String username) {
|
||||||
UUID uuid = Utils.getJavaUuid(xuid);
|
UUID uuid = Utils.toFloodgateUniqueId(xuid);
|
||||||
return removePlayerFromWhitelist(uuid, username);
|
return removePlayerFromWhitelist(uuid, username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,12 +85,16 @@ public class Utils {
|
|||||||
return locale.getLanguage() + "_" + locale.getCountry();
|
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);
|
return new UUID(0, xuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getJavaUuid(String xuid) {
|
public static UUID toFloodgateUniqueId(String xuid) {
|
||||||
return getJavaUuid(Long.parseLong(xuid));
|
return toFloodgateUniqueId(Long.parseLong(xuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID fromShortUniqueId(String uuid) {
|
public static UUID fromShortUniqueId(String uuid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user