Upload folder via GUI - src
This commit is contained in:
@@ -38,6 +38,7 @@ public class StatusAPIBridge extends JavaPlugin implements Listener {
|
|||||||
private final Map<UUID, String> lastPushedCompass = new ConcurrentHashMap<>();
|
private final Map<UUID, String> lastPushedCompass = new ConcurrentHashMap<>();
|
||||||
private final Map<UUID, String> lastPushedWorld = new ConcurrentHashMap<>();
|
private final Map<UUID, String> lastPushedWorld = new ConcurrentHashMap<>();
|
||||||
private final Map<UUID, String> lastPushedData = new ConcurrentHashMap<>();
|
private final Map<UUID, String> lastPushedData = new ConcurrentHashMap<>();
|
||||||
|
private final Map<UUID, String> lastPushedStats = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private final ExecutorService httpExecutor = Executors.newSingleThreadExecutor(r -> {
|
private final ExecutorService httpExecutor = Executors.newSingleThreadExecutor(r -> {
|
||||||
Thread t = new Thread(r, "StatusAPIBridge-HTTP");
|
Thread t = new Thread(r, "StatusAPIBridge-HTTP");
|
||||||
@@ -104,6 +105,7 @@ public class StatusAPIBridge extends JavaPlugin implements Listener {
|
|||||||
lastPushedCompass.remove(id);
|
lastPushedCompass.remove(id);
|
||||||
lastPushedWorld.remove(id);
|
lastPushedWorld.remove(id);
|
||||||
lastPushedData.remove(id);
|
lastPushedData.remove(id);
|
||||||
|
lastPushedStats.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
@@ -153,6 +155,7 @@ public class StatusAPIBridge extends JavaPlugin implements Listener {
|
|||||||
pushCompassIfChanged(player);
|
pushCompassIfChanged(player);
|
||||||
pushWorldIfChanged(player);
|
pushWorldIfChanged(player);
|
||||||
pushPlayerDataIfChanged(player);
|
pushPlayerDataIfChanged(player);
|
||||||
|
pushStatsIfChanged(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Push-Methoden ─────────────────────────────────────────────────────────
|
// ── Push-Methoden ─────────────────────────────────────────────────────────
|
||||||
@@ -269,6 +272,32 @@ public class StatusAPIBridge extends JavaPlugin implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void pushStatsIfChanged(Player player) {
|
||||||
|
int kills = player.getStatistic(org.bukkit.Statistic.PLAYER_KILLS);
|
||||||
|
int deaths = player.getStatistic(org.bukkit.Statistic.DEATHS);
|
||||||
|
// Playtime in Ticks aus Minecraft-Statistik → umrechnen in Sekunden
|
||||||
|
long playtimeTicks = player.getStatistic(org.bukkit.Statistic.PLAY_ONE_MINUTE); // tatsächlich in Ticks
|
||||||
|
long playtimeSecs = playtimeTicks / 20;
|
||||||
|
|
||||||
|
String key = kills + "," + deaths + "," + playtimeSecs;
|
||||||
|
if (key.equals(lastPushedStats.get(player.getUniqueId()))) return;
|
||||||
|
lastPushedStats.put(player.getUniqueId(), key);
|
||||||
|
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
String name = player.getName();
|
||||||
|
httpExecutor.execute(() -> {
|
||||||
|
try {
|
||||||
|
sendPost(statusApiUrl + "/stats/update",
|
||||||
|
"{\"uuid\":\"" + uuid + "\",\"name\":\"" + escapeName(name)
|
||||||
|
+ "\",\"kills\":" + kills
|
||||||
|
+ ",\"deaths\":" + deaths
|
||||||
|
+ ",\"playtime\":" + playtimeSecs + "}");
|
||||||
|
} catch (Exception e) {
|
||||||
|
getLogger().warning("Stats-Push fehlgeschlagen: " + e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void pushTpsAsync(UUID uuid, double tps) {
|
private void pushTpsAsync(UUID uuid, double tps) {
|
||||||
httpExecutor.execute(() -> {
|
httpExecutor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user