本文整理汇总了Java中org.bukkit.entity.Player.getAllowFlight方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getAllowFlight方法的具体用法?Java Player.getAllowFlight怎么用?Java Player.getAllowFlight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.getAllowFlight方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doAction
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean doAction(Player player, Command command, String s, String[] args)
{
if (!SamaGamesAPI.get().getPermissionsManager().hasPermission(player, "hub.fly"))
{
player.sendMessage(PlayerManager.SETTINGS_TAG + ChatColor.RED + "Vous n'avez pas le grade nécéssaire pour utiliser cette commande.");
return true;
}
if (player.getGameMode() != GameMode.ADVENTURE || this.hub.getPlayerManager().isBusy(player))
{
player.sendMessage(PlayerManager.SETTINGS_TAG + ChatColor.RED + "Vous ne pouvez pas utiliser cette commande actuellement.");
return true;
}
boolean now = !player.getAllowFlight();
player.setAllowFlight(now);
if (now)
player.sendMessage(PlayerManager.SETTINGS_TAG + ChatColor.GREEN + "Vous pouvez maintenant voler.");
else
player.sendMessage(PlayerManager.SETTINGS_TAG + ChatColor.GREEN + "Vous ne pouvez plus voler.");
return true;
}
示例2: onBlockBreak
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void onBlockBreak(BlockPlaceEvent event) {
if (event.isCancelled()) {
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE || player.getAllowFlight()) {
return;
}
Block block = event.getBlockPlaced();
if (block.getType().isSolid() && !(block.getState() instanceof Sign)) {
int playerY = player.getLocation().getBlockY();
int blockY = block.getLocation().getBlockY();
if (playerY > blockY) {
Vector vector = player.getVelocity();
vector.setX(-0.1);
vector.setZ(-0.1);
player.setVelocity(vector.setY(vector.getY() - 0.41999998688697815D)); // Magic number acquired from EntityLiving#bj()
}
}
}
}
示例3: 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;
}
示例4: storeTemporaryInventory
import org.bukkit.entity.Player; //导入方法依赖的package包/类
void storeTemporaryInventory(Player player) {
final TemporaryPlayerStorage storage = new TemporaryPlayerStorage();
storage.armorContent = player.getInventory().getArmorContents().clone();
storage.isFlying = player.getAllowFlight();
storage.inventory = player.getInventory().getContents().clone();
storage.gameMode = player.getGameMode();
storage.level = player.getLevel();
storage.exp = player.getExp();
storage.health = player.getHealth();
storage.foodLevel = player.getFoodLevel();
storage.scoreboard = player.getScoreboard();
this.temporaryStorage.put(player, storage);
}
示例5: storeTemporaryInventory
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void storeTemporaryInventory(Player player) {
final TemporaryPlayerStorage storage = new TemporaryPlayerStorage();
storage.armorContent = player.getInventory().getArmorContents().clone();
storage.isFlying = player.getAllowFlight();
storage.inventory = player.getInventory().getContents().clone();
storage.gameMode = player.getGameMode();
storage.level = player.getLevel();
storage.exp = player.getExp();
storage.scoreboard = player.getScoreboard();
this.temporaryStorage.put(player, storage);
}
示例6: call
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void call(Event event) {
if (profile.getBehaviour().getPotionEffectLevel(PotionEffectType.SPEED) > 2) {
/*
* Potion effects above this level cause false positives. They're
* not available without the /effect command anyway.
*/
return;
}
if (event instanceof PlayerMoveEvent) {
final Player player = profile.getPlayer();
if (!profile.getBehaviour().isInCreativeOrSpectator() || !player.getAllowFlight()) {
final PlayerMoveEvent pme = (PlayerMoveEvent) event;
final double distanceSquared = pme.getTo().toVector().distanceSquared(pme.getFrom().toVector());
/*
* If the player isn't on the ground (they could be walking),
* check if the block above the player is air and the player has
* not fallen.
*
* If so, they are using fly cheats.
*/
if (!profile.getBehaviour().isOnGround()
&& profile.getBehaviour().getBlockAbovePlayer().getType() == Material.AIR
&& !profile.getBehaviour().getMotion().isDescending()) {
if (startTime == -1) {
startTime = System.currentTimeMillis();
return;
}
/*
* Rough values for what this should be. Normal: 350, Jump
* Boost I: 250, Jump Boost II: Same as Normal.
*/
final long timeInAir = System.currentTimeMillis() - startTime;
int allowed = 0;
final int jumpBoostLevel = profile.getBehaviour().getPotionEffectLevel(PotionEffectType.JUMP);
if (jumpBoostLevel == 0 || jumpBoostLevel == 2) {
allowed = 350;
} else if (jumpBoostLevel == 1) {
allowed = 250;
} else {
return;
}
/*
* I roughly measured jumping as 0.25 as a vector squared
* between the to and from points.
*
* Here, 0.30 is being used to avoid false positives.
*/
if (distanceSquared > 0.30 && timeInAir > allowed) {
callback(true);
}
} else {
startTime = System.currentTimeMillis();
}
}
}
}
示例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;
}