SteamWar/SpigotCore
Archiviert
13
0

Fix CheckedSchematic

Dieser Commit ist enthalten in:
Chaoscaot 2021-01-26 00:26:58 +01:00
Ursprung 0895035b08
Commit 5a840b2194

Datei anzeigen

@ -32,16 +32,14 @@ import java.util.logging.Level;
public class CheckedSchematic { public class CheckedSchematic {
private final String schemName; private final int node;
private final int schemOwner;
private final int validator; private final int validator;
private final Timestamp startTime; private final Timestamp startTime;
private final Timestamp endTime; private final Timestamp endTime;
private final String declineReason; private final String declineReason;
private CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){ private CheckedSchematic(int node, int validator, Timestamp startTime, Timestamp endTime, String declineReason, boolean insertDB){
this.schemName = schemName; this.node = node;
this.schemOwner = schemOwner;
this.validator = validator; this.validator = validator;
this.startTime = startTime; this.startTime = startTime;
this.endTime = endTime; this.endTime = endTime;
@ -50,35 +48,34 @@ public class CheckedSchematic {
insertDB(); insertDB();
} }
public CheckedSchematic(String schemName, int schemOwner, int validator, Timestamp startTime, Timestamp endTime, String declineReason){ public CheckedSchematic(int node, int validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(schemName, schemOwner, validator, startTime, endTime, declineReason, true); this(node, validator, startTime, endTime, declineReason, true);
} }
public CheckedSchematic(String schemName, UUID schemOwner, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){ public CheckedSchematic(int node, UUID validator, Timestamp startTime, Timestamp endTime, String declineReason){
this(schemName, SteamwarUser.get(schemOwner).getId(), SteamwarUser.get(validator).getId(), startTime, endTime, declineReason, true); this(node, SteamwarUser.get(validator).getId(), startTime, endTime, declineReason, true);
} }
private void insertDB(){ private void insertDB(){
SQL.update("INSERT INTO CheckedSchematic" + SQL.update("INSERT INTO CheckedSchematic" +
" (SchemName, SchemOwner, Validator, StartTime, EndTime, DeclineReason) VALUES (?, ?, ?, ?, ?, ?)", " (NodeId, Validator, StartTime, EndTime, DeclineReason) VALUES (?, ?, ?, ?, ?)",
schemName, schemOwner, validator, startTime, endTime, declineReason); node, validator, startTime, endTime, declineReason);
} }
public static List<CheckedSchematic> getLastDeclined(UUID schemOwner){ public static List<CheckedSchematic> getLastDeclined(SchematicNode node){
return getLastDelined(SteamwarUser.get(schemOwner).getId()); return getLastDeclined(node.getId());
} }
public static List<CheckedSchematic> getLastDelined(int schemOwner){ public static List<CheckedSchematic> getLastDeclined(int node){
List<CheckedSchematic> lastDeclined = new LinkedList<>(); List<CheckedSchematic> lastDeclined = new LinkedList<>();
try{ 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()){ while(lastRS.next()){
String schemName = lastRS.getString("SchemName");
int validator = lastRS.getInt("Validator"); int validator = lastRS.getInt("Validator");
Timestamp startTime = lastRS.getTimestamp("StartTime"); Timestamp startTime = lastRS.getTimestamp("StartTime");
Timestamp endTime = lastRS.getTimestamp("EndTime"); Timestamp endTime = lastRS.getTimestamp("EndTime");
String declineReason = lastRS.getString("DeclineReason"); 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){ }catch(SQLException e){
Bukkit.getLogger().log(Level.SEVERE, "getLastDeclined failed", e); Bukkit.getLogger().log(Level.SEVERE, "getLastDeclined failed", e);
@ -87,15 +84,7 @@ public class CheckedSchematic {
} }
public void remove() { public void remove() {
SQL.update("DELETE FROM CheckedSchematic WHERE SchemOwner = ? AND SchemName = ?", schemOwner, schemName); SQL.update("DELETE FROM CheckedSchematic WHERE NodeId", node);
}
public String getSchemName() {
return schemName;
}
public int getSchemOwner() {
return schemOwner;
} }
public int getValidator() { public int getValidator() {