mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
KillAura check works now, currently uses 1 bot
This commit is contained in:
1 parent
4cc8ec9380
commit
fed95f8b70
8 files changed
+71
-8
No files matched your search
@@ -27,7 +27,9 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
|
|
||||||
|
import net.gravitydevelopment.anticheat.check.combat.KillAuraCheck;
|
||||||
import net.gravitydevelopment.anticheat.command.CommandHandler;
|
import net.gravitydevelopment.anticheat.command.CommandHandler;
|
||||||
import net.gravitydevelopment.anticheat.config.Configuration;
|
import net.gravitydevelopment.anticheat.config.Configuration;
|
||||||
import net.gravitydevelopment.anticheat.event.BlockListener;
|
import net.gravitydevelopment.anticheat.event.BlockListener;
|
||||||
@@ -51,7 +53,7 @@ public class AntiCheat extends JavaPlugin {
|
|||||||
private static boolean verbose;
|
private static boolean verbose;
|
||||||
private static boolean developer;
|
private static boolean developer;
|
||||||
private static final int PROJECT_ID = 38723;
|
private static final int PROJECT_ID = 38723;
|
||||||
private static PacketManager packetManager;
|
private static ProtocolManager protocolManager;
|
||||||
private static boolean protocolLib = false;
|
private static boolean protocolLib = false;
|
||||||
private static Long loadTime;
|
private static Long loadTime;
|
||||||
|
|
||||||
@@ -69,7 +71,7 @@ public class AntiCheat extends JavaPlugin {
|
|||||||
setupConfig();
|
setupConfig();
|
||||||
setupEvents();
|
setupEvents();
|
||||||
setupCommands();
|
setupCommands();
|
||||||
// setupProtocol(); TODO
|
setupProtocol();
|
||||||
// Enterprise must come before levels
|
// Enterprise must come before levels
|
||||||
setupEnterprise();
|
setupEnterprise();
|
||||||
restoreLevels();
|
restoreLevels();
|
||||||
@@ -90,6 +92,10 @@ public class AntiCheat extends JavaPlugin {
|
|||||||
// End tests
|
// End tests
|
||||||
verboseLog("Finished loading.");
|
verboseLog("Finished loading.");
|
||||||
getLogger().info("Running version " + VersionUtil.getVersion() + "...");
|
getLogger().info("Running version " + VersionUtil.getVersion() + "...");
|
||||||
|
|
||||||
|
// Enable packetlisteners
|
||||||
|
if (VersionUtil.getVersion().equals("v1_8_R3"))
|
||||||
|
KillAuraCheck.listenPackets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -105,7 +111,7 @@ public class AntiCheat extends JavaPlugin {
|
|||||||
private void setupProtocol() {
|
private void setupProtocol() {
|
||||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||||
protocolLib = true;
|
protocolLib = true;
|
||||||
packetManager = new PacketManager(ProtocolLibrary.getProtocolManager(), this, manager);
|
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
verboseLog("Hooked into ProtocolLib");
|
verboseLog("Hooked into ProtocolLib");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,4 +215,9 @@ public class AntiCheat extends JavaPlugin {
|
|||||||
public Long getLoadTime() {
|
public Long getLoadTime() {
|
||||||
return loadTime;
|
return loadTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ProtocolManager getProtocolManager() {
|
||||||
|
return protocolManager;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,8 @@ public enum CheckType {
|
|||||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
||||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
||||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||||
AUTOTOOL(Permission.CHECK_AUTOTOOL);
|
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
||||||
|
KILLAURA(Permission.CHECK_KILLAURA);
|
||||||
|
|
||||||
private final Permission permission;
|
private final Permission permission;
|
||||||
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
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.CheckerNPCS;
|
||||||
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
import net.gravitydevelopment.anticheat.util.VersionUtil;
|
||||||
|
|
||||||
@@ -18,11 +27,34 @@ import net.gravitydevelopment.anticheat.util.VersionUtil;
|
|||||||
public class KillAuraCheck {
|
public class KillAuraCheck {
|
||||||
|
|
||||||
private static final Map<UUID, CheckerNPCS> CHECKER_NPCS = new HashMap<UUID, CheckerNPCS>();
|
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) {
|
public static void cleanPlayer(Player p) {
|
||||||
CHECKER_NPCS.remove(p.getUniqueId());
|
CHECKER_NPCS.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()))
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
|
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
|
||||||
if (VersionUtil.getVersion().equals("v1_8_R3")) { // TODO 1.9 support
|
if (VersionUtil.getVersion().equals("v1_8_R3")) { // TODO 1.9 support
|
||||||
if (!CHECKER_NPCS.containsKey(p.getUniqueId())) { // Enable killaura check after player damaged other player, this is more efficient
|
if (!CHECKER_NPCS.containsKey(p.getUniqueId())) { // Enable killaura check after player damaged other player, this is more efficient
|
||||||
|
|||||||
@@ -373,4 +373,8 @@ public interface Magic {
|
|||||||
* Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE.
|
* Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE.
|
||||||
*/
|
*/
|
||||||
public int TELEPORT_MIN();
|
public int TELEPORT_MIN();
|
||||||
|
/**
|
||||||
|
* Maximum amount of times a player can hit a killaura bot; Type=INTEGER, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int KILLAURA_BOTHITS();
|
||||||
}
|
}
|
||||||
@@ -20,12 +20,22 @@ public class CheckerNPCS {
|
|||||||
public void doMove(PlayerMoveEvent e) {
|
public void doMove(PlayerMoveEvent e) {
|
||||||
NPC one = NPCS.get(0);
|
NPC one = NPCS.get(0);
|
||||||
Location eyeLocation = e.getPlayer().getEyeLocation();
|
Location eyeLocation = e.getPlayer().getEyeLocation();
|
||||||
Vector vec = e.getPlayer().getLocation().getDirection();
|
Vector vec = e.getFrom().getDirection();
|
||||||
Vector newVec = new Vector(vec.getX() * -2, vec.getY() * -2, vec.getZ() * -2);
|
Vector newVec = new Vector(vec.getX() * -2, vec.getY() * -2, vec.getZ() * -2);
|
||||||
Location backLocation = eyeLocation.add(newVec);
|
Location backLocation = eyeLocation.add(newVec);
|
||||||
if (e.getPlayer().getLocation().getPitch() <= -45) // TODO better fix for this
|
if (e.getPlayer().getLocation().getPitch() <= -45) {// TODO better fix for this
|
||||||
backLocation.add(0, -2.5, 0);
|
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());
|
one.move(backLocation, e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onHit(int entityId) {
|
||||||
|
for (NPC npc : NPCS)
|
||||||
|
if (npc.getEntityId() == entityId)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,10 @@ public class NPC {
|
|||||||
((CraftPlayer)owner).getHandle().playerConnection.sendPacket(new PacketPlayOutNamedEntitySpawn(this.npc));
|
((CraftPlayer)owner).getHandle().playerConnection.sendPacket(new PacketPlayOutNamedEntitySpawn(this.npc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getEntityId() {
|
||||||
|
return npc.getId();
|
||||||
|
}
|
||||||
|
|
||||||
public void move(Location loc, Player owner) {
|
public void move(Location loc, Player owner) {
|
||||||
this.npc.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
|
this.npc.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
|
||||||
((CraftPlayer)owner).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(this.npc));
|
((CraftPlayer)owner).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(this.npc));
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public enum Permission {
|
|||||||
SYSTEM_CALIBRATE,
|
SYSTEM_CALIBRATE,
|
||||||
SYSTEM_CHECK,
|
SYSTEM_CHECK,
|
||||||
SYSTEM_DEBUG,
|
SYSTEM_DEBUG,
|
||||||
SYSTEM_RELOAD;
|
SYSTEM_RELOAD, CHECK_KILLAURA;
|
||||||
|
|
||||||
private static final String PERMISSION_ALL = "anticheat.*";
|
private static final String PERMISSION_ALL = "anticheat.*";
|
||||||
private static final String PERMISSION_SPAM = "anticheat.check.spam";
|
private static final String PERMISSION_SPAM = "anticheat.check.spam";
|
||||||
|
|||||||
@@ -85,3 +85,4 @@ Y_SPEED_MAX: 0.5125
|
|||||||
Y_TIME: 1000
|
Y_TIME: 1000
|
||||||
GLIDE_LIMIT: 10
|
GLIDE_LIMIT: 10
|
||||||
GLIDE_MAX: -3.75
|
GLIDE_MAX: -3.75
|
||||||
|
KILLAURA_BOTHITS: 5
|
||||||
Reference in new issue
Block a user