Implement proper deactivation of ignored anticheat checks and temporarily disable KillauraTypeB

This commit is contained in:
AlexTheCoder 2018-06-14 02:12:56 -04:00
parent 6fb86c264d
commit d23bacb95a
3 changed files with 34 additions and 16 deletions

View File

@ -1,6 +1,5 @@
package mineplex.core.antihack; package mineplex.core.antihack;
import javax.xml.bind.DatatypeConverter;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@ -10,11 +9,7 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Consumer; import java.util.function.Consumer;
import net.md_5.bungee.api.ChatColor; import javax.xml.bind.DatatypeConverter;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,11 +23,13 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent; import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.mineplex.anticheat.MineplexAnticheat;
import com.mineplex.anticheat.api.GameEndEvent; import com.mineplex.anticheat.api.GameEndEvent;
import com.mineplex.anticheat.api.GameStartEvent; import com.mineplex.anticheat.api.GameStartEvent;
import com.mineplex.anticheat.api.MineplexLink; import com.mineplex.anticheat.api.MineplexLink;
@ -41,17 +38,14 @@ import com.mineplex.anticheat.checks.Check;
import com.mineplex.anticheat.checks.CheckManager; import com.mineplex.anticheat.checks.CheckManager;
import com.mineplex.anticheat.checks.combat.FastBow; import com.mineplex.anticheat.checks.combat.FastBow;
import com.mineplex.anticheat.checks.combat.KillauraTypeA; import com.mineplex.anticheat.checks.combat.KillauraTypeA;
import com.mineplex.anticheat.checks.combat.KillauraTypeB;
import com.mineplex.anticheat.checks.combat.KillauraTypeC; import com.mineplex.anticheat.checks.combat.KillauraTypeC;
import com.mineplex.anticheat.checks.combat.KillauraTypeD; import com.mineplex.anticheat.checks.combat.KillauraTypeD;
import com.mineplex.anticheat.checks.combat.KillauraTypeE; import com.mineplex.anticheat.checks.combat.KillauraTypeE;
import com.mineplex.anticheat.checks.combat.KillauraTypeF; import com.mineplex.anticheat.checks.combat.KillauraTypeF;
import com.mineplex.anticheat.checks.move.Glide; import com.mineplex.anticheat.checks.move.Glide;
import com.mineplex.anticheat.checks.move.HeadRoll; import com.mineplex.anticheat.checks.move.HeadRoll;
import com.mineplex.anticheat.checks.move.Phase;
import com.mineplex.anticheat.checks.move.Speed; import com.mineplex.anticheat.checks.move.Speed;
import com.mineplex.anticheat.checks.move.Timer; import com.mineplex.anticheat.checks.move.Timer;
import com.mineplex.anticheat.checks.move.Toggle;
import com.mineplex.anticheat.checks.player.BadPackets; import com.mineplex.anticheat.checks.player.BadPackets;
import com.mineplex.anticheat.checks.player.Scaffold; import com.mineplex.anticheat.checks.player.Scaffold;
@ -91,13 +85,18 @@ import mineplex.core.punish.PunishClient;
import mineplex.core.punish.Punishment; import mineplex.core.punish.Punishment;
import mineplex.core.punish.PunishmentResponse; import mineplex.core.punish.PunishmentResponse;
import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.commands.ServerCommandManager;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@ReflectivelyCreateMiniPlugin @ReflectivelyCreateMiniPlugin
public class AntiHack extends MiniPlugin public class AntiHack extends MiniPlugin
{ {
public 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", 25, 40, 60)) // .put(KillauraTypeB.class, new CheckThresholds("High CPS", 25, 40, 60))
.put(KillauraTypeC.class, new CheckThresholds("Reach", 35, 80, 120)) .put(KillauraTypeC.class, new CheckThresholds("Reach", 35, 80, 120))
.put(KillauraTypeD.class, new CheckThresholds("Kill Aura", 500, 1000, 1500)) .put(KillauraTypeD.class, new CheckThresholds("Kill Aura", 500, 1000, 1500))
.put(KillauraTypeE.class, new CheckThresholds("Kill Aura", 1000, 2000, 5000)) .put(KillauraTypeE.class, new CheckThresholds("Kill Aura", 1000, 2000, 5000))
@ -122,7 +121,7 @@ public class AntiHack extends MiniPlugin
public 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(150)) .put(KillauraTypeA.class, new ImmediateBanAction(150))
.put(KillauraTypeB.class, new BanwaveAction(80)) // .put(KillauraTypeB.class, new BanwaveAction(80))
.put(KillauraTypeD.class, new BanwaveAction(1500)) .put(KillauraTypeD.class, new BanwaveAction(1500))
.put(KillauraTypeF.class, new BanwaveAction(600)) .put(KillauraTypeF.class, new BanwaveAction(600))
.put(Glide.class, new ImmediateKickAction(1200)) .put(Glide.class, new ImmediateKickAction(1200))
@ -179,7 +178,7 @@ public class AntiHack extends MiniPlugin
private Set<UUID> _banned = Collections.synchronizedSet(new HashSet<>()); private Set<UUID> _banned = Collections.synchronizedSet(new HashSet<>());
// These are the GWEN checks to ignore when handling PlayerViolationEvent // These are the GWEN checks to ignore when handling PlayerViolationEvent
private HashSet<Class<? extends Check>> _ignoredChecks = new HashSet<>(); private Set<Class<? extends Check>> _ignoredChecks = new HashSet<>();
private boolean _strict; private boolean _strict;
private BanWaveManager _banWaveManager; private BanWaveManager _banWaveManager;
@ -527,6 +526,7 @@ public class AntiHack extends MiniPlugin
public void addIgnoredCheck(Class<? extends Check> check) public void addIgnoredCheck(Class<? extends Check> check)
{ {
_ignoredChecks.add(check); _ignoredChecks.add(check);
JavaPlugin.getPlugin(MineplexAnticheat.class).getCheckManager().disableCheck(check);
} }
/** /**
@ -535,12 +535,18 @@ public class AntiHack extends MiniPlugin
*/ */
public void resetIgnoredChecks() public void resetIgnoredChecks()
{ {
CheckManager cm = JavaPlugin.getPlugin(MineplexAnticheat.class).getCheckManager();
if (!cm.getActiveChecks().isEmpty())
{
_ignoredChecks.forEach(cm::enableCheck);
}
_ignoredChecks.clear(); _ignoredChecks.clear();
} }
public void enableAnticheat() public void enableAnticheat()
{ {
UtilServer.CallEvent(new GameStartEvent()); UtilServer.CallEvent(new GameStartEvent());
_ignoredChecks.forEach(JavaPlugin.getPlugin(MineplexAnticheat.class).getCheckManager()::disableCheck);
} }
public void disableAnticheat() public void disableAnticheat()
@ -578,7 +584,7 @@ public class AntiHack extends MiniPlugin
.append(" suspected of ", ComponentBuilder.FormatRetention.NONE).color(ChatColor.YELLOW); .append(" suspected of ", ComponentBuilder.FormatRetention.NONE).color(ChatColor.YELLOW);
thresholds.format(componentBuilder, violation.getViolations()); thresholds.format(componentBuilder, violation.getViolations());
if (!violation.getOriginatingServer().equals(this._thisServer)) if (!violation.getOriginatingServer().equals(_thisServer))
{ {
componentBuilder.append(" in ", ComponentBuilder.FormatRetention.NONE).color(ChatColor.YELLOW) componentBuilder.append(" in ", ComponentBuilder.FormatRetention.NONE).color(ChatColor.YELLOW)
.append(violation.getOriginatingServer()).color(ChatColor.AQUA) .append(violation.getOriginatingServer()).color(ChatColor.AQUA)
@ -608,4 +614,4 @@ public class AntiHack extends MiniPlugin
{ {
_strict = strict; _strict = strict;
} }
} }

View File

@ -57,7 +57,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.mineplex.anticheat.checks.combat.KillauraTypeA;
import mineplex.core.Managers; import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
@ -360,6 +363,9 @@ public class HideSeek extends TeamGame
.register(this); .register(this);
StrictAntiHack = true; StrictAntiHack = true;
AntiHack antiHack = Managers.get(AntiHack.class);
antiHack.addIgnoredCheck(KillauraTypeA.class);
} }
@EventHandler @EventHandler

View File

@ -32,6 +32,10 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.mineplex.anticheat.checks.combat.KillauraTypeA;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
@ -58,7 +62,6 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
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.events.GameStateChangeEvent;
@ -160,10 +163,13 @@ public class Minestrike extends TeamGame
this.PlayerGameMode = GameMode.ADVENTURE; this.PlayerGameMode = GameMode.ADVENTURE;
AntiHack antiHack = Managers.get(AntiHack.class);
antiHack.addIgnoredCheck(KillauraTypeA.class);
_scoreObj = Scoreboard.getScoreboard().registerNewObjective("HP", "dummy"); _scoreObj = Scoreboard.getScoreboard().registerNewObjective("HP", "dummy");
_scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME); _scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
this._help = new String[] _help = new String[]
{ {
//"Tap Crouch when close to an ally to Boost", //"Tap Crouch when close to an ally to Boost",
"Open Inventory at spawn to buy guns", "Open Inventory at spawn to buy guns",