Dieser Commit ist enthalten in:
Ursprung
7be744eb45
Commit
530171c2e3
@ -73,11 +73,11 @@ public class FightEndsHandler implements SpigotHandler {
|
|||||||
|
|
||||||
if (blueSchemOwner != 0 && redSchemOwner != 0) {
|
if (blueSchemOwner != 0 && redSchemOwner != 0) {
|
||||||
for (int bluePlayer : fightEndsPacket.getBluePlayers()) {
|
for (int bluePlayer : fightEndsPacket.getBluePlayers()) {
|
||||||
int playerElo = UserElo.getElo(bluePlayer, fightEndsPacket.getGameMode());
|
int playerElo = UserElo.getElo(bluePlayer, fightEndsPacket.getGameMode()).orElse(1000);
|
||||||
UserElo.setElo(bluePlayer, fightEndsPacket.getGameMode(), (int) Math.round(playerElo + K * (blueResult - blueWinExpectation)));
|
UserElo.setElo(bluePlayer, fightEndsPacket.getGameMode(), (int) Math.round(playerElo + K * (blueResult - blueWinExpectation)));
|
||||||
}
|
}
|
||||||
for (int redPlayer : fightEndsPacket.getRedPlayers()) {
|
for (int redPlayer : fightEndsPacket.getRedPlayers()) {
|
||||||
int playerElo = UserElo.getElo(redPlayer, fightEndsPacket.getGameMode());
|
int playerElo = UserElo.getElo(redPlayer, fightEndsPacket.getGameMode()).orElse(1000);
|
||||||
UserElo.setElo(redPlayer, fightEndsPacket.getGameMode(), (int) Math.round(playerElo + K * (1 - blueResult - redWinExpectation)));
|
UserElo.setElo(redPlayer, fightEndsPacket.getGameMode(), (int) Math.round(playerElo + K * (1 - blueResult - redWinExpectation)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.sql;
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class UserElo {
|
public class UserElo {
|
||||||
private UserElo() {
|
private UserElo() {
|
||||||
}
|
}
|
||||||
@ -27,15 +29,15 @@ public class UserElo {
|
|||||||
private static final Statement setElo = new Statement("UPDATE UserELo SET Elo = ? WHERE Season = ? AND UserID = ? AND GameMode = ?");
|
private static final Statement setElo = new Statement("UPDATE UserELo SET Elo = ? WHERE Season = ? AND UserID = ? AND GameMode = ?");
|
||||||
private static final Statement place = new Statement("SELECT COUNT(*) AS Place FROM UserElo WHERE GameMode = ? AND Elo > ? AND Season = ?");
|
private static final Statement place = new Statement("SELECT COUNT(*) AS Place FROM UserElo WHERE GameMode = ? AND Elo > ? AND Season = ?");
|
||||||
|
|
||||||
public static int getElo(int userID, String gameMode) {
|
public static Optional<Integer> getElo(int userID, String gameMode) {
|
||||||
return getElo(Season.getSeason(), userID, gameMode);
|
return getElo(Season.getSeason(), userID, gameMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getElo(int season, int userID, String gameMode) {
|
public static Optional<Integer> getElo(int season, int userID, String gameMode) {
|
||||||
return elo.select(rs -> {
|
return elo.select(rs -> {
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
return rs.getInt("Elo");
|
return Optional.of(rs.getInt("Elo"));
|
||||||
return 1000;
|
return Optional.empty();
|
||||||
}, userID, gameMode, season);
|
}, userID, gameMode, season);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren