mirror of
https://github.com/plexusorg/Plex.git
synced 2025-06-28 22:46:40 +00:00
Minor clean up
This commit is contained in:
@ -20,6 +20,7 @@ public class BungeeUtil
|
||||
return Bukkit.spigot().getPaperConfig().getBoolean("settings.velocity-support.enabled") && !Bukkit.spigot().getPaperConfig().getString("settings.velocity-support.secret", "").isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public static void kickPlayer(Player player, Component message)
|
||||
{
|
||||
if (isBungeeCord() || isVelocity())
|
||||
|
@ -24,6 +24,7 @@ public class GameRuleUtil
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> void readGameRules(World world, String s)
|
||||
{
|
||||
String gameRule = s.split(";")[0];
|
||||
@ -47,7 +48,7 @@ public class GameRuleUtil
|
||||
return Boolean.parseBoolean(value.toString());
|
||||
}
|
||||
|
||||
if (NumberUtils.isNumber(value.toString()))
|
||||
if (NumberUtils.isCreatable(value.toString()))
|
||||
{
|
||||
return Integer.parseInt(value.toString());
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class PlexUtils implements PlexBase
|
||||
{
|
||||
if (Plex.get().getSqlConnection().getDataSource() != null)
|
||||
{
|
||||
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||
try (Connection ignored = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
if (Plex.get().getStorageType() == StorageType.MARIADB)
|
||||
{
|
||||
@ -115,7 +115,7 @@ public class PlexUtils implements PlexBase
|
||||
List<Command> cmds = PluginCommandYamlParser.parse(plugin);
|
||||
for (Command pluginCmd : cmds)
|
||||
{
|
||||
List<String> cmdAliases = pluginCmd.getAliases().size() > 0 ? pluginCmd.getAliases().stream().map(String::toLowerCase).collect(Collectors.toList()) : null;
|
||||
List<String> cmdAliases = pluginCmd.getAliases().size() > 0 ? pluginCmd.getAliases().stream().map(String::toLowerCase).toList() : null;
|
||||
if (pluginCmd.getName().equalsIgnoreCase(cmd) || (cmdAliases != null && cmdAliases.contains(cmd.toLowerCase())))
|
||||
{
|
||||
return true;
|
||||
|
@ -11,7 +11,6 @@ import java.util.Set;
|
||||
|
||||
public class ReflectionsUtil
|
||||
{
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public static Set<Class<?>> getClassesFrom(String packageName)
|
||||
{
|
||||
Set<Class<?>> classes = new HashSet<>();
|
||||
|
@ -29,7 +29,7 @@ public class TimeUtils
|
||||
|
||||
private static int parseInteger(String s) throws NumberFormatException
|
||||
{
|
||||
if (!NumberUtils.isNumber(s))
|
||||
if (!NumberUtils.isCreatable(s))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package dev.plex.util.adapter;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import dev.plex.Plex;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
public class ZonedDateTimeAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime>
|
||||
{
|
||||
private static final String TIMEZONE = Plex.get().config.getString("server.timezone");
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(ZonedDateTime src, Type typeOfSrc, JsonSerializationContext context)
|
||||
{
|
||||
return new JsonPrimitive(src.toInstant().toEpochMilli());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZonedDateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
Instant instant = Instant.ofEpochMilli(json.getAsJsonPrimitive().getAsLong());
|
||||
return ZonedDateTime.ofInstant(instant, ZoneId.of(TIMEZONE));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user