Java Code Examples for org.bukkit.event.world.PortalCreateEvent#setCancelled()

The following examples show how to use org.bukkit.event.world.PortalCreateEvent#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: EntityListener.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPortalCreateEvent(PortalCreateEvent event)
{
	for(BlockState block : event.getBlocks())
	{
		ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
		if (regions.queryValue(null, Flags.NETHER_PORTALS) == State.DENY)
		{
			event.setCancelled(true);
			break;
		}
	}
}
 
Example 2
Source File: EntityListener.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPortalCreateEvent(PortalCreateEvent event)
{
	for(Block block : event.getBlocks())
	{
		//Unable to get the player who created it....
		
		ApplicableRegionSet regions = this.plugin.getWorldGuardCommunicator().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
		if (regions.queryValue(null, Flags.NETHER_PORTALS) == State.DENY)
		{
			event.setCancelled(true);
			break;
		}
	}
}
 
Example 3
Source File: PlayerListener.java    From civcraft with GNU General Public License v2.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST) 
public void onPortalCreate(PortalCreateEvent event) {
	event.setCancelled(true);
}