|
|
|
@ -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<String> awardedAdvancementCriteria) implements Serializable {
|
|
|
|
|
public static class AdvancementRecord implements Serializable {
|
|
|
|
|
String advancementKey;
|
|
|
|
|
ArrayList<String> awardedAdvancementCriteria;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A record used to store data for a player's statistics
|
|
|
|
|
*/
|
|
|
|
|
public record StatisticData(HashMap<Statistic, Integer> untypedStatisticValues,
|
|
|
|
|
HashMap<Statistic, HashMap<Material, Integer>> blockStatisticValues,
|
|
|
|
|
HashMap<Statistic, HashMap<Material, Integer>> itemStatisticValues,
|
|
|
|
|
HashMap<Statistic, HashMap<EntityType, Integer>> entityStatisticValues) implements Serializable {
|
|
|
|
|
@Value
|
|
|
|
|
public static class StatisticData implements Serializable {
|
|
|
|
|
HashMap<Statistic, Integer> untypedStatisticValues;
|
|
|
|
|
HashMap<Statistic, HashMap<Material, Integer>> blockStatisticValues;
|
|
|
|
|
HashMap<Statistic, HashMap<Material, Integer>> itemStatisticValues;
|
|
|
|
|
HashMap<Statistic, HashMap<EntityType, Integer>> entityStatisticValues;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A record used to store data for native advancement synchronisation, tracking advancement date progress
|
|
|
|
|
*/
|
|
|
|
|
public record AdvancementRecordDate(String key, Map<String, Date> criteriaMap) implements Serializable {
|
|
|
|
|
@Value
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public static class AdvancementRecordDate implements Serializable {
|
|
|
|
|
String key;
|
|
|
|
|
Map<String, Date> criteriaMap;
|
|
|
|
|
|
|
|
|
|
public AdvancementRecordDate(String key, List<String> criteriaList) {
|
|
|
|
|
this(key, new HashMap<>() {{
|
|
|
|
|
criteriaList.forEach(s -> put(s, Date.from(Instant.EPOCH)));
|
|
|
|
|
}});
|
|
|
|
|
this(key, fromStringList(criteriaList));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Map<String, Date> fromStringList(List<String> criteriaList) {
|
|
|
|
|
Map<String, Date> 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|