kerosene/remappedSrc/pm/j4/petroleum/util/config/Config.java

60 lines
1.2 KiB
Java
Raw Permalink Normal View History

2020-12-20 04:19:55 +00:00
package pm.j4.kerosene.util.config;
2020-12-19 23:30:50 +00:00
import java.util.ArrayList;
import java.util.List;
2020-12-20 04:19:55 +00:00
import pm.j4.kerosene.PetroleumMod;
import pm.j4.kerosene.util.module.ModuleBase;
2020-12-19 23:30:50 +00:00
/**
* The type Config.
*/
public abstract class Config {
/**
* The Enabled modules.
*/
public List<String> enabledModules = new ArrayList<>();
/**
* Is enabled boolean.
*
* @param mod the mod
* @return the boolean
*/
public boolean isEnabled(String mod) {
return enabledModules.contains(mod);
}
/**
* Disable module.
*
* @param mod the mod
*/
public void disableModule(String mod) {
if (isEnabled(mod) && PetroleumMod.isActive(mod) && PetroleumMod.getMod(mod).isPresent()) {
ModuleBase moduleInfo = PetroleumMod.getMod(mod).get();
if (moduleInfo.isActivatable()) {
enabledModules.remove(mod);
}
}
}
/**
* Toggle module.
*
* @param mod the mod
*/
public void toggleModule(String mod) {
if (PetroleumMod.isActive(mod) && PetroleumMod.getMod(mod).isPresent()) {
ModuleBase moduleInfo = PetroleumMod.getMod(mod).get();
if (moduleInfo.isActivatable()) {
if (isEnabled(mod)) {
enabledModules.remove(mod);
} else {
enabledModules.add(mod);
}
}
}
}
}