Skip to content

Commit

Permalink
feat: 移除了onPlayerJoin事件处理,更改了recordCurrentIP方法的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
shulng committed Aug 10, 2024
1 parent 5da12b0 commit 6553cdb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
6 changes: 0 additions & 6 deletions src/main/java/cc/baka9/catseedlogin/bukkit/CatSeedLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.bukkit.command.PluginCommand;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;

Expand Down Expand Up @@ -143,11 +142,6 @@ public void onPlayerQuit(PlayerQuitEvent event) {
timeoutManager.onPlayerQuit(event.getPlayer().getName());
}

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
// 当玩家加入时调用
timeoutManager.onPlayerJoin(event.getPlayer().getName());
}

@Override
public void onDisable(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,14 @@ public static boolean recordCurrentIP(Player player) {
List<String> storedIPs = getStoredIPs(loginPlayer);
if (storedIPs != null) {
long lastLoginTime = loginPlayer.getLastAction();
Long exitTime = playerExitTimes.get(playerName);
long timeoutInMilliseconds = Config.Settings.IPTimeout * 60 * 1000;

if (Config.Settings.IPTimeout == 0) {
return storedIPs.contains(currentIP);
} else {
if (storedIPs.contains(currentIP) && helper.onPlayerJoin(playerName)) {
if (exitTime != null)
if (storedIPs.contains(currentIP) && (currentTime - exitTime) <= timeoutInMilliseconds) {
return true;
}
}
Expand Down Expand Up @@ -142,15 +144,6 @@ public void onPlayerQuit(String playerName) {
System.out.println("当前退出时间记录: " + playerExitTimes);
}

public boolean onPlayerJoin(String playerName) {
long currentTime = System.currentTimeMillis();
Long exitTime = playerExitTimes.get(playerName);
// System.out.println("玩家 " + playerName + " 加入,时间: " + currentTime);
// System.out.println("玩家 " + playerName + " 退出时间: " + exitTime);
System.out.println("当前退出时间记录: " + playerExitTimes);

return (boolean) (exitTime != null && currentTime - exitTime <= timeoutDuration ? playerExitTimes.remove(playerName) : false);
}



Expand Down

0 comments on commit 6553cdb

Please sign in to comment.