From 8538a09a86b78343c616b1a193f77d35ecee9860 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 3 Aug 2024 13:15:28 +0200 Subject: [PATCH] Update EloPlayerHandler and EloSchemHandler to handle non schem FightEndsPackets --- .../network/handlers/EloPlayerHandler.java | 12 ++++++++++-- .../network/handlers/EloSchemHandler.java | 13 +++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java b/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java index 327adba..d98f2bc 100644 --- a/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java +++ b/src/de/steamwar/velocitycore/network/handlers/EloPlayerHandler.java @@ -32,6 +32,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.title.Title; +import javax.xml.validation.Schema; import java.time.Duration; import java.util.*; import java.util.concurrent.TimeUnit; @@ -52,8 +53,15 @@ public class EloPlayerHandler extends PacketHandler { */ @Handler public void handle(FightEndsPacket fightEndsPacket) { - if (!ArenaMode.getBySchemType(SchematicType.fromDB(fightEndsPacket.getGameMode())).isRanked()) - return; + SchematicType schematicType = SchematicType.fromDB(fightEndsPacket.getGameMode()); + 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)) return; diff --git a/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java b/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java index 6814473..5a37c86 100644 --- a/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java +++ b/src/de/steamwar/velocitycore/network/handlers/EloSchemHandler.java @@ -19,18 +19,21 @@ package de.steamwar.velocitycore.network.handlers; -import de.steamwar.velocitycore.ArenaMode; import de.steamwar.network.packets.PacketHandler; import de.steamwar.network.packets.common.FightEndsPacket; import de.steamwar.sql.SchemElo; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicType; +import de.steamwar.velocitycore.ArenaMode; public class EloSchemHandler extends PacketHandler { private static final int K = 20; public static boolean publicVsPrivate(FightEndsPacket packet) { + if (packet.getRedSchem() == -1 && packet.getBlueSchem() == -1) { + return false; + } SchematicNode blueSchem = SchematicNode.getSchematicNode(packet.getBlueSchem()); SchematicNode redSchem = SchematicNode.getSchematicNode(packet.getRedSchem()); return (blueSchem.getOwner() == 0) != (redSchem.getOwner() == 0); @@ -38,9 +41,11 @@ public class EloSchemHandler extends PacketHandler { @Handler public void handle(FightEndsPacket fightEndsPacket) { - if (!ArenaMode.getBySchemType(SchematicType.fromDB(fightEndsPacket.getGameMode())).isRanked()) { - return; - } + SchematicType type = SchematicType.fromDB(fightEndsPacket.getGameMode()); + if (type == null) return; + ArenaMode arenaMode = ArenaMode.getBySchemType(type); + if (arenaMode == null) return; + if (!arenaMode.isRanked()) return; if (publicVsPrivate(fightEndsPacket)) return;