Skip to content

Commit

Permalink
feat(LoginPlayerHelper): 优化记录登录IP逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
shulng committed Jul 18, 2024
1 parent 7b04e4e commit 708a899
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ public static Long getLastLoginTime(String name) {
}

// 记录登录IP
public static void recordCurrentIP(Player player, LoginPlayer lp){
public static void recordCurrentIP(Player player, LoginPlayer lp){
String currentIp = player.getAddress().getAddress().getHostAddress();
List<String> ipsList = lp.getIpsList();
ipsList.add(currentIp);
ipsList = ipsList.stream().distinct().collect(Collectors.toList());
if (ipsList.size() > 0) {
if (!ipsList.isEmpty()) {
ipsList.remove(0);
}
lp.setIps(String.join(";", ipsList.toArray(new String[0])));
lp.setIps(String.join(";", ipsList));
CatSeedLogin.instance.runTaskAsync(() -> {
try {
CatSeedLogin.sql.edit(lp);
Expand Down

0 comments on commit 708a899

Please sign in to comment.