From 361077cc3eca588f4804e1aa7c4b272731a8d0f5 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 8 Jan 2022 08:46:28 +0100 Subject: [PATCH] Fix future event participations on team deletion Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/sql/Team.java | 1 + src/de/steamwar/bungeecore/sql/TeamTeilnahme.java | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java index f721fa5..be3bbec 100644 --- a/src/de/steamwar/bungeecore/sql/Team.java +++ b/src/de/steamwar/bungeecore/sql/Team.java @@ -146,6 +146,7 @@ public class Team { user.setLeader(false); delete.update(teamId); teamCache.remove(this); + TeamTeilnahme.deleteFuture(teamId); } public List getMembers(){ diff --git a/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java b/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java index 68b1192..e8eabba 100644 --- a/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java +++ b/src/de/steamwar/bungeecore/sql/TeamTeilnahme.java @@ -28,6 +28,7 @@ public class TeamTeilnahme { private static final Statement insert = new Statement("INSERT INTO TeamTeilnahme (TeamID, EventID) VALUES (?, ?)"); private static final Statement delete = new Statement("DELETE FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?"); + private static final Statement deleteFuture = new Statement("DELETE FROM TeamTeilnahme t WHERE t.TeamID = ? AND (SELECT e.Start FROM Event e WHERE e.EventID = t.EventID) > NOW()"); private static final Statement byEventTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ? AND EventID = ?"); private static final Statement byEvent = new Statement("SELECT * FROM TeamTeilnahme WHERE EventID = ?"); private static final Statement byTeam = new Statement("SELECT * FROM TeamTeilnahme WHERE TeamID = ?"); @@ -44,6 +45,10 @@ public class TeamTeilnahme { return byEventTeam.select(ResultSet::next, teamID, eventID); } + public static void deleteFuture(int teamID) { + deleteFuture.update(teamID); + } + public static Set getTeams(int eventID){ return byEvent.select(rs -> { Set teams = new HashSet<>();