org.bukkit.entity.Player#isGliding ( )源码实例Demo

下面列出了org.bukkit.entity.Player#isGliding ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: RedProtect   文件: Compat19.java
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
    // Deny arrow booster
    Region r = RedProtect.get().rm.getTopRegion(e.getEntity().getLocation());
    if (r == null && e.getEntity() instanceof Player && e.getDamager() instanceof Arrow) {
        Player p = (Player) e.getEntity();
        Arrow arrow = (Arrow)e.getDamager();
        if (arrow.getShooter() instanceof Player && p.isGliding()) {
            if (arrow.getShooter().equals(p) && !p.hasPermission("redprotect.bypass.glide") &&
                    !RedProtect.get().config.globalFlagsRoot().worlds.get(p.getWorld().getName()).player_glide.allow_boost) {
                e.setCancelled(true);
                arrow.remove();
                RedProtect.get().lang.sendMessage(p, "globallistener.elytra.cantboost");
            }
        }
    }
}
 
源代码2 项目: MineTinker   文件: ShadowDive.java
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onSneak(PlayerToggleSneakEvent event) {
	Player player = event.getPlayer();
	if (!player.hasPermission("minetinker.modifiers.shadowdive.use")) return;

	ItemStack boots = player.getInventory().getBoots();
	if (!modManager.isArmorViable(boots)) return;
	if (!modManager.hasMod(boots, this)) return;

	if (event.isSneaking() && !player.isGliding()) { //enable
		Location loc = player.getLocation();
		byte lightlevel = player.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()).getLightLevel();
		boolean combatTagged = PlayerInfo.isCombatTagged(player);
		ChatWriter.logModifier(player, event, this, boots,
				String.format("LightLevel(%d/%d)", lightlevel, this.requiredLightLevel),
				String.format("InCombat(%b)", combatTagged));
		if (lightlevel > this.requiredLightLevel || player.hasPotionEffect(PotionEffectType.GLOWING)) {
			ChatWriter.sendActionBar(player, ChatColor.RED + this.getName() + ": "
					+ LanguageManager.getString("Modifier.Shadow-Dive.LightToHigh", player));
			return;
		}

		if (combatTagged) {
			ChatWriter.sendActionBar(player, ChatColor.RED + this.getName() + ": "
					+ LanguageManager.getString("Modifier.Shadow-Dive.InCombat", player));
			return;
		}

		hidePlayer(player);

	} else { //disable
		if (!activePlayers.contains(player)) return;
		showPlayer(player);
	}
}
 
private void handleValue(Player player, ForcedState state)
{
	if (state != null)
	{
		if (state == ForcedState.ALLOW)
		{
			return;
		}
		
		boolean value = (state == ForcedState.FORCE ? true : false);
		
		if (player.isGliding() != value)
		{
			if (this.originalGlide == null)
			{
				this.originalGlide = player.isGliding();
			}
			
			player.setGliding(value);
		}
	}
	else
	{
		if (this.originalGlide != null)
		{
			player.setGliding(this.originalGlide);
			
			this.originalGlide = null;
		}
	}
}
 
源代码4 项目: CombatLogX   文件: ListenerElytra.java
@EventHandler(priority=EventPriority.LOWEST, ignoreCancelled=true)
public void onTimerChange(PlayerCombatTimerChangeEvent e) {
    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    if(!config.getBoolean("items.prevent-elytra")) return;

    Player player = e.getPlayer();
    if(!player.isGliding()) return;

    player.setGliding(false);
    String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.elytra.force-disabled");
    this.plugin.sendMessage(player, message);
}
 
