1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-19 23:09:27 +00:00

Fixed a mistake introduced in one of the first versions of the 2.0

This commit is contained in:
Tim203
2021-01-15 23:10:51 +01:00
parent 9b0cbd5cdd
commit 4cf92c6551

View File

@@ -49,17 +49,17 @@ public class SimpleFloodgateApi implements FloodgateApi {
@Override @Override
public FloodgatePlayer getPlayer(UUID uuid) { public FloodgatePlayer getPlayer(UUID uuid) {
FloodgatePlayer player = players.get(uuid); FloodgatePlayer selfPlayer = players.get(uuid);
// bedrock players are always stored by their xuid, // bedrock players are always stored by their xuid,
// so we return the instance if we know that the given uuid is a Floodgate uuid // so we return the instance if we know that the given uuid is a Floodgate uuid
if (player != null || isFloodgateId(uuid)) { if (selfPlayer != null || isFloodgateId(uuid)) {
return player; return selfPlayer;
} }
// make it possible to find player by Java id (linked players) // make it possible to find player by Java id (linked players)
for (FloodgatePlayer player1 : players.values()) { for (FloodgatePlayer player : players.values()) {
if (player1.getCorrectUniqueId().equals(uuid)) { if (player.getCorrectUniqueId().equals(uuid)) {
return player1; return player;
} }
} }
return null; return null;
@@ -109,7 +109,7 @@ public class SimpleFloodgateApi implements FloodgateApi {
} }
// removeLogin logic // removeLogin logic
if (!shouldRemove(selfPlayer, removeLogin)) { if (!canRemove(selfPlayer, removeLogin)) {
return null; return null;
} }
@@ -121,17 +121,15 @@ public class SimpleFloodgateApi implements FloodgateApi {
// we still want to be able to remove a linked-player by his linked java uuid // we still want to be able to remove a linked-player by his linked java uuid
for (FloodgatePlayer player : players.values()) { for (FloodgatePlayer player : players.values()) {
if (shouldRemove(player, removeLogin) && player.getCorrectUniqueId().equals(onlineId)) { if (canRemove(player, removeLogin) && player.getCorrectUniqueId().equals(onlineId)) {
continue; players.remove(player.getJavaUniqueId());
return player;
} }
players.remove(player.getJavaUniqueId());
return player;
} }
return null; return null;
} }
protected boolean shouldRemove(FloodgatePlayer player, boolean removeLogin) { protected boolean canRemove(FloodgatePlayer player, boolean removeLogin) {
FloodgatePlayerImpl impl = player.as(FloodgatePlayerImpl.class); FloodgatePlayerImpl impl = player.as(FloodgatePlayerImpl.class);
return impl.isLogin() && removeLogin || !impl.isLogin() && !removeLogin; return impl.isLogin() && removeLogin || !impl.isLogin() && !removeLogin;
} }