From fa5d4ad983463e412bf5178adfee9e32388fa4d8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 9 Apr 2022 22:08:17 +0200 Subject: [PATCH] Update some stuff --- src/de/steamwar/bungeecore/sql/Fight.java | 6 +++-- src/de/steamwar/bungeecore/sql/Replay.java | 31 ---------------------- 2 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 src/de/steamwar/bungeecore/sql/Replay.java diff --git a/src/de/steamwar/bungeecore/sql/Fight.java b/src/de/steamwar/bungeecore/sql/Fight.java index 4fd0b7d9..e13b7872 100644 --- a/src/de/steamwar/bungeecore/sql/Fight.java +++ b/src/de/steamwar/bungeecore/sql/Fight.java @@ -11,7 +11,7 @@ import java.util.stream.Collectors; public class Fight { - private static final Statement getPage = new Statement("SELECT f.FightID, f.GameMode, f.Server, f.StartTime, f.BlueLeader, f.RedLeader, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed, f.Win FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?"); + private static final Statement getPage = new Statement("SELECT f.FightID, f.GameMode, f.Server, f.StartTime, f.BlueLeader, f.RedLeader, (b.NodeId IS NULL OR b.AllowReplay) AND (r.NodeId IS NULL OR r.AllowReplay) AS ReplayAllowed, f.Win, (SELECT COUNT(1) FROM Replay WHERE Replay.FightID = f.FightID) as ReplayAvailable FROM Fight f LEFT OUTER JOIN SchematicNode b ON f.BlueSchem = b.NodeId LEFT OUTER JOIN SchematicNode r ON f.RedSchem = r.NodeId ORDER BY FightID DESC LIMIT ?, ?"); private final int fightID; private final String gameMode; @@ -23,6 +23,7 @@ public class Fight { private final int win; private final boolean replayAllowed; + private final boolean replayAvailable; private final List bluePlayers = new ArrayList<>(); private final List redPlayers = new ArrayList<>(); @@ -35,6 +36,7 @@ public class Fight { blueLeader = rs.getInt("BlueLeader"); redLeader = rs.getInt("RedLeader"); replayAllowed = rs.getBoolean("ReplayAllowed"); + replayAvailable = rs.getBoolean("ReplayAvailable"); win = rs.getInt("Win"); } @@ -116,6 +118,6 @@ public class Fight { } public boolean replayExists() { - return getGameMode() != null && Replay.hasReplay(fightID); + return getGameMode() != null && replayAvailable; } } diff --git a/src/de/steamwar/bungeecore/sql/Replay.java b/src/de/steamwar/bungeecore/sql/Replay.java deleted file mode 100644 index a4f26514..00000000 --- a/src/de/steamwar/bungeecore/sql/Replay.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2020 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.bungeecore.sql; - -import java.sql.ResultSet; - -public class Replay { - - private static final Statement hasReplay = new Statement("SELECT 1 FROM Replay WHERE FightID = ?"); - - public static boolean hasReplay(int id) { - return hasReplay.select(ResultSet::next, id); - } -}