@EventHandler(priority = EventPriority.HIGH)
public void onPlayerVelocity(PlayerVelocityEvent event) {
Player player = event.getPlayer();
EntityDamageEvent lastDamage = player.getLastDamageCause();
if (lastDamage == null || !(lastDamage instanceof EntityDamageByEntityEvent)) {
return;
}
// Cancel the vanilla knockback
if (((EntityDamageByEntityEvent) lastDamage).getDamager() instanceof Player) {
event.setCancelled(true);
}
}
java类org.bukkit.event.player.PlayerVelocityEvent的实例源码
KnockBackListener.java 文件源码
项目:HCFCore
阅读 24
收藏 0
点赞 0
评论 0
FaultyBootsOfHermes.java 文件源码
项目:Demigods3
阅读 27
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerVelocity(PlayerVelocityEvent event) {
if (Zones.inNoDemigodsZone(event.getPlayer().getLocation()) || Zones.inNoBuildZone(event.getPlayer(), event.getPlayer().getLocation()))
return;
// Define variables
Player player = event.getPlayer();
if (player.getInventory().getBoots() != null && Items.areEqualIgnoreEnchantments(ITEM, player.getInventory().getBoots())) {
Vector victor = event.getVelocity();
event.setVelocity(new Vector(victor.getX() + 1, victor.getX() + 1, victor.getX() + 1));
player.setVelocity(new Vector(7, 7, 7));
}
}
AntiVelocityA.java 文件源码
项目:Crescent
阅读 22
收藏 0
点赞 0
评论 0
@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 */);
}
}
}
DetectionListener.java 文件源码
项目:Crescent
阅读 26
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerVelocity(PlayerVelocityEvent event) {
final Player player = event.getPlayer();
getCheckVersion(player, CheckType.ANTIVELOCITY, "A").call(event);
}
MovingListener.java 文件源码
项目:Arc-v2
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler
public void onVelocity(PlayerVelocityEvent event) {
Player player = event.getPlayer();
MovingData data = MovingData.getData(player);
data.getVelocityData().addVelocityTime(event.getVelocity());
}
Janitor.java 文件源码
项目:Janitor
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler
public void Velocity(PlayerVelocityEvent event) {
this.LastVelocity.put(event.getPlayer().getUniqueId(), new AbstractMap.SimpleEntry<Long, Vector>(System.currentTimeMillis(), event.getVelocity()));
}
CustomCheck.java 文件源码
项目:NoHack
阅读 26
收藏 0
点赞 0
评论 0
public void doAntiKnockBackCheck(NoHack nh, PlayerVelocityEvent event) {
final UUID uuid = event.getPlayer().getUniqueId();
final XYZ old = new XYZ(event.getPlayer().getLocation());
final XYZ expected = new XYZ(event.getPlayer().getLocation());
nh.getServer().getScheduler().runTaskLater(nh, new Runnable() {
@Override
public void run() {
Player p = Bukkit.getPlayer(uuid);
if (p != null) {
if (Settings.debug) {
p.sendMessage("Old Location: " + old.toString());
p.sendMessage("New Location: " + new XYZ(p.getLocation()).toString());
p.sendMessage("Expected Location: " + expected.toString());
p.sendMessage("Distance (NEW): " + old.getDistanceSqrd(new XYZ(p.getLocation())));
}
}
p = null;
}
}, 10);
}