geforkt von SteamWar/BungeeCore
Update FightEndsHandler
Update UserElo
Dieser Commit ist enthalten in:
Ursprung
2923d249db
Commit
0d7ebc224c
@ -85,7 +85,7 @@ public class FightEndsHandler implements SpigotHandler {
|
|||||||
|
|
||||||
private void calculateEloOfTeam(List<Integer> team, String gameMode, double factor) {
|
private void calculateEloOfTeam(List<Integer> team, String gameMode, double factor) {
|
||||||
for (int player : team) {
|
for (int player : team) {
|
||||||
int playerElo = UserElo.getElo(player, gameMode).orElse(ELO_DEFAULT);
|
int playerElo = UserElo.getEloOrDefault(player, gameMode);
|
||||||
UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * factor));
|
UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * factor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,10 @@ public class UserElo {
|
|||||||
private static final Statement maxElo = new Statement("SELECT MAX(Elo) AS MaxElo FROM UserElo WHERE Season = ? AND GameMode = ?");
|
private static final Statement maxElo = new Statement("SELECT MAX(Elo) AS MaxElo FROM UserElo WHERE Season = ? AND GameMode = ?");
|
||||||
private static final Statement fightsOfSeason = new Statement("SELECT COUNT(*) AS Fights FROM FightPlayer INNER JOIN Fight F on FightPlayer.FightID = F.FightID WHERE UserID = ? AND GameMode = ? AND UNIX_TIMESTAMP(StartTime) + Duration >= UNIX_TIMESTAMP(?)");
|
private static final Statement fightsOfSeason = new Statement("SELECT COUNT(*) AS Fights FROM FightPlayer INNER JOIN Fight F on FightPlayer.FightID = F.FightID WHERE UserID = ? AND GameMode = ? AND UNIX_TIMESTAMP(StartTime) + Duration >= UNIX_TIMESTAMP(?)");
|
||||||
|
|
||||||
|
public static int getEloOrDefault(int userID, String gameMode) {
|
||||||
|
return getElo(userID, gameMode).orElse(ELO_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<Integer> getElo(int userID, String gameMode) {
|
public static Optional<Integer> getElo(int userID, String gameMode) {
|
||||||
return gameModeUserEloCache.computeIfAbsent(gameMode, gm -> {
|
return gameModeUserEloCache.computeIfAbsent(gameMode, gm -> {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren