From 3d42b4e091a123b62e618ed622cf5b30ea51079d Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 16 Nov 2019 08:40:04 +0100 Subject: [PATCH] Adding public-team --- .../src/de/steamwar/sql/SchematicType.java | 2 +- SpigotCore_Main/src/de/steamwar/sql/Team.java | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java index 9860c27..330dd16 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java +++ b/SpigotCore_Main/src/de/steamwar/sql/SchematicType.java @@ -20,7 +20,7 @@ public enum SchematicType { CWarShip1_8("CWS1.8", Type.CHECK_TYPE), CWarGear1_7("CWG1.7", 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 fromDB = new HashMap<>(); diff --git a/SpigotCore_Main/src/de/steamwar/sql/Team.java b/SpigotCore_Main/src/de/steamwar/sql/Team.java index 3f03ef1..f82680e 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Team.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Team.java @@ -11,26 +11,30 @@ public class Team { private final String teamName; private final int teamLeader; - private Team(ResultSet rs){ - try { - teamId = rs.getInt("TeamID"); - teamKuerzel = rs.getString("TeamKuerzel"); - teamName = rs.getString("TeamName"); - teamLeader = rs.getInt("TeamLeader"); - } catch (SQLException e) { - throw new SecurityException("Could not load team", e); - } + private static final Team pub = new Team(0, "PUB", "Öffentlich", 0); + + private Team(int teamId, String teamKuerzel, String teamName, int teamLeader){ + this.teamId = teamId; + this.teamKuerzel = teamKuerzel; + this.teamName = teamName; + this.teamLeader = teamLeader; + } + + 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){ + if(id == 0) + return pub; ResultSet rs = SQL.select("SELECT * FROM Team WHERE TeamID = " + id); try { if(!rs.next()) return null; + return new Team(rs); } catch (SQLException e) { throw new SecurityException("Could not load team", e); } - return new Team(rs); } public int getTeamId() {