This commit is contained in:
Telesphoreo 2022-04-10 18:30:21 -05:00
parent ffe8993ee1
commit 1dc0e05715
8 changed files with 22 additions and 13 deletions

View File

@ -103,7 +103,7 @@ String getBuildNumber() {
}
static def getDate() {
return new Date().format("MM/dd/yyyy '<light_purple>at<gold>' hh:mm:ss a")
return new Date().format("MM/dd/yyyy '<light_purple>at<gold>' hh:mm:ss a z")
}
task buildProperties {

View File

@ -17,7 +17,6 @@ import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "flatlands", description = "Teleport to the flatlands")
public class FlatlandsCMD extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{

View File

@ -17,7 +17,6 @@ import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "masterbuilderworld", aliases = "mbw", description = "Teleport to the Master Builder world")
public class MasterbuilderworldCMD extends PlexCommand
{
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{

View File

@ -24,8 +24,6 @@ import org.jetbrains.annotations.Nullable;
@CommandPermissions(level = Rank.OP, permission = "plex.namehistory")
public class NameHistoryCMD extends PlexCommand
{
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a");
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
@ -50,7 +48,7 @@ public class NameHistoryCMD extends PlexCommand
historyList.add(
messageComponent("nameHistoryBody",
history.getUsername(),
DATE_FORMAT.format(history.getLocalDateTime())));
PlexUtils.useTimezone(history.getLocalDateTime())));
}
else
{

View File

@ -30,8 +30,6 @@ import java.util.concurrent.atomic.AtomicReference;
@CommandPermissions(level = Rank.ADMIN, permission = "plex.notes")
public class NotesCMD extends PlexCommand
{
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a");
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
@ -173,7 +171,7 @@ public class NotesCMD extends PlexCommand
AtomicReference<Component> noteList = new AtomicReference<>(Component.text("Player notes for: " + plexPlayer.getName()).color(NamedTextColor.GREEN));
for (Note note : notes)
{
Component noteLine = mmString("<gold><!italic>" + note.getId() + " - Written by: " + DataUtils.getPlayer(note.getWrittenBy()).getName() + " on " + DATE_FORMAT.format(note.getTimestamp()));
Component noteLine = mmString("<gold><!italic>" + note.getId() + " - Written by: " + DataUtils.getPlayer(note.getWrittenBy()).getName() + " on " + PlexUtils.useTimezone(note.getTimestamp()));
noteLine = noteLine.append(mmString("<newline><yellow># " + note.getNote()));
noteList.set(noteList.get().append(Component.newline()));
noteList.set(noteList.get().append(noteLine));

View File

@ -8,7 +8,6 @@ import dev.plex.util.PlexUtils;
import dev.plex.util.adapter.LocalDateTimeDeserializer;
import dev.plex.util.adapter.LocalDateTimeSerializer;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
@ -20,7 +19,6 @@ import net.kyori.adventure.text.Component;
public class Punishment
{
private static final String banUrl = Plex.get().config.getString("banning.ban_url");
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a");
private final UUID punished;
private final UUID punisher;
private String ip;
@ -45,8 +43,10 @@ public class Punishment
public static Component generateBanMessage(Punishment punishment)
{
return PlexUtils.messageComponent("banMessage", banUrl, punishment.getReason(),
DATE_FORMAT.format(punishment.getEndDate()), punishment.getPunisher() == null ? "CONSOLE" : MojangUtils.getInfo(punishment.getPunisher().toString()).getUsername());
PlexUtils.useTimezone(punishment.getEndDate()),
punishment.getPunisher() == null ? "CONSOLE" : MojangUtils.getInfo(punishment.getPunisher().toString()).getUsername());
}
public static Component generateIndefBanMessage(String type)

View File

@ -6,11 +6,11 @@ import dev.plex.Plex;
import dev.plex.PlexBase;
import dev.plex.config.Config;
import dev.plex.storage.StorageType;
import java.time.format.DateTimeFormatter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import net.kyori.adventure.text.minimessage.tag.standard.*;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.*;
@ -58,6 +58,9 @@ public class PlexUtils extends PlexBase
"ca83b658-c03b-4106-9edc-72f70a80656d", // ayunami2000
"2e06e049-24c8-42e4-8bcf-d35372af31e6" //Fleek
);
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a z");
private static final Set<String> TIMEZONES = Set.of(TimeZone.getAvailableIDs());
private static String TIMEZONE = Plex.get().config.getString("server.timezone");
static
{
@ -240,6 +243,16 @@ public class PlexUtils extends PlexBase
return (unit != null) ? unit : TimeUnit.DAY;
}
public static String useTimezone(LocalDateTime date)
{
// Use UTC if the timezone is null or not set correctly
if (TIMEZONE == null || !TIMEZONES.contains(TIMEZONE))
{
TIMEZONE = "Etc/UTC";
}
return DATE_FORMAT.withZone(ZoneId.of(TIMEZONE)).format(date);
}
public static LocalDateTime parseDateOffset(String... time)
{
Instant instant = Instant.now();

View File

@ -7,6 +7,8 @@ server:
colorize_motd: true
sample:
- "&cForums: https://forum.plex.us.org"
# What timezone should various messages appear in (e.g. ban message end date)
timezone: Etc/UTC
titles:
masterbuilders: [ ]