本文整理汇总了Java中org.bukkit.entity.Player.getFallDistance方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getFallDistance方法的具体用法?Java Player.getFallDistance怎么用?Java Player.getFallDistance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.getFallDistance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: check
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void check(Player player, MovingData data) {
if (data.getGroundLocation() == null) {
return;
}
Location location = data.getCurrentLocation();
Location ground = data.getGroundLocation();
double toGround = LocationHelper.distanceVertical(ground, location);
boolean isDescending = toGround >= 3.0 && data.isDescending() && !data.isOnGround();
// make sure we meet the req.
if (isDescending && !data.isClimbing()) {
boolean ccOnGround = data.isFlyingClientOnGround();
// we're not on ground but the client is?
if (ccOnGround && player.getFallDistance() == 0.0) {
boolean cancel = checkViolation(player, "Fall distance is 0 while not onGround. (Client faked)");
// if we cancel damage the player. (not accurate)
// TODO: Make accurate
if (cancel) {
player.damage(toGround);
}
}
}
}
示例2: checkNoFall
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void checkNoFall(Player player) {
if(player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping() && !Utilities.isInWater(player) && !Utilities.isInWeb(player) && !isMovingExempt
(player)) {
if(player.getFallDistance() == 0) {
if(nofallViolation.get(player) == null) {
nofallViolation.put(player,1);
} else {
nofallViolation.put(player, nofallViolation.get(player) + 1);
}
int i = nofallViolation.get(player);
if(i >= MagicNumbers.NOFALL_LIMIT) {
for(Player pla : DynamicAC.instance.onlinestaff) {
pla.sendMessage(DynamicAC.prefix + player.getName() + " failed No Fall!");
}
DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()),
"No Fall");
}
} else {
nofallViolation.put(player,0);
}
}
}
示例3: isCritical
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* @return Whether the hit is a critical hit or not.
*/
private boolean isCritical() {
final Player player = profile.getPlayer();
final Behaviour behaviour = profile.getBehaviour();
return player.getFallDistance() > 0.0 && !behaviour.isOnLadder() && !behaviour.isOnVine()
&& !behaviour.isInWater() && !player.hasPotionEffect(PotionEffectType.BLINDNESS)
&& !player.isInsideVehicle() && !player.isSprinting() && !((Entity) player).isOnGround();
}
示例4: isCritical
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Check if an attack was a critical.
*
* @param player the player
* @return true, if the attack was registered as a critical.
*/
public static boolean isCritical(Player player) {
boolean onGround = ((Entity) player).isOnGround();
return !onGround && player.getFallDistance() > 0.0F && !LocationHelper.isInLiquid(player.getLocation())
&& (player.getLocation().getBlock().getType() != Material.LADDER
|| player.getLocation().getBlock().getType() != Material.VINE)
&& player.getVehicle() == null && !player.hasPotionEffect(PotionEffectType.BLINDNESS);
}
示例5: isCritical
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static boolean isCritical(Player player) {
Location location = player.getLocation();
location.setY(player.getLocation().getY() -2);
return player.getFallDistance() > 0.0f && player.getLocation().getY() % 1 != 0 && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS) && !Utilities.isHoveringOverWater(location) &&
player
.getEyeLocation()
.getBlock()
.getType
() !=
Material
.LADDER;
}
示例6: onPacket
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void onPacket(Player player, Channel channel, Packet packet, EnumPacket.EnumPacketDirection networkDirection)
{
VirtualPlayer vPlayer = VirtualPlayer.getVirtualPlayer(player);
if (packet instanceof PacketPlayer)
{
String packetName = packet.getClass().getSimpleName();
vPlayer.increasePacketCounter(packetName);
}
else if (packet instanceof PacketBlockDig)
{
PacketBlockDig dig = (PacketBlockDig) packet;
// Check FastBow
if (dig.getStatus().equals(PacketBlockDig.DigType.RELEASE_USE_ITEM))
{
Vector posVec = dig.getPosition();
// Check if the packet is correct (BlockPos(0, 0, 0), Facing=DOWN)
if (posVec.getX() == 0 && posVec.getY() == 0 && posVec.getZ() == 0 && dig.getDirection().equals(Direction.DOWN))
{
Object lastPacket = vPlayer.getData("lastPacket-PFB");
// Possible packet overflow (FastBow?)
if (lastPacket != null && lastPacket instanceof PacketPlayer)
{
PacketPlayer packetPlayer = (PacketPlayer) lastPacket;
// You can't be on the air and have a fallDistance of 0, you are cheating, FastBow confirmed!
if (player.getFallDistance() <= 0 && !packetPlayer.isOnGround())
{
Integer i = vPlayer.getDataOrDefault("fastbow-alert", 0);
Boolean alreadyAlerted = vPlayer.getDataOrDefault("fastbow-alreadyAlerted", false);
if (i > 20 && !alreadyAlerted)
{
// Async, get the instance
samaritan.getPunishmentsManager().automaticBan(player, EnumCheat.FASTBOW, new BasicCheatLog(player, EnumCheat.FASTBOW));
vPlayer.setData("fastbow-alreadyAlerted", true);
}
else
{
i++;
vPlayer.setData("fastbow-alert", i);
}
}
}
}
// A normal client doesn't do that!
else
{
// TODO: Increase hack possibility percent or ignore (Maybe this will be used in the future by hacked client)
}
}
}
vPlayer.setData("lastPacket-PFB", packet);
}
示例7: 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;
}