SteamWar/SpigotCore
Archiviert
13
0

Implementing Elo database connection

Dieser Commit ist enthalten in:
Lixfel 2020-07-07 18:48:24 +02:00
Ursprung 90368b6600
Commit c943520418

Datei anzeigen

@ -0,0 +1,23 @@
package de.steamwar.sql;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Elo {
private Elo(){}
public static int getElo(int userId, String gameMode){
ResultSet rs = SQL.select("SELECT Elo FROM Elo WHERE UserID = ? AND GameMode = ?", userId, gameMode);
try{
if(!rs.next())
return 1000;
return rs.getInt("Elo");
}catch(SQLException e){
throw new SecurityException("Could not get elo", e);
}
}
public static void setElo(int userId, String gameMode, int elo){
SQL.update("INSERT INTO Elo (UserID, GameMode, Elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE Elo = VALUES(Elo)", userId, gameMode, elo);
}
}