SteamWar/SpigotCore
Archiviert
13
0

Adding public-team

Dieser Commit ist enthalten in:
Lixfel 2019-11-16 08:40:04 +01:00
Ursprung ecb8eec074
Commit 3d42b4e091
2 geänderte Dateien mit 15 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -20,7 +20,7 @@ public enum SchematicType {
CWarShip1_8("CWS1.8", Type.CHECK_TYPE), CWarShip1_8("CWS1.8", Type.CHECK_TYPE),
CWarGear1_7("CWG1.7", Type.CHECK_TYPE), CWarGear1_7("CWG1.7", Type.CHECK_TYPE),
WarShip1_8("WS1.8", Type.CHECK_TYPE), WarShip1_8("WS1.8", Type.CHECK_TYPE),
WarGear1_7("WG1.7", Type.FIGHT_TYPE, CWarGear1_7); WarGear1_7("WG1.7", Type.CHECK_TYPE);
private static Map<String, SchematicType> fromDB = new HashMap<>(); private static Map<String, SchematicType> fromDB = new HashMap<>();

Datei anzeigen

@ -11,26 +11,30 @@ public class Team {
private final String teamName; private final String teamName;
private final int teamLeader; private final int teamLeader;
private Team(ResultSet rs){ private static final Team pub = new Team(0, "PUB", "Öffentlich", 0);
try {
teamId = rs.getInt("TeamID"); private Team(int teamId, String teamKuerzel, String teamName, int teamLeader){
teamKuerzel = rs.getString("TeamKuerzel"); this.teamId = teamId;
teamName = rs.getString("TeamName"); this.teamKuerzel = teamKuerzel;
teamLeader = rs.getInt("TeamLeader"); this.teamName = teamName;
} catch (SQLException e) { this.teamLeader = teamLeader;
throw new SecurityException("Could not load team", e);
} }
private Team(ResultSet rs) throws SQLException {
this(rs.getInt("TeamID"), rs.getString("TeamKuerzel"), rs.getString("TeamName"), rs.getInt("TeamLeader"));
} }
public static Team get(int id){ public static Team get(int id){
if(id == 0)
return pub;
ResultSet rs = SQL.select("SELECT * FROM Team WHERE TeamID = " + id); ResultSet rs = SQL.select("SELECT * FROM Team WHERE TeamID = " + id);
try { try {
if(!rs.next()) if(!rs.next())
return null; return null;
return new Team(rs);
} catch (SQLException e) { } catch (SQLException e) {
throw new SecurityException("Could not load team", e); throw new SecurityException("Could not load team", e);
} }
return new Team(rs);
} }
public int getTeamId() { public int getTeamId() {