Skip to content

Commit 40b4eae

Browse files
author
games647
authored
Merge pull request #635 from Smart123s/fix/floodgate/prefix-detect
Fix Floodgate player detection (caused by prefixes)
2 parents ef6f0fc + 9978fe6 commit 40b4eae

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

core/src/main/java/com/github/games647/fastlogin/core/hooks/FloodgateService.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,25 @@ public void checkNameConflict(String username, LoginSource source) {
130130
* The FloodgateApi does not support querying players by name, so this function
131131
* iterates over every online FloodgatePlayer and checks if the requested
132132
* username can be found
133+
* <br>
134+
* <i>Falls back to non-prefixed name checks, if ProtocolLib is installed</i>
133135
*
134-
* @param username the name of the player
136+
* @param prefixedUsername the name of the player with the prefix appended
135137
* @return FloodgatePlayer if found, null otherwise
136138
*/
137-
public FloodgatePlayer getFloodgatePlayer(String username) {
139+
public FloodgatePlayer getFloodgatePlayer(String prefixedUsername) {
140+
//prefixes are broken with ProtocolLib, so fall back to name checks without prefixes
141+
//this should be removed if #493 gets fixed
142+
if (core.getPlugin().isPluginInstalled("ProtocolLib")) {
143+
for (FloodgatePlayer floodgatePlayer : FloodgateApi.getInstance().getPlayers()) {
144+
if (floodgatePlayer.getUsername().equals(prefixedUsername)) {
145+
return floodgatePlayer;
146+
}
147+
}
148+
return null;
149+
}
138150
for (FloodgatePlayer floodgatePlayer : FloodgateApi.getInstance().getPlayers()) {
139-
if (floodgatePlayer.getUsername().equals(username)) {
151+
if (floodgatePlayer.getCorrectUsername().equals(prefixedUsername)) {
140152
return floodgatePlayer;
141153
}
142154
}

0 commit comments

Comments
 (0)