Delete src/main/java/net/viper/status/stats/PlayerStats.java via Git Manager GUI
This commit is contained in:
@@ -1,70 +0,0 @@
|
|||||||
package net.viper.status.stats;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class PlayerStats {
|
|
||||||
public final UUID uuid;
|
|
||||||
public String name;
|
|
||||||
public long firstSeen;
|
|
||||||
public long lastSeen;
|
|
||||||
public long totalPlaytime;
|
|
||||||
public long currentSessionStart;
|
|
||||||
public int joins;
|
|
||||||
|
|
||||||
public PlayerStats(UUID uuid, String name) {
|
|
||||||
this.uuid = uuid;
|
|
||||||
this.name = name;
|
|
||||||
long now = System.currentTimeMillis() / 1000L;
|
|
||||||
this.firstSeen = now;
|
|
||||||
this.lastSeen = now;
|
|
||||||
this.totalPlaytime = 0;
|
|
||||||
this.currentSessionStart = 0;
|
|
||||||
this.joins = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void onJoin() {
|
|
||||||
long now = System.currentTimeMillis() / 1000L;
|
|
||||||
if (this.currentSessionStart == 0) this.currentSessionStart = now;
|
|
||||||
this.lastSeen = now;
|
|
||||||
this.joins++;
|
|
||||||
if (this.firstSeen == 0) this.firstSeen = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void onQuit() {
|
|
||||||
long now = System.currentTimeMillis() / 1000L;
|
|
||||||
if (this.currentSessionStart > 0) {
|
|
||||||
long session = now - this.currentSessionStart;
|
|
||||||
if (session > 0) this.totalPlaytime += session;
|
|
||||||
this.currentSessionStart = 0;
|
|
||||||
}
|
|
||||||
this.lastSeen = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized long getPlaytimeWithCurrentSession() {
|
|
||||||
long now = System.currentTimeMillis() / 1000L;
|
|
||||||
if (this.currentSessionStart > 0) return totalPlaytime + (now - currentSessionStart);
|
|
||||||
return totalPlaytime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized String toLine() {
|
|
||||||
return uuid + "|" + name.replace("|", "_") + "|" + firstSeen + "|" + lastSeen + "|" + totalPlaytime + "|" + currentSessionStart + "|" + joins;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerStats fromLine(String line) {
|
|
||||||
String[] parts = line.split("\\|", -1);
|
|
||||||
if (parts.length < 7) return null;
|
|
||||||
try {
|
|
||||||
UUID uuid = UUID.fromString(parts[0]);
|
|
||||||
String name = parts[1];
|
|
||||||
PlayerStats ps = new PlayerStats(uuid, name);
|
|
||||||
ps.firstSeen = Long.parseLong(parts[2]);
|
|
||||||
ps.lastSeen = Long.parseLong(parts[3]);
|
|
||||||
ps.totalPlaytime = Long.parseLong(parts[4]);
|
|
||||||
ps.currentSessionStart = Long.parseLong(parts[5]);
|
|
||||||
ps.joins = Integer.parseInt(parts[6]);
|
|
||||||
return ps;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user