diff --git a/build.gradle b/build.gradle index 88a7743..303f238 100644 --- a/build.gradle +++ b/build.gradle @@ -74,15 +74,15 @@ repositories { } dependencies { - compileOnly 'org.projectlombok:lombok:1.18.22' - testCompileOnly 'org.projectlombok:lombok:1.18.22' - annotationProcessor 'org.projectlombok:lombok:1.18.22' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' + compileOnly 'org.projectlombok:lombok:1.18.32' + testCompileOnly 'org.projectlombok:lombok:1.18.32' + annotationProcessor 'org.projectlombok:lombok:1.18.32' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.32' testImplementation 'junit:junit:4.13.2' testImplementation 'org.hamcrest:hamcrest:2.2' - compileOnly 'org.xerial:sqlite-jdbc:3.36.0' + compileOnly 'org.xerial:sqlite-jdbc:3.46.0.0' } task buildResources { diff --git a/src/de/steamwar/sql/EventFight.java b/src/de/steamwar/sql/EventFight.java index 7214d12..53e7757 100644 --- a/src/de/steamwar/sql/EventFight.java +++ b/src/de/steamwar/sql/EventFight.java @@ -116,6 +116,20 @@ public class EventFight { setFight.update(fight, fightID); } + public boolean hasFinished() { + return fight != 0 || ergebnis != 0; + } + + public void reschedule() { + startTime = Timestamp.from(new Date().toInstant().plus(30, SECONDS)); + reschedule.update(startTime, fightID); + } + + @Override + public int hashCode(){ + return fightID; + } + public void update() { update.update(startTime, spielModus, map, teamBlue, teamRed, spectatePort, fightID); } diff --git a/src/de/steamwar/sql/Referee.java b/src/de/steamwar/sql/Referee.java index 8cd7e75..d6b1a4f 100644 --- a/src/de/steamwar/sql/Referee.java +++ b/src/de/steamwar/sql/Referee.java @@ -44,6 +44,8 @@ public class Referee { delete.update(eventID, userID); } + private static final SelectStatement byEvent = table.selectFields("eventID"); + public static Set get(int eventID) { return byEvent.listSelect(eventID).stream().map(referee -> referee.userID).collect(Collectors.toSet()); } diff --git a/src/de/steamwar/sql/SWException.java b/src/de/steamwar/sql/SWException.java index 0a8ece3..4656804 100644 --- a/src/de/steamwar/sql/SWException.java +++ b/src/de/steamwar/sql/SWException.java @@ -38,7 +38,7 @@ public class SWException { private static final String SERVER_NAME = new File(CWD).getName(); private static final Table table = new Table<>(SWException.class, "Exception"); - private static final Statement insert = table.insertFields("server", "message", "stacktrace"); + private static final Statement insert = table.insertFields(true, "server", "message", "stacktrace"); @Field(keys = {Table.PRIMARY}, autoincrement = true) private final int id; @@ -52,10 +52,17 @@ public class SWException { private final String stacktrace; public static void log(String message, String stacktrace){ + insert.update(SERVER_NAME, generateMessage(message), stacktrace); + } + + public static int logGetId(String message, String stacktrace) { + return insert.insertGetKey(SERVER_NAME, generateMessage(message), stacktrace); + } + + private static String generateMessage(String message) { StringBuilder msgBuilder = new StringBuilder(message); SQLWrapper.impl.additionalExceptionMetadata(msgBuilder); msgBuilder.append("\nCWD: ").append(CWD); - - insert.update(SERVER_NAME, msgBuilder.toString(), stacktrace); + return msgBuilder.toString(); } } diff --git a/src/de/steamwar/sql/UserPerm.java b/src/de/steamwar/sql/UserPerm.java index 03b654a..5d41468 100644 --- a/src/de/steamwar/sql/UserPerm.java +++ b/src/de/steamwar/sql/UserPerm.java @@ -39,6 +39,7 @@ public enum UserPerm { RESTRICTED_MODS, COLOR_CHAT, TEAM, + TICKET_LOG, BUILD, CHECK, MODERATION,