mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-06-21 09:47:44 +02:00
fix(config): use .yaml extension instead of .yml
Rename the proxy configuration file and bundled default resource from velocity.yml/default-velocity.yml to velocity.yaml/default-velocity.yaml. Third-party plugin descriptor files (plugin.yml, bungee.yml, paper-plugin.yml) are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -414,7 +414,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
|
|
||||||
commandManager.setAnnounceProxyCommands(configuration.isAnnounceProxyCommands());
|
commandManager.setAnnounceProxyCommands(configuration.isAnnounceProxyCommands());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to read/load/save your velocity.yml. The server will shut down.", e);
|
logger.error("Unable to read/load/save your velocity.yaml. The server will shut down.", e);
|
||||||
LogManager.shutdown();
|
LogManager.shutdown();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
@@ -477,7 +477,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
* Reloads the proxy's configuration.
|
* Reloads the proxy's configuration.
|
||||||
*
|
*
|
||||||
* @return {@code true} if successful, {@code false} if we can't read the configuration
|
* @return {@code true} if successful, {@code false} if we can't read the configuration
|
||||||
* @throws IOException if we can't read {@code velocity.yml}
|
* @throws IOException if we can't read {@code velocity.yaml}
|
||||||
*/
|
*/
|
||||||
public boolean reloadConfiguration() throws IOException {
|
public boolean reloadConfiguration() throws IOException {
|
||||||
VelocityConfiguration newConfiguration = ConfigurationLoader.loadConfiguration();
|
VelocityConfiguration newConfiguration = ConfigurationLoader.loadConfiguration();
|
||||||
|
|||||||
@@ -49,15 +49,15 @@ public final class ConfigurationLoader {
|
|||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(ConfigurationLoader.class);
|
private static final Logger logger = LogManager.getLogger(ConfigurationLoader.class);
|
||||||
|
|
||||||
private static final String DEFAULT_CONFIG_RESOURCE = "default-velocity.yml";
|
private static final String DEFAULT_CONFIG_RESOURCE = "default-velocity.yaml";
|
||||||
private static final Path DEFAULT_CONFIG_PATH = Path.of("velocity.yml");
|
private static final Path DEFAULT_CONFIG_PATH = Path.of("velocity.yaml");
|
||||||
private static final Path LEGACY_CONFIG_PATH = Path.of("velocity.toml");
|
private static final Path LEGACY_CONFIG_PATH = Path.of("velocity.toml");
|
||||||
private static final String FORWARDING_SECRET_FILE_KEY = "forwarding-secret-file";
|
private static final String FORWARDING_SECRET_FILE_KEY = "forwarding-secret-file";
|
||||||
private static final String DEFAULT_FORWARDING_SECRET_FILE = "forwarding.secret";
|
private static final String DEFAULT_FORWARDING_SECRET_FILE = "forwarding.secret";
|
||||||
static final String CONFIG_VERSION_KEY = "config-version";
|
static final String CONFIG_VERSION_KEY = "config-version";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current {@code velocity.yml} schema version. Files are born at this version (either freshly
|
* Current {@code velocity.yaml} schema version. Files are born at this version (either freshly
|
||||||
* written from the bundled default or stamped during a {@code velocity.toml} migration). Once a
|
* written from the bundled default or stamped during a {@code velocity.toml} migration). Once a
|
||||||
* YAML-schema migration is needed, drive upgrades from here via
|
* YAML-schema migration is needed, drive upgrades from here via
|
||||||
* {@link org.spongepowered.configurate.transformation.ConfigurationTransformation#versionedBuilder()}
|
* {@link org.spongepowered.configurate.transformation.ConfigurationTransformation#versionedBuilder()}
|
||||||
@@ -77,7 +77,7 @@ public final class ConfigurationLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the Velocity configuration from {@code velocity.yml}, migrating a legacy
|
* Loads the Velocity configuration from {@code velocity.yaml}, migrating a legacy
|
||||||
* {@code velocity.toml} or writing the documented default on first start as needed.
|
* {@code velocity.toml} or writing the documented default on first start as needed.
|
||||||
*
|
*
|
||||||
* @return the loaded configuration
|
* @return the loaded configuration
|
||||||
@@ -119,7 +119,7 @@ public final class ConfigurationLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a legacy {@code velocity.toml} to {@code velocity.yml}. The legacy night-config
|
* Converts a legacy {@code velocity.toml} to {@code velocity.yaml}. The legacy night-config
|
||||||
* migrations are run first to normalise the file, then it is written out as YAML stamped with the
|
* migrations are run first to normalise the file, then it is written out as YAML stamped with the
|
||||||
* current schema version and the old file is preserved as {@code velocity.toml.migrated}.
|
* current schema version and the old file is preserved as {@code velocity.toml.migrated}.
|
||||||
*/
|
*/
|
||||||
@@ -161,7 +161,7 @@ public final class ConfigurationLoader {
|
|||||||
* Resolves the player-info forwarding secret. Mirrors the legacy behaviour: prefer the
|
* Resolves the player-info forwarding secret. Mirrors the legacy behaviour: prefer the
|
||||||
* {@code VELOCITY_FORWARDING_SECRET} environment variable, otherwise read (creating if absent) the
|
* {@code VELOCITY_FORWARDING_SECRET} environment variable, otherwise read (creating if absent) the
|
||||||
* file pointed at by {@code forwarding-secret-file}. The secret is deliberately kept out of
|
* file pointed at by {@code forwarding-secret-file}. The secret is deliberately kept out of
|
||||||
* {@code velocity.yml}.
|
* {@code velocity.yaml}.
|
||||||
*/
|
*/
|
||||||
private static byte[] readForwardingSecret(final ConfigurationNode node) throws IOException {
|
private static byte[] readForwardingSecret(final ConfigurationNode node) throws IOException {
|
||||||
String secret = System.getenv().getOrDefault("VELOCITY_FORWARDING_SECRET", "");
|
String secret = System.getenv().getOrDefault("VELOCITY_FORWARDING_SECRET", "");
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class LegacyConfigurationLoader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the raw {@code forwarding-secret-file} value from a legacy TOML configuration, so a
|
* Reads the raw {@code forwarding-secret-file} value from a legacy TOML configuration, so a
|
||||||
* custom secret location can be preserved when migrating to {@code velocity.yml}.
|
* custom secret location can be preserved when migrating to {@code velocity.yaml}.
|
||||||
*
|
*
|
||||||
* @param path the legacy configuration path
|
* @param path the legacy configuration path
|
||||||
* @return the configured forwarding-secret-file, or {@code null} if unset
|
* @return the configured forwarding-secret-file, or {@code null} if unset
|
||||||
|
|||||||
@@ -472,7 +472,7 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
|
|
||||||
static class Servers {
|
static class Servers {
|
||||||
|
|
||||||
// Example entries live in default-velocity.yml, not here: the code default must stay empty so
|
// Example entries live in default-velocity.yaml, not here: the code default must stay empty so
|
||||||
// that a user who removes the section gets an empty map rather than resurrected examples that
|
// that a user who removes the section gets an empty map rather than resurrected examples that
|
||||||
// reference servers they no longer have.
|
// reference servers they no longer have.
|
||||||
private Map<String, String> servers = ImmutableMap.of();
|
private Map<String, String> servers = ImmutableMap.of();
|
||||||
@@ -525,7 +525,7 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
|
|
||||||
static class ForcedHosts {
|
static class ForcedHosts {
|
||||||
|
|
||||||
// Example entries live in default-velocity.yml, not here: the code default must stay empty so
|
// Example entries live in default-velocity.yaml, not here: the code default must stay empty so
|
||||||
// that removing the section yields no forced hosts rather than examples pointing at servers the
|
// that removing the section yields no forced hosts rather than examples pointing at servers the
|
||||||
// user does not have (which would fail validation).
|
// user does not have (which would fail validation).
|
||||||
private Map<String, List<String>> forcedHosts = ImmutableMap.of();
|
private Map<String, List<String>> forcedHosts = ImmutableMap.of();
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ kick-existing-players: false
|
|||||||
|
|
||||||
# Should Velocity pass server list ping requests to a backend server?
|
# Should Velocity pass server list ping requests to a backend server?
|
||||||
# Available options:
|
# Available options:
|
||||||
# - "disabled": No pass-through will be done. The velocity.yml and server-icon.png
|
# - "disabled": No pass-through will be done. The velocity.yaml and server-icon.png
|
||||||
# will determine the initial server list ping response.
|
# will determine the initial server list ping response.
|
||||||
# - "mods": Passes only the mod list from your backend server into the response.
|
# - "mods": Passes only the mod list from your backend server into the response.
|
||||||
# The first server in your try list (or forced host) with a mod list will be
|
# The first server in your try list (or forced host) with a mod list will be
|
||||||
@@ -44,10 +44,10 @@ class ConfigurationLoaderTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void bundledDefaultLoads(@TempDir final Path dir) throws IOException {
|
void bundledDefaultLoads(@TempDir final Path dir) throws IOException {
|
||||||
final Path path = dir.resolve("velocity.yml");
|
final Path path = dir.resolve("velocity.yaml");
|
||||||
try (InputStream in = ConfigurationLoaderTest.class.getClassLoader()
|
try (InputStream in = ConfigurationLoaderTest.class.getClassLoader()
|
||||||
.getResourceAsStream("default-velocity.yml")) {
|
.getResourceAsStream("default-velocity.yaml")) {
|
||||||
assertNotNull(in, "default-velocity.yml is missing from resources");
|
assertNotNull(in, "default-velocity.yaml is missing from resources");
|
||||||
Files.copy(in, path);
|
Files.copy(in, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,19 +116,19 @@ class ConfigurationLoaderTest {
|
|||||||
metrics:
|
metrics:
|
||||||
enabled: false
|
enabled: false
|
||||||
""";
|
""";
|
||||||
final Path path = dir.resolve("velocity.yml");
|
final Path path = dir.resolve("velocity.yaml");
|
||||||
Files.writeString(path, yaml, StandardCharsets.UTF_8);
|
Files.writeString(path, yaml, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
assertConfig(ConfigurationLoader.load(path));
|
assertConfig(ConfigurationLoader.load(path));
|
||||||
|
|
||||||
// Round trip: save the loaded config out and read it back; everything must still match.
|
// Round trip: save the loaded config out and read it back; everything must still match.
|
||||||
final Path roundTripped = dir.resolve("velocity-roundtrip.yml");
|
final Path roundTripped = dir.resolve("velocity-roundtrip.yaml");
|
||||||
ConfigurationLoader.save(ConfigurationLoader.load(path), roundTripped);
|
ConfigurationLoader.save(ConfigurationLoader.load(path), roundTripped);
|
||||||
assertConfig(ConfigurationLoader.load(roundTripped));
|
assertConfig(ConfigurationLoader.load(roundTripped));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A legacy {@code velocity.toml} must be converted to {@code velocity.yml}: values carried over,
|
* A legacy {@code velocity.toml} must be converted to {@code velocity.yaml}: values carried over,
|
||||||
* the schema version stamped, a custom forwarding-secret-file preserved, and the old file
|
* the schema version stamped, a custom forwarding-secret-file preserved, and the old file
|
||||||
* archived as {@code velocity.toml.migrated}.
|
* archived as {@code velocity.toml.migrated}.
|
||||||
*/
|
*/
|
||||||
@@ -156,7 +156,7 @@ class ConfigurationLoaderTest {
|
|||||||
accepts-transfers = true
|
accepts-transfers = true
|
||||||
""".formatted(secretLiteral));
|
""".formatted(secretLiteral));
|
||||||
|
|
||||||
final Path yaml = dir.resolve("velocity.yml");
|
final Path yaml = dir.resolve("velocity.yaml");
|
||||||
final VelocityConfiguration config = ConfigurationLoader.loadConfiguration(yaml, toml);
|
final VelocityConfiguration config = ConfigurationLoader.loadConfiguration(yaml, toml);
|
||||||
|
|
||||||
assertTrue(Files.exists(yaml));
|
assertTrue(Files.exists(yaml));
|
||||||
@@ -186,7 +186,7 @@ class ConfigurationLoaderTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
void removedSectionsDoNotResurrectDefaults(@TempDir final Path dir) throws IOException {
|
void removedSectionsDoNotResurrectDefaults(@TempDir final Path dir) throws IOException {
|
||||||
final Path path = dir.resolve("velocity.yml");
|
final Path path = dir.resolve("velocity.yaml");
|
||||||
Files.writeString(path, """
|
Files.writeString(path, """
|
||||||
servers:
|
servers:
|
||||||
only: "1.2.3.4:25565"
|
only: "1.2.3.4:25565"
|
||||||
|
|||||||
Reference in New Issue
Block a user