Java 类org.bukkit.event.weather.LightningStrikeEvent 实例源码

项目:SpigotSource    文件:WorldServer.java   
public boolean strikeLightning(Entity entity) {
    // CraftBukkit start
    LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity());
    this.getServer().getPluginManager().callEvent(lightning);

    if (lightning.isCancelled()) {
        return false;
    }
    // CraftBukkit end
    if (super.strikeLightning(entity)) {
        this.server.getPlayerList().sendPacketNearby((EntityHuman) null, entity.locX, entity.locY, entity.locZ, 512.0D, dimension, new PacketPlayOutSpawnEntityWeather(entity)); // CraftBukkit - Use dimension
        return true;
    } else {
        return false;
    }
}
项目:Shopkeepers    文件:LivingEntityShopListener.java   
@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);
        }
    }
}
项目:Recreator    文件:StructureConductor.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void light(LightningStrikeEvent evt) {
    Location target = evt.getLightning().getLocation();
    World world = target.getWorld();

    for (Location each : locs) {
        if (each.getWorld() != world) return;

        Block self = world.getBlockAt(each);
        if (self == null) {
            locs.remove(target);
            return;
        }
        Structure s = StructureChangeListener.match(self);
        if (s == null || !(s instanceof StructureConductor)) {
            locs.remove(target);
            return;
        }

        if (target.distance(each) <= 50) {
            evt.setCancelled(true);
            world.strikeLightning(each);
        }
    }
}
项目:CraftBukkit    文件:WorldServer.java   
public boolean strikeLightning(Entity entity) {
    // CraftBukkit start
    LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity());
    this.getServer().getPluginManager().callEvent(lightning);

    if (lightning.isCancelled()) {
        return false;
    }

    if (super.strikeLightning(entity)) {
        this.server.getPlayerList().sendPacketNearby(entity.locX, entity.locY, entity.locZ, 512.0D, this.dimension, new PacketPlayOutSpawnEntityWeather(entity));
        // CraftBukkit end
        return true;
    } else {
        return false;
    }
}
项目:Almura-Server    文件:WorldServer.java   
public boolean strikeLightning(Entity entity) {
    // CraftBukkit start
    LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity());
    this.getServer().getPluginManager().callEvent(lightning);

    if (lightning.isCancelled()) {
        return false;
    }

    if (super.strikeLightning(entity)) {
        this.server.getPlayerList().sendPacketNearby(entity.locX, entity.locY, entity.locZ, 512.0D, this.dimension, new Packet71Weather(entity));
        // CraftBukkit end
        return true;
    } else {
        return false;
    }
}
项目:Tweakkit-Server    文件:WorldServer.java   
public boolean strikeLightning(Entity entity) {
    // CraftBukkit start
    LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity());
    this.getServer().getPluginManager().callEvent(lightning);

    if (lightning.isCancelled()) {
        return false;
    }

    if (super.strikeLightning(entity)) {
        this.server.getPlayerList().sendPacketNearby(entity.locX, entity.locY, entity.locZ, 512.0D, this.dimension, new PacketPlayOutSpawnEntityWeather(entity));
        // CraftBukkit end
        return true;
    } else {
        return false;
    }
}
项目:Cauldron    文件:WorldServer.java   
public boolean addWeatherEffect(Entity p_72942_1_)
{
    // Cauldron start - vanilla compatibility
    if (p_72942_1_ instanceof net.minecraft.entity.effect.EntityLightningBolt) 
    {
        // CraftBukkit start
        LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) p_72942_1_.getBukkitEntity());
        this.getServer().getPluginManager().callEvent(lightning);

        if (lightning.isCancelled())
        {
            return false;
        }
        // CraftBukkit end
    }
    // Cauldron end
    if (super.addWeatherEffect(p_72942_1_))
    {
        this.mcServer.getConfigurationManager().sendToAllNear(p_72942_1_.posX, p_72942_1_.posY, p_72942_1_.posZ, 512.0D, this.provider.dimensionId, new S2CPacketSpawnGlobalEntity(p_72942_1_));
        return true;
    }
    else
    {
        return false;
    }
}
项目:Craft-city    文件:WorldServer.java   
public boolean strikeLightning(Entity entity) {
    // CraftBukkit start
    LightningStrikeEvent lightning = new LightningStrikeEvent(this.getWorld(), (org.bukkit.entity.LightningStrike) entity.getBukkitEntity());
    this.getServer().getPluginManager().callEvent(lightning);

    if (lightning.isCancelled()) {
        return false;
    }

    if (super.strikeLightning(entity)) {
        this.server.getPlayerList().sendPacketNearby(entity.locX, entity.locY, entity.locZ, 512.0D, this.dimension, new Packet71Weather(entity));
        // CraftBukkit end
        return true;
    } else {
        return false;
    }
}
项目:Essentials    文件:EssentialsProtectWeatherListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onLightningStrike(final LightningStrikeEvent event)
{
    final ProtectHolder settings = prot.getSettings();

    if (!event.isCancelled() && settings.getData().isDisableLighting())
    {
        event.setCancelled(true);
    }
}
项目:UltimateSpawn    文件:BasicFeatures.java   
@EventHandler
public void onLightNing(LightningStrikeEvent e) {
    if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.LightningStrike.Disable")) {
        if (!ConfigGServerEvent.getConfig().getBoolean("Server.Disable.LightningStrike.World.All_World")) {
            if (WorldUtils.getWLS().contains(e.getLightning().getWorld().getName())) {
                e.setCancelled(true);
            }
        } else {
            e.setCancelled(true);
        }
    }
}
项目:CanaryBukkit    文件:CanaryWorldListener.java   
@HookHandler(priority = Priority.CRITICAL)
public void onLightningStrike(final LightningStrikeHook hook) {
    server.getPluginManager().callEvent(
            new LightningStrikeEvent(new CanaryWorld(hook.getLightningBolt().getWorld()),
                    new CanaryLightningStrike(hook.getLightningBolt())) {
                @Override
                public void setCancelled(boolean cancelled) {
                    super.setCancelled(cancelled);
                    //LightningStrikeHook isn't a CancelableHook :(
                }
            });
}
项目:RedProtect    文件:RPBlockListener.java   
@EventHandler
public void onLightning(LightningStrikeEvent e){
    RedProtect.get().logger.debug("RPBlockListener - Is LightningStrikeEvent event");
    Location l = e.getLightning().getLocation();
    Region r = RedProtect.get().rm.getTopRegion(l);
    if (r != null && !r.canFire()){
        e.setCancelled(true);
    }
}
项目:Kineticraft    文件:GeneralMechanics.java   
@EventHandler(ignoreCancelled = true)
public void onLightningStrike(LightningStrikeEvent evt) {
    evt.setCancelled(Utils.nextBool());
}
项目:RpgPlus    文件:ScriptEventManager.java   
@EventHandler
public void onLightningStrike(LightningStrikeEvent event) {
    callHandlers("weather.lightningStrike", event);
}
项目:Cardinal-Plus    文件:WorldFreeze.java   
@EventHandler
public void onLightningStrike(LightningStrikeEvent event) {
    event.setCancelled(true);
}
项目:CardinalPGM    文件:WorldFreeze.java   
@EventHandler
public void onLightningStrike(LightningStrikeEvent event) {
    event.setCancelled(true);
}