diff --git a/pom.xml b/pom.xml index 76ff63a..398ebbb 100644 --- a/pom.xml +++ b/pom.xml @@ -177,23 +177,6 @@ compile - - - com.fasterxml.jackson.core - jackson-core - 2.9.6 - - - com.fasterxml.jackson.core - jackson-annotations - 2.9.6 - - - com.fasterxml.jackson.core - jackson-databind - 2.9.10.1 - - 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 d6dfe81..c46917f 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/Commands/V10LiftCommand.java @@ -1,6 +1,5 @@ package nl.SBDeveloper.V10Lift.Commands; -import com.fasterxml.jackson.core.JsonProcessingException; import nl.SBDeveloper.V10Lift.API.Objects.Floor; import nl.SBDeveloper.V10Lift.API.Objects.Lift; import nl.SBDeveloper.V10Lift.API.Objects.LiftBlock; @@ -22,7 +21,6 @@ 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.*; @@ -357,7 +355,7 @@ public class V10LiftCommand implements CommandExecutor { try { V10LiftPlugin.getDBManager().save(); V10LiftPlugin.getDBManager().load(); - } catch (SQLException | IOException e) { + } catch (SQLException e) { e.printStackTrace(); } @@ -917,11 +915,7 @@ public class V10LiftCommand implements CommandExecutor { DataManager.removeRopeRemovesPlayer(p.getUniqueId()); DataManager.removeDoorEditPlayer(p.getUniqueId()); - try { - V10LiftPlugin.getDBManager().save(); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } + V10LiftPlugin.getDBManager().save(); BlockState bs; Sign sign; @@ -1087,7 +1081,7 @@ public class V10LiftCommand implements CommandExecutor { sender.sendMessage("§6/v10lift speed §f: Change the speed of a lift."); sender.sendMessage("§6/v10lift realistic§f: Toggle realistic mode."); sender.sendMessage("§6/v10lift repair§f: Repair a lift."); - sender.sendMessage("§6/v10lift whitelist [Floorname]§f: Add/remove someone of the whitelist."); + sender.sendMessage("§6/v10lift whitelist [Floorname]§f: Add/remove someone of the whitelist. Use g: for a group."); sender.sendMessage("§6/v10lift start [Name] [Floor]§f: Start a lift to a floor."); sender.sendMessage("§6/v10lift stop [Name]§f: Stop a lift."); sender.sendMessage("§6/v10lift repair§f: Repair a lift."); diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/Managers/DBManager.java b/src/main/lombok/nl/SBDeveloper/V10Lift/Managers/DBManager.java index 2c81e5e..52f054a 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/Managers/DBManager.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/Managers/DBManager.java @@ -1,12 +1,10 @@ package nl.SBDeveloper.V10Lift.Managers; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; 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; @@ -32,7 +30,7 @@ public class DBManager { } } - public void load() throws SQLException, IOException { + public void load() throws SQLException { String query = "SELECT * FROM lifts"; PreparedStatement statement = con.prepareStatement(query); ResultSet liftSet = statement.executeQuery(); @@ -48,8 +46,9 @@ public class DBManager { byte[] blob = liftSet.getBytes("liftData"); String json = new String(blob); - ObjectMapper mapper = new ObjectMapper(); - Lift lift = mapper.readValue(json, Lift.class); + + Gson gson = new Gson(); + Lift lift = gson.fromJson(json, Lift.class); DataManager.addLift(liftSet.getString("liftName"), lift); Bukkit.getLogger().info("[V10Lift] Loading lift " + liftSet.getString("liftName") + " from data..."); @@ -91,12 +90,11 @@ public class DBManager { } } - public void save() throws JsonProcessingException { + public void save() { for (Map.Entry entry : DataManager.getLifts().entrySet()) { - ObjectMapper mapper = new ObjectMapper(); - - byte[] blob = mapper.writeValueAsString(entry.getValue()).getBytes(); + Gson gson = new Gson(); + byte[] blob = gson.toJson(entry.getValue()).getBytes(); Bukkit.getLogger().info("[V10Lift] Saving lift " + entry.getKey() + " to data..."); diff --git a/src/main/lombok/nl/SBDeveloper/V10Lift/V10LiftPlugin.java b/src/main/lombok/nl/SBDeveloper/V10Lift/V10LiftPlugin.java index fe3b7a9..4d665f1 100644 --- a/src/main/lombok/nl/SBDeveloper/V10Lift/V10LiftPlugin.java +++ b/src/main/lombok/nl/SBDeveloper/V10Lift/V10LiftPlugin.java @@ -1,6 +1,5 @@ package nl.SBDeveloper.V10Lift; -import com.fasterxml.jackson.core.JsonProcessingException; import nl.SBDeveloper.V10Lift.API.V10LiftAPI; import nl.SBDeveloper.V10Lift.Commands.V10LiftCommand; import nl.SBDeveloper.V10Lift.Commands.V10LiftTabCompleter; @@ -18,7 +17,6 @@ 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; @@ -45,7 +43,7 @@ public class V10LiftPlugin extends JavaPlugin { dbManager = new DBManager("data"); try { dbManager.load(); - } catch (SQLException | IOException e) { + } catch (SQLException e) { e.printStackTrace(); } @@ -92,11 +90,7 @@ public class V10LiftPlugin extends JavaPlugin { public void onDisable() { V10LiftPlugin.getDBManager().removeFromData(); - try { - dbManager.save(); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } + dbManager.save(); dbManager.closeConnection(); instance = null;