/** Setup the required components of INSTANCE-triggered Mechanics.. */
  private void setupSelfTriggered(MechanicManager manager) {

    logger.info("CraftBook: Enumerating chunks for INSTANCE-triggered components...");

    long start = System.currentTimeMillis();
    int numWorlds = 0;
    int numChunks = 0;

    for (World world : getServer().getWorlds()) {
      for (Chunk chunk : world.getLoadedChunks()) {
        manager.enumerate(chunk);
        numChunks++;
      }

      numWorlds++;
    }

    long time = System.currentTimeMillis() - start;

    logger.info(
        "CraftBook: "
            + numChunks
            + " chunk(s) for "
            + numWorlds
            + " world(s) processed "
            + "("
            + Math.round(time / 1000.0 * 10) / 10
            + "s elapsed)");

    // Set up the clock for INSTANCE-triggered Mechanics.
    getServer().getScheduler().scheduleSyncRepeatingTask(this, new MechanicClock(manager), 0, 2);
  }
Exemple #2
0
  /**
   * Unregister a mechanic if possible TODO Ensure no remnants are left behind
   *
   * @param factory
   * @return true if the mechanic was successfully unregistered.
   */
  protected boolean unregisterMechanic(MechanicFactory<? extends Mechanic> factory) {

    return manager.unregister(factory);
  }
Exemple #3
0
  /**
   * Register a mechanic if possible
   *
   * @param factory
   */
  public void registerMechanic(MechanicFactory<? extends Mechanic> factory) {

    manager.register(factory);
  }
  /**
   * Unregister a mechanic if possible TODO Ensure no remnants are left behind
   *
   * @param factory
   * @return true if the mechanic was successfully unregistered.
   */
  @SuppressWarnings("unused")
  private boolean unregisterMechanic(MechanicFactory<? extends Mechanic> factory) {

    return manager.unregister(factory);
  }