Beispiel #1
0
  public ConfigurationNode getWorldConfiguration(World world) {
    ConfigurationNode finalConfiguration = new ConfigurationNode();
    finalConfiguration.put("name", world.getName());
    finalConfiguration.put("title", world.getName());

    ConfigurationNode worldConfiguration = getWorldConfigurationNode(world.getName());

    // Get the template.
    ConfigurationNode templateConfiguration = null;
    if (worldConfiguration != null) {
      String templateName = worldConfiguration.getString("template");
      if (templateName != null) {
        templateConfiguration = getTemplateConfigurationNode(templateName);
      }
    }

    // Template not found, using default template.
    if (templateConfiguration == null) {
      templateConfiguration = getDefaultTemplateConfigurationNode(world);
    }

    // Merge the finalConfiguration, templateConfiguration and worldConfiguration.
    finalConfiguration.extend(templateConfiguration);
    finalConfiguration.extend(worldConfiguration);

    Log.verboseinfo("Configuration of world " + world.getName());
    for (Map.Entry<String, Object> e : finalConfiguration.entrySet()) {
      Log.verboseinfo(e.getKey() + ": " + e.getValue());
    }

    return finalConfiguration;
  }
Beispiel #2
0
 private ConfigurationNode getDefaultTemplateConfigurationNode(World world) {
   Environment environment = world.getEnvironment();
   String environmentName = environment.name().toLowerCase();
   if (deftemplatesuffix.length() > 0) {
     environmentName += "-" + deftemplatesuffix;
   }
   Log.verboseinfo("Using environment as template: " + environmentName);
   return getTemplateConfigurationNode(environmentName);
 }
Beispiel #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));
  }
Beispiel #4
0
  @Override
  public void onEnable() {
    /* Start with clean events */
    events = new Events();

    permissions = NijikokunPermissions.create(getServer(), "dynmap");
    if (permissions == null) permissions = BukkitPermissions.create("dynmap");
    if (permissions == null)
      permissions =
          new OpPermissions(
              new String[] {
                "fullrender", "cancelrender", "radiusrender", "resetstats", "reload", "purgequeue"
              });

    dataDirectory = this.getDataFolder();
    if (dataDirectory.exists() == false) dataDirectory.mkdirs();

    /* Initialize confguration.txt if needed */
    File f = new File(this.getDataFolder(), "configuration.txt");
    if (!createDefaultFileFromResource("/configuration.txt", f)) {
      this.setEnabled(false);
      return;
    }
    /* Load configuration.txt */
    org.bukkit.util.config.Configuration bukkitConfiguration =
        new org.bukkit.util.config.Configuration(f);
    bukkitConfiguration.load();
    configuration = new ConfigurationNode(bukkitConfiguration);

    /* Load block models */
    HDBlockModels.loadModels(dataDirectory, configuration);
    /* Load texture mappings */
    TexturePack.loadTextureMapping(dataDirectory, configuration);

    /* Now, process worlds.txt - merge it in as an override of existing values (since it is only user supplied values) */
    f = new File(this.getDataFolder(), "worlds.txt");
    if (!createDefaultFileFromResource("/worlds.txt", f)) {
      this.setEnabled(false);
      return;
    }
    org.bukkit.util.config.Configuration cfg = new org.bukkit.util.config.Configuration(f);
    cfg.load();
    ConfigurationNode cn = new ConfigurationNode(cfg);
    mergeConfigurationBranch(cn, "worlds", true, true);

    /* Now, process templates */
    loadTemplates();

    Log.verbose = configuration.getBoolean("verbose", true);
    deftemplatesuffix = configuration.getString("deftemplatesuffix", "");
    /* Default swamp shading off for 1.8, on after */
    swampshading =
        configuration.getBoolean("swampshaded", !getServer().getVersion().contains("(MC: 1.8"));
    /* Default water biome shading off for 1.8, on after */
    waterbiomeshading =
        configuration.getBoolean(
            "waterbiomeshaded", !getServer().getVersion().contains("(MC: 1.8"));
    /* Default fence-to-block-join off for 1.8, on after */
    fencejoin =
        configuration.getBoolean(
            "fence-to-block-join", !getServer().getVersion().contains("(MC: 1.8"));
    /* Default compassmode to pre19, to newrose after */
    String cmode =
        configuration.getString(
            "compass-mode", getServer().getVersion().contains("(MC: 1.8") ? "pre19" : "newrose");
    if (cmode.equals("newnorth")) compassmode = CompassMode.NEWNORTH;
    else if (cmode.equals("newrose")) compassmode = CompassMode.NEWROSE;
    else compassmode = CompassMode.PRE19;

    loadDebuggers();

    tilesDirectory = getFile(configuration.getString("tilespath", "web/tiles"));
    if (!tilesDirectory.isDirectory() && !tilesDirectory.mkdirs()) {
      Log.warning("Could not create directory for tiles ('" + tilesDirectory + "').");
    }

    playerList = new PlayerList(getServer(), getFile("hiddenplayers.txt"), configuration);
    playerList.load();
    PlayerListener pl =
        new PlayerListener() {
          public void onPlayerJoin(PlayerJoinEvent evt) {
            playerList.updateOnlinePlayers(null);
          }

          public void onPlayerQuit(PlayerQuitEvent evt) {
            playerList.updateOnlinePlayers(evt.getPlayer());
          }
        };
    registerEvent(Type.PLAYER_JOIN, pl);
    registerEvent(Type.PLAYER_QUIT, pl);

    mapManager = new MapManager(this, configuration);
    mapManager.startRendering();

    playerfacemgr = new PlayerFaces(this);

    loadWebserver();

    enabledTriggers.clear();
    List<String> triggers = configuration.getStrings("render-triggers", new ArrayList<String>());
    if (triggers != null) {
      for (Object trigger : triggers) {
        enabledTriggers.add((String) trigger);
      }
    }

    // Load components.
    for (Component component :
        configuration.<Component>createInstances(
            "components", new Class<?>[] {DynmapPlugin.class}, new Object[] {this})) {
      componentManager.add(component);
    }
    Log.verboseinfo("Loaded " + componentManager.components.size() + " components.");

    registerEvents();

    if (!configuration.getBoolean("disable-webserver", false)) {
      startWebserver();
    }

    /* Print version info */
    PluginDescriptionFile pdfFile = this.getDescription();
    Log.info("version " + pdfFile.getVersion() + " is enabled");

    events.<Object>trigger("initialized", null);
  }