From d5d21a3fab49aaae9946941eab7ed16a92b2e375 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 20 Jul 2017 01:00:37 -0400 Subject: [PATCH] Disable anticheat checks in event servers --- .../src/mineplex/core/antihack/AntiHack.java | 4 ++-- .../game/arcade/managers/GameHostManager.java | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 69e00b2dd..159290bf3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -89,7 +89,7 @@ import mineplex.serverdata.commands.ServerCommandManager; @ReflectivelyCreateMiniPlugin public class AntiHack extends MiniPlugin { - private static final Map, CheckThresholds> CHECKS = ImmutableMap., CheckThresholds>builder() + public static final Map, CheckThresholds> CHECKS = ImmutableMap., CheckThresholds>builder() .put(KillauraTypeA.class, new CheckThresholds("Kill Aura", 25, 45, 60)) .put(KillauraTypeB.class, new CheckThresholds("High CPS", 0, 0, Integer.MAX_VALUE)) .put(KillauraTypeC.class, new CheckThresholds("Reach", 25, Integer.MAX_VALUE, Integer.MAX_VALUE)) @@ -106,7 +106,7 @@ public class AntiHack extends MiniPlugin private static final CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); - private static final Map, AntiHackAction> ACTIONS = ImmutableMap., AntiHackAction>builder() + public static final Map, AntiHackAction> ACTIONS = ImmutableMap., AntiHackAction>builder() .put(KillauraTypeA.class, new ImmediateBanAction(200)) .put(KillauraTypeD.class, new BanwaveAction(1500)) .put(KillauraTypeF.class, new BanwaveAction(600)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index f046626b4..0867fb6cc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -3,6 +3,7 @@ package nautilus.game.arcade.managers; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.stream.Stream; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -22,6 +23,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.Plugin; import mineplex.core.Managers; +import mineplex.core.antihack.AntiHack; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -40,14 +42,17 @@ import mineplex.core.portal.GenericServer; import mineplex.core.portal.Intent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.gui.privateServer.PrivateServerShop; import nautilus.game.arcade.gui.privateServer.page.GameVotingPage; public class GameHostManager implements Listener { + private final AntiHack _antiHack; private ArrayList ultraGames = new ArrayList(); private ArrayList heroGames = new ArrayList(); private ArrayList legendGames = new ArrayList(); @@ -79,6 +84,7 @@ public class GameHostManager implements Listener public GameHostManager(ArcadeManager manager) { + _antiHack = Managers.require(AntiHack.class); Manager = manager; _shop = new PrivateServerShop(manager, manager.GetClients(), manager.GetDonation()); Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); @@ -160,6 +166,18 @@ public class GameHostManager implements Listener return games; } + @EventHandler + public void onStateChange(GameStateChangeEvent event) + { + if (!isEventServer()) + { + return; + } + + // Disable all checks in event servers + Stream.concat(AntiHack.ACTIONS.keySet().stream(), AntiHack.CHECKS.keySet().stream()).distinct().forEach(_antiHack::addIgnoredCheck); + } + @EventHandler public void updateHost(UpdateEvent event) {