-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of the config manager
- Loading branch information
1 parent
6dfec3d
commit 3bff94c
Showing
6 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
....12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/configs/ConfigManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.imesense.dynamicspawncontrol.technical.configs; | ||
|
||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ConfigManager | ||
{ | ||
private static final List<IConfig> settingList = new ArrayList<>(); | ||
|
||
static | ||
{ | ||
settingList.add(new SettingsLogFile()); | ||
} | ||
|
||
public static void init(FMLPreInitializationEvent event) | ||
{ | ||
for (IConfig config : settingList) | ||
{ | ||
config.init(event, config.getClass().getSimpleName()); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...trol-1.12.2/src/main/java/org/imesense/dynamicspawncontrol/technical/configs/IConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.imesense.dynamicspawncontrol.technical.configs; | ||
|
||
import net.minecraftforge.common.config.Configuration; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
|
||
public interface IConfig | ||
{ | ||
void init(FMLPreInitializationEvent event, String nameClass); | ||
|
||
void readProperties(Configuration configuration); | ||
|
||
void read(); | ||
} |
54 changes: 54 additions & 0 deletions
54
...2.2/src/main/java/org/imesense/dynamicspawncontrol/technical/configs/SettingsLogFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.imesense.dynamicspawncontrol.technical.configs; | ||
|
||
import net.minecraftforge.common.config.Configuration; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import org.imesense.dynamicspawncontrol.DynamicSpawnControl; | ||
import org.imesense.dynamicspawncontrol.technical.customlibrary.Log; | ||
import org.imesense.dynamicspawncontrol.technical.proxy.ClientProxy; | ||
|
||
import java.io.File; | ||
|
||
public final class SettingsLogFile implements IConfig | ||
{ | ||
public static int LogMaxLines = 32767; | ||
|
||
@Override | ||
public void init(FMLPreInitializationEvent event, String nameClass) | ||
{ | ||
Log.writeDataToLogFile(Log.TypeLog[0], nameClass); | ||
|
||
ClientProxy.ConfigLogFile = new Configuration(new File(DynamicSpawnControl.getGlobalPathToConfigs().getPath() + | ||
File.separator + DynamicSpawnControl.NAME_DIRECTORY + File.separator + "configs", "log.ltx")); | ||
|
||
read(); | ||
} | ||
|
||
@Override | ||
public void readProperties(Configuration configuration) | ||
{ | ||
LogMaxLines = | ||
configuration.getInt | ||
("Log maximum lines", "log_file_settings", LogMaxLines, 5, 32767, | ||
"The parameter is responsible for the maximum number of lines in the log"); | ||
} | ||
|
||
@Override | ||
public void read() | ||
{ | ||
Configuration configuration = ClientProxy.ConfigLogFile; | ||
|
||
try | ||
{ | ||
configuration.load(); | ||
|
||
readProperties(configuration); | ||
} | ||
finally | ||
{ | ||
if (configuration.hasChanged()) | ||
{ | ||
configuration.save(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters