From 0c236bfabef8a2ca93f22401e9b0fa062d4a2be2 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 27 Dec 2019 12:51:23 +0100 Subject: [PATCH 1/2] Fixing potential NullPointerException --- SpigotCore_15/pom.xml | 4 ++-- SpigotCore_Main/src/de/steamwar/sql/Schematic.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SpigotCore_15/pom.xml b/SpigotCore_15/pom.xml index 610c11b..a678510 100644 --- a/SpigotCore_15/pom.xml +++ b/SpigotCore_15/pom.xml @@ -35,8 +35,8 @@ steamwar - FAWE - 1.14 + WorldEdit + 1.15 provided diff --git a/SpigotCore_Main/src/de/steamwar/sql/Schematic.java b/SpigotCore_Main/src/de/steamwar/sql/Schematic.java index 36854d2..9098e0e 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Schematic.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Schematic.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.sql.Blob; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -158,7 +159,10 @@ public class Schematic { ResultSet rs = SQL.select("SELECT SchemData FROM Schematic WHERE SchemID = " + schemID); try { rs.next(); - InputStream is = rs.getBlob("SchemData").getBinaryStream(); + Blob schemData = rs.getBlob("SchemData"); + if(schemData == null) + throw new IOException("SchemData is null"); + InputStream is = schemData.getBinaryStream(); switch(Core.getVersion()){ case 8: return Schematic_8.getClipboard(is); From dd36e34fc8e5ec7a801c033dd85e11e670e3b6fd Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 27 Dec 2019 14:45:04 +0100 Subject: [PATCH 2/2] Fixing Schematic deletion --- SpigotCore_Main/src/de/steamwar/sql/Schematic.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/Schematic.java b/SpigotCore_Main/src/de/steamwar/sql/Schematic.java index 9098e0e..9954681 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Schematic.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Schematic.java @@ -259,8 +259,8 @@ public class Schematic { } public void remove(){ - SQL.update("DELETE FROM Schematic WHERE SchemOwner = " + schemOwner + " AND SchemName = '" + schemName + "'"); SQL.update("DELETE FROM SchemMember WHERE SchemOwner = " + schemOwner + " AND SchemName = '" + schemName + "'"); + SQL.update("DELETE FROM Schematic WHERE SchemOwner = " + schemOwner + " AND SchemName = '" + schemName + "'"); } public static class WrongVersionException extends Exception{}