@Override
public void call(Event event) {
final Behaviour behaviour = profile.getBehaviour();
/*
* Thanks Eyremba for identifying these sources of false positives :D
* (https://github.com/Eyremba).
*/
if (behaviour.isOnLadder() || behaviour.isInWeb() || behaviour.getHeightOfSpace() <= 2) {
return;
}
if (event instanceof PlayerVelocityEvent) {
final PlayerVelocityEvent pve = (PlayerVelocityEvent) event;
final Player player = pve.getPlayer();
final double originalY = player.getLocation().getY();
final double ticksToMove = (Math.pow(profile.getPing(), 2.0) + 50.0) / 20.0;
final double expectedYVel = pve.getVelocity().getY();
// If the player is supposed to move a bit, check if they actually
// do so!
if (expectedYVel > 0.1) {
// Check a little later.
new BukkitRunnable() {
// Number of ticks that have been counted so far.
int time = 0;
@Override
public void run() {
time++;
final double current = player.getLocation().getY() - originalY;
if (current > expectedYVel || expectedYVel - current < 0.20) {
callback(false);
cancel();
return;
}
if (time > ticksToMove) {
callback(true);
cancel();
return;
}
}
}.runTaskTimer(Crescent.getInstance(), 0L,
1L /* Check every tick */);
}
}
}
AntiVelocityA.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:Crescent
作者:
评论列表
文章目录