SteamWar/SpigotCore
Archiviert
13
0

Adding statistics backend

Dieser Commit ist enthalten in:
Lixfel 2020-01-19 08:45:01 +01:00
Ursprung 7ca97476bd
Commit 21a2be5a43
2 geänderte Dateien mit 35 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,24 @@
package de.steamwar.sql;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
public class Fight {
private Fight(){}
public static int create(String gamemode, String arena, Timestamp starttime, int duration, int blueleader, int redleader, int blueschem, int redschem, int win, String wincondition){
SQL.update("INSERT INTO Fight (GameMode, Arena, StartTime, Duration, BlueLeader, RedLeader, BlueSchem, RedSchem, Win, WinCondition) VALUES (" +
"'" + SQL.disarmString(gamemode) + "', '" + SQL.disarmString(arena) + "', '" + starttime.toString() + "', " + duration + ", " + blueleader + ", " + redleader + ", " + blueschem + ", " + redschem + ", " + win + ", '" + SQL.disarmString(wincondition) + "'" +
")");
ResultSet rs = SQL.select("SELECT LAST_INSERT_ID() AS FightID");
try{
if(!rs.next())
throw new SecurityException("No last insert id");
return rs.getInt("FightID");
} catch (SQLException e) {
throw new SecurityException(e);
}
}
}

Datei anzeigen

@ -0,0 +1,11 @@
package de.steamwar.sql;
public class FightPlayer {
private FightPlayer(){}
public static void create(int fightID, int userID, String kit, int kills, boolean isOut){
SQL.update("INSERT INTO FightPlayer (FightID, UserID, Kit, Kills, IsOut) VALUES (" +
fightID + ", " + userID + ", '" + SQL.disarmString(kit) + "', " + kills + ", " + SQL.booleanToInt(isOut) +
")");
}
}