2 Commits
1.0.0 ... 1.0.1

Author SHA1 Message Date
Git Manager GUI
bb5f93d23f Upload folder via GUI - src 2026-06-18 21:21:36 +02:00
Git Manager GUI
52ad98a643 Upload folder via GUI - src 2026-06-18 20:56:01 +02:00
6 changed files with 37 additions and 11 deletions

View File

@@ -14,11 +14,15 @@ import java.util.concurrent.ConcurrentHashMap;
public class BungeeAlertManager { public class BungeeAlertManager {
private final BungeePlugin plugin; private final BungeePlugin plugin;
private final long pluginStartTimeMs;
private final long startupGracePeriodMs;
private final Map<String, Long> cooldowns = new ConcurrentHashMap<>(); private final Map<String, Long> cooldowns = new ConcurrentHashMap<>();
private static final long COOLDOWN_MS = 5 * 60 * 1000L; private static final long COOLDOWN_MS = 5 * 60 * 1000L;
public BungeeAlertManager(BungeePlugin plugin) { public BungeeAlertManager(BungeePlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
this.pluginStartTimeMs = System.currentTimeMillis();
this.startupGracePeriodMs = plugin.getBungeeConfig().getStartupCheckDelayMinutes() * 60_000L;
} }
/** /**
@@ -71,6 +75,11 @@ public class BungeeAlertManager {
private void trigger(String cooldownKey, String severity, private void trigger(String cooldownKey, String severity,
String serverName, String alertType, String message) { String serverName, String alertType, String message) {
if (isStartupGracePeriodActive()) {
plugin.debug("Startup-Delay aktiv: Alert unterdrückt (" + alertType + ")");
return;
}
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (cooldowns.containsKey(cooldownKey) if (cooldowns.containsKey(cooldownKey)
&& now - cooldowns.get(cooldownKey) < COOLDOWN_MS) return; && now - cooldowns.get(cooldownKey) < COOLDOWN_MS) return;
@@ -82,4 +91,8 @@ public class BungeeAlertManager {
plugin.getDiscordWebhook().sendServerAlert(serverName, alertType, severity, message); plugin.getDiscordWebhook().sendServerAlert(serverName, alertType, severity, message);
} }
} }
private boolean isStartupGracePeriodActive() {
return System.currentTimeMillis() - pluginStartTimeMs < startupGracePeriodMs;
}
} }

View File

@@ -41,6 +41,7 @@ public class BungeeConfig {
// ── General ────────────────────────────── // ── General ──────────────────────────────
public boolean isDebugMode() { return config.getBoolean("general.debug", false); } public boolean isDebugMode() { return config.getBoolean("general.debug", false); }
public int getPollInterval() { return config.getInt("general.poll-interval", 30); } public int getPollInterval() { return config.getInt("general.poll-interval", 30); }
public int getStartupCheckDelayMinutes() { return Math.max(0, config.getInt("general.startup-check-delay-minutes", 5)); }
// ── Discord ────────────────────────────── // ── Discord ──────────────────────────────
public boolean isDiscordEnabled() { return config.getBoolean("discord.enabled", false); } public boolean isDiscordEnabled() { return config.getBoolean("discord.enabled", false); }

View File

@@ -19,6 +19,8 @@ import java.util.Map;
public class AlertManager { public class AlertManager {
private final SpigotPlugin plugin; private final SpigotPlugin plugin;
private final long pluginStartTimeMs;
private final long startupGracePeriodMs;
// Cooldown: alertType -> letzter Trigger-Zeitpunkt (ms) // Cooldown: alertType -> letzter Trigger-Zeitpunkt (ms)
private final Map<String, Long> alertCooldowns = new HashMap<>(); private final Map<String, Long> alertCooldowns = new HashMap<>();
@@ -33,6 +35,8 @@ public class AlertManager {
public AlertManager(SpigotPlugin plugin) { public AlertManager(SpigotPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
this.pluginStartTimeMs = System.currentTimeMillis();
this.startupGracePeriodMs = plugin.getSpigotConfig().getStartupCheckDelayMinutes() * 60_000L;
} }
// ────────────────────────────────────────── // ──────────────────────────────────────────
@@ -44,6 +48,11 @@ public class AlertManager {
*/ */
public void triggerAlert(String alertType, AlertSeverity severity, String worldName, public void triggerAlert(String alertType, AlertSeverity severity, String worldName,
String message, Double currentValue, Double threshold) { String message, Double currentValue, Double threshold) {
if (isStartupGracePeriodActive()) {
plugin.debug("Startup-Delay aktiv: Alert unterdrückt (" + alertType + ")");
return;
}
// Cooldown prüfen // Cooldown prüfen
String cooldownKey = alertType + (worldName != null ? "_" + worldName : ""); String cooldownKey = alertType + (worldName != null ? "_" + worldName : "");
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -216,4 +225,8 @@ public class AlertManager {
public int getCriticalEventCount() { public int getCriticalEventCount() {
return criticalEventCount; return criticalEventCount;
} }
private boolean isStartupGracePeriodActive() {
return System.currentTimeMillis() - pluginStartTimeMs < startupGracePeriodMs;
}
} }

View File

@@ -15,8 +15,9 @@ public class MsgUtil {
// '─' (U+2500) ist in Minecraft's Standard-Schrift ca. 6px breit. // '─' (U+2500) ist in Minecraft's Standard-Schrift ca. 6px breit.
// Der Chat ist ~320px breit → ~53 Zeichen. // Der Chat ist ~320px breit → ~53 Zeichen.
// Mit Prefix "[ServerPulse] " (~14 Zeichen) bleiben ~39 Zeichen übrig. // Mit Prefix "[ServerPulse] " (~14 Zeichen) bleiben ~39 Zeichen übrig.
// Wir setzen LINE_LEN daher auf 38 damit es mit Prefix in eine Zeile passt. // In der Praxis wirkt die Zeile mit den Farbformatierungen etwas breiter.
private static final int LINE_LEN = 38; // 34 ergibt hier eine saubere Breite ohne Umbruch.
private static final int LINE_LEN = 34;
private static final char LINE_CHAR = '─'; private static final char LINE_CHAR = '─';
private MsgUtil() {} private MsgUtil() {}
@@ -78,22 +79,18 @@ public class MsgUtil {
} }
/** /**
* Zentrierter Header. * Zentrierter, symmetrischer Header.
* Beispiel: ───── ServerPulse Status ───── * Beispiel: ───── ServerPulse Status ─────
*
* Die Striche werden so berechnet, dass Titel + Striche = LINE_LEN ergibt.
* Wenn der Titel zu lang ist, werden mindestens 3 Striche pro Seite gesetzt.
*/ */
public static String header(String title) { public static String header(String title) {
int available = LINE_LEN - title.length() - 2; // -2 für Leerzeichen int available = Math.max(6, LINE_LEN - title.length() - 2); // -2 für Leerzeichen
int left = Math.max(3, available / 2); int side = Math.max(3, available / 2);
int right = Math.max(3, available - left);
String l = String.valueOf(LINE_CHAR); String l = String.valueOf(LINE_CHAR);
return colorize( return colorize(
"&8" + l.repeat(left) + "&8" + l.repeat(side) +
" &b&l" + title + " &b&l" + title +
" &8" + l.repeat(right) " &8" + l.repeat(side)
); );
} }
} }

View File

@@ -14,6 +14,7 @@ public class SpigotConfig {
public boolean isDebugMode() { return cfg.getBoolean("general.debug", false); } public boolean isDebugMode() { return cfg.getBoolean("general.debug", false); }
public int getMetricsInterval() { return Math.max(10, cfg.getInt("general.metrics-interval", 30)); } public int getMetricsInterval() { return Math.max(10, cfg.getInt("general.metrics-interval", 30)); }
public int getEntityInterval() { return Math.max(10, cfg.getInt("general.entity-interval", 60)); } public int getEntityInterval() { return Math.max(10, cfg.getInt("general.entity-interval", 60)); }
public int getStartupCheckDelayMinutes() { return Math.max(0, cfg.getInt("general.startup-check-delay-minutes", 5)); }
public int getDataRetentionDays() { return cfg.getInt("general.data-retention-days", 90); } public int getDataRetentionDays() { return cfg.getInt("general.data-retention-days", 90); }
public boolean isDatabaseEnabled() { return cfg.getBoolean("database.enabled", true); } public boolean isDatabaseEnabled() { return cfg.getBoolean("database.enabled", true); }
public String getDbHost() { return cfg.getString("database.host", "localhost"); } public String getDbHost() { return cfg.getString("database.host", "localhost"); }

View File

@@ -11,6 +11,7 @@
# ────────────────────────────────────────── # ──────────────────────────────────────────
general: general:
debug: false debug: false
startup-check-delay-minutes: 5 # Verzögerung nach Start, bevor Alerts/Prüfungen ausgelöst werden
metrics-interval: 30 # Sekunden (Spigot: Performance-Erfassung) metrics-interval: 30 # Sekunden (Spigot: Performance-Erfassung)
entity-interval: 60 # Sekunden (Spigot: Entity-Erfassung) entity-interval: 60 # Sekunden (Spigot: Entity-Erfassung)
poll-interval: 30 # Sekunden (BungeeCord: Daten-Weiterleitung) poll-interval: 30 # Sekunden (BungeeCord: Daten-Weiterleitung)