Java Code Examples for org.bukkit.event.block.EntityBlockFormEvent#setCancelled()

The following examples show how to use org.bukkit.event.block.EntityBlockFormEvent#setCancelled() . 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: BlockListener.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onEntityBlockFormEvent(EntityBlockFormEvent event)
{
	if (SupportedFeatures.isFrostwalkerSupported())
	{
		BlockState newState = event.getNewState();
		if (newState.getType() == Material.FROSTED_ICE)
		{
			ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(newState.getLocation());
			
			Entity entity = event.getEntity();
			if (entity instanceof Player)
			{
				Player player = (Player)entity;
				if (WorldGuardUtils.queryValue(player, player.getWorld(), regions.getRegions(), Flags.FROSTWALKER) == State.DENY)
				{
					event.setCancelled(true);
				}
			}
			else
			{
				if (regions.queryValue(null, Flags.FROSTWALKER) == State.DENY)
				{
					event.setCancelled(true);
				}
			}
		}
	}
}
 
Example 2
Source File: PetEntityListener.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockForm(EntityBlockFormEvent event) {
    Entity e = event.getEntity();
    if (plugin.isPet(e) && event.getNewState().getType().equals(Material.SNOW)) {
        event.setCancelled(true);
        event.getNewState().setType(Material.AIR);
    }
}
 
Example 3
Source File: EntityListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPlayerFrostWalk(EntityBlockFormEvent e) {
    if (e.getEntity() instanceof Player) {
        return;
    }
    RedProtect.get().logger.debug(LogLevel.ENTITY, "EntityListener - EntityBlockFormEvent");
    Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
    if (r != null && !r.canIceForm()) {
        e.setCancelled(true);
    }
}
 
Example 4
Source File: PlayerListener.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onPlayerFrostWalk(EntityBlockFormEvent e) {
    if (!(e.getEntity() instanceof Player)) {
        return;
    }
    RedProtect.get().logger.debug(LogLevel.PLAYER, "PlayerListener - EntityBlockFormEvent canceled? " + e.isCancelled());
    Player p = (Player) e.getEntity();
    Region r = RedProtect.get().rm.getTopRegion(e.getBlock().getLocation());
    if (r != null && e.getNewState().getType().name().contains("FROSTED_ICE") && !r.canIceForm(p)) {
        e.setCancelled(true);
    }
}
 
Example 5
Source File: IslandGuard1_9.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handles Frost Walking on visitor's islands
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onBlockForm(final EntityBlockFormEvent e) {
    if (e.getEntity() instanceof Player && e.getNewState().getType().equals(Material.FROSTED_ICE)) {
        Player player= (Player) e.getEntity();
        if (!IslandGuard.inWorld(player)) {
            return;
        }
        if (player.isOp()) {
            return;
        }
        // This permission bypasses protection
        if (VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        // Check island
        Island island = plugin.getGrid().getIslandAt(player.getLocation());
        if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.PLACE_BLOCKS)) {
            return;
        }
        if (island !=null) {
            if (island.getMembers().contains(player.getUniqueId()) || island.getIgsFlag(SettingsFlag.PLACE_BLOCKS)) {
                return;
            }
        }
        // Silently cancel the event
        e.setCancelled(true);
    }
}
 
Example 6
Source File: PetEntityListener.java    From EchoPet with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockForm(EntityBlockFormEvent event) {
    Entity e = event.getEntity();
    if (ReflectionUtil.getEntityHandle(e) instanceof IEntityPet && event.getNewState().getType().equals(Material.SNOW)) {
        event.setCancelled(true);
        event.getNewState().setType(Material.AIR);
    }
}
 
Example 7
Source File: LivingEntityShopListener.java    From Shopkeepers with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(ignoreCancelled = true)
void onEntityBlockForm(EntityBlockFormEvent event) {
	if (plugin.isShopkeeper(event.getEntity())) {
		event.setCancelled(true);
	}
}