From 0bc349fc6446d445914cd96a00c64d09d2523b97 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 15 Mar 2024 22:39:41 +0100 Subject: [PATCH 1/7] Kleiner Fehler --- src/de/steamwar/sql/Referee.java | 88 ++++++++++++++++---------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/de/steamwar/sql/Referee.java b/src/de/steamwar/sql/Referee.java index 2f606a9..9fdff54 100644 --- a/src/de/steamwar/sql/Referee.java +++ b/src/de/steamwar/sql/Referee.java @@ -1,44 +1,44 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2024 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.sql; - -import de.steamwar.sql.internal.Field; -import de.steamwar.sql.internal.SelectStatement; -import de.steamwar.sql.internal.Table; -import lombok.AllArgsConstructor; - -import java.util.Set; -import java.util.stream.Collectors; - -@AllArgsConstructor -public class Referee { - - private static final Table table = new Table<>(Referee.class); - private static final SelectStatement byEvent = table.select("eventID"); - - public static Set get(int eventID) { - return byEvent.listSelect(eventID).stream().map(referee -> referee.userID).collect(Collectors.toSet()); - } - - @Field(keys = {"eventReferee"}) - private final int eventID; - @Field(keys = {"eventReferee"}) - private final int userID; -} +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.sql; + +import de.steamwar.sql.internal.Field; +import de.steamwar.sql.internal.SelectStatement; +import de.steamwar.sql.internal.Table; +import lombok.AllArgsConstructor; + +import java.util.Set; +import java.util.stream.Collectors; + +@AllArgsConstructor +public class Referee { + + private static final Table table = new Table<>(Referee.class); + 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()); + } + + @Field(keys = {"eventReferee"}) + private final int eventID; + @Field(keys = {"eventReferee"}) + private final int userID; +} From 0c35be1fecf216fdfe05c1a2a798d4ac4f6fd284 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Fri, 15 Mar 2024 22:40:53 +0100 Subject: [PATCH 2/7] Kleiner Fehler --- src/de/steamwar/sql/Referee.java | 88 ++++++++++++++++---------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/de/steamwar/sql/Referee.java b/src/de/steamwar/sql/Referee.java index 9fdff54..281ad30 100644 --- a/src/de/steamwar/sql/Referee.java +++ b/src/de/steamwar/sql/Referee.java @@ -1,44 +1,44 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2024 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.sql; - -import de.steamwar.sql.internal.Field; -import de.steamwar.sql.internal.SelectStatement; -import de.steamwar.sql.internal.Table; -import lombok.AllArgsConstructor; - -import java.util.Set; -import java.util.stream.Collectors; - -@AllArgsConstructor -public class Referee { - - private static final Table table = new Table<>(Referee.class); - 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()); - } - - @Field(keys = {"eventReferee"}) - private final int eventID; - @Field(keys = {"eventReferee"}) - private final int userID; -} +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.sql; + +import de.steamwar.sql.internal.Field; +import de.steamwar.sql.internal.SelectStatement; +import de.steamwar.sql.internal.Table; +import lombok.AllArgsConstructor; + +import java.util.Set; +import java.util.stream.Collectors; + +@AllArgsConstructor +public class Referee { + + private static final Table table = new Table<>(Referee.class); + 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()); + } + + @Field(keys = {"eventReferee"}) + private final int eventID; + @Field(keys = {"eventReferee"}) + private final int userID; +} From 0caf8859590e453bda3085888ba3ca57e7179e2c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 3 Jul 2024 22:05:46 +0200 Subject: [PATCH 3/7] Add TICKET_LOG, Update dependencies Signed-off-by: Lixfel --- build.gradle | 10 +++++----- src/de/steamwar/sql/UserPerm.java | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index d5f000a..c0be9ff 100755 --- 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/UserPerm.java b/src/de/steamwar/sql/UserPerm.java index d26da21..0aca031 100644 --- a/src/de/steamwar/sql/UserPerm.java +++ b/src/de/steamwar/sql/UserPerm.java @@ -42,6 +42,7 @@ public enum UserPerm { RESTRICTED_MODS, COLOR_CHAT, TEAM, + TICKET_LOG, BUILD, CHECK, MODERATION, From e76473e0beffe3df5c6d1c3430f62332b7371579 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 3 Jul 2024 22:17:39 +0200 Subject: [PATCH 4/7] Fix SWCommand with 0 args Signed-off-by: Lixfel --- src/de/steamwar/command/AbstractSWCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/command/AbstractSWCommand.java b/src/de/steamwar/command/AbstractSWCommand.java index 65f6643..3a44271 100644 --- a/src/de/steamwar/command/AbstractSWCommand.java +++ b/src/de/steamwar/command/AbstractSWCommand.java @@ -102,7 +102,7 @@ public abstract class AbstractSWCommand { protected final List tabComplete(T sender, String alias, String[] args) throws IllegalArgumentException { initialize(); - String string = args[args.length - 1].toLowerCase(); + String string = args.length > 0 ? args[args.length - 1].toLowerCase() : ""; return Stream.concat(commandList.stream(), helpCommandList.stream()) .filter(s -> !s.noTabComplete) .map(s -> s.tabComplete(sender, args)) From 1237a699ba244ecfac65478df34e714afbe2366e Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 5 Jul 2024 10:07:22 +0200 Subject: [PATCH 5/7] Fix SWCommand with 0 args, Add SWException option to get ID Signed-off-by: Lixfel --- src/de/steamwar/command/AbstractSWCommand.java | 2 +- src/de/steamwar/sql/SWException.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/command/AbstractSWCommand.java b/src/de/steamwar/command/AbstractSWCommand.java index 3a44271..65f6643 100644 --- a/src/de/steamwar/command/AbstractSWCommand.java +++ b/src/de/steamwar/command/AbstractSWCommand.java @@ -102,7 +102,7 @@ public abstract class AbstractSWCommand { protected final List tabComplete(T sender, String alias, String[] args) throws IllegalArgumentException { initialize(); - String string = args.length > 0 ? args[args.length - 1].toLowerCase() : ""; + String string = args[args.length - 1].toLowerCase(); return Stream.concat(commandList.stream(), helpCommandList.stream()) .filter(s -> !s.noTabComplete) .map(s -> s.tabComplete(sender, args)) diff --git a/src/de/steamwar/sql/SWException.java b/src/de/steamwar/sql/SWException.java index 0a8ece3..ca87a09 100644 --- a/src/de/steamwar/sql/SWException.java +++ b/src/de/steamwar/sql/SWException.java @@ -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(); } } From d000b8687d93eb43520bbf6685281099055eab9f Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 6 Jul 2024 15:12:16 +0200 Subject: [PATCH 6/7] Fix logGetId Signed-off-by: Lixfel --- src/de/steamwar/sql/SWException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/sql/SWException.java b/src/de/steamwar/sql/SWException.java index ca87a09..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; From 14bea165c5e13a6ed955a5b9b545a770b0475c27 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Aug 2024 15:29:33 +0200 Subject: [PATCH 7/7] Update EventFight.hasFinished --- src/de/steamwar/sql/EventFight.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/sql/EventFight.java b/src/de/steamwar/sql/EventFight.java index 4df1ff6..623e383 100644 --- a/src/de/steamwar/sql/EventFight.java +++ b/src/de/steamwar/sql/EventFight.java @@ -107,7 +107,7 @@ public class EventFight implements Comparable { } public boolean hasFinished() { - return fight != 0; + return fight != 0 || ergebnis != 0; } public void reschedule() {