Java源码示例:org.bukkit.event.weather.LightningStrikeEvent

示例1
@EventHandler(ignoreCancelled = true)
public void onLightning(LightningStrikeEvent e) {
    RedProtect.get().logger.debug(LogLevel.BLOCKS, "BlockListener - Is LightningStrikeEvent event");
    Location l = e.getLightning().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    if (r != null && !r.canFire()) {
        e.setCancelled(true);
    }
}
 
示例2
@EventHandler(ignoreCancelled = true)
void onLightningStrike(LightningStrikeEvent event) {
	// workaround: preventing lightning strikes near villager shopkeepers
	// because they would turn into witches
	Location loc = event.getLightning().getLocation();
	for (Entity entity : Utils.getNearbyEntities(loc, VILLAGER_ZAP_RADIUS, EntityType.VILLAGER)) {
		if (plugin.isShopkeeper(entity)) {
			event.setCancelled(true);
		}
	}
}
 
示例3
@EventHandler
public void onLightningStrike(LightningStrikeEvent event) {
    event.setCancelled(true);
}