Archiviert
13
0

Improve migration file errors (#7929)

Dieser Commit ist enthalten in:
Jake Potrebic 2022-06-10 10:01:09 -07:00 committet von GitHub
Ursprung 8bca9190a4
Commit 698b3152cf
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
3 geänderte Dateien mit 24 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -847,10 +847,10 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1
+}
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
new file mode 100644
index 0000000000000000000000000000000000000000..be64437ba7630fe069aaea502932b514c85162f8
index 0000000000000000000000000000000000000000..bc46e342b398dc56c976702d98ff3646995eb41e
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -0,0 +1,384 @@
@@ -0,0 +1,396 @@
+package io.papermc.paper.configuration;
+
+import com.google.common.base.Suppliers;
@ -926,7 +926,8 @@ index 0000000000000000000000000000000000000000..be64437ba7630fe069aaea502932b514
+ static final String GLOBAL_CONFIG_FILE_NAME = "paper-global.yml";
+ static final String WORLD_DEFAULTS_CONFIG_FILE_NAME = "paper-world-defaults.yml";
+ static final String WORLD_CONFIG_FILE_NAME = "paper-world.yml";
+ private static final Path BACKUP_DIR = Path.of("legacy-backup");
+ public static final String CONFIG_DIR = "config";
+ private static final String BACKUP_DIR ="legacy-backup";
+
+ private static final String GLOBAL_HEADER = """
+ This is the global configuration file for Paper.
@ -1139,12 +1140,23 @@ index 0000000000000000000000000000000000000000..be64437ba7630fe069aaea502932b514
+ public static PaperConfigurations setup(final Path legacyConfig, final Path configDir, final Path worldFolder, final File spigotConfig) throws Exception {
+ if (needsConverting(legacyConfig)) {
+ try {
+ Files.createDirectories(configDir.resolve(BACKUP_DIR));
+ final Path legacyConfigBackup = configDir.resolve(BACKUP_DIR).resolve(legacyConfig.getFileName().toString() + ".old");
+ if (Files.exists(configDir) && !Files.isDirectory(configDir)) {
+ throw new RuntimeException("Paper needs to create a '" + CONFIG_DIR + "' folder in the root of your server. You already have a non-directory named '" + CONFIG_DIR + "'. Please remove it and restart the server.");
+ }
+ final Path backupDir = configDir.resolve(BACKUP_DIR);
+ if (Files.exists(backupDir) && !Files.isDirectory(backupDir)) {
+ throw new RuntimeException("Paper needs to create a '" + BACKUP_DIR + "' directory in the '" + CONFIG_DIR + "' folder. You already have a non-directory named '" + BACKUP_DIR + "'. Please remove it and restart the server.");
+ }
+ Files.createDirectories(backupDir);
+ final String backupFileName = legacyConfig.getFileName().toString() + ".old";
+ final Path legacyConfigBackup = backupDir.resolve(backupFileName);
+ if (Files.exists(legacyConfigBackup) && !Files.isRegularFile(legacyConfigBackup)) {
+ throw new RuntimeException("Paper needs to create a '" + backupFileName + "' file in the '" + BACKUP_DIR + "' folder. You already have a non-file named '" + backupFileName + "'. Please remove it and restart the server.");
+ }
+ Files.move(legacyConfig, legacyConfigBackup, StandardCopyOption.REPLACE_EXISTING); // make backup
+ convert(legacyConfigBackup, configDir, worldFolder, spigotConfig);
+ } catch (final IOException ex) {
+ throw new RuntimeException("Could not convert paper.yml to the new configuration format", ex);
+ throw new RuntimeException("Could not convert '" + legacyConfig.getFileName().toString() + "' to the new configuration format", ex);
+ }
+ }
+ try {
@ -4020,7 +4032,7 @@ index 6cc81495d8d09ff1fbb09f2e63a16ec4fa6138ec..73662a463fc9d38b39c4c779fcfaa09a
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/Services.java b/src/main/java/net/minecraft/server/Services.java
index 697ca7457115423a8c4d8a7d1f7a353237b56509..86c218e41fbe2a55b1319b37d26fd5da4f0b3da6 100644
index 697ca7457115423a8c4d8a7d1f7a353237b56509..3997024eca83af2d82132de3bb5770e155659797 100644
--- a/src/main/java/net/minecraft/server/Services.java
+++ b/src/main/java/net/minecraft/server/Services.java
@@ -7,14 +7,28 @@ import java.io.File;
@ -4050,7 +4062,7 @@ index 697ca7457115423a8c4d8a7d1f7a353237b56509..86c218e41fbe2a55b1319b37d26fd5da
SignatureValidator signatureValidator = SignatureValidator.from(authenticationService.getServicesKey());
- return new Services(minecraftSessionService, signatureValidator, gameProfileRepository, gameProfileCache);
+ // Paper start
+ io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(((File) optionSet.valueOf("paper-settings")).toPath(), java.nio.file.Path.of("config"), rootDirectory.toPath(), (File) optionSet.valueOf("spigot-settings"));
+ io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(((File) optionSet.valueOf("paper-settings")).toPath(), java.nio.file.Path.of(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR), rootDirectory.toPath(), (File) optionSet.valueOf("spigot-settings"));
+ return new Services(minecraftSessionService, signatureValidator, gameProfileRepository, gameProfileCache, paperConfigurations);
+ // Paper end
}

Datei anzeigen

@ -1017,7 +1017,7 @@ index 0000000000000000000000000000000000000000..80a2dfb266ae1221680a7b24fee2f7e2
+ }
+}
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
index be64437ba7630fe069aaea502932b514c85162f8..922ce2f0f4fa10c585939d6682b1a0a8612de0ea 100644
index bc46e342b398dc56c976702d98ff3646995eb41e..39522b2150106082754150ca77cb04e80ae35fac 100644
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -1,5 +1,6 @@
@ -1027,7 +1027,7 @@ index be64437ba7630fe069aaea502932b514c85162f8..922ce2f0f4fa10c585939d6682b1a0a8
import com.google.common.base.Suppliers;
import com.google.common.collect.Table;
import com.mojang.logging.LogUtils;
@@ -191,6 +192,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
@@ -192,6 +193,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
.register(DoubleOrDefault.SERIALIZER)
.register(BooleanOrDefault.SERIALIZER)
.register(Duration.SERIALIZER)

Datei anzeigen

@ -29,7 +29,7 @@ index 8fda43173012ed3134ed1f114143ceaad66cae4a..3e1b589031d46126bdd6b6f63d7a1333
String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath());
diff --git a/src/main/java/net/minecraft/server/Services.java b/src/main/java/net/minecraft/server/Services.java
index 86c218e41fbe2a55b1319b37d26fd5da4f0b3da6..c424ae9cc8d346d0f685de463f4e5772077c61dd 100644
index 3997024eca83af2d82132de3bb5770e155659797..fbcbec480f66f0ebb57e1b937cb1bd320d53748c 100644
--- a/src/main/java/net/minecraft/server/Services.java
+++ b/src/main/java/net/minecraft/server/Services.java
@@ -19,12 +19,12 @@ public record Services(MinecraftSessionService sessionService, SignatureValidato
@ -47,4 +47,4 @@ index 86c218e41fbe2a55b1319b37d26fd5da4f0b3da6..c424ae9cc8d346d0f685de463f4e5772
+ GameProfileCache gameProfileCache = new GameProfileCache(gameProfileRepository, userCacheFile); // Paper
SignatureValidator signatureValidator = SignatureValidator.from(authenticationService.getServicesKey());
// Paper start
io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(((File) optionSet.valueOf("paper-settings")).toPath(), java.nio.file.Path.of("config"), rootDirectory.toPath(), (File) optionSet.valueOf("spigot-settings"));
io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(((File) optionSet.valueOf("paper-settings")).toPath(), java.nio.file.Path.of(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR), rootDirectory.toPath(), (File) optionSet.valueOf("spigot-settings"));