mirror of
https://github.com/plexusorg/Module-HTTPD.git
synced 2024-11-23 12:15:00 +00:00
update to use zoned date time
This commit is contained in:
parent
7760eb6ff2
commit
41459ad404
@ -10,9 +10,10 @@ import dev.plex.rank.enums.Rank;
|
|||||||
import dev.plex.request.AbstractServlet;
|
import dev.plex.request.AbstractServlet;
|
||||||
import dev.plex.request.GetMapping;
|
import dev.plex.request.GetMapping;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.adapter.LocalDateTimeSerializer;
|
import dev.plex.util.adapter.ZonedDateTimeSerializer;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
@ -35,7 +36,7 @@ public class AdminsEndpoint extends AbstractServlet
|
|||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
// This likely means they've never joined the server before. That's okay. We can just not return IPs.
|
// This likely means they've never joined the server before. That's okay. We can just not return IPs.
|
||||||
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()));
|
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
if (Plex.get().getSystem().equalsIgnoreCase("ranks"))
|
if (Plex.get().getSystem().equalsIgnoreCase("ranks"))
|
||||||
{
|
{
|
||||||
@ -43,7 +44,7 @@ public class AdminsEndpoint extends AbstractServlet
|
|||||||
if (!player.getRankFromString().isAtLeast(Rank.ADMIN))
|
if (!player.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||||
{
|
{
|
||||||
// Don't return IPs either if the person is not an Admin or above.
|
// Don't return IPs either if the person is not an Admin or above.
|
||||||
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()));
|
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Plex.get().getSystem().equalsIgnoreCase("permissions"))
|
else if (Plex.get().getSystem().equalsIgnoreCase("permissions"))
|
||||||
@ -53,10 +54,10 @@ public class AdminsEndpoint extends AbstractServlet
|
|||||||
if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.admins.access"))
|
if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.admins.access"))
|
||||||
{
|
{
|
||||||
// If the person doesn't have permission, don't return IPs
|
// If the person doesn't have permission, don't return IPs
|
||||||
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()));
|
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers().stream().peek(plexPlayer -> plexPlayer.setIps(Lists.newArrayList())).peek(plexPlayer -> plexPlayer.setPunishments(Lists.newArrayList())).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers());
|
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(Plex.get().getAdminList().getAllAdminPlayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String adminsHTML(String message)
|
private String adminsHTML(String message)
|
||||||
|
@ -9,9 +9,10 @@ import dev.plex.rank.enums.Rank;
|
|||||||
import dev.plex.request.AbstractServlet;
|
import dev.plex.request.AbstractServlet;
|
||||||
import dev.plex.request.GetMapping;
|
import dev.plex.request.GetMapping;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.adapter.LocalDateTimeSerializer;
|
import dev.plex.util.adapter.ZonedDateTimeSerializer;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
@ -58,7 +59,7 @@ public class PunishmentsEndpoint extends AbstractServlet
|
|||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
// If the player is null, give it to them without the IPs
|
// If the player is null, give it to them without the IPs
|
||||||
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
|
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
|
||||||
}
|
}
|
||||||
if (Plex.get().getSystem().equalsIgnoreCase("ranks"))
|
if (Plex.get().getSystem().equalsIgnoreCase("ranks"))
|
||||||
{
|
{
|
||||||
@ -66,7 +67,7 @@ public class PunishmentsEndpoint extends AbstractServlet
|
|||||||
if (!player.getRankFromString().isAtLeast(Rank.ADMIN))
|
if (!player.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||||
{
|
{
|
||||||
// Don't return IPs either if the person is not an Admin or above.
|
// Don't return IPs either if the person is not an Admin or above.
|
||||||
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
|
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Plex.get().getSystem().equalsIgnoreCase("permissions"))
|
else if (Plex.get().getSystem().equalsIgnoreCase("permissions"))
|
||||||
@ -76,10 +77,10 @@ public class PunishmentsEndpoint extends AbstractServlet
|
|||||||
if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.punishments.access"))
|
if (!HTTPDModule.getPermissions().playerHas(null, offlinePlayer, "plex.httpd.punishments.access"))
|
||||||
{
|
{
|
||||||
// If the person doesn't have permission, don't return IPs
|
// If the person doesn't have permission, don't return IPs
|
||||||
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
|
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new GsonBuilder().registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().toList());
|
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String punishmentsHTML(String message)
|
private String punishmentsHTML(String message)
|
||||||
|
Loading…
Reference in New Issue
Block a user