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);
try {
if(!rs.next())
return null;
return new PersonalKit(rs);
List<PersonalKit> list = new ArrayList<>();
while (rs.next())
list.add(new PersonalKit(rs));
return list;
} catch (SQLException e) {
throw new SecurityException("Failed loading personal kit", e);
}
@ -93,7 +94,9 @@ public class PersonalKit {
list.forEach(kit -> {
if(list.indexOf(kit) >= 1) kit.setInUse(false);
});
list.removeIf(kit -> !kit.isInUse());
}
if(list.isEmpty()) return null;
return list.get(0);
} catch (SQLException e) {
throw new SecurityException("Failed loading personal kit", e);