diff --git a/pom.xml b/pom.xml
index 2712fc0..946f9f1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,6 +10,11 @@
bukkit-repo
http://repo.bukkit.org/content/repositories/public/
+
+ comphenix-rep
+ Comphenix Repository
+ http://repo.comphenix.net/content/groups/public
+
${basedir}/src/main/java
@@ -52,7 +57,7 @@
org.bukkit
bukkit
- 1.6.2-R0.1-SNAPSHOT
+ 1.6.4-R0.1-SNAPSHOT
jar
compile
@@ -63,6 +68,11 @@
jar
test
+
+ com.comphenix.protocol
+ ProtocolLib
+ 2.7.0
+
@@ -70,4 +80,4 @@
file:///var/lib/jenkins/repo
-
\ No newline at end of file
+
diff --git a/src/main/java/net/h31ix/anticheat/AntiCheat.java b/src/main/java/net/h31ix/anticheat/AntiCheat.java
index 1b65c92..d5f89af 100644
--- a/src/main/java/net/h31ix/anticheat/AntiCheat.java
+++ b/src/main/java/net/h31ix/anticheat/AntiCheat.java
@@ -18,17 +18,15 @@
package net.h31ix.anticheat;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
+import com.comphenix.protocol.ProtocolLibrary;
import net.h31ix.anticheat.config.Configuration;
import net.h31ix.anticheat.event.*;
import net.h31ix.anticheat.manage.AnticheatManager;
+import net.h31ix.anticheat.manage.PacketManager;
import net.h31ix.anticheat.manage.User;
import net.h31ix.anticheat.update.Updater;
import net.h31ix.anticheat.util.Utilities;
@@ -49,6 +47,8 @@ public class AntiCheat extends JavaPlugin {
private static boolean verbose;
private static boolean developer;
private static final long XRAY_TIME = 1200;
+ private static PacketManager packetManager;
+ private static boolean protocolLib = false;
@Override
public void onEnable() {
@@ -65,6 +65,7 @@ public class AntiCheat extends JavaPlugin {
setupEvents();
setupCommands();
setupUpdater();
+ setupProtocol();
restoreLevels();
// Check if NoCheatPlus is installed
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
@@ -93,6 +94,16 @@ public class AntiCheat extends JavaPlugin {
cleanup();
}
+ private void setupProtocol() {
+ if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
+ protocolLib = true;
+ packetManager = new PacketManager(ProtocolLibrary.getProtocolManager(), this, manager);
+ if (verbose) {
+ getLogger().log(Level.INFO, "Hooked into ProtocolLib");
+ }
+ }
+ }
+
private void setupXray() {
final XRayTracker xtracker = manager.getXRayTracker();
if (config.getConfig().logXRayStats.getValue()) {
@@ -198,6 +209,10 @@ public class AntiCheat extends JavaPlugin {
developer = b;
}
+ public static boolean isUsingProtocolLib() {
+ return protocolLib;
+ }
+
public static void debugLog(final String string) {
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
public void run() {
diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java
index 9829e70..381b7b9 100644
--- a/src/main/java/net/h31ix/anticheat/manage/Backend.java
+++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java
@@ -915,6 +915,7 @@ public class Backend {
}
public void logAnimation(final Player player) {
+ System.out.println("Log animation");
animated.put(player.getName(), System.currentTimeMillis());
increment(player, blockPunches, magic.BLOCK_PUNCH_MIN);
itemInHand.put(player.getName(), player.getItemInHand().getType());
diff --git a/src/main/java/net/h31ix/anticheat/manage/PacketManager.java b/src/main/java/net/h31ix/anticheat/manage/PacketManager.java
new file mode 100644
index 0000000..616c444
--- /dev/null
+++ b/src/main/java/net/h31ix/anticheat/manage/PacketManager.java
@@ -0,0 +1,37 @@
+package net.h31ix.anticheat.manage;
+
+import com.comphenix.protocol.Packets;
+import com.comphenix.protocol.ProtocolManager;
+import com.comphenix.protocol.events.*;
+import net.h31ix.anticheat.AntiCheat;
+
+public class PacketManager {
+
+ private ProtocolManager protocolManager;
+ private AntiCheat plugin;
+ private AnticheatManager manager;
+
+ public PacketManager(ProtocolManager protocolManager, AntiCheat plugin, AnticheatManager manager) {
+ this.protocolManager = protocolManager;
+ this.plugin = plugin;
+ this.manager = manager;
+ addListeners();
+ }
+
+ private void addListeners() {
+ // Arm Animation
+ protocolManager.addPacketListener(new PacketAdapter(plugin,
+ ConnectionSide.CLIENT_SIDE,
+ ListenerPriority.NORMAL,
+ Packets.Client.ARM_ANIMATION) {
+
+ @Override
+ public void onPacketReceiving(PacketEvent event) {
+ if (event.getPacketID() == Packets.Client.ARM_ANIMATION) {
+ PacketContainer packet = event.getPacket();
+ //System.out.println("Arm animation from "+packet.getIntegers().read(0));
+ }
+ }
+ });
+ }
+}
diff --git a/src/main/java/net/h31ix/anticheat/manage/User.java b/src/main/java/net/h31ix/anticheat/manage/User.java
index cb5be9e..f0dbef3 100644
--- a/src/main/java/net/h31ix/anticheat/manage/User.java
+++ b/src/main/java/net/h31ix/anticheat/manage/User.java
@@ -33,6 +33,7 @@ import java.util.*;
public class User {
private final String name;
+ private final int id;
private int level = 0;
private Location goodLocation;
private List inventorySnapshot = null;
@@ -59,6 +60,7 @@ public class User {
public User(String name, int level) {
this.name = name;
this.level = level;
+ this.id = getPlayer().getEntityId();
}
/**
@@ -70,6 +72,15 @@ public class User {
return name;
}
+ /**
+ * Get the player's entity ID
+ *
+ * @return Entity id
+ */
+ public int getId() {
+ return id;
+ }
+
/**
* Get the Bukkit player
*
@@ -164,7 +175,7 @@ public class User {
if (goodLocation == null) {
return location;
}
-
+
return goodLocation;
}
@@ -178,7 +189,7 @@ public class User {
if (Utilities.cantStandAtExp(location) || (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location))) {
return false;
}
-
+
goodLocation = location;
return true;
}
diff --git a/src/main/java/net/h31ix/anticheat/update/Updater.java b/src/main/java/net/h31ix/anticheat/update/Updater.java
index 2243503..43b1546 100644
--- a/src/main/java/net/h31ix/anticheat/update/Updater.java
+++ b/src/main/java/net/h31ix/anticheat/update/Updater.java
@@ -1,12 +1,14 @@
/*
* Updater for Bukkit.
*
- * This class provides the means to safetly and easily update a plugin, or check to see if it is updated using dev.bukkit.org
+ * This class provides the means to safely and easily update a plugin, or check to see if it is updated using dev.bukkit.org
*/
package net.h31ix.anticheat.update;
import java.io.*;
+import java.lang.Runnable;
+import java.lang.Thread;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -51,7 +53,7 @@ public class Updater
private File file; // The plugin's file
private Thread thread; // Updater thread
private static final String DBOUrl = "http://dev.bukkit.org/server-mods/"; // Slugs will be appended to this to get to the project's RSS feed
- private String [] noUpdateTag = {"-DEV","-PRE"}; // If the version number contains one of these, don't update.
+ private String [] noUpdateTag = {"-DEV","-PRE","-SNAPSHOT"}; // If the version number contains one of these, don't update.
private static final int BYTE_SIZE = 1024; // Used for downloading files
private String updateFolder = YamlConfiguration.loadConfiguration(new File("bukkit.yml")).getString("settings.update-folder"); // The folder that downloads will be placed in
private Updater.UpdateResult result = Updater.UpdateResult.SUCCESS; // Used for determining the outcome of the update process
@@ -186,7 +188,7 @@ public class Updater
try {
thread.join();
} catch (InterruptedException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ e.printStackTrace();
}
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 3a013f9..7a113a2 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,9 +1,9 @@
-author: H31IX
+author: Gravity
database: false
description: Prevention of hacks and other malicious tinkering on a Minecraft server.
main: net.h31ix.anticheat.AntiCheat
name: AntiCheat
-softdepend: [AntiCheat]
+softdepend: [ProtocolLib]
startup: postworld
url: http://gravitydevelopment.net
version: ${project.version}-b${BUILD_NUMBER}
@@ -11,7 +11,7 @@ commands:
anticheat:
description: Control and view info about AntiCheat
usage: /anticheat help
- aliases: anti
+ aliases: [anti, ac]
permissions:
anticheat.alert:
description: Get alerts