DoubleJumpListener.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:Cardinal 作者:
/**
 * Cancels the player from flying and adds to the player's velocity.
 *
 * @param event The event called.
 */
@EventHandler
public void onPlayerToggleFly(PlayerToggleFlightEvent event) {
  Player player = event.getPlayer();
  UUID id = player.getUniqueId();
  KitDoubleJump.DoubleJumpData data = players.get(id);
  if (data != null && data.isEnabled() && players.containsKey(player.getUniqueId())
      && player.getExp() <= 1.0f && event.isFlying()) {
    player.setAllowFlight(false);
    player.setExp(0.0f);
    event.setCancelled(true);

    Vector normal = player.getEyeLocation().getDirection();
    normal.setY(0.75 + Math.max(normal.getY() * 0.5, 0));
    normal.multiply(data.getPower() / 2);
    event.getPlayer().setVelocity(normal);

    player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_INFECT, 0.5f, 1.8f);
  }

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号