From b6e1e80b000c18b9d5df8e134912dab4e2cd4aff Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 10 Mar 2022 22:04:23 +0100 Subject: [PATCH] Update stuff --- .../comms/handlers/FightEndsHandler.java | 14 ++++++++ src/de/steamwar/bungeecore/sql/SchemNode.java | 32 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/de/steamwar/bungeecore/sql/SchemNode.java diff --git a/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java index 1592fccc..9b3e64a6 100644 --- a/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java +++ b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java @@ -30,5 +30,19 @@ public class FightEndsHandler implements SpigotHandler { public void handle(ByteArrayDataInput in, ServerInfo info) { FightEndsPacket fightEndsPacket = new FightEndsPacket(in); + double playerRatio = Math.min(fightEndsPacket.getBluePlayers().size(), fightEndsPacket.getRedPlayers().size()) / (double )Math.max(fightEndsPacket.getBluePlayers().size(), fightEndsPacket.getRedPlayers().size()); + if (playerRatio >= 0.4) { + return; + } + + double blueResult; + if (fightEndsPacket.getWin() == 0) { + blueResult = 0.5; + } else if (fightEndsPacket.getWin() == 1) { + blueResult = 1; + } else { + blueResult = 0; + } + } } diff --git a/src/de/steamwar/bungeecore/sql/SchemNode.java b/src/de/steamwar/bungeecore/sql/SchemNode.java new file mode 100644 index 00000000..c08c06b2 --- /dev/null +++ b/src/de/steamwar/bungeecore/sql/SchemNode.java @@ -0,0 +1,32 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bungeecore.sql; + +public class SchemNode { + private SchemNode() {} + + private static final Statement getSchemOwner = new Statement("SELECT NodeOwner FROM SchematicNode WHERE NodeId = ?"); + + public static int getSchematicOwner(int schemId) { + return getSchemOwner.select(rs -> { + return rs.getInt("NodeOwner"); + }, schemId); + } +}