Java Code Examples for com.sk89q.worldguard.protection.ApplicableRegionSet#queryValue()

The following examples show how to use com.sk89q.worldguard.protection.ApplicableRegionSet#queryValue() . 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: Radiation.java    From CraftserveRadiation with Apache License 2.0 5 votes vote down vote up
@Override
public boolean test(Player player, RegionContainer regionContainer) {
    Location location = BukkitAdapter.adapt(player.getLocation());
    location = location.setY(Math.max(0, Math.min(255, location.getY())));
    ApplicableRegionSet regions = regionContainer.createQuery().getApplicableRegions(location);

    Boolean value = regions.queryValue(WorldGuardPlugin.inst().wrapPlayer(player), this.flag);
    return value != null && value;
}
 
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(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 3
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 4
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 5
Source File: HookWorldGuard_V6_2.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static boolean allowsTagging(Location location) {
    ApplicableRegionSet regions = getRegions(location);
    Boolean value = regions.queryValue(null, noTaggingFlag);
    return (value == null || !value);
}
 
Example 6
Source File: HookWorldGuard_V6_1.java    From CombatLogX with GNU General Public License v3.0 4 votes vote down vote up
public static boolean allowsTagging(Location location) {
    ApplicableRegionSet regions = getRegions(location);
    Boolean value = regions.queryValue(null, noTaggingFlag);
    return (value == null || !value);
}