From 27bf53aaad1f58002aa802c30ef5d75f7bacbded Mon Sep 17 00:00:00 2001 From: stijnb1234 Date: Sat, 8 Feb 2020 10:59:57 +0100 Subject: [PATCH] Fixed saving issues --- pom.xml | 16 ++++++++++++++-- .../SBDeveloper/V10Lift/API/Objects/Floor.java | 11 ++++++----- .../SBDeveloper/V10Lift/API/Objects/Lift.java | 4 +++- .../V10Lift/API/Objects/LiftBlock.java | 18 ++++++++++-------- .../V10Lift/API/Objects/LiftRope.java | 17 +++++++++-------- .../V10Lift/API/Objects/LiftSign.java | 5 +++-- .../V10Lift/API/Objects/V10Entity.java | 7 ++++--- .../V10Lift/Managers/DBManager.java | 11 +++++++++-- 8 files changed, 58 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index 11e8f08..829d30b 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,6 @@ UTF-8 1.8 1.8 - 2.10.0 @@ -53,6 +52,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + -parameters + + @@ -105,7 +112,12 @@ com.fasterxml.jackson.core jackson-databind - ${jackson.version} + 2.10.2 + + + com.fasterxml.jackson.module + jackson-module-parameter-names + 2.10.2 diff --git a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/Floor.java b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/Floor.java index d03aca8..a7d6f9a 100644 --- a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/Floor.java +++ b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/Floor.java @@ -1,6 +1,7 @@ package nl.SBDeveloper.V10Lift.API.Objects; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import java.lang.reflect.Field; @@ -8,12 +9,12 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.UUID; -@Getter @Setter +@Getter @Setter @NoArgsConstructor public class Floor { - private final String world; - private final int y; - private final ArrayList doorBlocks = new ArrayList<>(); - private final HashSet whitelist = new HashSet<>(); + private String world; + private int y; + private ArrayList doorBlocks = new ArrayList<>(); + private HashSet whitelist = new HashSet<>(); public Floor(int y, String world) { this.y = y; diff --git a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/Lift.java b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/Lift.java index 4b1b02f..c90f5b4 100644 --- a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/Lift.java +++ b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/Lift.java @@ -1,16 +1,18 @@ package nl.SBDeveloper.V10Lift.API.Objects; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import nl.SBDeveloper.V10Lift.API.Runnables.DoorCloser; import java.lang.reflect.Field; import java.util.*; +@NoArgsConstructor public class Lift { @Getter @Setter private String worldName; @Getter @Setter private int y; - @Getter private final HashSet owners; + @Getter private HashSet owners; //@Getter @Setter private ArrayList whitelist; @Getter private final TreeSet blocks = new TreeSet<>(); @Getter private final LinkedHashMap floors = new LinkedHashMap<>(); diff --git a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftBlock.java b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftBlock.java index 8552487..799b702 100644 --- a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftBlock.java +++ b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftBlock.java @@ -1,6 +1,7 @@ package nl.SBDeveloper.V10Lift.API.Objects; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.bukkit.Material; import org.bukkit.block.BlockFace; @@ -9,22 +10,23 @@ import javax.annotation.Nonnull; import java.lang.reflect.Field; import java.util.Map; +@NoArgsConstructor public class LiftBlock implements Comparable { @Getter @Setter private String world; - @Getter private final int x; + @Getter private int x; @Getter @Setter private int y; - @Getter private final int z; + @Getter private int z; //Only used for cabine blocks, because those need caching! - @Getter private final Material mat; - @Getter private final byte data; - @Getter private final BlockFace face; - @Getter private final String bisected; - @Getter private final String[] signLines; + @Getter private Material mat; + @Getter private byte data; + @Getter private BlockFace face; + @Getter private String bisected; + @Getter private String[] signLines; //Only used for inputs! - @Getter private final String floor; + @Getter private String floor; @Getter @Setter private boolean active = false; //Only used for chests diff --git a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftRope.java b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftRope.java index 67e898e..9985dee 100644 --- a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftRope.java +++ b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftRope.java @@ -1,21 +1,22 @@ package nl.SBDeveloper.V10Lift.API.Objects; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.bukkit.Material; import org.bukkit.block.BlockFace; import java.lang.reflect.Field; -@Getter @Setter +@Getter @Setter @NoArgsConstructor public class LiftRope { - private final Material type; - private final BlockFace face; - private final String world; - private final int x; - private final int minY; - private final int maxY; - private final int z; + private Material type; + private BlockFace face; + private String world; + private int x; + private int minY; + private int maxY; + private int z; private int currently; public LiftRope(Material type, BlockFace face, String world, int x, int minY, int maxY, int z) { diff --git a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftSign.java b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftSign.java index d684271..a4442c0 100644 --- a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftSign.java +++ b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/LiftSign.java @@ -1,18 +1,19 @@ package nl.SBDeveloper.V10Lift.API.Objects; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import java.lang.reflect.Field; -@Getter @Setter +@Getter @Setter @NoArgsConstructor public class LiftSign { private String world; private int x; private int z; private int y; private String oldText = null; - private final byte type; + private byte type; private byte state; public LiftSign(String world, int x, int y, int z, byte type, byte state) { diff --git a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/V10Entity.java b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/V10Entity.java index 042ec96..32fb61a 100644 --- a/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/V10Entity.java +++ b/src/main/java/nl/SBDeveloper/V10Lift/API/Objects/V10Entity.java @@ -1,6 +1,7 @@ package nl.SBDeveloper.V10Lift.API.Objects; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -9,14 +10,14 @@ import org.bukkit.entity.Entity; import java.lang.reflect.Field; import java.util.UUID; -@Getter +@Getter @NoArgsConstructor public class V10Entity { - private final UUID entityUUID; + private UUID entityUUID; private String world; private int locX; private int locY; private int locZ; - private final int y; + private int y; @Setter private short step; public V10Entity(UUID entityUUID, String worldName, int x, int y, int z, int cury) { diff --git a/src/main/java/nl/SBDeveloper/V10Lift/Managers/DBManager.java b/src/main/java/nl/SBDeveloper/V10Lift/Managers/DBManager.java index 2e16aa5..02284bf 100644 --- a/src/main/java/nl/SBDeveloper/V10Lift/Managers/DBManager.java +++ b/src/main/java/nl/SBDeveloper/V10Lift/Managers/DBManager.java @@ -1,7 +1,10 @@ package nl.SBDeveloper.V10Lift.Managers; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import nl.SBDeveloper.V10Lift.API.Objects.Lift; import nl.SBDevelopment.SBUtilities.Data.SQLiteDB; import org.bukkit.Bukkit; @@ -47,7 +50,9 @@ public class DBManager { byte[] blob = liftSet.getBytes("liftData"); String json = new String(blob); - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper() + .enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES) + .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)); Lift lift = mapper.readValue(json, Lift.class); DataManager.addLift(liftSet.getString("liftName"), lift); @@ -93,7 +98,9 @@ public class DBManager { public void save() throws JsonProcessingException { for (Map.Entry entry : DataManager.getLifts().entrySet()) { - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper() + .enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES) + .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)); byte[] blob = mapper.writeValueAsString(entry.getValue()).getBytes();