diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/ConnectionRecord.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/console/ConnectionRecord.java')
| -rw-r--r-- | NET/worlds/console/ConnectionRecord.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/NET/worlds/console/ConnectionRecord.java b/NET/worlds/console/ConnectionRecord.java new file mode 100644 index 0000000..74e7867 --- /dev/null +++ b/NET/worlds/console/ConnectionRecord.java @@ -0,0 +1,47 @@ +package NET.worlds.console; + +import java.util.Date; +import java.util.Vector; + +class ConnectionRecord { + private static Vector<ConnectionRecord> recordList = new Vector<ConnectionRecord>(); + private String _who = null; + private Date _startDelayTime = null; + + public ConnectionRecord(String who) { + this._who = who; + this._startDelayTime = new Date(); + } + + public boolean isExpired(Date now) { + return now.getTime() - this._startDelayTime.getTime() > 15000L; + } + + public String getWho() { + return this._who; + } + + public static Vector<ConnectionRecord> getList() { + return recordList; + } + + public static synchronized boolean checkList(String w) { + boolean delayed = false; + int i = 0; + Date now = new Date(); + + while (!recordList.isEmpty() && i < recordList.size()) { + ConnectionRecord r = recordList.elementAt(i); + if (r.isExpired(now)) { + recordList.removeElementAt(i); + } else { + i++; + if (r.getWho().equals(w)) { + delayed = true; + } + } + } + + return delayed; + } +} |