Update compatibility with Plex and Gradle

This commit is contained in:
Telesphoreo 2023-03-08 13:21:31 -06:00
parent 4426c4b4b7
commit 46ff09bf58
5 changed files with 10 additions and 11 deletions

Binary file not shown.

View file

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000 networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -11,7 +11,7 @@ import dev.plex.request.AbstractServlet;
import dev.plex.request.GetMapping; import dev.plex.request.GetMapping;
import dev.plex.request.MappingHeaders; import dev.plex.request.MappingHeaders;
import dev.plex.util.PlexLog; import dev.plex.util.PlexLog;
import dev.plex.util.adapter.ZonedDateTimeSerializer; import dev.plex.util.adapter.ZonedDateTimeAdapter;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
@ -23,7 +23,7 @@ public class AdminsEndpoint extends AbstractServlet
{ {
private static final Gson GSON = private static final Gson GSON =
new GsonBuilder() new GsonBuilder()
.registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()) .registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter())
.setPrettyPrinting() .setPrettyPrinting()
.create(); .create();

View file

@ -9,9 +9,8 @@ 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.ZonedDateTimeSerializer; import dev.plex.util.adapter.ZonedDateTimeAdapter;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.UUID; import java.util.UUID;
@ -59,7 +58,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(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList()); return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
} }
if (Plex.get().getSystem().equalsIgnoreCase("ranks")) if (Plex.get().getSystem().equalsIgnoreCase("ranks"))
{ {
@ -67,7 +66,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(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList()); return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter()).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"))
@ -77,12 +76,12 @@ 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(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList()); return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().peek(punishment -> punishment.setIp("")).toList());
} }
} }
response.setHeader("content-type", "application/json"); response.setHeader("content-type", "application/json");
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().toList()); return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter()).setPrettyPrinting().create().toJson(punishedPlayer.getPunishments().stream().toList());
} }
private String punishmentsHTML(String message) private String punishmentsHTML(String message)