Example #1
0
  @Override
  public void onEnable() {
    log = this.getLogger();
    boolean loadError = false;
    jarUtil = new JarUtils(this, getFile(), log, logPrefix);
    buildNumber = jarUtil.getBuildNumber();

    playerNonOreCount = new HashMap<String, Counter>();
    playerRecentBlocks = new HashMap<String, RecentBlocks>();

    pluginName = getDescription().getName();
    logPrefix = "[" + pluginName + "]";

    logQueue = new LogQueue();
    blockListener = new LogOresBlockListener(this);

    initPermissions();

    try {
      loadConfig();
    } catch (Exception e) {
      loadError = true;
      log.severe("Error loading plugin: " + pluginName);
      e.printStackTrace();
    }

    if (loadError) {
      log.severe("Error detected when loading plugin " + pluginName + ", plugin shutting down.");
      shutdownPlugin();
      return;
    }

    getServer().getPluginManager().registerEvents(blockListener, this);
    //        getServer().getPluginManager().registerEvent(Event.Type.BLOCK_BREAK, blockListener,
    // Priority.Monitor, this);

    oreProcessor = new LogEventProcessor(this);
    oreProcessor.reloadConfig();

    getServer().getScheduler().scheduleAsyncRepeatingTask(this, oreProcessor, 200, 100);

    log.info(
        logPrefix
            + "version "
            + getDescription().getVersion()
            + ", build "
            + buildNumber
            + " is enabled");
  }
Example #2
0
  public void loadConfig() {
    // copy default config.yml into place if it's not there
    File file = new File(getDataFolder(), "config.yml");
    if (!file.exists()) {
      jarUtil.copyConfigFromJar("config.yml", file);
    }

    if (!configLoaded) {
      super.getConfig();
      configLoaded = true;
    } else super.reloadConfig();

    logOresConfig = new LogOresConfig(this);
    logOresConfig.processConfig();

    if (blockListener != null) blockListener.reloadConfig();
    if (oreProcessor != null) oreProcessor.reloadConfig();
  }