示例#1
0
 public void startWebserver() {
   try {
     webServer.startServer();
   } catch (IOException e) {
     Log.severe(
         "Failed to start WebServer on "
             + webServer.getAddress()
             + ":"
             + webServer.getPort()
             + "!");
   }
 }
示例#2
0
  @Override
  public void onDisable() {
    if (componentManager != null) {
      int componentCount = componentManager.components.size();
      for (Component component : componentManager.components) {
        component.dispose();
      }
      componentManager.clear();
      Log.info("Unloaded " + componentCount + " components.");
    }

    if (mapManager != null) {
      mapManager.stopRendering();
      mapManager = null;
    }

    if (webServer != null) {
      webServer.shutdown();
      webServer = null;
    }
    /* Clean up all registered handlers */
    for (Event.Type t : event_handlers.keySet()) {
      List<Listener> ll = event_handlers.get(t);
      ll
          .clear(); /* Empty list - we use presence of list to remember that we've registered with Bukkit */
    }
    playerfacemgr = null;

    /* Don't clean up markerAPI - other plugins may still be accessing it */

    Debug.clearDebuggers();
  }
示例#3
0
  public void loadWebserver() {
    InetAddress bindAddress;
    {
      String address = configuration.getString("webserver-bindaddress", "0.0.0.0");
      try {
        bindAddress = address.equals("0.0.0.0") ? null : InetAddress.getByName(address);
      } catch (UnknownHostException e) {
        bindAddress = null;
      }
    }
    int port = configuration.getInteger("webserver-port", 8123);
    boolean allow_symlinks = configuration.getBoolean("allow-symlinks", false);
    boolean checkbannedips = configuration.getBoolean("check-banned-ips", true);
    int maxconnections = configuration.getInteger("max-sessions", 30);
    if (maxconnections < 2) maxconnections = 2;
    /* Load customized response headers, if any */
    ConfigurationNode custhttp = configuration.getNode("http-response-headers");
    HashMap<String, String> custhdrs = new HashMap<String, String>();
    if (custhttp != null) {
      for (String k : custhttp.keySet()) {
        String v = custhttp.getString(k);
        if (v != null) {
          custhdrs.put(k, v);
        }
      }
    }
    HttpServer.setCustomHeaders(custhdrs);

    if (allow_symlinks) Log.verboseinfo("Web server is permitting symbolic links");
    else Log.verboseinfo("Web server is not permitting symbolic links");
    webServer = new HttpServer(bindAddress, port, checkbannedips, maxconnections);
    webServer.handlers.put(
        "/",
        new FilesystemHandler(getFile(configuration.getString("webpath", "web")), allow_symlinks));
    webServer.handlers.put("/tiles/", new FilesystemHandler(tilesDirectory, allow_symlinks));
    webServer.handlers.put("/up/configuration", new ClientConfigurationHandler(this));
  }