Skip to content

Commit

Permalink
change config type from common to server
Browse files Browse the repository at this point in the history
to allow each save has its own config values

close IntelligenceModding#693
  • Loading branch information
zyxkad committed Jan 21, 2025
1 parent 708c1c7 commit 2d8c8e2
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.ConfigFileTypeHandler;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.loading.FMLPaths;

Expand All @@ -12,8 +11,6 @@

public class APConfig extends ModConfig {

public static final ConfigFileHandler CONFIG_FILE_HANDLER = new ConfigFileHandler();

public static final GeneralConfig GENERAL_CONFIG = new GeneralConfig();
public static final PeripheralsConfig PERIPHERALS_CONFIG = new PeripheralsConfig();
public static final MetaphysicsConfig METAPHYSICS_CONFIG = new MetaphysicsConfig();
Expand All @@ -24,37 +21,10 @@ public APConfig(IAPConfig config, ModContainer container) {
}

public static void register(ModLoadingContext context) {
//Creates the config folder
FMLPaths.getOrCreateGameRelativePath(FMLPaths.CONFIGDIR.get().resolve("Advancedperipherals"), "Advancedperipherals");

ModContainer modContainer = context.getActiveContainer();
modContainer.addConfig(new APConfig(GENERAL_CONFIG, modContainer));
modContainer.addConfig(new APConfig(PERIPHERALS_CONFIG, modContainer));
modContainer.addConfig(new APConfig(METAPHYSICS_CONFIG, modContainer));
modContainer.addConfig(new APConfig(WORLD_CONFIG, modContainer));
}

@Override
public ConfigFileTypeHandler getHandler() {
return CONFIG_FILE_HANDLER;
}

public static class ConfigFileHandler extends ConfigFileTypeHandler {

public static Path getPath(Path path) {
if (path.endsWith("serverconfig")) return FMLPaths.CONFIGDIR.get();

return path;
}

@Override
public Function<ModConfig, CommentedFileConfig> reader(Path configBasePath) {
return super.reader(getPath(configBasePath));
}

@Override
public void unload(Path configBasePath, ModConfig config) {
super.unload(getPath(configBasePath), config);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public String getFileName() {

@Override
public ModConfig.Type getType() {
return ModConfig.Type.COMMON;
return ModConfig.Type.SERVER;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public String getFileName() {

@Override
public ModConfig.Type getType() {
return ModConfig.Type.COMMON;
return ModConfig.Type.SERVER;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public String getFileName() {

@Override
public ModConfig.Type getType() {
return ModConfig.Type.COMMON;
return ModConfig.Type.SERVER;
}

private List<Predicate<String>> parseChatBoxCommandFilters() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ public String getFileName() {

@Override
public ModConfig.Type getType() {
return ModConfig.Type.COMMON;
return ModConfig.Type.SERVER;
}
/*
[
*/
}

0 comments on commit 2d8c8e2

Please sign in to comment.