From 82d66ca392b8e7df30123d31e2e410e63a4897b2 Mon Sep 17 00:00:00 2001 From: s809 <43530948+s809@users.noreply.github.com> Date: Sat, 25 Nov 2023 17:44:51 +0500 Subject: [PATCH] Basic chat commands --- .../distanthorizons/core/config/Config.java | 22 +++++++++---------- .../core/config/file/ConfigFileHandling.java | 4 ++-- .../core/config/types/ConfigEntry.java | 16 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index ef7e0a69e..15d254785 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -155,7 +155,7 @@ public class Config .build(); public static ConfigEntry lodChunkRenderDistanceRadius = new ConfigEntry.Builder() - .enableOnServer() + .setServersideShortName("renderDistanceRadius") .setMinDefaultMax(32, 128, 4096) .comment("The radius of the mod's render distance. (measured in chunks)") .setPerformance(EConfigEntryPerformance.HIGH) @@ -661,7 +661,7 @@ public class Config public static class WorldGenerator { public static ConfigEntry enableDistantGeneration = new ConfigEntry.Builder() - .enableOnServer() + .setServersideShortName("enableDistantGeneration") .set(true) .comment("" + " Should Distant Horizons slowly generate LODs \n" @@ -672,7 +672,7 @@ public class Config .build(); public static ConfigEntry distantGeneratorMode = new ConfigEntry.Builder() - .enableOnServer() + .setServersideShortName("distantGeneratorMode") .set(EDhApiDistantGeneratorMode.FEATURES) .comment("" + "How detailed should LODs be generated outside the vanilla render distance? \n" @@ -714,7 +714,7 @@ public class Config .build(); public static ConfigEntry worldGenerationTimeoutLengthInSeconds = new ConfigEntry.Builder() - .enableOnServer() + .setServersideShortName("worldGenerationTimeout") .setMinDefaultMax(5, 60, 60 * 10/*10 minutes*/ ) .comment("" + "How long should a world generator thread run for before timing out? \n" @@ -758,7 +758,7 @@ public class Config public static class LodBuilding { public static ConfigEntry minTimeBetweenChunkUpdatesInSeconds = new ConfigEntry.Builder() - .enableOnServer() + .setServersideShortName("minTimeBetweenChunkUpdates") .setMinDefaultMax(0, 1, 60) .comment("" + "Determines how long must pass between LOD chunk updates before another. \n" @@ -824,7 +824,7 @@ public class Config public static class ServerNetworking { public static ConfigEntry enableServerNetworking = new ConfigEntry.Builder() - .enableOnServer() + .setServersideShortName("enableServerNetworking") .set(true) .comment("" + "Attention: \n" @@ -839,7 +839,7 @@ public class Config .build(); public static ConfigEntry requestRateLimit = new ConfigEntry.Builder() - .enableOnServer() + .setServersideShortName("requestRateLimit") .setMinDefaultMax(1, 20, 100) .comment("" + "Limits the amount of sent/processed LOD requests concurrently. \n" @@ -849,7 +849,7 @@ public class Config .build(); public static ConfigEntry enableRealTimeUpdates = new ConfigEntry.Builder() - .enableOnServer() + .setServersideShortName("enableRealTimeUpdates") .set(false) .comment("" + "Enables real time updates from server." @@ -857,7 +857,7 @@ public class Config .build(); public static ConfigEntry enablePostRelogUpdate = new ConfigEntry.Builder() - .enableOnServer() + .setServersideShortName("enablePostRelogUpdate") .set(false) .comment("" + "Enables updating of LODs after relog." @@ -865,8 +865,8 @@ public class Config .build(); public static ConfigEntry serverPort = new ConfigEntry.Builder() - .enableOnServer() - .set(25049) + .setServersideShortName("serverPort") + .setMinDefaultMax(1, 25049, 65535) .comment("" + "The port on the server that's used for sending LOD data." + "") diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java index a465908ff..8459ce9ef 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java @@ -192,7 +192,7 @@ public class ConfigFileHandling public void saveEntry(ConfigEntry entry, CommentedFileConfig workConfig) { if (!entry.getAppearance().showInFile) return; - if (SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class).isDedicatedServer() && !entry.isEnabledOnServer()) + if (SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class).isDedicatedServer() && entry.getServersideShortName() == null) 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"); @@ -256,7 +256,7 @@ public class ConfigFileHandling ) return; - if (SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class).isDedicatedServer() && !entry.isEnabledOnServer()) + if (SingletonInjector.INSTANCE.get(IMinecraftSharedWrapper.class).isDedicatedServer() && entry.getServersideShortName() == null) return; nightConfig.setComment(entry.getNameWCategory(), " " + entry.getComment().replaceAll("\n", "\n ") + "\n "); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java index b15e5a14e..5a877f9f7 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java @@ -44,7 +44,7 @@ public class ConfigEntry extends AbstractConfigType> implem private T min; private T max; private final ArrayList listenerList; - private final boolean enabledOnServer; + private final String serversideShortName; // API control // /** @@ -58,14 +58,14 @@ public class ConfigEntry extends AbstractConfigType> implem /** Creates the entry */ - private ConfigEntry(EConfigEntryAppearance appearance, T value, String comment, T min, T max, boolean enabledOnServer, boolean allowApiOverride, EConfigEntryPerformance performance, ArrayList listenerList) + private ConfigEntry(EConfigEntryAppearance appearance, T value, String comment, T min, T max, String serversideShortName, boolean allowApiOverride, EConfigEntryPerformance performance, ArrayList listenerList) { super(appearance, value); this.comment = comment; this.min = min; this.max = max; - this.enabledOnServer = enabledOnServer; + this.serversideShortName = serversideShortName; this.allowApiOverride = allowApiOverride; this.performance = performance; this.listenerList = listenerList; @@ -181,7 +181,7 @@ public class ConfigEntry extends AbstractConfigType> implem if (validness == 1) this.value = (T) NumberUtil.getMaximum(this.value.getClass()); } - public boolean isEnabledOnServer() { return this.enabledOnServer; } + public String getServersideShortName() { return this.serversideShortName; } @Override public String getComment() { return this.comment; } @@ -301,7 +301,7 @@ public class ConfigEntry extends AbstractConfigType> implem private String tmpComment = null; private T tmpMin = null; private T tmpMax = null; - protected boolean tmpEnabledOnServer = false; + protected String tmpServersideShortName = null; private boolean tmpUseApiOverwrite = true; private EConfigEntryPerformance tmpPerformance = EConfigEntryPerformance.DONT_SHOW; protected ArrayList tmpIConfigListener = new ArrayList<>(); @@ -339,9 +339,9 @@ public class ConfigEntry extends AbstractConfigType> implem return this; } - public Builder enableOnServer() + public Builder setServersideShortName(String name) { - this.tmpEnabledOnServer = true; + this.tmpServersideShortName = name; return this; } @@ -387,7 +387,7 @@ public class ConfigEntry extends AbstractConfigType> implem public ConfigEntry build() { - return new ConfigEntry<>(this.tmpAppearance, this.tmpValue, this.tmpComment, this.tmpMin, this.tmpMax, this.tmpEnabledOnServer, this.tmpUseApiOverwrite, this.tmpPerformance, this.tmpIConfigListener); + return new ConfigEntry<>(this.tmpAppearance, this.tmpValue, this.tmpComment, this.tmpMin, this.tmpMax, this.tmpServersideShortName, this.tmpUseApiOverwrite, this.tmpPerformance, this.tmpIConfigListener); } }