Added a SessionConfig
class that can generate config files inside a world folder
This commit is contained in:
parent
fee7cbc93a
commit
102c9ec0cc
2 changed files with 32 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.bclib.config.ConfigKeeper.Entry;
|
||||
import ru.bclib.config.ConfigKeeper.FloatRange;
|
||||
|
@ -8,7 +10,11 @@ import ru.bclib.config.ConfigKeeper.IntegerRange;
|
|||
public class PathConfig extends Config {
|
||||
|
||||
public PathConfig(String modID, String group) {
|
||||
super(modID, group);
|
||||
this(modID, group, null);
|
||||
}
|
||||
|
||||
protected PathConfig(String modID, String group, File path) {
|
||||
super(modID, group, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
25
src/main/java/ru/bclib/config/SessionConfig.java
Normal file
25
src/main/java/ru/bclib/config/SessionConfig.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package ru.bclib.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import ru.bclib.BCLib;
|
||||
|
||||
public class SessionConfig extends PathConfig{
|
||||
private static File getWorldFolder(LevelStorageSource.LevelStorageAccess session, ServerLevel world){
|
||||
File dir = session.getDimensionPath(world.dimension());
|
||||
if (!new File(dir, "level.dat").exists()) {
|
||||
dir = dir.getParentFile();
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
public final File levelFolder;
|
||||
|
||||
public SessionConfig(String modID, String group, LevelStorageSource.LevelStorageAccess session, ServerLevel world) {
|
||||
super(modID, group, new File(getWorldFolder(session, world), BCLib.MOD_ID));
|
||||
|
||||
this.levelFolder = new File(getWorldFolder(session, world), BCLib.MOD_ID);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue