mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Removed NoSwing & KillAura check, noswing is broken since 1.10 and i'm
rewriting killaura
This commit is contained in:
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -109,9 +109,6 @@ public class EntityListener extends EventListener {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
VelocityCheck.runCheck(e, player);
|
||||
if (Utilities.hasArmorEnchantment(player, Enchantment.THORNS)) {
|
||||
getBackend().logAnimation(player);
|
||||
}
|
||||
if (e.getDamager() instanceof Player) {
|
||||
Player p = (Player) e.getDamager();
|
||||
getBackend().logDamage(p, 1);
|
||||
@@ -153,14 +150,6 @@ public class EntityListener extends EventListener {
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.NO_SWING)) {
|
||||
CheckResult result = getBackend().checkAnimation(player, event.getEntity());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.NO_SWING);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.FORCEFIELD)) {
|
||||
CheckResult result = getBackend().checkSight(player, e.getEntity());
|
||||
if (result.failed()) {
|
||||
|
||||
@@ -273,8 +273,6 @@ public class PlayerListener extends EventListener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
||||
getBackend().logAnimation(event.getPlayer());
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package net.gravitydevelopment.anticheat.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CheckerNPCS {
|
||||
|
||||
private List<NPC> NPCS = new ArrayList<NPC>();
|
||||
|
||||
public CheckerNPCS(Player p) {
|
||||
NPC npcOne = new NPC(NameUtil.getRandomName(), p.getWorld(), p);
|
||||
NPCS.add(npcOne);
|
||||
}
|
||||
|
||||
public void doMove(PlayerMoveEvent e) {
|
||||
NPC one = NPCS.get(0);
|
||||
Location eyeLocation = e.getPlayer().getEyeLocation();
|
||||
Vector vec = e.getFrom().getDirection();
|
||||
Vector newVec = new Vector(vec.getX() * -2, vec.getY() * -2, vec.getZ() * -2);
|
||||
Location backLocation = eyeLocation.add(newVec);
|
||||
if (e.getPlayer().getLocation().getPitch() <= -45) {// TODO better fix for this
|
||||
Vector direction = e.getFrom().getDirection();
|
||||
Vector addVector = direction.setX(direction.getX() * -2).setY(direction.getY() * -2).setZ(direction.getZ() * -2);
|
||||
backLocation.add(addVector);
|
||||
}
|
||||
one.move(backLocation, e.getPlayer());
|
||||
}
|
||||
|
||||
public boolean onHit(int entityId) {
|
||||
for (NPC npc : NPCS)
|
||||
if (npc.getEntityId() == entityId)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void clean(Player p) {
|
||||
if (!p.isOnline())
|
||||
return;
|
||||
for (NPC npc : NPCS)
|
||||
npc.destroy(p);
|
||||
NPCS.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package net.gravitydevelopment.anticheat.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.server.v1_9_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayOutEntityDestroy;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayOutNamedEntitySpawn;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_9_R1.PlayerInteractManager;
|
||||
|
||||
public class NPC {
|
||||
|
||||
private final EntityPlayer npc;
|
||||
|
||||
public NPC(String name, World w, Player owner) {
|
||||
this.npc = new EntityPlayer(((CraftServer) Bukkit.getServer()).getServer(), ((CraftWorld) w).getHandle(), new GameProfile(UUID.randomUUID(), name), new PlayerInteractManager(((CraftWorld) w).getHandle()));
|
||||
((CraftPlayer)owner).getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{this.npc}));
|
||||
this.npc.setInvisible(true);
|
||||
Location eyeLocation = owner.getEyeLocation();
|
||||
Vector vec = owner.getLocation().getDirection();
|
||||
Vector newVec = new Vector(vec.getX() * -2, vec.getY() * -2, vec.getZ() * -2);
|
||||
Location backLocation = eyeLocation.add(newVec);
|
||||
if (owner.getLocation().getPitch() < -50 && owner.getLocation().getPitch() > -75)
|
||||
this.npc.setLocation(backLocation.getX(), backLocation.getY() + 1, backLocation.getZ(), 0, 0);
|
||||
else if (owner.getLocation().getPitch() >= -50)
|
||||
this.npc.setLocation(backLocation.getX(), backLocation.getY() - 0.25, backLocation.getZ(), 0, 0);
|
||||
else
|
||||
this.npc.setLocation(backLocation.getX(), backLocation.getY() + 1.75, backLocation.getZ(), 0, 0);
|
||||
((CraftPlayer)owner).getHandle().playerConnection.sendPacket(new PacketPlayOutNamedEntitySpawn(this.npc));
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return npc.getId();
|
||||
}
|
||||
|
||||
public void move(Location loc, Player owner) {
|
||||
this.npc.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
|
||||
((CraftPlayer)owner).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(this.npc));
|
||||
}
|
||||
|
||||
public void destroy(Player p) {
|
||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[] { this.npc }));
|
||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(new int[] { this.npc.getId() }));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user