Fixed descending waterfalls (or climbing out of them to get air) and a few logging issues.

This commit is contained in:
h31ix committed 2012-09-29 14:43:29 -04:00
1 parent 077f67f900
commit 9253a93fe0
4 files changed
+47 -33

No files matched your search

@@ -77,16 +77,25 @@ public class AnticheatManager
fileLogger.setUseParentHandlers(false); fileLogger.setUseParentHandlers(false);
fileLogger.addHandler(fileHandler); fileLogger.addHandler(fileHandler);
} }
public void log(String message) public void log(String message)
{
log(message, 0);
}
public void log(String message, int i)
{ {
if (getConfiguration().logConsole()) if (getConfiguration().logConsole())
{ {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED+message); Bukkit.getConsoleSender().sendMessage(ChatColor.RED+message);
} }
if (getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH) if(i == 0 && getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH) // Not an alert, normal log message
{ {
fileLog(ChatColor.stripColor(message)); fileLog(message);
}
else if(getConfiguration().getFileLogLevel() != 0)// alert
{
fileLog(message);
} }
logs.add(ChatColor.stripColor(message)); logs.add(ChatColor.stripColor(message));
} }
@@ -103,9 +112,9 @@ public class AnticheatManager
{ {
return logs; return logs;
} }
for(int i = 1; i < 31; i++) for(int i = logs.size()-1; i >= 0; i--)
{ {
log.add(logs.get(logs.size() - i)); log.add(logs.get(i));
} }
logs.clear(); logs.clear();
return log; return log;
@@ -591,39 +591,42 @@ public class Backend
String name = player.getName(); String name = player.getName();
int y1 = (int)distance.fromY(); int y1 = (int)distance.fromY();
int y2 = (int)distance.toY(); int y2 = (int)distance.toY();
if(!isMovingExempt(player) && (y1 == y2 || y1 < y2) && !Utilities.isInWater(player) && !Utilities.canStand(player.getLocation().getBlock()) && Utilities.cantStandAt(player.getLocation().add(0, -1, 0).getBlock()) && Utilities.cantStandAt(player.getLocation().add(0, -2, 0).getBlock())) if(!isMovingExempt(player) && !Utilities.isInWater(player) && !Utilities.canStand(player.getLocation().getBlock()) && Utilities.cantStandAt(player.getLocation().add(0, -1, 0).getBlock()) && Utilities.cantStandAt(player.getLocation().add(0, -2, 0).getBlock()))
{ {
Block block = player.getLocation().getBlock(); Block block = player.getLocation().getBlock();
//Check if the player is climbing up water. //Check if the player is climbing up water.
if(block.getRelative(BlockFace.NORTH).isLiquid() || block.getRelative(BlockFace.SOUTH).isLiquid() || block.getRelative(BlockFace.EAST).isLiquid() || block.getRelative(BlockFace.WEST).isLiquid()) if(block.getRelative(BlockFace.NORTH).isLiquid() || block.getRelative(BlockFace.SOUTH).isLiquid() || block.getRelative(BlockFace.EAST).isLiquid() || block.getRelative(BlockFace.WEST).isLiquid())
{ {
//Even if they are using a hacked client and flying next to water to abuse this, they can't be go past the speed limit so they might as well swim if(y1 < y2)
return distance.getYDifference() > magic.WATER_CLIMB_MAX; {
//Even if they are using a hacked client and flying next to water to abuse this, they can't be go past the speed limit so they might as well swim
return distance.getYDifference() > magic.WATER_CLIMB_MAX;
}
} }
//Check if the player is crouching on slabs else if(y1 == y2 || y1 < y2)
if(player.isSneaking())
{ {
if(block.getRelative(BlockFace.NORTH).getTypeId() == 43 || block.getRelative(BlockFace.NORTH).getTypeId() == 44 || block.getRelative(BlockFace.SOUTH).getTypeId() == 43 || block.getRelative(BlockFace.SOUTH).getTypeId() == 44 || block.getRelative(BlockFace.EAST).getTypeId() == 43 || block.getRelative(BlockFace.EAST).getTypeId() == 44 || block.getRelative(BlockFace.WEST).getTypeId() == 43 || block.getRelative(BlockFace.WEST).getTypeId() == 44) //Check if the player is crouching on slabs
if(player.isSneaking())
{
if(block.getRelative(BlockFace.NORTH).getTypeId() == 43 || block.getRelative(BlockFace.NORTH).getTypeId() == 44 || block.getRelative(BlockFace.SOUTH).getTypeId() == 43 || block.getRelative(BlockFace.SOUTH).getTypeId() == 44 || block.getRelative(BlockFace.EAST).getTypeId() == 43 || block.getRelative(BlockFace.EAST).getTypeId() == 44 || block.getRelative(BlockFace.WEST).getTypeId() == 43 || block.getRelative(BlockFace.WEST).getTypeId() == 44)
{
return false;
}
}
int violation = flightViolation.containsKey(name) ? flightViolation.get(name)+1 : 1;
increment(player, flightViolation, violation);
if(violation > magic.FLIGHT_LIMIT)
{
return true;
}
else
{ {
return false; return false;
} }
} }
int violation = flightViolation.containsKey(name) ? flightViolation.get(name)+1 : 1;
increment(player, flightViolation, violation);
if(violation > magic.FLIGHT_LIMIT)
{
return true;
}
else
{
return false;
}
}
else
{
flightViolation.put(name, 0);
return false;
} }
flightViolation.put(name, 0);
return false;
} }
public void logAscension(Player player, double y1, double y2) public void logAscension(Player player, double y1, double y2)
@@ -80,19 +80,14 @@ public class User
if(level == med) if(level == med)
{ {
Anticheat.getManager().getUserManager().alertMed(this, type); Anticheat.getManager().getUserManager().alertMed(this, type);
return true;
} }
else if(level == high) else if(level == high)
{ {
Anticheat.getManager().getUserManager().alertHigh(this, type); Anticheat.getManager().getUserManager().alertHigh(this, type);
// Prevent the player from going over the high limit // Prevent the player from going over the high limit
level = high-10; level = high-10;
return true;
}
else
{
return true;
} }
return true;
} }
} }
@@ -52,6 +52,13 @@ public final class Utilities
Anticheat.getManager().log(msg); Anticheat.getManager().log(msg);
} }
} }
if (Anticheat.getManager().getConfiguration().getFileLogLevel() != 0)
{
for (String msg : message)
{
Anticheat.getManager().log(msg, 1);
}
}
} }
public static boolean cantStandAt(Block block) public static boolean cantStandAt(Block block)