From 23f1ae53b5f92dc5120ce4b77889a8cda9f15fa0 Mon Sep 17 00:00:00 2001 From: InkerBot Date: Thu, 22 Aug 2024 19:26:09 +0800 Subject: [PATCH] use java8 to build --- build.gradle | 18 ++++++- lombok.config | 14 ++++++ .../husksync/bukkit/data/DataSerializer.java | 47 ++++++++++++++----- .../william278/hslmigrator/HSLConverter.java | 3 +- 4 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 lombok.config diff --git a/build.gradle b/build.gradle index e6690ec..d02c7ba 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id 'maven-publish' } -group 'net.william278' +group 'org.inksnow.husk' version '1.0' repositories { @@ -14,6 +14,12 @@ repositories { } dependencies { + // lombok + compileOnly 'org.projectlombok:lombok:1.18.34' + annotationProcessor 'org.projectlombok:lombok:1.18.34' + testCompileOnly 'org.projectlombok:lombok:1.18.34' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.34' + compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT' compileOnly 'org.jetbrains:annotations:23.0.0' @@ -22,6 +28,16 @@ dependencies { } publishing { + repositories { + maven { + name = 'husk-release' + url = findProperty("repository.huskrelease.url") + credentials { + username = findProperty("repository.huskrelease.username") + password = findProperty("repository.huskrelease.password") + } + } + } publications { gpr(MavenPublication) { from(components.java) diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..1dec874 --- /dev/null +++ b/lombok.config @@ -0,0 +1,14 @@ +lombok.accessors.fluent=true +lombok.accessors.chain=true + +lombok.builder.className=Builder + +lombok.log.fieldName=logger +lombok.log.custom.flagUsage=error +lombok.log.apacheCommons.flagUsage=error +lombok.log.flogger.flagUsage=error +lombok.log.jbosslog.flagUsage=error +lombok.log.javaUtilLogging.flagUsage=error +lombok.log.log4j.flagUsage=error +lombok.log.log4j2.flagUsage=error +lombok.log.xslf4j.flagUsage=error \ No newline at end of file diff --git a/src/main/java/me/william278/husksync/bukkit/data/DataSerializer.java b/src/main/java/me/william278/husksync/bukkit/data/DataSerializer.java index b8fb5ef..a4de99c 100644 --- a/src/main/java/me/william278/husksync/bukkit/data/DataSerializer.java +++ b/src/main/java/me/william278/husksync/bukkit/data/DataSerializer.java @@ -1,5 +1,8 @@ package me.william278.husksync.bukkit.data; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.Value; import org.bukkit.Material; import org.bukkit.Statistic; import org.bukkit.World; @@ -19,38 +22,58 @@ public class DataSerializer { * * @deprecated Old format - Use {@link AdvancementRecordDate} instead */ + @Value @Deprecated @SuppressWarnings("DeprecatedIsStillUsed") // Suppress deprecation warnings here (still used for backwards compatibility) - public record AdvancementRecord(String advancementKey, - ArrayList awardedAdvancementCriteria) implements Serializable { + public static class AdvancementRecord implements Serializable { + String advancementKey; + ArrayList awardedAdvancementCriteria; } /** * A record used to store data for a player's statistics */ - public record StatisticData(HashMap untypedStatisticValues, - HashMap> blockStatisticValues, - HashMap> itemStatisticValues, - HashMap> entityStatisticValues) implements Serializable { + @Value + public static class StatisticData implements Serializable { + HashMap untypedStatisticValues; + HashMap> blockStatisticValues; + HashMap> itemStatisticValues; + HashMap> entityStatisticValues; } /** * A record used to store data for native advancement synchronisation, tracking advancement date progress */ - public record AdvancementRecordDate(String key, Map criteriaMap) implements Serializable { + @Value + @RequiredArgsConstructor + public static class AdvancementRecordDate implements Serializable { + String key; + Map criteriaMap; + public AdvancementRecordDate(String key, List criteriaList) { - this(key, new HashMap<>() {{ - criteriaList.forEach(s -> put(s, Date.from(Instant.EPOCH))); - }}); + this(key, fromStringList(criteriaList)); + } + + private static Map fromStringList(List criteriaList) { + Map criteriaMap = new HashMap<>(); + criteriaList.forEach(s -> criteriaMap.put(s, Date.from(Instant.EPOCH))); + return criteriaMap; } } /** * A record used to store data for a player's location */ - public record PlayerLocation(double x, double y, double z, float yaw, float pitch, - String worldName, World.Environment environment) implements Serializable { + @Value + public static class PlayerLocation implements Serializable { + double x; + double y; + double z; + float yaw; + float pitch; + String worldName; + World.Environment environment; } } diff --git a/src/main/java/net/william278/hslmigrator/HSLConverter.java b/src/main/java/net/william278/hslmigrator/HSLConverter.java index ba1002c..0e3aa06 100644 --- a/src/main/java/net/william278/hslmigrator/HSLConverter.java +++ b/src/main/java/net/william278/hslmigrator/HSLConverter.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Base64; import java.util.HashMap; import java.util.List; +import java.util.stream.Collectors; /** @@ -80,7 +81,7 @@ public class HSLConverter { .map(o -> new DataSerializer.AdvancementRecordDate( o.advancementKey(), o.awardedAdvancementCriteria() - )).toList(); + )).collect(Collectors.toList()); } return (List) deserialize;