diff --git a/pom.xml b/pom.xml
index b35fe6c..ea24122 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,16 +11,6 @@
http://repo.bukkit.org/content/repositories/releases/
-
-
- jenkins
-
-
- env.BUILD_NUMBER
-
-
-
-
diff --git a/src/main/java/net/h31ix/anticheat/Anticheat.java b/src/main/java/net/h31ix/anticheat/Anticheat.java
index 179d9a1..cede415 100644
--- a/src/main/java/net/h31ix/anticheat/Anticheat.java
+++ b/src/main/java/net/h31ix/anticheat/Anticheat.java
@@ -10,9 +10,11 @@ import net.h31ix.anticheat.event.EntityListener;
import net.h31ix.anticheat.event.PlayerListener;
import net.h31ix.anticheat.manage.BowManager;
import net.h31ix.anticheat.manage.ItemManager;
+import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
public class Anticheat extends JavaPlugin {
+ //Define and initialize managers, used for various checks and tasks in the listeners.
public ChatManager cm = new ChatManager(this);
public AnimationManager am = new AnimationManager(this);
public ExemptManager ex = new ExemptManager(this);
@@ -20,13 +22,16 @@ public class Anticheat extends JavaPlugin {
public BowManager bm = new BowManager(this);
public HealthManager hm = new HealthManager();
public LoginManager lm = new LoginManager(this);
- public Configuration config;
- public PlayerTracker tracker;
+ //End Managers
+
+ public Configuration config;
+ public PlayerTracker tracker; //PlayerTracker for monitoring levels
private static final Logger l = Logger.getLogger("Minecraft");
private long lastTime = System.currentTimeMillis();
private long time = 0;
- public boolean lagged = false;
- public boolean log;
+ public boolean lagged = false;
+ public boolean logConsole;
+ public FileConfiguration log;
@Override
public void onDisable() {
@@ -37,10 +42,10 @@ public class Anticheat extends JavaPlugin {
if(!new File(this.getDataFolder()+"\\config.yml").exists())
{
this.saveDefaultConfig();
- }
+ }
config = new Configuration(this);
tracker = new PlayerTracker(this);
- log = config.logConsole;
+ logConsole = config.logConsole;
getServer().getPluginManager().registerEvents(new PlayerListener(this), this);
getServer().getPluginManager().registerEvents(new BlockListener(this), this);
@@ -66,7 +71,7 @@ public class Anticheat extends JavaPlugin {
public void log(String s)
{
- if(this.log)
+ if(this.logConsole)
{
l.log(Level.WARNING,"[AntiCheat] "+s);
}
diff --git a/src/main/java/net/h31ix/anticheat/Configuration.java b/src/main/java/net/h31ix/anticheat/Configuration.java
index 07b259a..856a15b 100644
--- a/src/main/java/net/h31ix/anticheat/Configuration.java
+++ b/src/main/java/net/h31ix/anticheat/Configuration.java
@@ -29,7 +29,7 @@ public class Configuration {
{
config.set("Logging.Log to console", b);
this.logConsole = b;
- plugin.log = b;
+ plugin.logConsole = b;
try {
config.save(configFile);
} catch (IOException ex) {
diff --git a/src/main/java/net/h31ix/anticheat/checks/EyeCheck.java b/src/main/java/net/h31ix/anticheat/checks/EyeCheck.java
index c22981e..13570f1 100644
--- a/src/main/java/net/h31ix/anticheat/checks/EyeCheck.java
+++ b/src/main/java/net/h31ix/anticheat/checks/EyeCheck.java
@@ -1,10 +1,8 @@
package net.h31ix.anticheat.checks;
-import java.util.HashSet;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.Block;
-import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class EyeCheck {
@@ -15,6 +13,7 @@ public class EyeCheck {
public boolean canSee(Player player, Block block)
{
+ //TODO: The logic here is NOT concrete, especially when looking down at an angle.
List blocks = player.getLineOfSight(null, 20);
Location bloc = block.getLocation();
boolean see = false;
diff --git a/src/main/java/net/h31ix/anticheat/checks/LengthCheck.java b/src/main/java/net/h31ix/anticheat/checks/LengthCheck.java
index 54fb461..95dcaad 100644
--- a/src/main/java/net/h31ix/anticheat/checks/LengthCheck.java
+++ b/src/main/java/net/h31ix/anticheat/checks/LengthCheck.java
@@ -4,7 +4,7 @@ import org.bukkit.Location;
public class LengthCheck {
Location l1, l2;
-
+ //Used for checking how far a player travels on an event and how far they are from another location
public LengthCheck(Location l1, Location l2)
{
this.l1 = l1;
diff --git a/src/main/java/net/h31ix/anticheat/event/BlockListener.java b/src/main/java/net/h31ix/anticheat/event/BlockListener.java
index 944a314..d796102 100644
--- a/src/main/java/net/h31ix/anticheat/event/BlockListener.java
+++ b/src/main/java/net/h31ix/anticheat/event/BlockListener.java
@@ -32,6 +32,7 @@ public class BlockListener implements Listener {
Block block = event.getBlock();
if(player != null)
{
+ //Check if an animation was done before this
if(!am.swungArm(player))
{
tracker.increaseLevel(player);
@@ -40,6 +41,7 @@ public class BlockListener implements Listener {
}
else
{
+ //If so, check the distance from the block. Is it too far away?
LengthCheck c = new LengthCheck(block.getLocation(),event.getPlayer().getLocation());
if(c.getXDifference() > 6.0D || c.getZDifference() > 6.0D || c.getYDifference() > 6.0D)
{
@@ -63,12 +65,16 @@ public class BlockListener implements Listener {
Block block = event.getBlock();
if(player != null)
{
+ //Check if the player can see the block they are placing
+ //This is mostly used for preventing build/autobuild hacks (Logic not yet finished)
if(!e.canSee(player, block) && !player.getWorld().getBlockAt(player.getLocation()).isLiquid())
{
- tracker.increaseLevel(player);
+ //TODO: this is causing false alerts. Re-work the vision logic?
+ //tracker.increaseLevel(player);
plugin.log(player.getName()+" tried to place a block that they couldn't see!");
event.setCancelled(true);
}
+ //Is the player too far away?
LengthCheck c = new LengthCheck(block.getLocation(),event.getPlayer().getLocation());
if(c.getXDifference() > 6.0D || c.getZDifference() > 6.0D || c.getYDifference() > 6.0D)
{
diff --git a/src/main/java/net/h31ix/anticheat/event/EntityListener.java b/src/main/java/net/h31ix/anticheat/event/EntityListener.java
index cbf7b4d..53c6d40 100644
--- a/src/main/java/net/h31ix/anticheat/event/EntityListener.java
+++ b/src/main/java/net/h31ix/anticheat/event/EntityListener.java
@@ -33,6 +33,7 @@ public class EntityListener implements Listener {
{
if(event.getEntity() instanceof Player)
{
+ //This mostly prevents bow spam, hopefully more auto-firing in the future
Player player = (Player)event.getEntity();
if(!bm.hasShot(player))
{
@@ -60,12 +61,16 @@ public class EntityListener implements Listener {
if(event.getEntity() instanceof Player)
{
Player player = (Player)event.getEntity();
+ //Being damaged causes the player to move really fast, usually triggering a warning and
+ //A teleport, so give them a grace period after damaging someone or being hit for recovery.
int time = 50;
if(p.getInventory().getItemInHand().getEnchantments().containsKey(Enchantment.KNOCKBACK))
{
+ //If they were hit using knockback supply double recovery time
time = 100;
}
ex.logHit(p,50);
+ //Make sure they are close enough to the entity to hit them
LengthCheck lc = new LengthCheck(event.getEntity().getLocation(),p.getLocation());
if(lc.getXDifference() > 5.0D || lc.getZDifference() > 5.0D || lc.getYDifference() > 4.3D)
{
diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java
index 9d5c25e..b698dc3 100644
--- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java
+++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java
@@ -47,6 +47,7 @@ public class PlayerListener implements Listener {
{
if(!lm.log())
{
+ //Make sure a player has not joined in the last .5th of a second
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Please do not flood the server!");
}
}
@@ -54,6 +55,7 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
+ //Disable zombe's mods
event.getPlayer().sendMessage("§f §f §1 §0 §2 §4");
event.getPlayer().sendMessage("§f §f §2 §0 §4 §8");
event.getPlayer().sendMessage("§f §f §4 §0 §9 §6");
@@ -65,6 +67,8 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
if(!im.hasDropped(player))
{
+ //Make sure the player isn't spamming drops
+ //For a normal user this is no big deal, but to hackers it gets rid of most of the items in their inventory
im.logDrop(player);
}
else
@@ -79,6 +83,7 @@ public class PlayerListener implements Listener {
{
if(event.getAnimationType() == PlayerAnimationType.ARM_SWING)
{
+ //Log animations for future checks
am.logAnimation(event.getPlayer());
}
}
@@ -88,6 +93,7 @@ public class PlayerListener implements Listener {
{
if(event.getEntered() instanceof Player)
{
+ //Give the player a grace period as they enter a vehicle, as they move very fast.
ex.logEnter((Player)event.getEntered());
}
}
@@ -97,6 +103,7 @@ public class PlayerListener implements Listener {
{
if(!plugin.lagged)
{
+ //Block command spamming (consider them chats)
plugin.cm.addChat(event.getPlayer());
}
}
@@ -107,11 +114,13 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
if(player.getLocation().equals(player.getWorld().getSpawnLocation()))
{
+ //Make sure the player is not a potential spambot
event.setCancelled(true);
player.sendMessage("Please move from spawn before speaking.");
}
if(!plugin.lagged)
{
+ //Block chat spamming
plugin.cm.addChat(player);
}
}
@@ -119,6 +128,7 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerKick(PlayerKickEvent event)
{
+ //Clear the player's chat level when they disconnect
plugin.cm.clear(event.getPlayer());
}
@@ -128,14 +138,18 @@ public class PlayerListener implements Listener {
Player player = event.getPlayer();
if(!plugin.lagged && !ex.isHit(player))
{
+ //Log the player's health level
hm.log(player);
+ //Get distances for hack checks.
LengthCheck c = new LengthCheck(event.getFrom(), event.getTo());
double xd = c.getXDifference();
double zd = c.getZDifference();
double yd = c.getYDifference();
Block p1 = player.getLocation().getWorld().getBlockAt(player.getLocation());
+ //Is the player in water?
if(p1.isLiquid())
{
+ //Are they using a boat? If so give them a bit more leniency
if (player.getVehicle() != null)
{
if(xd > 2.0D || zd > 2.0D)
@@ -146,6 +160,7 @@ public class PlayerListener implements Listener {
}
else if(xd > 0.19D || zd > 0.19D)
{
+ //Otherwise check for normal walking speeds, making sure they aren't using 'jesus' hacks
if(!player.isSprinting() && !player.isFlying())
{
tracker.increaseLevel(player);
@@ -155,6 +170,7 @@ public class PlayerListener implements Listener {
}
else
{
+ //If they are flying/sprinting give them a bit of slack
if(xd > 0.3D || zd > 0.3D)
{
tracker.increaseLevel(player);
@@ -165,8 +181,10 @@ public class PlayerListener implements Listener {
}
else
{
+ //Are they in a vehicle?
if (player.getVehicle() != null)
{
+ //If they are just entering it, skip the check. They are moving way too fast naturally.
if(!ex.isEntering(player))
{
if(xd > 0.6D || zd > 0.6D)
@@ -176,17 +194,21 @@ public class PlayerListener implements Listener {
event.setTo(event.getFrom().clone());
}
}
- }
+ }
+ //Otherwise, are they sneaking?
else if(player.isSneaking())
{
+ //Make sure they are at normal sneak speeds. (not using sneak hacks)
if(xd > 0.17D || zd > 0.17D)
{
tracker.increaseLevel(player);
plugin.log(player.getName()+" is sneaking too fast! XSpeed="+xd+" ZSpeed="+zd);
event.setTo(event.getFrom().clone());
+ //If they are, force them out of it.
player.setSneaking(false);
}
}
+ //Otherwise set a hardcoded limit to any other traveling
else if(xd > 0.32D || zd > 0.32D)
{
if(!player.isSprinting() && !player.isFlying())
@@ -197,6 +219,7 @@ public class PlayerListener implements Listener {
}
else
{
+ //If they are sprinting or flying give slack
if(xd > 0.62D || zd > 0.62D)
{
tracker.increaseLevel(player);
@@ -205,18 +228,22 @@ public class PlayerListener implements Listener {
}
}
}
+ //If the player is ascending
if(event.getFrom().getY() < event.getTo().getY())
{
//TODO: This is a little hacky. Any better way to figure this out?
+ //Are they climbing something?
if(yd <= 0.11761 && yd >= 0.11759)
{
if(player.getLocation().getBlock().getType() != Material.VINE && player.getLocation().getBlock().getType() != Material.LADDER)
{
+ //If it's not climbable, block it.
plugin.log(player.getName()+" tried to climb a wall!");
tracker.increaseLevel(player);
event.setTo(event.getFrom().clone());
}
}
+ //Otherwise check for fast ascension
else if(yd > 0.5D)
{
tracker.increaseLevel(player);
@@ -224,14 +251,17 @@ public class PlayerListener implements Listener {
event.setTo(event.getFrom().clone());
}
}
+ //If they are falling
if(event.getFrom().getY() > event.getTo().getY())
{
-
+ //Ignore players in creative or in vehicles, they give a fall distance of 0 naturally.
if(player.getGameMode() != GameMode.CREATIVE && player.getVehicle() == null)
{
hm.log(player);
+ //Log health (for nofall detection)
if(hm.checkFall(player))
{
+ //If the player is falling but has a 0 fall distance
plugin.log(player.getName()+" tried to avoid fall damage!");
tracker.increaseLevel(player);
}
diff --git a/src/main/java/net/h31ix/anticheat/manage/BowManager.java b/src/main/java/net/h31ix/anticheat/manage/BowManager.java
index fd301d9..7ae0dbf 100644
--- a/src/main/java/net/h31ix/anticheat/manage/BowManager.java
+++ b/src/main/java/net/h31ix/anticheat/manage/BowManager.java
@@ -29,6 +29,7 @@ public class BowManager {
public boolean hasShot(Player player)
{
+ //If the player has shot in the last .5 seconds
if(shot.get(player) == null || shot.get(player) == false)
{
return false;
diff --git a/src/main/java/net/h31ix/anticheat/manage/ExemptManager.java b/src/main/java/net/h31ix/anticheat/manage/ExemptManager.java
index 8e23a23..694c883 100644
--- a/src/main/java/net/h31ix/anticheat/manage/ExemptManager.java
+++ b/src/main/java/net/h31ix/anticheat/manage/ExemptManager.java
@@ -17,6 +17,7 @@ public class ExemptManager {
public void logEnter(final Player player)
{
+ //For ignoring players entering vehicles
enter.put(player, true);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
diff --git a/src/main/java/net/h31ix/anticheat/manage/HealthManager.java b/src/main/java/net/h31ix/anticheat/manage/HealthManager.java
index f486690..48a5691 100644
--- a/src/main/java/net/h31ix/anticheat/manage/HealthManager.java
+++ b/src/main/java/net/h31ix/anticheat/manage/HealthManager.java
@@ -21,6 +21,8 @@ public class HealthManager {
public boolean checkFall(Player player)
{
+ //Sometimes a player's fall distance is 0 when they reach the peak of their jump
+ //To combat false positives, the player must have 10 fall distance values of 0 in a row to trigger.
if(fall.get(player) == 0)
{
if(fallvl.get(player) == null)
diff --git a/src/main/java/net/h31ix/anticheat/manage/ItemManager.java b/src/main/java/net/h31ix/anticheat/manage/ItemManager.java
index c10f23c..4d06530 100644
--- a/src/main/java/net/h31ix/anticheat/manage/ItemManager.java
+++ b/src/main/java/net/h31ix/anticheat/manage/ItemManager.java
@@ -16,6 +16,7 @@ public class ItemManager {
public void logDrop(final Player player)
{
+ //Stop players from dropping blocks too fast.
drop.put(player, true);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
{
diff --git a/src/main/java/net/h31ix/anticheat/manage/LoginManager.java b/src/main/java/net/h31ix/anticheat/manage/LoginManager.java
index 5563348..841ab79 100644
--- a/src/main/java/net/h31ix/anticheat/manage/LoginManager.java
+++ b/src/main/java/net/h31ix/anticheat/manage/LoginManager.java
@@ -1,7 +1,6 @@
package net.h31ix.anticheat.manage;
import net.h31ix.anticheat.Anticheat;
-import org.bukkit.entity.Player;
public class LoginManager {
Anticheat plugin;
@@ -14,6 +13,7 @@ public class LoginManager {
public boolean log()
{
+ //Log players entering the server. Don't allow them to join way too fast.
if(join == true)
{
return false;