源代码5 项目: RedProtect   文件: Compat19.java
@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
    Player p = event.getPlayer();
    Block b = event.getClickedBlock();
    ItemStack itemInHand = event.getItem();

    Location l;

    if (b != null) {
        l = b.getLocation();
        RedProtect.get().logger.debug(LogLevel.DEFAULT, "PlayerListener - Is PlayerInteractEvent event. The block is " + b.getType().name());
    } else {
        l = p.getLocation();
    }

    if (RedProtect.get().tpWait.contains(p.getName())) {
        RedProtect.get().tpWait.remove(p.getName());
        RedProtect.get().lang.sendMessage(p, "cmdmanager.region.tpcancelled");
    }

    if (itemInHand != null && (event.getAction().name().equals("RIGHT_CLICK_BLOCK") || b == null)) {
        Material hand = itemInHand.getType();
        Region r = RedProtect.get().rm.getTopRegion(l);
        // Deny chorus teleport
        if (r != null && hand.equals(Material.CHORUS_FRUIT) && !r.canTeleport(p)) {
            RedProtect.get().lang.sendMessage(p, "playerlistener.region.cantuse");
            event.setCancelled(true);
            event.setUseItemInHand(Event.Result.DENY);
        }
        // Deny glide boost
        if (r == null && p.isGliding() && itemInHand.getType().name().contains("FIREWORK") && !p.hasPermission("redprotect.bypass.glide") &&
                !RedProtect.get().config.globalFlagsRoot().worlds.get(p.getWorld().getName()).player_glide.allow_boost) {
            event.setUseItemInHand(Event.Result.DENY);
            event.setCancelled(true);
            RedProtect.get().lang.sendMessage(p, "globallistener.elytra.cantboost");
        }
    }
}
 
源代码6 项目: NyaaUtils   文件: ElytraEnhanceListener.java
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void playerMove(PlayerMoveEvent e) {
    Player player = e.getPlayer();
    if (player.isGliding() &&
            plugin.cfg.elytra_enhance_enabled &&
            !plugin.cfg.disabled_world.contains(player.getWorld().getName()) &&
            player.getLocation().getBlock().isEmpty() &&
            player.getEyeLocation().getBlock().isEmpty() &&
            !disableFuelMode.contains(player.getUniqueId()) &&
            !player.isSneaking()) {
        if (!FuelMode.contains(player.getUniqueId()) &&
                player.getVelocity().length() >= 0.75 &&
                plugin.fuelManager.getFuelAmount(player, false) > 0) {
            FuelMode.add(player.getUniqueId());
        }
        if (duration.containsKey(player.getUniqueId()) &&
                duration.get(player.getUniqueId()) >= System.currentTimeMillis()) {
            player.setVelocity(player.getEyeLocation().getDirection().multiply(plugin.cfg.elytra_max_velocity));
        }
        if (FuelMode.contains(player.getUniqueId()) &&
                player.getVelocity().length() <= plugin.cfg.elytra_min_velocity &&
                player.getLocation().getBlockY() <= plugin.cfg.elytra_boost_max_height &&
                player.getLocation().getPitch() < 50) {
            if (player.getInventory().getChestplate() != null &&
                    player.getInventory().getChestplate().getType() == Material.ELYTRA) {
                int durability = player.getInventory().getChestplate().getType().getMaxDurability() -
                                         ((Damageable)player.getInventory().getChestplate().getItemMeta()).getDamage();
                if (durability <= plugin.cfg.elytra_durability_notify) {
                    player.sendMessage(I18n.format("user.elytra_enhance.durability_notify", durability));
                }
            }
            if (!plugin.fuelManager.useFuel(player)) {
                FuelMode.remove(player.getUniqueId());
                if (duration.containsKey(player.getUniqueId())) {
                    duration.remove(player.getUniqueId());
                }
                return;
            } else {
                duration.put(player.getUniqueId(), System.currentTimeMillis() + (plugin.cfg.elytra_power_duration * 1000));
                player.setVelocity(player.getEyeLocation().getDirection().multiply(plugin.cfg.elytra_max_velocity));
            }
            int fuelAmount = plugin.fuelManager.getFuelAmount(player, false);
            if (fuelAmount <= plugin.cfg.elytra_fuel_notify) {
                player.sendMessage(I18n.format("user.elytra_enhance.fuel_notify", fuelAmount));
            }
        }
        return;
    } else if (FuelMode.contains(player.getUniqueId())) {
        FuelMode.remove(player.getUniqueId());
    }
}