Dateien nach "src/main/java/me/viper/teamplugin/util" hochladen
This commit is contained in:
38
src/main/java/me/viper/teamplugin/util/Utils.java
Normal file
38
src/main/java/me/viper/teamplugin/util/Utils.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package me.viper.teamplugin.util;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static String formatIsoNow() {
|
||||
return DateTimeFormatter.ISO_INSTANT
|
||||
.withZone(ZoneId.systemDefault())
|
||||
.format(Instant.now());
|
||||
}
|
||||
|
||||
public static String prettifyIso(String iso) {
|
||||
if (iso == null || iso.isEmpty()) return "—";
|
||||
Instant inst = Instant.parse(iso);
|
||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
|
||||
.withLocale(Locale.getDefault())
|
||||
.withZone(ZoneId.systemDefault());
|
||||
return fmt.format(inst);
|
||||
}
|
||||
|
||||
public static String color(String s) {
|
||||
return s == null ? "" : s.replace("&", "§");
|
||||
}
|
||||
|
||||
// Ersetze Platzhalter %player% %rank% %joindate%
|
||||
public static String replace(String template, String... pairs) {
|
||||
if (template == null) return "";
|
||||
String out = template;
|
||||
for (int i = 0; i + 1 < pairs.length; i += 2) {
|
||||
out = out.replace(pairs[i], pairs[i + 1]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user