mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2026-01-06 15:42:03 +00:00
committed by
GitHub
parent
2904612b5a
commit
95e1a8122b
@@ -127,7 +127,7 @@ public class PacketHandler extends SimpleChannelInboundHandler<Object> {
|
||||
}
|
||||
|
||||
static {
|
||||
handshakeHandler = new HandshakeHandler(plugin.getConfiguration().getPrivateKey(), false);
|
||||
handshakeHandler = new HandshakeHandler(plugin.getConfiguration().getPrivateKey(), false, plugin.getConfiguration().getUsernamePrefix());
|
||||
|
||||
networkManagerClass = getPrefixedClass("NetworkManager");
|
||||
loginStartPacketClass = getPrefixedClass("PacketLoginInStart");
|
||||
|
||||
@@ -35,7 +35,7 @@ public class BungeePlugin extends Plugin implements Listener {
|
||||
getDataFolder().mkdir();
|
||||
}
|
||||
config = FloodgateConfig.load(getLogger(), getDataFolder().toPath().resolve("config.yml"), BungeeFloodgateConfig.class);
|
||||
handshakeHandler = new HandshakeHandler(config.getPrivateKey(), true);
|
||||
handshakeHandler = new HandshakeHandler(config.getPrivateKey(), true, config.getUsernamePrefix());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
# The public key should be used for the Geyser(s) and the private key for the Floodgate(s)
|
||||
key-file-name: key.pem
|
||||
|
||||
# Floodgate appends a prefix to bedrock usernames to avoid conflicts
|
||||
# However, certain conflicts can cause issues with some plugins so this prefix is configurable using the property below
|
||||
# It is recommended to use a prefix that does not contain alphanumerical to avoid the possibility of duplicate usernames.
|
||||
username-prefix: "*"
|
||||
|
||||
# Should Bungeecord send the bedrock player data to the servers it is connecting to?
|
||||
# This requires Floodgate to be installed on the servers.
|
||||
# You'll get kicked if you don't use the plugin. The default value is false because of it
|
||||
|
||||
@@ -25,6 +25,8 @@ public class FloodgateConfig {
|
||||
private String keyFileName;
|
||||
@JsonProperty(value = "disconnect")
|
||||
private DisconnectMessages messages;
|
||||
@JsonProperty(value = "username-prefix")
|
||||
private String usernamePrefix;
|
||||
|
||||
@JsonProperty
|
||||
private boolean debug;
|
||||
|
||||
@@ -37,10 +37,11 @@ public class FloodgatePlayer {
|
||||
*/
|
||||
private UUID javaUniqueId;
|
||||
|
||||
FloodgatePlayer(BedrockData data) {
|
||||
FloodgatePlayer(BedrockData data, String prefix) {
|
||||
version = data.getVersion();
|
||||
username = data.getUsername();
|
||||
javaUsername = "*" + data.getUsername().substring(0, Math.min(data.getUsername().length(), 15));
|
||||
if (prefix.length() < 1) prefix = "*";
|
||||
javaUsername = prefix + data.getUsername().substring(0, Math.min(data.getUsername().length(), 16 - prefix.length()));
|
||||
xuid = data.getXuid();
|
||||
deviceOS = DeviceOS.getById(data.getDeviceId());
|
||||
languageCode = data.getLanguageCode();
|
||||
|
||||
@@ -17,10 +17,12 @@ import static org.geysermc.floodgate.util.BedrockData.FLOODGATE_IDENTIFIER;
|
||||
public class HandshakeHandler {
|
||||
private PrivateKey privateKey;
|
||||
private boolean bungee;
|
||||
private String usernamePrefix;
|
||||
|
||||
public HandshakeHandler(@NonNull PrivateKey privateKey, boolean bungee) {
|
||||
public HandshakeHandler(@NonNull PrivateKey privateKey, boolean bungee, String usernamePrefix) {
|
||||
this.privateKey = privateKey;
|
||||
this.bungee = bungee;
|
||||
this.usernamePrefix = usernamePrefix;
|
||||
}
|
||||
|
||||
public HandshakeResult handle(@NonNull String handshakeData) {
|
||||
@@ -40,7 +42,7 @@ public class HandshakeHandler {
|
||||
return ResultType.INVALID_DATA_LENGTH.getCachedResult();
|
||||
}
|
||||
|
||||
FloodgatePlayer player = new FloodgatePlayer(bedrockData);
|
||||
FloodgatePlayer player = new FloodgatePlayer(bedrockData, usernamePrefix);
|
||||
AbstractFloodgateAPI.players.put(player.getJavaUniqueId(), player);
|
||||
return new HandshakeResult(ResultType.SUCCESS, data, bedrockData, player);
|
||||
} catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
# The public key should be used for the Geyser(s) and the private key for the Floodgate(s)
|
||||
key-file-name: key.pem
|
||||
|
||||
# Floodgate appends a prefix to bedrock usernames to avoid conflicts
|
||||
# However, certain conflicts can cause issues with some plugins so this prefix is configurable using the property below
|
||||
# It is recommended to use a prefix that does not contain alphanumerical to avoid the possibility of duplicate usernames.
|
||||
username-prefix: "*"
|
||||
|
||||
disconnect:
|
||||
# The disconnect message Geyser users should get when connecting
|
||||
# to the server with an invalid key
|
||||
|
||||
@@ -78,7 +78,7 @@ public class VelocityPlugin {
|
||||
}
|
||||
|
||||
config = FloodgateConfig.load(logger, dataFolder.toPath().resolve("config.yml"), VelocityFloodgateConfig.class);
|
||||
handshakeHandler = new HandshakeHandler(config.getPrivateKey(), true);
|
||||
handshakeHandler = new HandshakeHandler(config.getPrivateKey(), true, config.getUsernamePrefix());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
Reference in New Issue
Block a user