From 5a840b219451cea5de1cdb22bb1c9ba6375b2b5f Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 26 Jan 2021 00:26:58 +0100 Subject: [PATCH] Fix CheckedSchematic --- .../src/de/steamwar/sql/CheckedSchematic.java | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/CheckedSchematic.java b/SpigotCore_Main/src/de/steamwar/sql/CheckedSchematic.java index 4f13f10..9097420 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/CheckedSchematic.java +++ b/SpigotCore_Main/src/de/steamwar/sql/CheckedSchematic.java @@ -32,16 +32,14 @@ import java.util.logging.Level; public class CheckedSchematic { - private final String schemName; - private final int schemOwner; + private final int node; private final int validator; private final Timestamp startTime; private final Timestamp endTime; private final String declineReason; - private CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){ - this.schemName = schemName; - this.schemOwner = schemOwner; + private CheckedSchematic(int node, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){ + this.node = node; this.validator = validator; this.startTime = startTime; this.endTime = endTime; @@ -50,35 +48,34 @@ public class CheckedSchematic { insertDB(); } - public CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason){ - this(schemName, schemOwner, validator, startTime, endTime, declineReason, true); + public CheckedSchematic(int node, int validator, Timestamp startTime, Timestamp endTime, String declineReason){ + this(node, validator, startTime, endTime, declineReason, true); } - public CheckedSchematic(String schemName, UUID schemOwner, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){ - this(schemName, SteamwarUser.get(schemOwner).getId(), SteamwarUser.get(validator).getId(), startTime, endTime, declineReason, true); + public CheckedSchematic(int node, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){ + this(node, SteamwarUser.get(validator).getId(), startTime, endTime, declineReason, true); } private void insertDB(){ SQL.update("INSERT INTO CheckedSchematic" + - " (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason) VALUES (?, ?, ?, ?, ?, ?)", - schemName, schemOwner, validator, startTime, endTime, declineReason); + " (NodeId, Validator, StartTime, EndTime, DeclineReason) VALUES (?, ?, ?, ?, ?)", + node, validator, startTime, endTime, declineReason); } - public static List getLastDeclined(UUID schemOwner){ - return getLastDelined(SteamwarUser.get(schemOwner).getId()); + public static List getLastDeclined(SchematicNode node){ + return getLastDeclined(node.getId()); } - public static List getLastDelined(int schemOwner){ + public static List getLastDeclined(int node){ List lastDeclined = new LinkedList<>(); try{ - ResultSet lastRS = SQL.select("SELECT * FROM CheckedSchematic WHERE SchemOwner = ? AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' ORDER BY EndTime DESC", schemOwner); + ResultSet lastRS = SQL.select("SELECT * FROM CheckedSchematic WHERE NodeId = ? AND DeclineReason != '' AND DeclineReason != 'Prüfvorgang abgebrochen' ORDER BY EndTime DESC", node); while(lastRS.next()){ - String schemName = lastRS.getString("SchemName"); int validator = lastRS.getInt("Validator"); Timestamp startTime = lastRS.getTimestamp("StartTime"); Timestamp endTime = lastRS.getTimestamp("EndTime"); String declineReason = lastRS.getString("DeclineReason"); - lastDeclined.add(new CheckedSchematic(schemName, schemOwner, validator, startTime, endTime, declineReason, false)); + lastDeclined.add(new CheckedSchematic(node, validator, startTime, endTime, declineReason, false)); } }catch(SQLException e){ Bukkit.getLogger().log(Level.SEVERE, "getLastDeclined failed", e); @@ -87,15 +84,7 @@ public class CheckedSchematic { } public void remove() { - SQL.update("DELETE FROM CheckedSchematic WHERE SchemOwner = ? AND SchemName = ?", schemOwner, schemName); - } - - public String getSchemName() { - return schemName; - } - - public int getSchemOwner() { - return schemOwner; + SQL.update("DELETE FROM CheckedSchematic WHERE NodeId", node); } public int getValidator() {