Skip to content

Commit 9978fe6

Browse files
committed
Fix Floodgate detection for buggy ProtocolLib
1 parent 94299d2 commit 9978fe6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,23 @@ 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
*
134136
* @param prefixedUsername the name of the player with the prefix appended
135137
* @return FloodgatePlayer if found, null otherwise
136138
*/
137139
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()) {
139151
if (floodgatePlayer.getCorrectUsername().equals(prefixedUsername)) {
140152
return floodgatePlayer;

0 commit comments

Comments
 (0)