本文整理汇总了Java中org.bukkit.entity.Player.isFlying方法的典型用法代码示例。如果您正苦于以下问题:Java Player.isFlying方法的具体用法?Java Player.isFlying怎么用?Java Player.isFlying使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.isFlying方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerMove
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
final Player player = event.getPlayer();
final Material from = event.getFrom().getBlock().getRelative(BlockFace.DOWN).getType();
final Behaviour behaviour = Profile.getProfile(player.getUniqueId()).getBehaviour();
final long current = System.currentTimeMillis();
if (player.isSprinting()) {
behaviour.getMotion().setLastSprint(current);
}
if (player.isFlying()) {
behaviour.getMotion().setLastFly(current);
}
if (from.isSolid() || behaviour.getMotion().getLastY() == -1.0 || !behaviour.getMotion().isDescending()) {
behaviour.getMotion().setLastY(player.getLocation().getY());
}
if (!behaviour.isOnGround()) {
behaviour.getMotion().setLastYDiff(event.getTo().getY() - event.getFrom().getY());
}
}
示例2: onPlayerFall
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPlayerFall(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player) || player.isFlying()
|| player.getVehicle() != null) {
return;
}
PlayerWrapper playerWrapper = InventoryManager.get(player);
boolean endFalling = false;
if (!player.isOnGround()) {
if (playerIsSneakOnLadder(player) || isPlayerCanFall(player)) {
playerWrapper.onFall();
} else if (!player.isGliding()) {
endFalling = true;
}
} else if (playerWrapper.isFalling()) {
endFalling = true;
}
if (endFalling) {
playerWrapper.setFalling(false);
}
}
示例3: checkAscension
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void checkAscension(Player player, double y1, double y2) {
int max = MagicNumbers.ASCENSION_COUNT_MAX;
if(player.hasPotionEffect(PotionEffectType.JUMP)) {
max += 12;
}
Block block = player.getLocation().getBlock();
if(!isMovingExempt(player) && !Utilities.isInWater(player) && !player.isFlying() && !Utilities
.isClimbableBlock(player.getLocation().getBlock()) && !player.isInsideVehicle() && !MOVE_UP_BLOCKS
.contains(player.getLocation().add(0,-1,0).getBlock().getType()) && !MOVE_UP_BLOCKS.contains(player
.getLocation().add(0,-1.5,0).getBlock().getType())) {
if(y1 < y2) {
if(!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.WEST).isLiquid()) {
incrementOld(player,ascensionCount,max);
if(ascensionCount.get(player) > max) {
for(Player pla : DynamicAC.instance.onlinestaff) {
pla.sendMessage(DynamicAC.prefix + player.getName() + " ascended Y Axis too fast!");
}
DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName
()),"Climbed too fast");
}
}
}
}
}
示例4: isPlayerExempt
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Check if the player is exempt.
*
* @param check the check
* @param player the check
* @return if we are exempted or not.
*/
public boolean isPlayerExempt(Player player, CheckType check) {
// check for common exemptions first.
boolean hasExemption = checkCommonExemptions(player, check);
if (hasExemption) {
return true;
}
// iterate through the array of checks that need to be exempted for if we are flying.
for (CheckType element : EXEMPT_BECAUSE_FLYING) {
if (!(element.equals(check))) {
continue;
}
if (Arc.COMPATIBILITY) {
hasExemption = player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight
() || player
.isFlying();
} else {
hasExemption = player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR || player
.getAllowFlight
() || player
.isFlying();
}
break;
}
return hasExemption;
}
示例5: checkYSpeed
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void checkYSpeed(Player player, double y) {
if(!isMovingExempt(player) && !player.isInsideVehicle() && (y > MagicNumbers.Y_SPEED_MAX) && !isDoing(player,
velocitized,MagicNumbers.VELOCITY_TIME) && !player.hasPotionEffect(PotionEffectType.JUMP) && !player
.isFlying()) {
for(Player pla : DynamicAC.instance.onlinestaff) {
pla.sendMessage(DynamicAC.prefix + player.getName() + " went too fast on the Y Axis!");
}
DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()),"Y axis");
}
}
示例6: checkSneak
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void checkSneak(Player player, double x, double z) {
if(player.isSneaking() && !player.isFlying() && !isMovingExempt(player) && !player.isInsideVehicle()) {
double i = x > MagicNumbers.XZ_SPEED_MAX_SNEAK ? x : z > MagicNumbers.XZ_SPEED_MAX_SNEAK ? z : -1.0;
if(i != -1.0) {
for(Player pla : DynamicAC.instance.onlinestaff) {
pla.sendMessage(DynamicAC.prefix + player.getName() + " failed Sneak Speed! (also a good " +
"indicator of Flight)");
}
DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()),
"Sneak Speed");
}
}
}
示例7: runCheck
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void runCheck(Player player, Distance distance) {
if (distance.getYDifference() > 400 || player.isFlying() || player.getGameMode().equals(GameMode.CREATIVE)) {
return; //This is to prevent a player using /fly getting AC'd
}
final double y1 = distance.fromY();
final double y2 = distance.toY();
if (!isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1) && Utilities
.cantStandAtExp(player.getLocation()) && Utilities.blockIsnt(player.getLocation().getBlock()
.getRelative(BlockFace.DOWN), new Material[]{Material.FENCE, Material.FENCE_GATE, Material
.COBBLE_WALL})) { //prevents fancy minecraft magicky crap
for(double i = player.getLocation().getY(); new Location(player.getWorld(),player
.getLocation().getX(),i,
player.getLocation().getZ()).getBlock().getType() != Material.AIR; i--) {
if(player.getVelocity().getY() >= 0 && player.getLocation()
.add(0,-2,0).getBlock().getType() != Material.AIR) {
repeated.put(player,repeated.containsKey(player)?repeated.put(player,repeated.get(player) + 1)
:repeated.put(player,1));
}
}
if (repeated.containsKey(player) && repeated.get(player) > MagicNumbers.MAX_FLY){
for (Player pla : DynamicAC.instance.onlinestaff) {
pla.sendMessage(DynamicAC.prefix + player.getName() + " failed Fly!");
}
DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()),
"Flight");
}
}
}
示例8: e
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@GameEvent
public void e(@Nonnull PlayerMoveEvent event) {
Player player = event.getPlayer();
if (player.getLocation().getBlock().getRelative(0, -1, 0).getType() != Material.AIR && (!player.isFlying())) {
player.setAllowFlight(true);
}
}
示例9: show
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void show(VPPlayer player) {
Player p = player.getPlayer();
Object nmsPlay = getNMSPlayer(p);
Object arrayPlayer = ReflectionUtils.getArrayOf(nmsPlayer, nmsPlay);
final ReflectionObject add = PacketUtils.craftPacket(PacketPlayOutPlayerInfo, addPlayerEnum.getClass(), arrayPlayer.getClass())
.instance(addPlayerEnum, arrayPlayer);
Object difficulty = ReflectionUtils.invoke(getDifficulty, enumDifficulty, player.getLocation().getWorld().getDifficulty().getValue());
Object type = ReflectionUtils.invoke("getType", worldType, player.getLocation().getWorld().getWorldType().getName());
Object gamemode = ReflectionUtils.invoke(getGamemode, enumGamemode, player.getGameMode().getValue());
final ReflectionObject respawn = PacketUtils.craftPacket(PacketPlayOutRespawn, int.class, difficulty.getClass(), type.getClass(), gamemode.getClass())
.instance(0, difficulty, type, gamemode);
boolean flying = p.isFlying();
Location location = player.getLocation();
int level = player.getLevel();
float xp = p.getExp();
double maxHealth = p.getMaxHealth();
double health = p.getHealth();
PacketUtils.sendPacket(respawn, player);
p.setFlying(flying);
player.teleport(location);
p.updateInventory();
player.setLevel(level);
p.setExp(xp);
p.setMaxHealth(maxHealth);
p.setHealth(health);
for(VPPlayer vp : VanillaPlusCore.getPlayerManager().getOnlinePlayers())
PacketUtils.sendPacket(add, vp);
}
示例10: updateSelf
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void updateSelf(VPPlayer player){
Player p = player.getPlayer();
Object nmsPlay = getNMSPlayer(p);
Object arrayPlayer = ReflectionUtils.getArrayOf(nmsPlayer, nmsPlay);
ReflectionObject del = PacketUtils.craftPacket(PacketPlayOutPlayerInfo, removePlayerEnum.getClass(), arrayPlayer.getClass())
.instance(removePlayerEnum, arrayPlayer);
final ReflectionObject add = PacketUtils.craftPacket(PacketPlayOutPlayerInfo, addPlayerEnum.getClass(), arrayPlayer.getClass())
.instance(addPlayerEnum, arrayPlayer);
Object difficulty = ReflectionUtils.invoke(getDifficulty, enumDifficulty, player.getLocation().getWorld().getDifficulty().getValue());
Object type = ReflectionUtils.invoke("getType", worldType, player.getLocation().getWorld().getWorldType().getName());
Object gamemode = ReflectionUtils.invoke(getGamemode, enumGamemode, player.getGameMode().getValue());
final ReflectionObject respawn = PacketUtils.craftPacket(PacketPlayOutRespawn, int.class, difficulty.getClass(), type.getClass(), gamemode.getClass())
.instance(0, difficulty, type, gamemode);
PacketUtils.sendPacket(del, player);
boolean flying = p.isFlying();
Location location = player.getLocation();
int level = player.getLevel();
float xp = p.getExp();
double maxHealth = p.getMaxHealth();
double health = p.getHealth();
PacketUtils.sendPacket(respawn, player);
p.setFlying(flying);
player.teleport(location);
p.updateInventory();
player.setLevel(level);
p.setExp(xp);
p.setMaxHealth(maxHealth);
p.setHealth(health);
PacketUtils.sendPacket(add, player);
}
示例11: call
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void call(Event event) {
// Causes false positives.
if (profile.getBehaviour().getMotion().isDescending()) {
return;
}
if (event instanceof PlayerMoveEvent) {
final Player player = profile.getPlayer();
if (player.getGameMode() == GameMode.SPECTATOR || player.isInsideVehicle()) {
/*
* If the player is in spectator mode, return out of the method
* as the speed function in this GameMode could cause false
* positives.
*/
return;
}
final PlayerMoveEvent pme = (PlayerMoveEvent) event;
final int speedLevel = profile.getBehaviour().getPotionEffectLevel(PotionEffectType.SPEED);
// Ignore if the player's speed is higher than two.
if (speedLevel > 2) {
return;
}
/*
* Ignore y for this check. We only want to check speed on the x and
* z axes.
*/
final Vector from = pme.getFrom().toVector().clone().setY(0.0),
to = pme.getTo().toVector().clone().setY(0.0);
double distance = to.distanceSquared(from);
if (speedLevel > 0) {
// Take into account speed potions.
distance -= (distance / 100.0) * (speedLevel * 20.0);
}
/*
* Walking and flying (but not sprinting): 0.40, Sprinting and
* flying: 1.25
*/
final long current = System.currentTimeMillis();
if ((player.isFlying() && player.isSprinting()) || (current
- profile.getBehaviour().getMotion().getLastFly() <= 500
&& current - profile.getBehaviour().getMotion()
.getLastSprint() <= 500) /*
* Player is flying and
* sprinting and flying
* or has been in the
* last half a second.
*/) {
callback(distance > 1.25);
} else {
callback(distance > 0.40);
}
}
}
示例12: getImminentDeath
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Get the cause of the player's imminent death, or null if they are not about to die
* NOTE: not idempotent, has the side effect of clearing the recentDamage cache
*/
public @Nullable ImminentDeath getImminentDeath(Player player) {
// If the player is already dead or in creative mode, we don't care
if(player.isDead() || player.getGameMode() == GameMode.CREATIVE) return null;
// If the player was on the ground, or is flying, or is able to fly, they are fine
if(!(player.isOnGround() || player.isFlying() || player.getAllowFlight())) {
// If the player is falling, detect an imminent falling death
double fallDistance = player.getFallDistance();
Block landingBlock = null;
int waterDepth = 0;
Location location = player.getLocation();
if(location.getY() > 256) {
// If player is above Y 256, assume they fell at least to there
fallDistance += location.getY() - 256;
location.setY(256);
}
// Search the blocks directly beneath the player until we find what they would have landed on
Block block = null;
for(; location.getY() >= 0; location.add(0, -1, 0)) {
block = location.getBlock();
if(block != null) {
landingBlock = block;
if(Materials.isWater(landingBlock.getType())) {
// If the player falls through water, reset fall distance and inc the water depth
fallDistance = -1;
waterDepth += 1;
// Break if they have fallen through enough water to stop falling
if(waterDepth >= BREAK_FALL_WATER_DEPTH) break;
} else {
// If the block is not water, reset the water depth
waterDepth = 0;
if(Materials.isColliding(landingBlock.getType()) || Materials.isLava(landingBlock.getType())) {
// Break if the player hits a solid block or lava
break;
} else if(landingBlock.getType() == Material.WEB) {
// If they hit web, reset their fall distance, but assume they keep falling
fallDistance = -1;
}
}
}
fallDistance += 1;
}
double resistanceFactor = getResistanceFactor(player);
boolean fireResistance = hasFireResistance(player);
// Now decide if the landing would have killed them
if(location.getBlockY() < 0) {
// The player would have fallen into the void
return new ImminentDeath(EntityDamageEvent.DamageCause.VOID, location, null, false);
} else if(landingBlock != null) {
if(Materials.isColliding(landingBlock.getType()) && player.getHealth() <= resistanceFactor * (fallDistance - SAFE_FALL_DISTANCE)) {
// The player would have landed on a solid block and taken enough fall damage to kill them
return new ImminentDeath(EntityDamageEvent.DamageCause.FALL, landingBlock.getLocation().add(0, 0.5, 0), null, false);
} else if (Materials.isLava(landingBlock.getType()) && resistanceFactor > 0 && !fireResistance) {
// The player would have landed in lava, and we give the lava the benefit of the doubt
return new ImminentDeath(EntityDamageEvent.DamageCause.LAVA, landingBlock.getLocation(), landingBlock, false);
}
}
}
// If we didn't predict a falling death, detect combat log due to recent damage
Damage damage = this.recentDamage.remove(player);
if(damage != null && damage.time.plus(RECENT_DAMAGE_THRESHOLD).isAfter(Instant.now())) {
// Player logged out too soon after taking damage
return new ImminentDeath(damage.event.getCause(), player.getLocation(), null, true);
}
return null;
}
示例13: onEntityDamageEvent
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
protected void onEntityDamageEvent(final EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) {
if ((!e.getDamager().hasMetadata("NPC") && SkyWarsReloaded.getPC().getPlayer(((Player) e.getDamager()).getUniqueId()).isSpectating()) || (!e.getEntity().hasMetadata("NPC") && SkyWarsReloaded.getPC().getPlayer(((Player) e.getEntity()).getUniqueId()).isSpectating())) {
e.setCancelled(true);
}
} else if (!(e.getEntity() instanceof Player) && e.getDamager() instanceof Player) {
if (!e.getDamager().hasMetadata("NPC") && SkyWarsReloaded.getPC().getPlayer(((Player) e.getDamager()).getUniqueId()).isSpectating()) {
e.setCancelled(true);
}
} else if (e.getEntity() instanceof Player && !(e.getDamager() instanceof Player)) {
if (!e.getEntity().hasMetadata("NPC") && SkyWarsReloaded.getPC().getPlayer(((Player) e.getEntity()).getUniqueId()).isSpectating()) {
e.setCancelled(true);
}
}
if(e.getDamager() instanceof Projectile
&& !(e.getDamager() instanceof ThrownPotion)
&& e.getEntity() instanceof Player
&& !e.getEntity().hasMetadata("NPC")
&& SkyWarsReloaded.getPC().getPlayer(((Player) e.getEntity()).getUniqueId()).isSpectating()) {
e.setCancelled(true);
e.getDamager().remove();
final Player spectatorInvolved = (Player) e.getEntity();
final boolean wasFlying = spectatorInvolved.isFlying();
final Location initialSpectatorLocation = spectatorInvolved.getLocation();
final Vector initialProjectileVelocity = e.getDamager().getVelocity();
final Location initialProjectileLocation = e.getDamager().getLocation();
final Projectile proj = (Projectile) e.getDamager();
if (spectatorInvolved != proj.getShooter()) {
spectatorInvolved.setAllowFlight(true);
spectatorInvolved.setFlying(true);
spectatorInvolved.teleport(initialSpectatorLocation.clone().add(0, 6, 0), TeleportCause.PLUGIN);
Bukkit.getScheduler().runTaskLater(SkyWarsReloaded.get(), new Runnable() {
@Override
public void run() {
if (proj instanceof Arrow) {
Arrow arrow = initialProjectileLocation.getWorld().spawn(initialProjectileLocation, Arrow.class);
arrow.setBounce(false);
arrow.setVelocity(initialProjectileVelocity);
arrow.setShooter(proj.getShooter());
} else if (proj instanceof Snowball) {
Snowball snowball = initialProjectileLocation.getWorld().spawn(initialProjectileLocation, Snowball.class);
snowball.setVelocity(initialProjectileVelocity);
snowball.setShooter(proj.getShooter());
} else if (proj instanceof Egg) {
Egg egg = initialProjectileLocation.getWorld().spawn(initialProjectileLocation, Egg.class);
egg.setVelocity(initialProjectileVelocity);
egg.setShooter(proj.getShooter());
} else if (proj instanceof EnderPearl) {
Player p = (Player) proj.getShooter();
p.launchProjectile(EnderPearl.class, initialProjectileVelocity);
}
}
}, 1L);
Bukkit.getScheduler().runTaskLater(SkyWarsReloaded.get(), new Runnable() {
@Override
public void run() {
spectatorInvolved.teleport(new Location(initialSpectatorLocation.getWorld(), initialSpectatorLocation.getX(), initialSpectatorLocation.getY(), initialSpectatorLocation.getZ(), spectatorInvolved.getLocation().getYaw(), spectatorInvolved.getLocation().getPitch()), TeleportCause.PLUGIN);
spectatorInvolved.setAllowFlight(true);
spectatorInvolved.setFlying(wasFlying);
}
}, 5L);
}
}
}
示例14: checkXZSpeed
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void checkXZSpeed(Player player, double x, double z) {
if(player.getVehicle() == null && !player.isFlying() && !Flight.movingExempt.containsKey(player)) {
String reason = "";
double max = 0.25;
if(player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
if(player.isSprinting()) {
reason = "on soulsand while sprinting";
max = 0.2;
} else if(player.hasPotionEffect(PotionEffectType.SPEED)) {
max = 0.16;
reason = "on soulsand with speed pot";
} else {
max = 0.13;
}
} else if(player.hasPotionEffect(PotionEffectType.SPEED)) {
if(player.isSprinting()) {
reason = "with speed pot while sprinting";
max = 0.95;
} else {
reason = "with speed pot";
max = 0.7;
}
} else if(player.isSprinting()) {
max = 0.65;
reason = "while sprinting";
}
float speed = player.getWalkSpeed();
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
if(x > max || z > max) {
speedViolation.put(player, speedViolation.containsKey(player) ? speedViolation.get(player) + 1 : 1);
if(speedViolation.get(player) > MagicNumbers.SPEED_MAX) {
for(Player pla : DynamicAC.instance.onlinestaff) {
pla.sendMessage(ChatColor.RED + "[DAC] " + ChatColor.GREEN + player.getName() + " failed " +
"Speed " + reason + "!");
}
DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()),
"Speed " + reason);
}
} else {
speedViolation.put(player, 0);
}
}
}
示例15: sprintFly
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static boolean sprintFly(Player player) {
return player.isSprinting() || player.isFlying();
}