Dieser Commit ist enthalten in:
Ursprung
bbd2b1950b
Commit
895ac9843b
@ -26,11 +26,15 @@ import de.steamwar.bungeecore.comms.packets.FightEndsPacket;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FightEndsHandler implements SpigotHandler {
|
||||
|
||||
private int K = 20;
|
||||
private long fightRange = 1000 /* Milliseconds */ * 60 /* Seconds */ * 30 /* Minutes */;
|
||||
|
||||
@Override
|
||||
public void handle(ByteArrayDataInput in, ServerInfo info) {
|
||||
@ -63,7 +67,9 @@ public class FightEndsHandler implements SpigotHandler {
|
||||
blueResult = 0;
|
||||
}
|
||||
|
||||
// TODO: Implement hourly unranked when against same team maybe half hourly
|
||||
if (teamComboExistedAlready(fightEndsPacket.getBluePlayers(), fightEndsPacket.getRedPlayers(), fightEndsPacket.getGameMode())) {
|
||||
return;
|
||||
}
|
||||
|
||||
int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem());
|
||||
int redSchemElo = SchemElo.getElo(fightEndsPacket.getRedSchem());
|
||||
@ -88,4 +94,25 @@ public class FightEndsHandler implements SpigotHandler {
|
||||
UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * (result - winTeamExpectation) * multiplier));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean teamComboExistedAlready(List<Integer> bluePlayers, List<Integer> redPlayers, String gameMode) {
|
||||
long time = Timestamp.from(Instant.now()).getTime() - fightRange;
|
||||
int page = 0;
|
||||
do {
|
||||
List<Fight> fightsPage = Fight.getPage(page, 32);
|
||||
if (fightsPage.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (Fight fight : fightsPage) {
|
||||
if (!fight.getGameMode().getSchemType().equals(gameMode)) continue;
|
||||
if (fight.getStartTime().getTime() < time) return false;
|
||||
if (fight.getBluePlayers().stream().map(FightPlayer::getUserID).collect(Collectors.toList()).containsAll(bluePlayers)) {
|
||||
if (fight.getRedPlayers().stream().map(FightPlayer::getUserID).collect(Collectors.toList()).containsAll(redPlayers)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
page++;
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren