mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-01 07:36:42 +00:00
add tempban punishment type and swap localdatetime zoneddatetime, as well as reload timezone on /plex reload
This commit is contained in:
@ -14,8 +14,11 @@ import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import dev.plex.util.WebUtils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -84,7 +87,7 @@ public class BanCMD extends PlexCommand
|
||||
punishment.setReason("No reason provided.");
|
||||
}
|
||||
punishment.setPunishedUsername(plexPlayer.getName());
|
||||
LocalDateTime date = LocalDateTime.now();
|
||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||
punishment.setEndDate(date.plusDays(1));
|
||||
punishment.setCustomTime(false);
|
||||
punishment.setActive(!isAdmin(plexPlayer));
|
||||
|
@ -10,7 +10,11 @@ import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import dev.plex.util.TimeUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -51,7 +55,7 @@ public class FreezeCMD extends PlexCommand
|
||||
|
||||
Punishment punishment = new Punishment(punishedPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setCustomTime(false);
|
||||
LocalDateTime date = LocalDateTime.now();
|
||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||
punishment.setEndDate(date.plusMinutes(5));
|
||||
punishment.setType(PunishmentType.FREEZE);
|
||||
punishment.setPunishedUsername(player.getName());
|
||||
|
@ -11,8 +11,11 @@ import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import dev.plex.util.WebUtils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -57,7 +60,7 @@ public class KickCMD extends PlexCommand
|
||||
}
|
||||
|
||||
punishment.setPunishedUsername(plexPlayer.getName());
|
||||
punishment.setEndDate(LocalDateTime.now());
|
||||
punishment.setEndDate(ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)));
|
||||
punishment.setCustomTime(false);
|
||||
punishment.setActive(false);
|
||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||
|
@ -10,7 +10,11 @@ import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import dev.plex.util.TimeUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -51,7 +55,7 @@ public class MuteCMD extends PlexCommand
|
||||
|
||||
Punishment punishment = new Punishment(punishedPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setCustomTime(false);
|
||||
LocalDateTime date = LocalDateTime.now();
|
||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||
punishment.setEndDate(date.plusMinutes(5));
|
||||
punishment.setType(PunishmentType.MUTE);
|
||||
punishment.setPunishedUsername(player.getName());
|
||||
|
@ -43,12 +43,12 @@ public class NameHistoryCMD extends PlexCommand
|
||||
List<Component> historyList = Lists.newArrayList();
|
||||
Arrays.stream(info.getUsernameHistories()).forEach(history ->
|
||||
{
|
||||
if (history.getLocalDateTime() != null)
|
||||
if (history.getZonedDateTime() != null)
|
||||
{
|
||||
historyList.add(
|
||||
messageComponent("nameHistoryBody",
|
||||
history.getUsername(),
|
||||
TimeUtils.useTimezone(history.getLocalDateTime())));
|
||||
TimeUtils.useTimezone(history.getZonedDateTime())));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -11,6 +11,8 @@ import dev.plex.storage.StorageType;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -75,7 +77,7 @@ public class NotesCMD extends PlexCommand
|
||||
String content = StringUtils.join(ArrayUtils.subarray(args, 2, args.length), " ");
|
||||
if (playerSender != null)
|
||||
{
|
||||
Note note = new Note(plexPlayer.getUuid(), content, playerSender.getUniqueId(), LocalDateTime.now());
|
||||
Note note = new Note(plexPlayer.getUuid(), content, playerSender.getUniqueId(), ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)));
|
||||
plexPlayer.getNotes().add(note);
|
||||
if (plugin.getStorageType() != StorageType.MONGODB)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
@ -15,6 +16,8 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import dev.plex.util.TimeUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -63,6 +66,8 @@ public class PlexCMD extends PlexCommand
|
||||
plugin.getServiceManager().endServices();
|
||||
plugin.getServiceManager().startServices();
|
||||
PlexLog.debug("Restarted services");
|
||||
TimeUtils.TIMEZONE = plugin.config.getString("server.timezone");
|
||||
send(sender, "Set timezone to: " + TimeUtils.TIMEZONE);
|
||||
send(sender, "Plex successfully reloaded.");
|
||||
return null;
|
||||
}
|
||||
|
@ -10,8 +10,12 @@ import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import dev.plex.util.TimeUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.title.Title;
|
||||
@ -125,7 +129,7 @@ public class SmiteCMD extends PlexCommand
|
||||
|
||||
Punishment punishment = new Punishment(plexPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setCustomTime(false);
|
||||
punishment.setEndDate(LocalDateTime.now());
|
||||
punishment.setEndDate(ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)));
|
||||
punishment.setType(PunishmentType.SMITE);
|
||||
punishment.setPunishedUsername(player.getName());
|
||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||
|
Reference in New Issue
Block a user