feat: add NATS chat sync plugin
Build / build (push) Failing after 57s

This commit is contained in:
dmg
2026-01-29 21:24:23 -05:00
commit bdd9b4bb8b
13 changed files with 608 additions and 0 deletions
@@ -0,0 +1,34 @@
package com.spigotchatsync;
import java.time.Instant;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
public final class MessageFormatter {
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm");
private MessageFormatter() {
}
public static String format(String template, ChatSyncMessage message) {
String output = template;
output = output.replace("{server}", nullSafe(message.getServer()));
output = output.replace("{player}", nullSafe(message.getPlayerName()));
output = output.replace("{message}", nullSafe(message.getMessage()));
output = output.replace("{time}", formatTime(message.getTimestamp()));
return output;
}
private static String nullSafe(String value) {
return value == null ? "" : value;
}
private static String formatTime(long epochSeconds) {
if (epochSeconds <= 0) {
return "";
}
LocalTime time = Instant.ofEpochSecond(epochSeconds).atZone(ZoneId.systemDefault()).toLocalTime();
return TIME_FORMAT.format(time);
}
}