2020-05-02 00:03:47 +02:00
|
|
|
From 931ba2eb4a1ff18a65fa4918ad652d8e62ae1925 Mon Sep 17 00:00:00 2001
|
2018-09-18 05:38:17 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
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
|
2020-04-27 09:34:45 +02:00
|
|
|
index 214b577b32..559e6b42ba 100644
|
2018-09-18 05:38:17 +02:00
|
|
|
--- 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;
|
2019-12-12 17:20:43 +01:00
|
|
|
import java.util.regex.Pattern;
|
|
|
|
@@ -19,6 +20,7 @@ import com.google.common.collect.Lists;
|
2018-09-18 05:38:17 +02:00
|
|
|
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;
|
2019-12-12 17:20:43 +01:00
|
|
|
@@ -310,4 +312,23 @@ public class PaperConfig {
|
2018-09-18 05:38:17 +02:00
|
|
|
}
|
|
|
|
tabSpamLimit = getInt("settings.spam-limiter.tab-spam-limit", tabSpamLimit);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public static Map<String, Long> 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
|
2020-04-27 09:34:45 +02:00
|
|
|
index 056cbdeec8..ec4ce59c5e 100644
|
2018-09-18 05:38:17 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -378,7 +378,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2018-09-18 05:38:17 +02:00
|
|
|
this.convertWorld(name); // Run conversion now
|
|
|
|
|
|
|
|
org.bukkit.generator.ChunkGenerator gen = this.server.getGenerator(name);
|
|
|
|
- WorldSettings worldsettings = new WorldSettings(i, this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype);
|
|
|
|
+ WorldSettings worldsettings = new WorldSettings(com.destroystokyo.paper.PaperConfig.seedOverride.getOrDefault(name, i), this.getGamemode(), this.getGenerateStructures(), this.isHardcore(), worldtype); // Paper
|
|
|
|
worldsettings.setGeneratorSettings(jsonelement);
|
|
|
|
|
|
|
|
if (j == 0) {
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldData.java b/src/main/java/net/minecraft/server/WorldData.java
|
2020-04-27 09:34:45 +02:00
|
|
|
index 561b6d9469..95518e54d1 100644
|
2018-09-18 05:38:17 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldData.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldData.java
|
2020-01-22 03:02:07 +01:00
|
|
|
@@ -127,7 +127,7 @@ public class WorldData {
|
2018-09-18 05:38:17 +02:00
|
|
|
this.d = nbttagcompound2.getBoolean("Snapshot");
|
|
|
|
}
|
|
|
|
|
|
|
|
- this.e = nbttagcompound.getLong("RandomSeed");
|
|
|
|
+ this.e = com.destroystokyo.paper.PaperConfig.seedOverride.getOrDefault(nbttagcompound.getString("LevelName"), nbttagcompound.getLong("RandomSeed")); // Paper
|
|
|
|
if (nbttagcompound.hasKeyOfType("generatorName", 8)) {
|
|
|
|
String s = nbttagcompound.getString("generatorName");
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2020-04-27 09:34:45 +02:00
|
|
|
index d15a857b30..011d0927da 100644
|
2018-09-18 05:38:17 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2020-04-27 09:34:45 +02:00
|
|
|
@@ -1016,7 +1016,7 @@ public final class CraftServer implements Server {
|
2019-05-06 04:58:04 +02:00
|
|
|
WorldSettings worldSettings;
|
|
|
|
// See MinecraftServer.a(String, String, long, WorldType, JsonElement)
|
2018-09-18 05:38:17 +02:00
|
|
|
if (worlddata == null) {
|
|
|
|
- worldSettings = new WorldSettings(creator.seed(), EnumGamemode.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
|
|
|
|
+ worldSettings = new WorldSettings(com.destroystokyo.paper.PaperConfig.seedOverride.getOrDefault(name, creator.seed()), EnumGamemode.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type); // Paper
|
|
|
|
JsonElement parsedSettings = new JsonParser().parse(creator.generatorSettings());
|
|
|
|
if (parsedSettings.isJsonObject()) {
|
|
|
|
worldSettings.setGeneratorSettings(parsedSettings.getAsJsonObject());
|
|
|
|
--
|
2020-04-27 09:34:45 +02:00
|
|
|
2.26.2
|
2018-09-18 05:38:17 +02:00
|
|
|
|