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

The following examples show how to use org.bukkit.entity.Player#setGliding() . 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: EntityListenerOnePointNine.java    From WorldGuardExtraFlagsPlugin with MIT License 6 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onEntityToggleGlideEvent(EntityToggleGlideEvent event)
{
	Entity entity = event.getEntity();
	if (entity instanceof Player)
	{
		Player player = (Player)entity;
		
		ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(player.getLocation());

		ForcedState state = WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.GLIDE);
		if (state != ForcedState.ALLOW)
		{
			event.setCancelled(true);
			
			player.setGliding(state == ForcedState.FORCE);
			
			if (state == ForcedState.DENY)
			{
				player.teleport(player.getLocation());
			}
		}
	}
}
 
Example 2
Source File: ListenerElytra.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority= EventPriority.HIGH, ignoreCancelled=true)
public void onToggleGlide(EntityToggleGlideEvent e) {
    if(!e.isGliding()) return;

    FileConfiguration config = this.expansion.getConfig("cheat-prevention.yml");
    if(!config.getBoolean("items.prevent-elytra")) return;

    Entity entity = e.getEntity();
    if(!(entity instanceof Player)) return;

    Player player = (Player) entity;
    ICombatManager combatManager = this.plugin.getCombatManager();
    if(!combatManager.isInCombat(player)) return;

    e.setCancelled(true);
    player.setGliding(false);

    String message = this.plugin.getLanguageMessageColoredWithPrefix("cheat-prevention.elytra.no-gliding");
    this.plugin.sendMessage(player, message);
}
 
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);
}