SteamWar/SpigotCore
Archiviert
13
0

List at get with name

Dieser Commit ist enthalten in:
Chaoscaot 2021-01-09 17:36:03 +01:00
Ursprung e88f183e72
Commit 5266bb6492

Datei anzeigen

@ -61,12 +61,13 @@ public class PersonalKit {
} }
} }
public static PersonalKit get(int userID, String gamemode, String name) { public static List<PersonalKit> get(int userID, String gamemode, String name) {
ResultSet rs = SQL.select("SELECT * FROM PersonalKit WHERE UserID = ? AND GameMode = ? AND Name = ?", userID, gamemode, name); ResultSet rs = SQL.select("SELECT * FROM PersonalKit WHERE UserID = ? AND GameMode = ? AND Name = ?", userID, gamemode, name);
try { try {
if(!rs.next()) List<PersonalKit> list = new ArrayList<>();
return null; while (rs.next())
return new PersonalKit(rs); list.add(new PersonalKit(rs));
return list;
} catch (SQLException e) { } catch (SQLException e) {
throw new SecurityException("Failed loading personal kit", e); throw new SecurityException("Failed loading personal kit", e);
} }
@ -93,7 +94,9 @@ public class PersonalKit {
list.forEach(kit -> { list.forEach(kit -> {
if(list.indexOf(kit) >= 1) kit.setInUse(false); if(list.indexOf(kit) >= 1) kit.setInUse(false);
}); });
list.removeIf(kit -> !kit.isInUse());
} }
if(list.isEmpty()) return null;
return list.get(0); return list.get(0);
} catch (SQLException e) { } catch (SQLException e) {
throw new SecurityException("Failed loading personal kit", e); throw new SecurityException("Failed loading personal kit", e);