Upload folder via GUI - src

This commit is contained in:
Git Manager GUI
2026-06-15 07:03:50 +02:00
parent 0e1d193653
commit 684f300775
42 changed files with 7336 additions and 0 deletions
@@ -0,0 +1,99 @@
package de.serverpulse.spigot.utils;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.command.CommandSender;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class MsgUtil {
private static final DecimalFormat DF2 = new DecimalFormat("##.##");
private static final DateTimeFormatter DT = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss");
// '─' (U+2500) ist in Minecraft's Standard-Schrift ca. 6px breit.
// Der Chat ist ~320px breit → ~53 Zeichen.
// Mit Prefix "[ServerPulse] " (~14 Zeichen) bleiben ~39 Zeichen übrig.
// Wir setzen LINE_LEN daher auf 38 damit es mit Prefix in eine Zeile passt.
private static final int LINE_LEN = 38;
private static final char LINE_CHAR = '─';
private MsgUtil() {}
// ── Farben ───────────────────────────────────────────────────────────────
public static String colorize(String s) {
return s == null ? "" : ChatColor.translateAlternateColorCodes('&', s);
}
public static void send(CommandSender sender, String msg) {
sender.sendMessage(colorize(msg));
}
// ── Zahlenformatierung ───────────────────────────────────────────────────
public static String formatTps(double tps) {
return colorize((tps >= 18 ? "&a" : tps >= 15 ? "&e" : "&c")
+ DF2.format(Math.min(20.0, tps)));
}
public static String formatMspt(double mspt) {
return colorize((mspt <= 40 ? "&a" : mspt <= 50 ? "&e" : "&c")
+ DF2.format(mspt) + "ms");
}
public static String formatRam(long used, long max) {
double pct = (double) used / max * 100;
return colorize((pct <= 75 ? "&a" : pct <= 90 ? "&e" : "&c")
+ used + "MB / " + max + "MB (" + (int) pct + "%)");
}
public static String formatCount(int val, int warn, int crit) {
return colorize((val >= crit ? "&c" : val >= warn ? "&e" : "&a") + val);
}
// ── Fortschrittsbalken ───────────────────────────────────────────────────
public static String bar(double val, double max, int len) {
int filled = (int) Math.min(Math.round((val / max) * len), len);
double pct = val / max * 100;
String col = pct <= 50 ? "&a" : pct <= 75 ? "&e" : "&c";
return colorize(col + "█".repeat(filled) + "&8" + "░".repeat(Math.max(0, len - filled)));
}
// ── Zeitstempel ──────────────────────────────────────────────────────────
public static String timestamp() {
return LocalDateTime.now().format(DT);
}
// ── Trennlinien ──────────────────────────────────────────────────────────
/**
* Einfache Trennlinie – passt zur Chat-Breite mit Prefix.
*/
public static String separator() {
return colorize("&8" + String.valueOf(LINE_CHAR).repeat(LINE_LEN));
}
/**
* Zentrierter Header.
* 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) {
int available = LINE_LEN - title.length() - 2; // -2 für Leerzeichen
int left = Math.max(3, available / 2);
int right = Math.max(3, available - left);
String l = String.valueOf(LINE_CHAR);
return colorize(
"&8" + l.repeat(left) +
" &b&l" + title +
" &8" + l.repeat(right)
);
}
}