mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-06-21 17:57:47 +02:00
feat(config): load velocity.yml at startup and reload
Route VelocityServer's startup and reload paths through ConfigurationLoader.loadConfiguration(), so the proxy now reads velocity.yml (migrating an existing velocity.toml on first start) instead of reading velocity.toml directly. LegacyConfigurationLoader is retained behind the migration path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -46,7 +46,7 @@ import com.velocitypowered.proxy.command.builtin.SendCommand;
|
|||||||
import com.velocitypowered.proxy.command.builtin.ServerCommand;
|
import com.velocitypowered.proxy.command.builtin.ServerCommand;
|
||||||
import com.velocitypowered.proxy.command.builtin.ShutdownCommand;
|
import com.velocitypowered.proxy.command.builtin.ShutdownCommand;
|
||||||
import com.velocitypowered.proxy.command.builtin.VelocityCommand;
|
import com.velocitypowered.proxy.command.builtin.VelocityCommand;
|
||||||
import com.velocitypowered.proxy.config.LegacyConfigurationLoader;
|
import com.velocitypowered.proxy.config.ConfigurationLoader;
|
||||||
import com.velocitypowered.proxy.config.VelocityConfiguration;
|
import com.velocitypowered.proxy.config.VelocityConfiguration;
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.connection.player.resourcepack.VelocityResourcePackInfo;
|
import com.velocitypowered.proxy.connection.player.resourcepack.VelocityResourcePackInfo;
|
||||||
@@ -403,8 +403,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
@SuppressFBWarnings("DM_EXIT")
|
@SuppressFBWarnings("DM_EXIT")
|
||||||
private void doStartupConfigLoad() {
|
private void doStartupConfigLoad() {
|
||||||
try {
|
try {
|
||||||
Path configPath = Path.of("velocity.toml");
|
configuration = ConfigurationLoader.loadConfiguration();
|
||||||
configuration = LegacyConfigurationLoader.read(configPath);
|
|
||||||
|
|
||||||
if (!configuration.validate()) {
|
if (!configuration.validate()) {
|
||||||
logger.error("Your configuration is invalid. Velocity will not start up until the errors "
|
logger.error("Your configuration is invalid. Velocity will not start up until the errors "
|
||||||
@@ -415,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.toml. The server will shut down.", e);
|
logger.error("Unable to read/load/save your velocity.yml. The server will shut down.", e);
|
||||||
LogManager.shutdown();
|
LogManager.shutdown();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
@@ -478,11 +477,10 @@ 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.toml}
|
* @throws IOException if we can't read {@code velocity.yml}
|
||||||
*/
|
*/
|
||||||
public boolean reloadConfiguration() throws IOException {
|
public boolean reloadConfiguration() throws IOException {
|
||||||
Path configPath = Path.of("velocity.toml");
|
VelocityConfiguration newConfiguration = ConfigurationLoader.loadConfiguration();
|
||||||
VelocityConfiguration newConfiguration = LegacyConfigurationLoader.read(configPath);
|
|
||||||
|
|
||||||
if (!newConfiguration.validate()) {
|
if (!newConfiguration.validate()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user