Skip to content

Commit

Permalink
Add players to non voted cache before checking if they are online
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCodez committed Feb 4, 2024
1 parent d6fa68d commit 9f85149
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public void addPlayer(ProxiedPlayer proxiedPlayer) {
public void addPlayer(String uuid, String playerName) {
getData().set("NonVotedPlayers." + playerName + ".UUID", uuid);
getData().set("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
save();
}

public void addPlayerCheck(String uuid, String playerName) {
if (!bungee.getMysql().containsKeyQuery(uuid)) {
addPlayer(uuid, playerName);
}
}

public void check() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,9 @@ protected void onMessage(String channel, String[] message) {
server = message[3];
}
debug("Login: " + player + "/" + uuid + " " + server);
if (nonVotedPlayersCache != null) {
nonVotedPlayersCache.addPlayerCheck(uuid, player);
}
ProxiedPlayer p = getProxy().getPlayer(player);
login(p);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public void addPlayer(String uuid, String playerName) {
save();
}

public void addPlayerCheck(String uuid, String playerName) {
if (!plugin.getMysql().containsKeyQuery(uuid)) {
addPlayer(uuid, playerName);
}
}

public void check() {
for (String player : getKeys(getNode("NonVotedPlayers"))) {
long time = getNode("NonVotedPlayers", player, "LastTime").getLong(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,9 @@ protected void onMessage(String channel, String[] message) {
serverName = message[3];
}
debug("Login: " + player + "/" + uuid + " " + serverName);
if (nonVotedPlayersCache != null) {
nonVotedPlayersCache.addPlayerCheck(uuid, player);
}
if (server.getPlayer(player).isPresent() && (getGlobalDataHandler() == null
|| !getGlobalDataHandler().isTimeChangedHappened())) {
Player p = server.getPlayer(player).get();
Expand Down

0 comments on commit 9f85149

Please sign in to comment.