Пример #1
0
  public MineManager(ConRiot plugin) {
    this.plugin = plugin;

    // Get the file for the block data
    dataFile = new ConfigAccessor(plugin, file);

    // Instantiate mines hashmap
    mines = new HashMap<String, Mine>();

    // Verify we have enough info
    if (!(valid = hasNeededKeys())) {
      plugin.getLogger().warning("Mines data file '" + file + "' didn't have sufficient keys!");
      return; // Log a nice warning so we know what's up
    }

    // Load all the cells in the block
    List<String> list = dataFile.getConfig().getStringList("mines");
    for (String entry : list) {
      Mine m = new Mine(plugin, dataFile, entry, true);
      if (m.isValid()) mines.put(entry, m);
    }

    // Load up the correct MineRefiller implementation, log manager as active
    String p = plugin.getServer().getClass().getPackage().getName();
    String version = p.substring(p.lastIndexOf('.') + 1);
    if (version.equals("v1_5_R3")) {
      refiller = new V1_5_R3MineRefiller(this);
      plugin.getLogger().info("Mine Manager is online! [V1_5_R3 NMS]");
    } else {
      refiller = new BukkitMineRefiller(this);
      plugin.getLogger().info("Mine Manager is online! [Bukkit API]");
    }

    // Set up piston event listener
    plugin.getServer().getPluginManager().registerEvents(this, plugin);

    // Done loading, call setup to start the refills
    setup();
  }