Java Code Examples for org.bukkit.entity.Player#isGliding()

The following examples show how to use org.bukkit.entity.Player#isGliding() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Compat19.java    From RedProtect with GNU General Public License v3.0 6 votes vote down vote up
@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");
            }
        }
    }
}
 
Example 2
Source File: ShadowDive.java    From MineTinker with GNU General Public License v3.0 5 votes vote down vote up
@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);
	}
}
 
Example 3
Source File: GlideFlagHandler.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
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;
		}
	}
}
 
Example 4
Source File: ListenerElytra.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 5
Source File: Compat19.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@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");
        }
    }
}
 
Example 6
Source File: ElytraEnhanceListener.java    From NyaaUtils with MIT License 4 votes vote down vote up
@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());
    }
}