Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change config type from common to server #703

Open
wants to merge 2 commits into
base: dev/0.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
package de.srendi.advancedperipherals.common.configuration;

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;

import java.nio.file.Path;
import java.util.function.Function;

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 +16,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;
}
/*
[
*/
}