Made KillAura/Botcheck more effective; tested with Wolfram 1.10

This commit is contained in:
Rammelkast committed 2016-11-14 15:01:45 +01:00
1 parent 7a17837d28
commit f26e63b45f
3 files changed
+21 -16

No files matched your search

@@ -30,14 +30,16 @@ public class KillAuraCheck {
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>(); private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
public static void cleanPlayer(Player p) { public static void cleanPlayer(Player p) {
if (!VersionUtil.getVersion().equals("v1_10_R1")) if (!VersionUtil.getVersion().equals("v1_10_R1")) {
return; return;
}
NPC_LIST.remove(p.getUniqueId()); NPC_LIST.remove(p.getUniqueId());
} }
public static void listenPackets() { public static void listenPackets() {
if (!VersionUtil.getVersion().equals("v1_10_R1")) if (!VersionUtil.getVersion().equals("v1_10_R1")) {
return; return;
}
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.USE_ENTITY}) { AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.USE_ENTITY}) {
@Override @Override
public void onPacketReceiving(PacketEvent e) { public void onPacketReceiving(PacketEvent e) {
@@ -45,11 +47,13 @@ public class KillAuraCheck {
if (!NPC_LIST.containsKey(p.getUniqueId())) if (!NPC_LIST.containsKey(p.getUniqueId()))
return; return;
int id = e.getPacket().getIntegers().read(0); int id = e.getPacket().getIntegers().read(0);
if (NPC_LIST.containsKey(p.getUniqueId())) if (NPC_LIST.containsKey(p.getUniqueId())) {
if (NPC_LIST.get(p.getUniqueId()).getID() != id) if (NPC_LIST.get(p.getUniqueId()).getID() != id) {
return; return;
}
}
if (!VL_COUNT.containsKey(p.getUniqueId())) { if (!VL_COUNT.containsKey(p.getUniqueId())) {
VL_COUNT.put(p.getUniqueId(), 0); VL_COUNT.put(p.getUniqueId(), 1);
NPC_LIST.get(p.getUniqueId()).damage(); NPC_LIST.get(p.getUniqueId()).damage();
}else { }else {
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1); VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
@@ -63,8 +67,9 @@ public class KillAuraCheck {
} }
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) { public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
if (!VersionUtil.getVersion().equals("v1_10_R1")) if (!VersionUtil.getVersion().equals("v1_10_R1")) {
return; return;
}
if (NPC_LIST.containsKey(p.getUniqueId())) if (NPC_LIST.containsKey(p.getUniqueId()))
NPC_LIST.get(p.getUniqueId()).damage(e, p); NPC_LIST.get(p.getUniqueId()).damage(e, p);
else { else {
@@ -75,8 +80,9 @@ public class KillAuraCheck {
} }
public static void doMove(PlayerMoveEvent e) { public static void doMove(PlayerMoveEvent e) {
if (!VersionUtil.getVersion().equals("v1_10_R1")) if (!VersionUtil.getVersion().equals("v1_10_R1")) {
return; return;
}
if (NPC_LIST.containsKey(e.getPlayer().getUniqueId())) if (NPC_LIST.containsKey(e.getPlayer().getUniqueId()))
NPC_LIST.get(e.getPlayer().getUniqueId()).move(e); NPC_LIST.get(e.getPlayer().getUniqueId()).move(e);
} }
@@ -1,9 +1,7 @@
package net.gravitydevelopment.anticheat.check.movement; package net.gravitydevelopment.anticheat.check.movement;
import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@@ -92,7 +92,7 @@ public class NPC_1_10 {
NPC_1_10.this.npc.setInvisible(true); NPC_1_10.this.npc.setInvisible(true);
((CraftPlayer) NPC_1_10.this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false)); ((CraftPlayer) NPC_1_10.this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
} }
}.runTaskLater(AntiCheat.getPlugin(), 3); }.runTaskLater(AntiCheat.getPlugin(), 4);
} }
}else { }else {
Location eyelocation = e.getPlayer().getEyeLocation(); Location eyelocation = e.getPlayer().getEyeLocation();
@@ -108,9 +108,9 @@ public class NPC_1_10 {
} else if (e.getTo().getPitch() >= 22) { } else if (e.getTo().getPitch() >= 22) {
Location eyelocation = e.getPlayer().getEyeLocation(); Location eyelocation = e.getPlayer().getEyeLocation();
Vector vec = e.getPlayer().getLocation().getDirection(); Vector vec = e.getPlayer().getLocation().getDirection();
vec.setX(-2.5 * vec.getX()); vec.setX(-3 * vec.getX());
vec.setY(e.getPlayer().getLocation().getY() + 1.5); vec.setY(e.getPlayer().getLocation().getY() - 0.4);
vec.setZ(-2.5 * vec.getZ()); vec.setZ(-3 * vec.getZ());
Location back = eyelocation.add(vec); Location back = eyelocation.add(vec);
this.location = back; // TODO this.location = back; // TODO
this.npc.teleportTo(back, false); this.npc.teleportTo(back, false);
@@ -128,6 +128,7 @@ public class NPC_1_10 {
vec.setZ(-1.95 * vec.getZ()); vec.setZ(-1.95 * vec.getZ());
Location back = eyelocation.add(vec); Location back = eyelocation.add(vec);
this.location = back; // TODO this.location = back; // TODO
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
this.npc.teleportTo(back, false); this.npc.teleportTo(back, false);
((CraftPlayer) this.getOwner()).getHandle().playerConnection ((CraftPlayer) this.getOwner()).getHandle().playerConnection
.sendPacket(new PacketPlayOutEntityTeleport(npc)); .sendPacket(new PacketPlayOutEntityTeleport(npc));
@@ -140,7 +141,7 @@ public class NPC_1_10 {
NPC_1_10.this.npc.setInvisible(true); NPC_1_10.this.npc.setInvisible(true);
((CraftPlayer) NPC_1_10.this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false)); ((CraftPlayer) NPC_1_10.this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
} }
}.runTaskLater(AntiCheat.getPlugin(), 5); }.runTaskLater(AntiCheat.getPlugin(), 6);
} }
} }
} }
@@ -161,7 +162,7 @@ public class NPC_1_10 {
NPC_1_10.this.npc.setInvisible(true); NPC_1_10.this.npc.setInvisible(true);
((CraftPlayer) NPC_1_10.this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false)); ((CraftPlayer) NPC_1_10.this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
} }
}.runTaskLater(AntiCheat.getPlugin(), 5 + new Random().nextInt(5)); }.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(7));
} }
} }
@@ -175,7 +176,7 @@ public class NPC_1_10 {
NPC_1_10.this.npc.setInvisible(true); NPC_1_10.this.npc.setInvisible(true);
((CraftPlayer) NPC_1_10.this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false)); ((CraftPlayer) NPC_1_10.this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
} }
}.runTaskLater(AntiCheat.getPlugin(), 5 + new Random().nextInt(8)); }.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(8));
} }
} }