当前位置: 首页>>代码示例>>Java>>正文


Java PlayerVelocityEvent类代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerVelocityEvent的典型用法代码示例。如果您正苦于以下问题:Java PlayerVelocityEvent类的具体用法?Java PlayerVelocityEvent怎么用?Java PlayerVelocityEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PlayerVelocityEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerVelocityEvent类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlayerVelocity

import org.bukkit.event.player.PlayerVelocityEvent; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:15,代码来源:KnockBackListener.java

示例2: onPlayerVelocity

import org.bukkit.event.player.PlayerVelocityEvent; //导入依赖的package包/类
@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));
    }
}
 
开发者ID:DemigodsRPG,项目名称:Demigods3,代码行数:16,代码来源:FaultyBootsOfHermes.java

示例3: call

import org.bukkit.event.player.PlayerVelocityEvent; //导入依赖的package包/类
@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 */);

		}
	}

}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:54,代码来源:AntiVelocityA.java

示例4: onPlayerVelocity

import org.bukkit.event.player.PlayerVelocityEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerVelocity(PlayerVelocityEvent event) {
	final Player player = event.getPlayer();

	getCheckVersion(player, CheckType.ANTIVELOCITY, "A").call(event);
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:7,代码来源:DetectionListener.java

示例5: onVelocity

import org.bukkit.event.player.PlayerVelocityEvent; //导入依赖的package包/类
@EventHandler
public void onVelocity(PlayerVelocityEvent event) {
    Player player = event.getPlayer();
    MovingData data = MovingData.getData(player);
    data.getVelocityData().addVelocityTime(event.getVelocity());
}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:7,代码来源:MovingListener.java

示例6: Velocity

import org.bukkit.event.player.PlayerVelocityEvent; //导入依赖的package包/类
@EventHandler
public void Velocity(PlayerVelocityEvent event) {
    this.LastVelocity.put(event.getPlayer().getUniqueId(), new AbstractMap.SimpleEntry<Long, Vector>(System.currentTimeMillis(), event.getVelocity()));
}
 
开发者ID:cumpe,项目名称:Janitor,代码行数:5,代码来源:Janitor.java

示例7: doAntiKnockBackCheck

import org.bukkit.event.player.PlayerVelocityEvent; //导入依赖的package包/类
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);

    }
 
开发者ID:johnnywoof,项目名称:NoHack,代码行数:36,代码来源:CustomCheck.java


注:本文中的org.bukkit.event.player.PlayerVelocityEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。