Finally patched the cocky Y-axis fly.

This commit is contained in:
Super Spy committed 2012-05-25 19:07:36 -05:00
1 parent ae41d9c21e
commit c7ee0d9661
2 files changed
+92

No files matched your search

@@ -197,6 +197,31 @@ public class PlayerListener extends EventListener
}
log("tried to fly.",player,CheckType.FLY);
}
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkDoomsOfTheYHeckers(player)) {
from.setX(from.getX()-1);
from.setY(from.getY()-1);
from.setZ(from.getZ()-1);
if(from.getBlock().getTypeId() == 0)
event.setTo(from);
for(int i= 5;i>0;i--)
{
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-i, player.getLocation().getZ());
Block lower = newLocation.getBlock();
if(lower.getTypeId() == 0)
{
player.teleport(newLocation);
break;
}
}
//Lets really give this flyer a real pushdown.
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-2, player.getLocation().getZ());
Block newBlock = newLocation.getBlock();
if(newBlock.getTypeId() != 0)
{
event.setTo(newLocation);
}
log("tried to fly on y-axis", player, CheckType.FLY); //cause he's poor.
}
if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
{
if(event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y))
@@ -56,6 +56,10 @@ public class Backend
private static final int CHAT_BAN_LEVEL = 3;
public static final int FLIGHT_LIMIT = 4;
public static final int FLIGHT_MINIMUM = 1;
public static final int FLIGHT_TIMELIMIT = 5000;
public static final int Y_MAXVIOLATIONS = 1;
public static final int Y_MAXVIOTIME = 5000;
public static final int NOFALL_LIMIT = 5;
public static final int SPRINT_FOOD_MIN = 6;
@@ -75,6 +79,8 @@ public class Backend
public static final double LADDER_Y_MIN = 0.11759;
public static final double Y_SPEED_MAX = 0.5;
public static final double Y_MAXDIFF = 5;
public static final double Y_TIME = 1000;
public static final double XZ_SPEED_MAX = 0.4;
public static final double XZ_SPEED_MAX_SPRINT = 0.65;
public static final double XZ_SPEED_MAX_SNEAK = 0.2;
@@ -99,6 +105,10 @@ public class Backend
private Map<String,Integer> chatKicks = new HashMap<String,Integer>();
private Map<String,Integer> nofallViolation = new HashMap<String,Integer>();
private Map<String,Integer> fastBreakViolation = new HashMap<String,Integer>();
private Map<String,Integer> YaxisViolations = new HashMap<String,Integer>();
private Map<String,Long> YaxisLastVio = new HashMap<String,Long>();
private Map<String,Double> lastYcoord = new HashMap<String,Double>();
private Map<String,Long> lastYtime = new HashMap<String,Long>();
private Map<String,Integer> blocksBroken = new HashMap<String,Integer>();
private Map<String,Long> lastBlockBroken = new HashMap<String,Long>();
private Map<String,Integer> fastPlaceViolation = new HashMap<String,Integer>();
@@ -235,6 +245,63 @@ public class Backend
return false;
}
public boolean checkDoomsOfTheYHeckers(Player player) {
double y1 = player.getLocation().getY();
String name = player.getName();
//Fix Y axis spam.
if(!lastYcoord.containsKey(name) || !lastYtime.containsKey(name)
|| !YaxisViolations.containsKey(name) || !YaxisLastVio.containsKey(name))
{
lastYcoord.put(name, y1);
YaxisViolations.put(name, 0);
YaxisLastVio.put(name, 0L);
lastYtime.put(name, System.currentTimeMillis());
}
else
{
if(y1 > lastYcoord.get(name) && YaxisViolations.get(name) > Y_MAXVIOLATIONS
&& (System.currentTimeMillis() - YaxisLastVio.get(name)) < Y_MAXVIOTIME)
{
Location g = player.getLocation();
g.setY(lastYcoord.get(name));
player.sendMessage(ChatColor.RED + "[AntiCheat] Fly hacking on the y-axis detected. Please wait 5 seconds to prevent getting damage.");
YaxisViolations.put(name, YaxisViolations.get(name)+1);
YaxisLastVio.put(name, System.currentTimeMillis());
if(g.getBlock().getTypeId() == 0)
player.teleport(g);
return true;
}
else
{
if(YaxisViolations.get(name) > Y_MAXVIOLATIONS
&& (System.currentTimeMillis() - YaxisLastVio.get(name)) > Y_MAXVIOTIME) {
YaxisViolations.put(name, 0);
YaxisLastVio.put(name, 0L);
}
}
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF && (System.currentTimeMillis() - lastYtime.get(name)) < Y_TIME)
{
Location g = player.getLocation();
g.setY(lastYcoord.get(name));
YaxisViolations.put(name, YaxisViolations.get(name)+1);
YaxisLastVio.put(name, System.currentTimeMillis());
if(g.getBlock().getTypeId() == 0)
player.teleport(g);
return true;
}
else
{
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF + 1 || (System.currentTimeMillis() - lastYtime.get(name)) > Y_TIME)
{
lastYtime.put(name, System.currentTimeMillis());
lastYcoord.put(name, y1);
}
}
}
//Fix Y axis spam
return false;
}
public boolean checkFlight(Player player, double y1, double y2)
{
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);