From 9c56e5b38dccb44ef611e39c8ce232d7672d38e6 Mon Sep 17 00:00:00 2001 From: stijnb1234 Date: Mon, 24 Feb 2020 18:10:37 +0100 Subject: [PATCH] Fixed jackson issues --- pom.xml | 15 ++++++++------- .../V10Lift/Commands/V10LiftCommand.java | 3 ++- .../SBDeveloper/V10Lift/Managers/DBManager.java | 14 ++++---------- .../nl/SBDeveloper/V10Lift/V10LiftPlugin.java | 3 ++- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index 46da243..be3e3f9 100644 --- a/pom.xml +++ b/pom.xml @@ -177,19 +177,20 @@ com.fasterxml.jackson.core jackson-core - 2.10.2 + 2.9.6 + + + com.fasterxml.jackson.core + jackson-annotations + 2.9.6 com.fasterxml.jackson.core jackson-databind - 2.10.2 - - - com.fasterxml.jackson.module - jackson-module-parameter-names - 2.10.2 + 2.9.6 + org.bstats diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java b/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java index ad1f8f3..1eabe85 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java @@ -21,6 +21,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import javax.annotation.Nonnull; +import java.io.IOException; import java.sql.SQLException; import java.util.*; @@ -355,7 +356,7 @@ public class V10LiftCommand implements CommandExecutor { try { V10LiftPlugin.getDBManager().save(); V10LiftPlugin.getDBManager().load(); - } catch (SQLException | JsonProcessingException e) { + } catch (SQLException | IOException e) { e.printStackTrace(); } diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/Managers/DBManager.java b/src/main/lombok/nl/SBDeveloper/V10Lift/Managers/DBManager.java index 02284bf..2c81e5e 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/Managers/DBManager.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/Managers/DBManager.java @@ -1,14 +1,12 @@ 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; +import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -34,7 +32,7 @@ public class DBManager { } } - public void load() throws SQLException, JsonProcessingException { + public void load() throws SQLException, IOException { String query = "SELECT * FROM lifts"; PreparedStatement statement = con.prepareStatement(query); ResultSet liftSet = statement.executeQuery(); @@ -50,9 +48,7 @@ public class DBManager { byte[] blob = liftSet.getBytes("liftData"); String json = new String(blob); - ObjectMapper mapper = new ObjectMapper() - .enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES) - .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)); + ObjectMapper mapper = new ObjectMapper(); Lift lift = mapper.readValue(json, Lift.class); DataManager.addLift(liftSet.getString("liftName"), lift); @@ -98,9 +94,7 @@ public class DBManager { public void save() throws JsonProcessingException { for (Map.Entry entry : DataManager.getLifts().entrySet()) { - ObjectMapper mapper = new ObjectMapper() - .enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES) - .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)); + ObjectMapper mapper = new ObjectMapper(); byte[] blob = mapper.writeValueAsString(entry.getValue()).getBytes(); diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/V10LiftPlugin.java b/src/main/lombok/nl/SBDeveloper/V10Lift/V10LiftPlugin.java index ed575a9..e662d9f 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/V10LiftPlugin.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/V10LiftPlugin.java @@ -17,6 +17,7 @@ import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; +import java.io.IOException; import java.sql.SQLException; import java.util.Objects; @@ -42,7 +43,7 @@ public class V10LiftPlugin extends JavaPlugin { dbManager = new DBManager("data"); try { dbManager.load(); - } catch (SQLException | JsonProcessingException e) { + } catch (SQLException | IOException e) { e.printStackTrace(); }