This commit is contained in:
paulevsGitch 2020-10-29 00:46:48 +03:00
parent b13da60a35
commit 4ddeb92680
2 changed files with 52 additions and 52 deletions

View file

@ -48,7 +48,7 @@ public class EndStructures {
}*/ }*/
} }
private static void addStructure(EndStructureFeature feature, Collection<Supplier<ConfiguredStructureFeature<?, ?>>> collection) { protected static void addStructure(EndStructureFeature feature, Collection<Supplier<ConfiguredStructureFeature<?, ?>>> collection) {
collection.add(() -> { return feature.getFeatureConfigured(); }); collection.add(() -> { return feature.getFeatureConfigured(); });
} }
} }

View file

@ -1,51 +1,51 @@
package ru.betterend.world.biome; package ru.betterend.world.biome;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import ru.betterend.config.Config; import ru.betterend.config.Config;
import ru.betterend.config.ConfigWriter; import ru.betterend.config.ConfigWriter;
public class BiomeConfig extends Config { public class BiomeConfig extends Config {
private final static Path BIOME_CONFIG_DIR = ConfigWriter.MOD_CONFIG_DIR.toPath().resolve("biomes"); private final static Path BIOME_CONFIG_DIR = ConfigWriter.MOD_CONFIG_DIR.toPath().resolve("biomes");
private EndBiome biome; //private EndBiome biome;
private ConfigWriter configWriter; private ConfigWriter configWriter;
private File configFile; private File configFile;
public BiomeConfig(EndBiome biome) { public BiomeConfig(EndBiome biome) {
this.biome = biome; //this.biome = biome;
Identifier biomeId = biome.getID(); Identifier biomeId = biome.getID();
String folder = ConfigWriter.scrubFileName(biomeId.toString()); String folder = ConfigWriter.scrubFileName(biomeId.toString());
this.configFile = new File(BIOME_CONFIG_DIR.toFile(), folder + ".json"); this.configFile = new File(BIOME_CONFIG_DIR.toFile(), folder + ".json");
this.configWriter = new ConfigWriter(); this.configWriter = new ConfigWriter();
this.registerEntries(); this.registerEntries();
JsonObject config = configWriter.loadConfig(configFile); JsonObject config = configWriter.loadConfig(configFile);
if (config.size() > 0) { if (config.size() > 0) {
this.configKeeper.fromJson(config); this.configKeeper.fromJson(config);
} else { } else {
this.configKeeper.toJson(config); this.configKeeper.toJson(config);
this.configWriter.saveConfig(); this.configWriter.saveConfig();
} }
} }
private void registerEntries() { private void registerEntries() {
//TODO: Need to register config params in the Keeper //TODO: Need to register config params in the Keeper
} }
@Override @Override
public void saveChanges() { public void saveChanges() {
this.configKeeper.toJson(configWriter.getConfig()); this.configKeeper.toJson(configWriter.getConfig());
this.configWriter.saveConfig(); this.configWriter.saveConfig();
} }
static { static {
if (!BIOME_CONFIG_DIR.toFile().exists()) { if (!BIOME_CONFIG_DIR.toFile().exists()) {
BIOME_CONFIG_DIR.toFile().mkdir(); BIOME_CONFIG_DIR.toFile().mkdir();
} }
} }
} }