Disable anticheat checks in event servers

This commit is contained in:
cnr 2017-07-20 01:00:37 -04:00
parent 2c0d460357
commit d5d21a3fab
2 changed files with 20 additions and 2 deletions

View File

@ -89,7 +89,7 @@ import mineplex.serverdata.commands.ServerCommandManager;
@ReflectivelyCreateMiniPlugin @ReflectivelyCreateMiniPlugin
public class AntiHack extends MiniPlugin public class AntiHack extends MiniPlugin
{ {
private static final Map<Class<? extends Check>, CheckThresholds> CHECKS = ImmutableMap.<Class<? extends Check>, CheckThresholds>builder() public static final Map<Class<? extends Check>, CheckThresholds> CHECKS = ImmutableMap.<Class<? extends Check>, CheckThresholds>builder()
.put(KillauraTypeA.class, new CheckThresholds("Kill Aura", 25, 45, 60)) .put(KillauraTypeA.class, new CheckThresholds("Kill Aura", 25, 45, 60))
.put(KillauraTypeB.class, new CheckThresholds("High CPS", 0, 0, Integer.MAX_VALUE)) .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)) .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 CheckThresholds NOOP_THRESHOLD = new CheckThresholds("Unknown", Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
private static final Map<Class<? extends Check>, AntiHackAction> ACTIONS = ImmutableMap.<Class<? extends Check>, AntiHackAction>builder() public static final Map<Class<? extends Check>, AntiHackAction> ACTIONS = ImmutableMap.<Class<? extends Check>, AntiHackAction>builder()
.put(KillauraTypeA.class, new ImmediateBanAction(200)) .put(KillauraTypeA.class, new ImmediateBanAction(200))
.put(KillauraTypeD.class, new BanwaveAction(1500)) .put(KillauraTypeD.class, new BanwaveAction(1500))
.put(KillauraTypeF.class, new BanwaveAction(600)) .put(KillauraTypeF.class, new BanwaveAction(600))

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.managers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.stream.Stream;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -22,6 +23,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import mineplex.core.Managers; import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -40,14 +42,17 @@ import mineplex.core.portal.GenericServer;
import mineplex.core.portal.Intent; import mineplex.core.portal.Intent;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.gui.privateServer.PrivateServerShop; import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
import nautilus.game.arcade.gui.privateServer.page.GameVotingPage; import nautilus.game.arcade.gui.privateServer.page.GameVotingPage;
public class GameHostManager implements Listener public class GameHostManager implements Listener
{ {
private final AntiHack _antiHack;
private ArrayList<GameType> ultraGames = new ArrayList<GameType>(); private ArrayList<GameType> ultraGames = new ArrayList<GameType>();
private ArrayList<GameType> heroGames = new ArrayList<GameType>(); private ArrayList<GameType> heroGames = new ArrayList<GameType>();
private ArrayList<GameType> legendGames = new ArrayList<GameType>(); private ArrayList<GameType> legendGames = new ArrayList<GameType>();
@ -79,6 +84,7 @@ public class GameHostManager implements Listener
public GameHostManager(ArcadeManager manager) public GameHostManager(ArcadeManager manager)
{ {
_antiHack = Managers.require(AntiHack.class);
Manager = manager; Manager = manager;
_shop = new PrivateServerShop(manager, manager.GetClients(), manager.GetDonation()); _shop = new PrivateServerShop(manager, manager.GetClients(), manager.GetDonation());
Manager.getPluginManager().registerEvents(this, Manager.getPlugin()); Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
@ -160,6 +166,18 @@ public class GameHostManager implements Listener
return games; 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 @EventHandler
public void updateHost(UpdateEvent event) public void updateHost(UpdateEvent event)
{ {