Dieser Commit ist enthalten in:
Ursprung
1647713647
Commit
10b6d2b38e
@ -29,7 +29,7 @@ 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) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE TeamName = VALUES(TeamName), TeamKuerzel = VALUES(TeamKuerzel), TeamColor = VALUES(TeamColor)");
|
||||
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 = ?");
|
||||
@ -37,14 +37,16 @@ public class Team {
|
||||
private static final Statement all = new Statement("SELECT * FROM Team WHERE NOT TeamDeleted");
|
||||
|
||||
private static final List<Team> teamCache = new LinkedList<>();
|
||||
private static final Team pub = new Team(0, "PUB", "Öffentlich", "8");
|
||||
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){
|
||||
private Team(int id, String kuerzel, String name, String color, String address, int port){
|
||||
teamId = id;
|
||||
teamKuerzel = kuerzel;
|
||||
teamName = name;
|
||||
@ -52,10 +54,12 @@ public class Team {
|
||||
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"));
|
||||
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){
|
||||
@ -64,7 +68,7 @@ public class Team {
|
||||
|
||||
public static Team get(int id){
|
||||
if(id == -1)
|
||||
return new Team(-1, "?", "?", "8");
|
||||
return new Team(-1, "?", "?", "8", null, 25565);
|
||||
if(id == 0)
|
||||
return pub;
|
||||
for(Team team : teamCache)
|
||||
@ -101,7 +105,7 @@ public class Team {
|
||||
}
|
||||
|
||||
private void updateDB(){
|
||||
update.update(teamId, teamKuerzel, teamName, teamColor);
|
||||
update.update(teamId, teamKuerzel, teamName, teamColor, address, port);
|
||||
}
|
||||
|
||||
public int getTeamId() {
|
||||
@ -135,6 +139,24 @@ public class Team {
|
||||
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();
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren