From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 17 Sep 2018 23:05:31 -0400 Subject: [PATCH] Support Overriding World Seeds Allows you to add to paper.yml seed-overrides: world_name: some seed value This will ignore every where a seed is set/created/loaded and force a world to use the specified seed. This seed will end up being saved to the world data file, so it is a permanent change in that it won't go back if you remove it from paper.yml diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java index 214b577b326bc794fa3721deb6171228dd4f25e6..559e6b42ba5bf0ea92cccbabd2ef1d4c27b03064 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -11,6 +11,7 @@ import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.regex.Pattern; @@ -19,6 +20,7 @@ import com.google.common.collect.Lists; import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; import org.bukkit.command.Command; +import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import co.aikar.timings.Timings; @@ -310,4 +312,23 @@ public class PaperConfig { } tabSpamLimit = getInt("settings.spam-limiter.tab-spam-limit", tabSpamLimit); } + + public static Map seedOverride = new java.util.HashMap<>(); + private static void worldSeedOverrides() { + ConfigurationSection seeds = config.getConfigurationSection("seed-overrides"); + if (seeds != null) { + TimingsManager.hiddenConfigs.add("seed-overrides"); + for (String key : seeds.getKeys(false)) { + String seedString = seeds.getString(key); + long seed; + try { + seed = Long.parseLong(seedString); + } catch (Exception e) { + seed = (long) seedString.hashCode(); + } + log("Seed Override: " + key + " => " + seed); + seedOverride.put(key, seed); + } + } + } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 056cbdeec8a1c17de44d59f16b77a995c82a3abb..ec4ce59c5e29b68d96856a9086fe2ba1bdbb1df1 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -378,7 +378,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant