SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Update EloPlayerHandler and EloSchemHandler to handle non schem FightEndsPackets' (#519) from EloForMissileWars into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #519
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2024-08-03 13:25:17 +02:00
Commit d8c10bba9b
2 geänderte Dateien mit 19 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -20,13 +20,13 @@
package de.steamwar.velocitycore.network.handlers; package de.steamwar.velocitycore.network.handlers;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import de.steamwar.velocitycore.ArenaMode;
import de.steamwar.velocitycore.VelocityCore;
import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.common.FightEndsPacket; import de.steamwar.network.packets.common.FightEndsPacket;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserElo; import de.steamwar.sql.UserElo;
import de.steamwar.velocitycore.ArenaMode;
import de.steamwar.velocitycore.VelocityCore;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
@ -52,8 +52,15 @@ public class EloPlayerHandler extends PacketHandler {
*/ */
@Handler @Handler
public void handle(FightEndsPacket fightEndsPacket) { public void handle(FightEndsPacket fightEndsPacket) {
if (!ArenaMode.getBySchemType(SchematicType.fromDB(fightEndsPacket.getGameMode())).isRanked()) SchematicType schematicType = SchematicType.fromDB(fightEndsPacket.getGameMode());
return; ArenaMode arenaMode;
if (schematicType == null) {
arenaMode = ArenaMode.getByChat(fightEndsPacket.getGameMode());
} else {
arenaMode = ArenaMode.getBySchemType(schematicType);
}
if (arenaMode == null) return;
if (!arenaMode.isRanked()) return;
if (EloSchemHandler.publicVsPrivate(fightEndsPacket)) if (EloSchemHandler.publicVsPrivate(fightEndsPacket))
return; return;

Datei anzeigen

@ -19,18 +19,21 @@
package de.steamwar.velocitycore.network.handlers; package de.steamwar.velocitycore.network.handlers;
import de.steamwar.velocitycore.ArenaMode;
import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.PacketHandler;
import de.steamwar.network.packets.common.FightEndsPacket; import de.steamwar.network.packets.common.FightEndsPacket;
import de.steamwar.sql.SchemElo; import de.steamwar.sql.SchemElo;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import de.steamwar.velocitycore.ArenaMode;
public class EloSchemHandler extends PacketHandler { public class EloSchemHandler extends PacketHandler {
private static final int K = 20; private static final int K = 20;
public static boolean publicVsPrivate(FightEndsPacket packet) { public static boolean publicVsPrivate(FightEndsPacket packet) {
if (packet.getRedSchem() == -1 && packet.getBlueSchem() == -1) {
return false;
}
SchematicNode blueSchem = SchematicNode.getSchematicNode(packet.getBlueSchem()); SchematicNode blueSchem = SchematicNode.getSchematicNode(packet.getBlueSchem());
SchematicNode redSchem = SchematicNode.getSchematicNode(packet.getRedSchem()); SchematicNode redSchem = SchematicNode.getSchematicNode(packet.getRedSchem());
return (blueSchem.getOwner() == 0) != (redSchem.getOwner() == 0); return (blueSchem.getOwner() == 0) != (redSchem.getOwner() == 0);
@ -38,9 +41,10 @@ public class EloSchemHandler extends PacketHandler {
@Handler @Handler
public void handle(FightEndsPacket fightEndsPacket) { public void handle(FightEndsPacket fightEndsPacket) {
if (!ArenaMode.getBySchemType(SchematicType.fromDB(fightEndsPacket.getGameMode())).isRanked()) { SchematicType type = SchematicType.fromDB(fightEndsPacket.getGameMode());
return; if (type == null) return;
} ArenaMode arenaMode = ArenaMode.getBySchemType(type);
if (!arenaMode.isRanked()) return;
if (publicVsPrivate(fightEndsPacket)) if (publicVsPrivate(fightEndsPacket))
return; return;