org.bukkit.event.block.BlockPhysicsEvent#setCancelled ( )源码实例Demo

下面列出了org.bukkit.event.block.BlockPhysicsEvent#setCancelled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AreaShop   文件: SignsFeature.java
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onIndirectSignBreak(BlockPhysicsEvent event) {
	// Check if the block is a sign
	if(!Materials.isSign(event.getBlock().getType())) {
		return;
	}

	// Check if still attached to a block
	Block attachedBlock = plugin.getBukkitHandler().getSignAttachedTo(event.getBlock());
	// TODO: signs cannot be placed on all blocks, improve this check to isSolid()?
	if (attachedBlock.getType() != Material.AIR) {
		return;
	}

	// Check if the sign is really the same as a saved rent
	RegionSign regionSign = SignsFeature.getSignByLocation(event.getBlock().getLocation());
	if(regionSign == null) {
		return;
	}

	// Remove the sign so that it does not fall on the floor as an item (next region update will place it back when possible)
	AreaShop.debug("onIndirectSignBreak: Removed block of sign for", regionSign.getRegion().getName(), "at", regionSign.getStringLocation());
	event.getBlock().setType(Material.AIR);
	event.setCancelled(true);
}
 
源代码2 项目: Shopkeepers   文件: SignShopListener.java
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
void onBlockPhysics(BlockPhysicsEvent event) {
	Block block = event.getBlock();
	if (cancelNextBlockPhysicsLoc != null && cancelNextBlockPhysicsLoc.equals(block.getLocation())) {
		event.setCancelled(true);
	} else {
		if (Utils.isSign(block.getType()) && plugin.getShopkeeperByBlock(block) != null) {
			event.setCancelled(true);
		}
	}
}
 
源代码3 项目: GriefDefender   文件: BlockEventHandler.java
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockNotify(BlockPhysicsEvent event) {
    final Block source = NMSUtil.getInstance().getSourceBlock(event);
    if (source == null) {
        return;
    }

    final Location sourceLocation = source.getLocation();
    if (sourceLocation != null && sourceLocation.equals(event.getBlock().getLocation())) {
        return;
    }

    final GDPermissionUser user = CauseContextHelper.getEventUser(sourceLocation);
    final Location location = event.getBlock().getLocation();
    if (user == null) {
        return;
    }

    final World world = event.getBlock().getWorld();
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) {
        return;
    }

    final GDPlayerData playerData =  GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(world, user.getUniqueId());
    final GDClaim sourceClaim = this.storage.getClaimAt(sourceLocation);
    final Vector3i pos = VecHelper.toVector3i(location);
    final GDClaim targetClaim = this.storage.getClaimAt(location);
    if (sourceClaim.isWilderness() && targetClaim.isWilderness()) {
        if (playerData != null) {
            playerData.eventResultCache = new EventResultCache(targetClaim, "block-notify", Tristate.TRUE);
        }

        return;
    } else if (!sourceClaim.isWilderness() && targetClaim.isWilderness()) {
        if (playerData != null) {
            playerData.eventResultCache = new EventResultCache(targetClaim, "block-notify", Tristate.TRUE);
        }

        return;
    } // Redstone sources can end up in target
    else if (sourceClaim.getUniqueId().equals(targetClaim.getUniqueId())) {
        if (playerData != null) {
            playerData.eventResultCache = new EventResultCache(targetClaim, "block-notify", Tristate.TRUE);
        }

        return;
    } else {
        if (playerData.eventResultCache != null && playerData.eventResultCache.checkEventResultCache(targetClaim) == Tristate.TRUE) {
            return;
        }
        // Needed to handle levers notifying doors to open etc.
        if (targetClaim.isUserTrusted(user, TrustTypes.ACCESSOR)) {
            if (playerData != null) {
                playerData.eventResultCache = new EventResultCache(targetClaim, "block-notify", Tristate.TRUE);
            }
            return;
        }
    }

    event.setCancelled(true);
}
 
源代码4 项目: ProjectAres   文件: BlockPhysicsListener.java
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) {
    if(!allowPhysics()) {
        event.setCancelled(true);
    }
}
 
源代码5 项目: ProjectAres   文件: EnvironmentControlListener.java
@EventHandler(priority = EventPriority.HIGH)
public void physics(final BlockPhysicsEvent event) {
    event.setCancelled(true);
}
 
源代码6 项目: DungeonsXL   文件: GlobalProtectionListener.java
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockPhysics(BlockPhysicsEvent event) {
    if (DPortal.getByBlock(plugin, event.getBlock()) != null) {
        event.setCancelled(true);
    }
}
 
源代码7 项目: FunnyGuilds   文件: BlockPhysics.java
@EventHandler
public void onPhysics(BlockPhysicsEvent event) {
    if (GuildHeartProtectionHandler.isGuildHeart(event.getBlock())) {
        event.setCancelled(true);
    }
}
 
源代码8 项目: CardinalPGM   文件: WorldFreeze.java
@EventHandler
public void onBlockPysics(BlockPhysicsEvent event) {
    if (!match.isRunning()) {
        event.setCancelled(true);
    }
}
 
源代码9 项目: CardinalPGM   文件: BlockEventRegion.java
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) {
    if (region.contains(new BlockRegion(null, event.getBlock().getLocation().toVector())) && filter.evaluate(event.getBlock(), event).equals(FilterState.DENY)) {
        event.setCancelled(true);
    }
}