diff --git a/core/src/main/java/org/geysermc/floodgate/addon/data/HandshakeDataImpl.java b/core/src/main/java/org/geysermc/floodgate/addon/data/HandshakeDataImpl.java index 480175e9..3f1b5cfb 100644 --- a/core/src/main/java/org/geysermc/floodgate/addon/data/HandshakeDataImpl.java +++ b/core/src/main/java/org/geysermc/floodgate/addon/data/HandshakeDataImpl.java @@ -68,7 +68,11 @@ public HandshakeDataImpl( if (bedrockData != null) { String prefix = config.getUsernamePrefix(); int usernameLength = Math.min(bedrockData.getUsername().length(), 16 - prefix.length()); - javaUsername = prefix + bedrockData.getUsername().substring(0, usernameLength); + if (config.isUsernamePrefixIsSuffix()) { + javaUsername = bedrockData.getUsername().substring(0, usernameLength) + prefix; + } else { + javaUsername = prefix + bedrockData.getUsername().substring(0, usernameLength); + } if (config.isReplaceSpaces()) { javaUsername = javaUsername.replace(" ", "_"); } diff --git a/core/src/main/java/org/geysermc/floodgate/command/WhitelistCommand.java b/core/src/main/java/org/geysermc/floodgate/command/WhitelistCommand.java index 54c5efcb..1e14760c 100644 --- a/core/src/main/java/org/geysermc/floodgate/command/WhitelistCommand.java +++ b/core/src/main/java/org/geysermc/floodgate/command/WhitelistCommand.java @@ -110,8 +110,14 @@ public void performCommand(CommandContext context, boolean add) { return; } - if (name.startsWith(config.getUsernamePrefix())) { - name = name.substring(config.getUsernamePrefix().length()); + if (config.isUsernamePrefixIsSuffix()) { + if (name.endsWith(config.getUsernamePrefix())) { + name = name.substring(0, name.length() - config.getUsernamePrefix().length()); + } + } else { + if (name.startsWith(config.getUsernamePrefix())) { + name = name.substring(config.getUsernamePrefix().length()); + } } if (name.isEmpty() || name.length() > 16) { @@ -125,7 +131,7 @@ public void performCommand(CommandContext context, boolean add) { if (config.isReplaceSpaces()) { tempName = tempName.replace(' ', '_'); } - final String correctName = config.getUsernamePrefix() + tempName; + final String correctName = config.isUsernamePrefixIsSuffix() ? tempName + config.getUsernamePrefix() : config.getUsernamePrefix() + tempName; final String strippedName = name; // We need to get the UUID of the player if it's not manually specified diff --git a/core/src/main/java/org/geysermc/floodgate/config/FloodgateConfig.java b/core/src/main/java/org/geysermc/floodgate/config/FloodgateConfig.java index 4a87b0d4..c25721b9 100644 --- a/core/src/main/java/org/geysermc/floodgate/config/FloodgateConfig.java +++ b/core/src/main/java/org/geysermc/floodgate/config/FloodgateConfig.java @@ -41,6 +41,7 @@ public class FloodgateConfig implements GenericPostInitializeCallback { private String keyFileName; private String usernamePrefix = ""; + private boolean usernamePrefixIsSuffix = true; private boolean replaceSpaces; private String defaultLocale; diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index 27d23b77..c60805a9 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -8,6 +8,9 @@ key-file-name: key.pem # It is recommended to use a prefix that does not contain alphanumerical to avoid the possibility of duplicate usernames. username-prefix: "." +# Change username prefix to suffix +username-prefix-is-suffix: true + # Should spaces be replaced with '_' in bedrock usernames? replace-spaces: true