diff --git a/CommonCore b/CommonCore
index d439ecb..3e1c4e9 160000
--- a/CommonCore
+++ b/CommonCore
@@ -1 +1 @@
-Subproject commit d439ecb8d01d576310766e497c970bce7eb1db2f
+Subproject commit 3e1c4e9059ef2400c79aaa5089eaafca075640c6
diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java
index 6d3a3d7..cd52b48 100644
--- a/src/de/steamwar/bungeecore/BungeeCore.java
+++ b/src/de/steamwar/bungeecore/BungeeCore.java
@@ -34,6 +34,7 @@ import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.SWTypeMapperCreator;
import de.steamwar.command.TabCompletionCache;
import de.steamwar.command.TypeMapper;
+import de.steamwar.sql.Team;
import de.steamwar.sql.internal.Statement;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ChatMessageType;
@@ -200,7 +201,7 @@ public class BungeeCore extends Plugin {
getProxy().getScheduler().schedule(this, () -> {
SteamwarUser.clearCache();
UserElo.clearCache();
- Team.clearCache();
+ Team.clear();
}, 1, 1, TimeUnit.HOURS);
if (SteamwarDiscordBotConfig.loaded) {
diff --git a/src/de/steamwar/bungeecore/EventStarter.java b/src/de/steamwar/bungeecore/EventStarter.java
index 7113e5d..67a2d7e 100644
--- a/src/de/steamwar/bungeecore/EventStarter.java
+++ b/src/de/steamwar/bungeecore/EventStarter.java
@@ -21,7 +21,7 @@ package de.steamwar.bungeecore;
import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.bungeecore.sql.SteamwarUser;
-import de.steamwar.bungeecore.sql.Team;
+import de.steamwar.sql.Team;
import de.steamwar.sql.Event;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java
index f3b805a..5ad9a6f 100644
--- a/src/de/steamwar/bungeecore/ServerStarter.java
+++ b/src/de/steamwar/bungeecore/ServerStarter.java
@@ -2,7 +2,7 @@ package de.steamwar.bungeecore;
import de.steamwar.bungeecore.sql.EventFight;
import de.steamwar.bungeecore.sql.SteamwarUser;
-import de.steamwar.bungeecore.sql.Team;
+import de.steamwar.sql.Team;
import de.steamwar.bungeecore.sql.Tutorial;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
diff --git a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java
index c6448eb..b8c5d4e 100644
--- a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java
+++ b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java
@@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.commands;
import de.steamwar.sql.Event;
import de.steamwar.bungeecore.sql.SteamwarUser;
-import de.steamwar.bungeecore.sql.Team;
+import de.steamwar.sql.Team;
import de.steamwar.sql.TeamTeilnahme;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Emoji;
diff --git a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java
index 8608047..0ce37b3 100644
--- a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java
+++ b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java
@@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.commands;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
-import de.steamwar.bungeecore.sql.Team;
+import de.steamwar.sql.Team;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.interactions.commands.OptionType;
diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java
index 33054ee..c6f61e9 100644
--- a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java
+++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java
@@ -22,7 +22,7 @@ package de.steamwar.bungeecore.bot.listeners;
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import de.steamwar.bungeecore.bot.events.EventManager;
import de.steamwar.bungeecore.sql.SteamwarUser;
-import de.steamwar.bungeecore.sql.Team;
+import de.steamwar.sql.Team;
import de.steamwar.sql.TeamTeilnahme;
import de.steamwar.sql.Event;
import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent;
diff --git a/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java b/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java
index e44a318..16e98e1 100644
--- a/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java
+++ b/src/de/steamwar/bungeecore/commands/EventRescheduleCommand.java
@@ -21,7 +21,7 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.sql.EventFight;
-import de.steamwar.bungeecore.sql.Team;
+import de.steamwar.sql.Team;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.sql.Event;
diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java
index 3f45be6..e7ee335 100644
--- a/src/de/steamwar/bungeecore/commands/TeamCommand.java
+++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java
@@ -25,7 +25,7 @@ import de.steamwar.bungeecore.inventory.SWItem;
import de.steamwar.bungeecore.inventory.SWListInv;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
-import de.steamwar.bungeecore.sql.Team;
+import de.steamwar.sql.Team;
import de.steamwar.sql.TeamTeilnahme;
import de.steamwar.messages.ChatSender;
import de.steamwar.sql.Event;
diff --git a/src/de/steamwar/bungeecore/commands/TpCommand.java b/src/de/steamwar/bungeecore/commands/TpCommand.java
index 9b48eaa..d7bb956 100644
--- a/src/de/steamwar/bungeecore/commands/TpCommand.java
+++ b/src/de/steamwar/bungeecore/commands/TpCommand.java
@@ -23,7 +23,7 @@ import de.steamwar.bungeecore.*;
import de.steamwar.sql.BauweltMember;
import de.steamwar.bungeecore.sql.Punishment;
import de.steamwar.bungeecore.sql.SteamwarUser;
-import de.steamwar.bungeecore.sql.Team;
+import de.steamwar.sql.Team;
import de.steamwar.bungeecore.util.BauLock;
import de.steamwar.bungeecore.util.Chat19;
import de.steamwar.messages.ChatSender;
diff --git a/src/de/steamwar/bungeecore/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/commands/WhoisCommand.java
index 095f0fc..856e99a 100644
--- a/src/de/steamwar/bungeecore/commands/WhoisCommand.java
+++ b/src/de/steamwar/bungeecore/commands/WhoisCommand.java
@@ -26,6 +26,7 @@ import de.steamwar.bungeecore.sql.*;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
+import de.steamwar.sql.Team;
import de.steamwar.sql.UserGroup;
import lombok.Getter;
import net.md_5.bungee.BungeeCord;
diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java
index 68e86f7..dd84a9f 100644
--- a/src/de/steamwar/bungeecore/listeners/ChatListener.java
+++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java
@@ -26,6 +26,7 @@ import de.steamwar.bungeecore.sql.*;
import de.steamwar.bungeecore.util.Chat19;
import de.steamwar.messages.ChatSender;
import de.steamwar.network.packets.server.PingPacket;
+import de.steamwar.sql.Team;
import de.steamwar.sql.UserGroup;
import net.md_5.bungee.api.*;
import net.md_5.bungee.api.connection.ProxiedPlayer;
diff --git a/src/de/steamwar/bungeecore/sql/Team.java b/src/de/steamwar/bungeecore/sql/Team.java
deleted file mode 100644
index 4cb71d8..0000000
--- a/src/de/steamwar/bungeecore/sql/Team.java
+++ /dev/null
@@ -1,185 +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 de.steamwar.sql.TeamTeilnahme;
-import de.steamwar.sql.internal.Statement;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-public class Team {
-
- private static final Statement insert = new Statement("INSERT INTO Team (TeamKuerzel, TeamName) VALUES (?, ?)");
- private static final Statement delete = new Statement("UPDATE Team SET TeamDeleted = 1 WHERE TeamID = ?");
- private static final Statement update = new Statement("INSERT INTO Team (TeamID, TeamKuerzel, TeamName, TeamColor, Address, Port) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE TeamName = VALUES(TeamName), TeamKuerzel = VALUES(TeamKuerzel), TeamColor = VALUES(TeamColor), Address = VALUES(Address), Port = VALUES(Port)");
- private static final Statement getSize = new Statement("SELECT COUNT(id) FROM UserData WHERE Team = ?");
- private static final Statement getMembers = new Statement("SELECT id FROM UserData WHERE Team = ?");
- private static final Statement byId = new Statement("SELECT * FROM Team WHERE TeamID = ?");
- private static final Statement byName = new Statement("SELECT * FROM Team WHERE (lower(TeamName) = ? OR lower(TeamKuerzel) = ?) AND NOT TeamDeleted");
- private static final Statement all = new Statement("SELECT * FROM Team WHERE NOT TeamDeleted");
-
- private static final List teamCache = new LinkedList<>();
- private static final Team pub = new Team(0, "PUB", "Öffentlich", "8", null, 25565);
-
- private final int teamId;
- private String teamKuerzel;
- private String teamName;
- private String teamColor;
- private String address;
- private int port;
-
- private Team(int id, String kuerzel, String name, String color, String address, int port){
- teamId = id;
- teamKuerzel = kuerzel;
- teamName = name;
- teamColor = color;
- if (id != 0) {
- teamCache.add(this);
- }
- this.address = address;
- this.port = port;
- }
-
- private Team(ResultSet rs) throws SQLException {
- this(rs.getInt("TeamID"), rs.getString("TeamKuerzel"), rs.getString("TeamName"), rs.getString("TeamColor"), rs.getString("Address"), rs.getInt("Port"));
- }
-
- public static void create(String kuerzel, String name){
- insert.update(kuerzel, name);
- }
-
- public static Team get(int id){
- if(id == -1)
- return new Team(-1, "?", "?", "8", null, 25565);
- if(id == 0)
- return pub;
- for(Team team : teamCache)
- if(team.teamId == id)
- return team;
- return byId.select(rs -> {
- rs.next();
- return new Team(rs);
- }, id);
- }
-
- public static Team get(String name){
- for(Team team : teamCache)
- if(team.teamName.equalsIgnoreCase(name) || team.teamKuerzel.equalsIgnoreCase(name))
- return team;
- return byName.select(rs -> {
- if(rs.next())
- return new Team(rs);
- return null;
- }, name.toLowerCase(), name.toLowerCase());
- }
-
- public static List getAll(){
- clearCache();
- return all.select(rs -> {
- while(rs.next())
- new Team(rs);
- return teamCache;
- });
- }
-
- public static void clearCache(){
- teamCache.clear();
- }
-
- private void updateDB(){
- update.update(teamId, teamKuerzel, teamName, teamColor, address, port);
- }
-
- public int getTeamId() {
- return teamId;
- }
-
- public String getTeamKuerzel() {
- return teamKuerzel;
- }
-
- public void setTeamKuerzel(String teamKuerzel) {
- this.teamKuerzel = teamKuerzel;
- updateDB();
- }
-
- public String getTeamName() {
- return teamName;
- }
-
- public void setTeamName(String teamName) {
- this.teamName = teamName;
- updateDB();
- }
-
- public String getTeamColor() {
- return teamColor;
- }
-
- public void setTeamColor(String teamColor) {
- this.teamColor = teamColor;
- updateDB();
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- updateDB();
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- updateDB();
- }
-
- public int size(){
- return getSize.select(rs -> {
- rs.next();
- return rs.getInt("COUNT(id)");
- }, teamId);
- }
-
- public void disband(SteamwarUser user){
- user.setLeader(false);
- delete.update(teamId);
- teamCache.remove(this);
- TeamTeilnahme.deleteFuture(teamId);
- }
-
- public List getMembers(){
- return getMembers.select(rs -> {
- List members = new ArrayList<>();
- while(rs.next())
- members.add(rs.getInt("id"));
- return members;
- }, teamId);
- }
-}