mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Floodgate now uses identity instead of xuid
This commit is contained in:
@@ -79,12 +79,12 @@ public class PacketHandler extends SimpleChannelInboundHandler<Object> {
|
||||
|
||||
if (bungee = (data.length == 6 || data.length == 7)) {
|
||||
setValue(packet, hostField, data[0] + '\0' +
|
||||
bedrockData.getIp() + '\0' + fPlayer.getJavaUniqueId() +
|
||||
bedrockData.getIp() + '\0' + fPlayer.getBedrockId() +
|
||||
(data.length == 7 ? '\0' + data[6] : "")
|
||||
);
|
||||
} else {
|
||||
// Use a spoofedUUID for initUUID (just like Bungeecord)
|
||||
setValue(networkManager, "spoofedUUID", fPlayer.getJavaUniqueId());
|
||||
setValue(networkManager, "spoofedUUID", fPlayer.getBedrockId());
|
||||
// Use the player his IP for stuff instead of Geyser his IP
|
||||
SocketAddress newAddress = new InetSocketAddress(
|
||||
bedrockData.getIp(),
|
||||
@@ -92,14 +92,14 @@ public class PacketHandler extends SimpleChannelInboundHandler<Object> {
|
||||
);
|
||||
setValue(networkManager, getFieldOfType(networkManagerClass, SocketAddress.class, false), newAddress);
|
||||
}
|
||||
plugin.getLogger().info("Added " + fPlayer.getJavaUsername() + " " + fPlayer.getJavaUniqueId());
|
||||
plugin.getLogger().info("Added " + fPlayer.getJavaUsername() + " " + fPlayer.getBedrockId());
|
||||
} else if (isLogin) {
|
||||
if (!bungee) {
|
||||
// we have to fake the offline player cycle
|
||||
Object loginListener = packetListenerField.get(networkManager);
|
||||
|
||||
// Set the player his GameProfile
|
||||
Object gameProfile = gameProfileConstructor.newInstance(fPlayer.getJavaUniqueId(), fPlayer.getJavaUsername());
|
||||
Object gameProfile = gameProfileConstructor.newInstance(fPlayer.getBedrockId(), fPlayer.getJavaUsername());
|
||||
setValue(loginListener, gameProfileField, gameProfile);
|
||||
|
||||
initUUIDMethod.invoke(loginListener); // LoginListener#initUUID
|
||||
|
||||
@@ -94,10 +94,10 @@ public class BungeePlugin extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
FloodgatePlayer player = result.getFloodgatePlayer();
|
||||
FloodgateAPI.addEncryptedData(player.getJavaUniqueId(), result.getHandshakeData()[2] + '\0' + result.getHandshakeData()[3]);
|
||||
FloodgateAPI.addEncryptedData(player.getBedrockId(), result.getHandshakeData()[2] + '\0' + result.getHandshakeData()[3]);
|
||||
|
||||
event.getConnection().setOnlineMode(false);
|
||||
event.getConnection().setUniqueId(player.getJavaUniqueId());
|
||||
event.getConnection().setUniqueId(player.getBedrockId());
|
||||
|
||||
ReflectionUtil.setValue(event.getConnection(), "name", player.getJavaUsername());
|
||||
Object channelWrapper = ReflectionUtil.getValue(event.getConnection(), "ch");
|
||||
@@ -121,8 +121,8 @@ public class BungeePlugin extends Plugin implements Listener {
|
||||
public void onPlayerDisconnect(PlayerDisconnectEvent event) {
|
||||
FloodgatePlayer player = FloodgateAPI.getPlayerByConnection(event.getPlayer().getPendingConnection());
|
||||
if (player != null) {
|
||||
FloodgateAPI.players.remove(player.getJavaUniqueId());
|
||||
FloodgateAPI.removeEncryptedData(player.getJavaUniqueId());
|
||||
FloodgateAPI.players.remove(player.getBedrockId());
|
||||
FloodgateAPI.removeEncryptedData(player.getBedrockId());
|
||||
System.out.println("Removed " + player.getUsername() + " " + event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,18 +17,20 @@ abstract class AbstractFloodgateAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to determine if the given <b>online</b> player is a bedrock player
|
||||
* @param uuid The uuid of the <b>online</b> player
|
||||
* @return true if the given <b>online</b> player is a Bedrock player
|
||||
* Method to determine if the given player is a Bedrock player
|
||||
* @param uuid The uuid of the player
|
||||
* @return true if the given player is a Bedrock player
|
||||
*/
|
||||
public static boolean isBedrockPlayer(UUID uuid) {
|
||||
return players.containsKey(uuid);
|
||||
return uuid.version() == 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a valid Java player uuid of a xuid
|
||||
* Method to determine if the given player is a Java player
|
||||
* @param uuid The uuid of the player
|
||||
* @return true if the given player is a Bedrock player
|
||||
*/
|
||||
public static UUID createJavaPlayerId(long xuid) {
|
||||
return new UUID(0, xuid);
|
||||
public static boolean isJavaPlayer(UUID uuid) {
|
||||
return uuid.version() == 4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public class FloodgatePlayer {
|
||||
*/
|
||||
private String javaUsername;
|
||||
/**
|
||||
* The Xbox Unique Identifier
|
||||
* The Unique Identifier of the Bedrock client.
|
||||
*/
|
||||
private String xuid;
|
||||
private UUID bedrockId;
|
||||
/**
|
||||
* The operation system of the bedrock client
|
||||
*/
|
||||
@@ -32,18 +32,13 @@ public class FloodgatePlayer {
|
||||
* The language code of the bedrock client
|
||||
*/
|
||||
private String languageCode;
|
||||
/**
|
||||
* The Java UUID used to identify the bedrock client
|
||||
*/
|
||||
private UUID javaUniqueId;
|
||||
|
||||
FloodgatePlayer(BedrockData data) {
|
||||
version = data.getVersion();
|
||||
username = data.getUsername();
|
||||
javaUsername = "*" + data.getUsername().substring(0, Math.min(data.getUsername().length(), 15));
|
||||
xuid = data.getXuid();
|
||||
bedrockId = data.getBedrockId();
|
||||
deviceOS = DeviceOS.getById(data.getDeviceId());
|
||||
languageCode = data.getLanguageCode();
|
||||
javaUniqueId = AbstractFloodgateAPI.createJavaPlayerId(Long.parseLong(data.getXuid()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class HandshakeHandler {
|
||||
}
|
||||
|
||||
FloodgatePlayer player = new FloodgatePlayer(bedrockData);
|
||||
AbstractFloodgateAPI.players.put(player.getJavaUniqueId(), player);
|
||||
AbstractFloodgateAPI.players.put(player.getBedrockId(), player);
|
||||
return new HandshakeResult(ResultType.SUCCESS, data, bedrockData, player);
|
||||
} catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -105,9 +105,9 @@ public class VelocityPlugin {
|
||||
}
|
||||
|
||||
FloodgatePlayer player = result.getFloodgatePlayer();
|
||||
FloodgateAPI.addEncryptedData(player.getJavaUniqueId(), result.getHandshakeData()[2] + '\0' + result.getHandshakeData()[3]);
|
||||
FloodgateAPI.addEncryptedData(player.getBedrockId(), result.getHandshakeData()[2] + '\0' + result.getHandshakeData()[3]);
|
||||
playerCache.put(event.getConnection(), player);
|
||||
logger.info("Added " + player.getJavaUsername() + " " + player.getJavaUniqueId());
|
||||
logger.info("Added " + player.getJavaUsername() + " " + player.getBedrockId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@@ -159,7 +159,7 @@ public class VelocityPlugin {
|
||||
FloodgatePlayer player = playerCache.getIfPresent(event.getConnection());
|
||||
if (player != null) {
|
||||
playerCache.invalidate(event.getConnection());
|
||||
event.setGameProfile(new GameProfile(player.getJavaUniqueId(), player.getJavaUsername(), new ArrayList<>()));
|
||||
event.setGameProfile(new GameProfile(player.getBedrockId(), player.getJavaUsername(), new ArrayList<>()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user