add more getDimensinoName() calls and minor cleanup
This commit is contained in:
+37
-7
@@ -25,6 +25,7 @@ import com.seibel.distanthorizons.core.config.ConfigBase;
|
||||
import com.seibel.distanthorizons.core.config.types.AbstractConfigType;
|
||||
import com.seibel.distanthorizons.core.config.types.ConfigEntry;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftSharedWrapper;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -40,6 +41,9 @@ import java.nio.file.Path;
|
||||
*/
|
||||
public class ConfigFileHandling
|
||||
{
|
||||
private static final IMinecraftSharedWrapper MC_SHARED = SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class);
|
||||
|
||||
|
||||
public final ConfigBase configBase;
|
||||
public final Path configPath;
|
||||
|
||||
@@ -48,6 +52,12 @@ public class ConfigFileHandling
|
||||
/** This is the object for night-config */
|
||||
private final CommentedFileConfig nightConfig;
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
public ConfigFileHandling(ConfigBase configBase, Path configPath)
|
||||
{
|
||||
this.LOGGER = LogManager.getLogger(this.getClass().getSimpleName() + ", " + configBase.modID);
|
||||
@@ -57,6 +67,9 @@ public class ConfigFileHandling
|
||||
this.nightConfig = CommentedFileConfig.builder(this.configPath.toFile()).build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** Saves the entire config to the file */
|
||||
public void saveToFile()
|
||||
{
|
||||
@@ -190,9 +203,20 @@ public class ConfigFileHandling
|
||||
/** Save an entry */
|
||||
public void saveEntry(ConfigEntry<?> entry, CommentedFileConfig workConfig)
|
||||
{
|
||||
if (!entry.getAppearance().showInFile) return;
|
||||
if (entry.getTrueValue() == null)
|
||||
throw new IllegalArgumentException("Entry [" + entry.getNameWCategory() + "] is null, this may be a problem with [" + configBase.modName + "]. Please contact the authors");
|
||||
if (!entry.getAppearance().showInFile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (MC_SHARED.isDedicatedServer() && entry.getServersideShortName() == null)
|
||||
{
|
||||
// don't save server configs on the client
|
||||
return;
|
||||
}
|
||||
else if (entry.getTrueValue() == null)
|
||||
{
|
||||
// TODO when can this happen?
|
||||
throw new IllegalArgumentException("Entry [" + entry.getNameWCategory() + "] is null, this may be a problem with [" + configBase.modName + "]. Please contact the authors.");
|
||||
}
|
||||
|
||||
workConfig.set(entry.getNameWCategory(), ConfigTypeConverters.attemptToConvertToString(entry.getType(), entry.getTrueValue()));
|
||||
}
|
||||
@@ -259,11 +283,17 @@ public class ConfigFileHandling
|
||||
// Creates a comment for an entry
|
||||
public void createComment(ConfigEntry<?> entry, CommentedFileConfig nightConfig)
|
||||
{
|
||||
if (
|
||||
!entry.getAppearance().showInFile ||
|
||||
entry.getComment() == null
|
||||
)
|
||||
if (!entry.getAppearance().showInFile
|
||||
|| entry.getComment() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MC_SHARED.isDedicatedServer() && entry.getServersideShortName() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String comment = entry.getComment().replaceAll("\n", "\n ").trim();
|
||||
// the new line makes it easier to read and separate configs
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ public class SubDimensionLevelMatcher implements AutoCloseable
|
||||
//================================//
|
||||
|
||||
// log the start of this attempt
|
||||
LOGGER.info("Attempting to determine sub-dimension for [" + MC_CLIENT.getWrappedClientLevel().getDimensionType().getDimensionName() + "]");
|
||||
LOGGER.info("Attempting to determine sub-dimension for [" + MC_CLIENT.getWrappedClientLevel().getDimensionName() + "]");
|
||||
LOGGER.info("Player block pos in dimension: [" + this.playerData.playerBlockPos.getX() + "," + this.playerData.playerBlockPos.getY() + "," + this.playerData.playerBlockPos.getZ() + "]");
|
||||
LOGGER.info("Potential Sub Dimension folders: [" + this.potentialLevelFolders.size() + "]");
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ public class DhClientLevel extends AbstractDhLevel implements IDhClientLevel
|
||||
@Override
|
||||
public void addDebugMenuStringsToList(List<String> messageList)
|
||||
{
|
||||
String dimName = this.levelWrapper.getDimensionType().getDimensionName();
|
||||
String dimName = this.levelWrapper.getDimensionName();
|
||||
boolean rendering = this.clientside.isRendering();
|
||||
messageList.add("["+dimName+"] rendering: "+(rendering ? "yes" : "no"));
|
||||
|
||||
|
||||
@@ -73,15 +73,13 @@ public class DhApiWorldProxy implements IDhApiWorldProxy
|
||||
throw new IllegalStateException(NO_WORLD_EXCEPTION_STRING);
|
||||
}
|
||||
|
||||
|
||||
if (!MC_SHARED.isDedicatedServer())
|
||||
{
|
||||
return MC_CLIENT.getWrappedClientLevel();
|
||||
}
|
||||
else
|
||||
if (MC_SHARED.isDedicatedServer())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return MC_CLIENT.getWrappedClientLevel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -186,8 +186,10 @@ public class DhServerWorld extends AbstractDhWorld implements IDhServerWorld
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverTick() { this.levels.values().forEach(DhServerLevel::serverTick); }
|
||||
|
||||
@Override
|
||||
public void doWorldGen() { this.levels.values().forEach(DhServerLevel::doWorldGen); }
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user