Ejemplo n.º 1
0
  /**
   * Convenience method for creating a config function. Used to create the default config functions.
   *
   * @param <E>
   * @param world
   * @param clazz
   * @param args
   * @return
   */
  public static <T> ConfigFunction<?> create(
      T holder, Class<? extends ConfigFunction<T>> clazz, Object... args) {
    List<String> stringArgs = new ArrayList<String>(args.length);
    for (Object arg : args) {
      stringArgs.add("" + arg);
    }

    ConfigFunction<?> configFunction;
    try {
      configFunction = clazz.newInstance();
    } catch (InstantiationException e) {
      return null;
    } catch (IllegalAccessException e) {
      return null;
    }
    configFunction.setHolder(holder);
    try {
      configFunction.load(stringArgs);
    } catch (InvalidResourceException e) {
      TerrainControl.log(
          "Invalid default config function! Please report! "
              + clazz.getName()
              + ": "
              + e.getMessage());
      e.printStackTrace();
    }

    return configFunction;
  }
 @Override
 public boolean isAnalogousTo(ConfigFunction<BiomeConfig> other) {
   if (getClass() == other.getClass()) {
     try {
       CustomStructureGen otherO = (CustomStructureGen) other;
       return otherO.objectNames.size() == this.objectNames.size()
           && otherO.objectNames.containsAll(this.objectNames);
     } catch (Exception ex) {
       TerrainControl.log(LogMarker.WARN, ex.getMessage());
     }
   }
   return false;
 }
Ejemplo n.º 3
0
 @Override
 public boolean isAnalogousTo(ConfigFunction<BiomeConfig> other) {
   return getClass() == other.getClass();
 }