Removed NoSwing & KillAura check, noswing is broken since 1.10 and i'm

rewriting killaura
This commit is contained in:
Rammelkast committed 2016-07-17 19:49:09 +02:00
1 parent f8a58fa888
commit cf36228285
7 files changed
+14 -230

No files matched your search

@@ -71,7 +71,6 @@ public class Backend {
private Map<String, Integer> projectilesShot = new HashMap<String, Integer>();
private Map<String, Long> velocitized = new HashMap<String, Long>();
private Map<String, Integer> velocitytrack = new HashMap<String, Integer>();
private Map<String, Long> animated = new HashMap<String, Long>();
private Map<String, Long> startEat = new HashMap<String, Long>();
private Map<String, Long> lastHeal = new HashMap<String, Long>();
private Map<String, Long> projectileTime = new HashMap<String, Long>();
@@ -155,7 +154,6 @@ public class Backend {
projectilesShot.remove(pN);
velocitized.remove(pN);
velocitytrack.remove(pN);
animated.remove(pN);
startEat.remove(pN);
lastHeal.remove(pN);
projectileTime.remove(pN);
@@ -703,14 +701,6 @@ public class Backend {
}
}
public CheckResult checkAnimation(Player player, Entity e) {
if (!justAnimated(player)) {
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " didn't animate before damaging a " + e.getType());
} else {
return PASS;
}
}
public CheckResult checkFastHeal(Player player) {
if (lastHeal.containsKey(player.getName())) // Otherwise it was modified by a plugin, don't worry about it.
{
@@ -735,13 +725,6 @@ public class Backend {
return PASS;
}
public void logAnimation(final Player player) {
animated.put(player.getName(), System.currentTimeMillis());
increment(player, blockPunches, magic.BLOCK_PUNCH_MIN());
itemInHand.put(player.getName(), player.getItemInHand().getType());
interactionCount.put(player.getName(), 0);
}
public void logInstantBreak(final Player player) {
instantBreakExempt.put(player.getName(), System.currentTimeMillis());
}
@@ -765,7 +748,6 @@ public class Backend {
public void logBlockBreak(final Player player) {
brokenBlock.put(player.getName(), System.currentTimeMillis());
resetAnimation(player);
}
public boolean justBroke(Player player) {
@@ -807,29 +789,6 @@ public class Backend {
public boolean justPlaced(Player player) {
return isDoing(player, placedBlock, magic.BLOCK_PLACE_MIN());
}
public void resetAnimation(final Player player) {
animated.remove(player.getName());
blockPunches.put(player.getName(), 0);
}
private boolean justAnimated(Player player) {
String name = player.getName();
if (animated.containsKey(name)) {
long time = System.currentTimeMillis() - animated.get(name);
int count = interactionCount.get(player.getName()) + 1;
interactionCount.put(player.getName(), count);
if (count > magic.ANIMATION_INTERACT_MAX()) {
animated.remove(player.getName());
return false;
}
return time < magic.ANIMATION_MIN();
} else {
return false;
}
}
public void logDamage(final Player player, int type) {
long time;
switch (type) {
@@ -1,83 +1,28 @@
package net.gravitydevelopment.anticheat.check.combat;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.check.CheckType;
import net.gravitydevelopment.anticheat.event.EventListener;
import net.gravitydevelopment.anticheat.util.CheckerNPCS;
import net.gravitydevelopment.anticheat.util.VersionUtil;
/**
* @author Rammelkast
*/
public class KillAuraCheck {
private static final Map<UUID, CheckerNPCS> CHECKER_NPCS = new HashMap<UUID, CheckerNPCS>();
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
public static void cleanPlayer(Player p) {
if (CHECKER_NPCS.containsKey(p.getUniqueId()))
CHECKER_NPCS.get(p.getUniqueId()).clean(p);
CHECKER_NPCS.remove(p.getUniqueId());
VL_COUNT.remove(p.getUniqueId());
}
public static void listenPackets() {
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.USE_ENTITY}) {
@Override
public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
if (!CHECKER_NPCS.containsKey(p.getUniqueId()) || AntiCheat.getManager().getCheckManager().isOpExempt(p) || AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.KILLAURA))
return;
int entityId = ((Integer)e.getPacket().getIntegers().read(0));
boolean isBot = CHECKER_NPCS.get(p.getUniqueId()).onHit(entityId);
if (isBot) {
if (!VL_COUNT.containsKey(p.getUniqueId()))
VL_COUNT.put(p.getUniqueId(), 1);
else {
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
if (VL_COUNT.get(p.getUniqueId()) >= AntiCheat.getManager().getBackend().getMagic().KILLAURA_BOTHITS()) {
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Killaura, hit the bot " + VL_COUNT.get(p.getUniqueId()) + " times (max=" + AntiCheat.getManager().getBackend().getMagic().KILLAURA_BOTHITS() + ")").getMessage(), p, CheckType.KILLAURA);
VL_COUNT.remove(p.getUniqueId());
}
}
}
}
});
}
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
if (AntiCheat.getManager().getCheckManager().isOpExempt(p) || AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.KILLAURA))
return;
if (VersionUtil.getVersion().equals("v1_9_R1")) { // TODO 1.9 R2 support
if (!CHECKER_NPCS.containsKey(p.getUniqueId())) { // Enable killaura check after player damaged other player, this is more efficient
CHECKER_NPCS.put(p.getUniqueId(), new CheckerNPCS(p));
}
}
}
public static void doMove(PlayerMoveEvent e) {
if (CHECKER_NPCS.containsKey(e.getPlayer().getUniqueId())) {
if (AntiCheat.getManager().getCheckManager().isOpExempt(e.getPlayer()) || AntiCheat.getManager().getCheckManager().isExempt(e.getPlayer(), CheckType.KILLAURA)) {
cleanPlayer(e.getPlayer());
return;
}
CHECKER_NPCS.get(e.getPlayer().getUniqueId()).doMove(e);
}
}
}