180 lines
7.8 KiB
Diff
180 lines
7.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
|
Date: Sun, 26 Nov 2023 10:40:56 +0800
|
|
Subject: [PATCH] Added empty luminol config
|
|
|
|
|
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
|
index d295ee01481b088a376691de7c0927e95d7a68a8..54d761d7e4733c12fbb4957acd509d278ae11316 100644
|
|
--- a/build.gradle.kts
|
|
+++ b/build.gradle.kts
|
|
@@ -19,6 +19,7 @@ dependencies {
|
|
exclude("io.papermc.paper", "paper-api")
|
|
}
|
|
// Folia end
|
|
+ implementation("com.electronwill.night-config:toml:3.6.0") //Luminol - Night config
|
|
// Paper start
|
|
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
|
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
|
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..1f9ff0fc33fa36c90fc4cbbd21b7b790de581632
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
@@ -0,0 +1,99 @@
|
|
+package me.earthme.luminol;
|
|
+
|
|
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
|
+import net.minecraft.server.level.ServerLevel;
|
|
+
|
|
+import java.io.File;
|
|
+import java.io.IOException;
|
|
+
|
|
+public class LuminolConfig {
|
|
+ private static final File PARENT_FOLDER = new File("luminol_config");
|
|
+ private static final File MAIN_CONFIG_FILE = new File(PARENT_FOLDER,"luminol_global.toml");
|
|
+ private static CommentedFileConfig MAIN_CONFIG;
|
|
+
|
|
+ public static String serverModName = "Luminol";
|
|
+ public static boolean fakeVanillaModeEnabled = false;
|
|
+
|
|
+ public static void init() throws IOException {
|
|
+ PARENT_FOLDER.mkdir();
|
|
+
|
|
+ if (!MAIN_CONFIG_FILE.exists()){
|
|
+ MAIN_CONFIG_FILE.createNewFile();
|
|
+ }
|
|
+
|
|
+ MAIN_CONFIG = CommentedFileConfig.ofConcurrent(MAIN_CONFIG_FILE);
|
|
+
|
|
+ MAIN_CONFIG.load();
|
|
+ initValues();
|
|
+ MAIN_CONFIG.save();
|
|
+ }
|
|
+
|
|
+ public static void initValues(){
|
|
+ serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
|
+ fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
|
+ }
|
|
+
|
|
+ public static <T> T get(String key,T def){
|
|
+ if (MAIN_CONFIG.contains(key)){
|
|
+ return MAIN_CONFIG.get(key);
|
|
+ }
|
|
+
|
|
+ MAIN_CONFIG.set(key,def);
|
|
+ return def;
|
|
+ }
|
|
+
|
|
+ public static <T> T get(String key,T def,String comment){
|
|
+ MAIN_CONFIG.setComment(key,comment);
|
|
+
|
|
+ if (MAIN_CONFIG.contains(key)){
|
|
+ return MAIN_CONFIG.get(key);
|
|
+ }
|
|
+
|
|
+ MAIN_CONFIG.set(key,def);
|
|
+ return def;
|
|
+ }
|
|
+
|
|
+ public static class LumionalWorldConfig{
|
|
+ private final File configFile;
|
|
+ private CommentedFileConfig commentedFileConfig;
|
|
+
|
|
+ public LumionalWorldConfig(ServerLevel level) {
|
|
+ this.configFile = new File(PARENT_FOLDER,"luminol_world_"+level.getWorld().getName()+".toml");
|
|
+ }
|
|
+
|
|
+ public void init() throws IOException {
|
|
+ if (!this.configFile.exists()){
|
|
+ this.configFile.createNewFile();
|
|
+ }
|
|
+
|
|
+ this.commentedFileConfig = CommentedFileConfig.ofConcurrent(this.configFile);
|
|
+ this.commentedFileConfig.load();
|
|
+ this.initValues();
|
|
+ this.commentedFileConfig.save();
|
|
+ }
|
|
+
|
|
+ public void initValues(){
|
|
+
|
|
+ }
|
|
+
|
|
+ public <T> T get(String key,T def,String comment){
|
|
+ this.commentedFileConfig.setComment(key,comment);
|
|
+
|
|
+ if (this.commentedFileConfig.contains(key)){
|
|
+ return this.commentedFileConfig.get(key);
|
|
+ }
|
|
+
|
|
+ this.commentedFileConfig.set(key,def);
|
|
+ return def;
|
|
+ }
|
|
+
|
|
+ public <T> T get(String key,T def){
|
|
+ if (this.commentedFileConfig.contains(key)){
|
|
+ return this.commentedFileConfig.get(key);
|
|
+ }
|
|
+
|
|
+ this.commentedFileConfig.set(key,def);
|
|
+ return def;
|
|
+ }
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index 05d8cabd2294456e3c8df60265f8b035990dd896..f0bf57a7acd77eeffbeeb6743ba58166823022fd 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -19,6 +19,8 @@ import java.util.Locale;
|
|
import java.util.Optional;
|
|
import java.util.function.BooleanSupplier;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import me.earthme.luminol.LuminolConfig;
|
|
import net.minecraft.DefaultUncaughtExceptionHandler;
|
|
import net.minecraft.DefaultUncaughtExceptionHandlerWithName;
|
|
import net.minecraft.SharedConstants;
|
|
@@ -206,6 +208,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
// Spigot end
|
|
// Paper start
|
|
io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // Paper - load mappings for stacktrace deobf and etc.
|
|
+ LuminolConfig.init(); //Luminol
|
|
paperConfigurations.initializeGlobalConfiguration();
|
|
paperConfigurations.initializeWorldDefaultsConfiguration();
|
|
// Paper start - moved up to right after PlayerList creation but before file load/save
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 724aa1d8147ea2fb5e46d291adacfb7e1f5b5f62..e274c501e2455845f6f9a4614802336205362b69 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -38,6 +38,8 @@ import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
import javax.annotation.Nonnull;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import me.earthme.luminol.LuminolConfig;
|
|
import net.minecraft.CrashReport;
|
|
import net.minecraft.Util;
|
|
import net.minecraft.core.BlockPos;
|
|
@@ -766,6 +768,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
}
|
|
// Folia end - region threading
|
|
|
|
+ public final LuminolConfig.LumionalWorldConfig lumionalWorldConfig; //Luminol
|
|
+
|
|
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
|
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
|
// IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error
|
|
@@ -850,6 +854,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
this.chunkTaskScheduler = new io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler(this, io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.workerThreads); // Paper - rewrite chunk system
|
|
this.entityLookup = new io.papermc.paper.chunk.system.entity.EntityLookup(this, new EntityCallbacks()); // Paper - rewrite chunk system
|
|
this.updateTickData(); // Folia - region threading - make sure it is initialised before ticked
|
|
+ this.lumionalWorldConfig = new LuminolConfig.LumionalWorldConfig(this);
|
|
+ try {
|
|
+ this.lumionalWorldConfig.init();
|
|
+ } catch (IOException e) {
|
|
+ throw new RuntimeException("Failed to create luminol config for level "+ this.getWorld().getName()+"!",e);
|
|
+ }
|
|
}
|
|
|
|
// Folia start - region threading
|