Implementing Elo database connection
Dieser Commit ist enthalten in:
Ursprung
90368b6600
Commit
c943520418
23
SpigotCore_Main/src/de/steamwar/sql/Elo.java
Normale Datei
23
SpigotCore_Main/src/de/steamwar/sql/Elo.java
Normale Datei
@ -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);
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren