Example #1
0
  // @EventHandler(priority = EventPriority.NORMAL)
  public void explodingArrow(ProjectileHitEvent event) {
    Entity projectile = event.getEntity();
    World w = projectile.getWorld();
    Location hit = projectile.getLocation();

    if (w.getName().equals(name)) {

      if (projectile instanceof Arrow) {
        Arrow arrow = (Arrow) projectile;
        Entity shooter = arrow.getShooter();
        Location l = shooter.getLocation();
        Block bl = l.getBlock();
        Block b = bl.getRelative(BlockFace.DOWN, 2);
        Material mat = b.getType();

        if (shooter instanceof Player) {
          Player p = (Player) shooter;
          ItemStack is = p.getItemInHand();
          Material i = is.getType();
          if (i == Material.BOW && mat == Material.SPONGE) {
            p.getInventory().removeItem(new ItemStack(Material.ARROW, 20));
            w.createExplosion(hit, 8);
            int strikes = 0;
            while (strikes < 20) {
              strikes++;
              w.strikeLightning(hit);
            }
          }
          Bukkit.getWorld(name).playEffect(arrow.getLocation(), Effect.STEP_SOUND, 10);
        }
      }
    }
  }
Example #2
0
  /** Stops this server. */
  @Override
  public void shutdown() {
    // Just in case this gets called twice
    if (isShuttingDown) {
      return;
    }
    isShuttingDown = true;
    logger.info("The server is shutting down...");

    // Disable plugins
    pluginManager.clearPlugins();

    // Kick all players (this saves their data too)
    for (Player player : getOnlinePlayers()) {
      player.kickPlayer(getShutdownMessage());
    }

    // Stop the network servers - starts the shutdown process
    // It may take a second or two for Netty to totally clean up
    networkServer.shutdown();
    if (queryServer != null) {
      queryServer.shutdown();
    }
    if (rconServer != null) {
      rconServer.shutdown();
    }

    // Save worlds
    for (World world : getWorlds()) {
      logger.info("Saving world: " + world.getName());
      unloadWorld(world, true);
    }

    // Stop scheduler and console
    scheduler.stop();
    consoleManager.stop();

    // Wait for a while and terminate any rogue threads
    new ShutdownMonitorThread().start();
  }
Example #3
0
  @Override
  public OfflinePlayer[] getOfflinePlayers() {
    Set<OfflinePlayer> result = new HashSet<>();
    Set<UUID> uuids = new HashSet<>();

    // add the currently online players
    for (World world : getWorlds()) {
      for (Player player : world.getPlayers()) {
        result.add(player);
        uuids.add(player.getUniqueId());
      }
    }

    // add all offline players that aren't already online
    for (OfflinePlayer offline : getPlayerDataService().getOfflinePlayers()) {
      if (!uuids.contains(offline.getUniqueId())) {
        result.add(offline);
        uuids.add(offline.getUniqueId());
      }
    }

    return result.toArray(new OfflinePlayer[result.size()]);
  }