Java 类org.bukkit.event.player.PlayerVelocityEvent 实例源码

项目:HCFCore    文件:KnockBackListener.java   
@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);
    }
}
项目:Demigods3    文件:FaultyBootsOfHermes.java   
@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));
    }
}
项目:Crescent    文件:AntiVelocityA.java   
@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 */);

        }
    }

}
项目:Crescent    文件:DetectionListener.java   
@EventHandler
public void onPlayerVelocity(PlayerVelocityEvent event) {
    final Player player = event.getPlayer();

    getCheckVersion(player, CheckType.ANTIVELOCITY, "A").call(event);
}
项目:Arc-v2    文件:MovingListener.java   
@EventHandler
public void onVelocity(PlayerVelocityEvent event) {
    Player player = event.getPlayer();
    MovingData data = MovingData.getData(player);
    data.getVelocityData().addVelocityTime(event.getVelocity());
}
项目:Janitor    文件:Janitor.java   
@EventHandler
public void Velocity(PlayerVelocityEvent event) {
    this.LastVelocity.put(event.getPlayer().getUniqueId(), new AbstractMap.SimpleEntry<Long, Vector>(System.currentTimeMillis(), event.getVelocity()));
}
项目:NoHack    文件:CustomCheck.java   
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);

    }