示例#1
0
  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;
    }
  }
 @EventHandler
 public void onEntityStruckbyLight(LightningStrikeEvent event) {
   for (Entity entity : event.getLightning().getNearbyEntities(1, 1, 1)) {
     if (entity instanceof Zombie) {
       plugin.getServer().broadcastMessage(ChatColor.RED + "Lightning Struck a Zombie!");
       event
           .getLightning()
           .getLocation()
           .getWorld()
           .spawn(event.getLightning().getLocation(), Giant.class);
       event.setCancelled(true);
     }
     if (entity instanceof Player || entity instanceof Chicken) {
       event
           .getLightning()
           .getLocation()
           .getWorld()
           .createExplosion(event.getLightning().getLocation(), 4.0F);
     }
   }
 }