Delete src/main/java/net/viper/status/stats/PlayerStats.java via Git Manager GUI

This commit is contained in:
2026-05-07 19:49:49 +00:00
parent 3f282ec83b
commit a6a4713dd7

View File

@@ -1,113 +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;
// Economy
public double balance;
public double totalEarned;
public double totalSpent;
public int transactionsCount;
// Punishments
public int bansCount;
public int mutesCount;
public int warnsCount;
public long lastPunishmentAt; // Unix-Timestamp (Sek.), 0 = nie
public String lastPunishmentType; // "ban", "mute", "warn", "kick", "" = nie
public int punishmentScore;
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;
this.balance = 0.0;
this.totalEarned = 0.0;
this.totalSpent = 0.0;
this.transactionsCount = 0;
this.bansCount = 0;
this.mutesCount = 0;
this.warnsCount = 0;
this.lastPunishmentAt = 0;
this.lastPunishmentType = "";
this.punishmentScore = 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() {
String safeType = (lastPunishmentType == null ? "" : lastPunishmentType).replace("|", "_");
return uuid + "|" + name.replace("|", "_") + "|" + firstSeen + "|" + lastSeen + "|" + totalPlaytime + "|" + currentSessionStart + "|" + joins
+ "|" + balance + "|" + totalEarned + "|" + totalSpent + "|" + transactionsCount
+ "|" + bansCount + "|" + mutesCount + "|" + warnsCount + "|" + lastPunishmentAt + "|" + safeType + "|" + punishmentScore;
}
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]);
// Economy (felder 7-10)
if (parts.length >= 11) {
try { ps.balance = Double.parseDouble(parts[7]); } catch (Exception ignored) {}
try { ps.totalEarned = Double.parseDouble(parts[8]); } catch (Exception ignored) {}
try { ps.totalSpent = Double.parseDouble(parts[9]); } catch (Exception ignored) {}
try { ps.transactionsCount = Integer.parseInt(parts[10]); } catch (Exception ignored) {}
}
// Punishments (felder 11-16)
if (parts.length >= 17) {
try { ps.bansCount = Integer.parseInt(parts[11]); } catch (Exception ignored) {}
try { ps.mutesCount = Integer.parseInt(parts[12]); } catch (Exception ignored) {}
try { ps.warnsCount = Integer.parseInt(parts[13]); } catch (Exception ignored) {}
try { ps.lastPunishmentAt = Long.parseLong(parts[14]); } catch (Exception ignored) {}
ps.lastPunishmentType = parts[15];
try { ps.punishmentScore = Integer.parseInt(parts[16]); } catch (Exception ignored) {}
}
return ps;
} catch (Exception e) {
return null;
}
}
}