mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Fix for bug #38, added ascension checking
This commit is contained in:
1 parent
517a12f339
commit
b8dd6b0f58
4 files changed
+38
-36
No files matched your search
@@ -56,6 +56,7 @@ public class Anticheat extends JavaPlugin
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
AnticheatManager.close();
|
||||
Map<String, Integer> map = manager.getPlayerManager().getLevels();
|
||||
Iterator<String> set = map.keySet().iterator();
|
||||
while (set.hasNext())
|
||||
|
||||
@@ -221,48 +221,21 @@ public class PlayerListener extends EventListener
|
||||
double x = distance.getXDifference();
|
||||
double y = distance.getYDifference();
|
||||
double z = distance.getZDifference();
|
||||
backend.checkAscension(player,from.getY(),to.getY());
|
||||
backend.logAscension(player,from.getY(),to.getY());
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance))
|
||||
{
|
||||
from.setX(from.getX()-1);
|
||||
from.setY(from.getY()-1);
|
||||
from.setZ(from.getZ()-1);
|
||||
event.setTo(from);
|
||||
//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);
|
||||
}
|
||||
Block lower = player.getWorld().getHighestBlockAt(from);
|
||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(),lower.getLocation().getY()+2,lower.getLocation().getZ()));
|
||||
log("tried to fly.",player,CheckType.FLY);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkYAxis(player, distance))
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && (backend.checkYAxis(player, distance) || backend.checkAscension(player,from.getY(),to.getY())))
|
||||
{
|
||||
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);
|
||||
}
|
||||
Block lower = player.getWorld().getHighestBlockAt(player.getLocation());
|
||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(),lower.getLocation().getY()+2,lower.getLocation().getZ()));
|
||||
log("tried to fly on y-axis", player, CheckType.FLY);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
||||
|
||||
@@ -125,4 +125,8 @@ public class AnticheatManager
|
||||
{
|
||||
return backend;
|
||||
}
|
||||
public static void close()
|
||||
{
|
||||
handler.close();
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,7 @@ public class Backend
|
||||
private static final int Y_MAXVIOTIME = 5000;
|
||||
private static final int NOFALL_LIMIT = 5;
|
||||
|
||||
private static final int ASCENSION_COUNT_MAX = 8;
|
||||
private static final int WATER_ASCENSION_VIOLATION_MAX = 13;
|
||||
private static final int WATER_SPEED_VIOLATION_MAX = 4;
|
||||
|
||||
@@ -119,6 +120,7 @@ public class Backend
|
||||
private List<String> instantBreakExempt = new ArrayList<String>();
|
||||
private List<String> isAscending = new ArrayList<String>();
|
||||
private List<String> trackingProjectiles = new ArrayList<String>();
|
||||
private Map<String,Integer> ascensionCount = new HashMap<String,Integer>();
|
||||
private Map<String,String> oldMessage = new HashMap<String,String>();
|
||||
private Map<String,String> lastMessage = new HashMap<String,String>();
|
||||
private Map<String,Integer> flightViolation = new HashMap<String,Integer>();
|
||||
@@ -375,7 +377,7 @@ public class Backend
|
||||
yAxisLastViolation.put(name, System.currentTimeMillis());
|
||||
if(g.getBlock().getTypeId() == 0)
|
||||
{
|
||||
player.teleport(g);
|
||||
player.teleport(g);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -463,16 +465,38 @@ public class Backend
|
||||
return false;
|
||||
}
|
||||
|
||||
public void checkAscension(Player player, double y1, double y2)
|
||||
public void logAscension(Player player, double y1, double y2)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(y1 < y2)
|
||||
{
|
||||
isAscending.add(player.getName());
|
||||
isAscending.add(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
isAscending.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkAscension(Player player, double y1, double y2)
|
||||
{
|
||||
if(!isMovingExempt(player))
|
||||
{
|
||||
String name = player.getName();
|
||||
if(y1 < y2)
|
||||
{
|
||||
increment(player, ascensionCount, ASCENSION_COUNT_MAX);
|
||||
if(ascensionCount.get(name) >= ASCENSION_COUNT_MAX)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ascensionCount.put(name,0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkSwing(Player player, Block block)
|
||||
|
||||
Reference in new issue
Block a user