Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,35 @@ public ServerRegistrationListener(ForcePackVelocity plugin) {
public void onServerRegistered(ServerRegisteredEvent event) {
RegisteredServer registeredServer = event.registeredServer();
String serverName = registeredServer.getServerInfo().getName();
VelocityConfig groups = plugin.getConfig().getConfig("groups");

if (groups == null) return;

// Check if we already have packs for this server
boolean hasPack = plugin.getResourcePacks().stream()
.anyMatch(pack -> pack.getServer().equals(serverName));

if (hasPack) return;

// Check the "servers" configuration first
VelocityConfig servers = plugin.getConfig().getConfig("servers");
if (servers != null) {
VelocityConfig serverConfig = servers.getConfig(serverName);
Comment on lines +32 to +34
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VelocityConfig servers is declared here, but later in the method (inside the groups loop) there is also a List<String> servers local variable. Java does not allow redeclaring a local variable name in an inner scope, so this will fail to compile. Rename one of them (e.g., serversConfig for the config section, or serverPatterns for the list).

Suggested change
VelocityConfig servers = plugin.getConfig().getConfig("servers");
if (servers != null) {
VelocityConfig serverConfig = servers.getConfig(serverName);
VelocityConfig serversConfig = plugin.getConfig().getConfig("servers");
if (serversConfig != null) {
VelocityConfig serverConfig = serversConfig.getConfig(serverName);

Copilot uses AI. Check for mistakes.
if (serverConfig != null) {
plugin.log("New server %s matches servers configuration, adding resource packs...", serverName);

final Map<String, VelocityConfig> configs = plugin.getPackConfigs(serverConfig, serverName);

configs.forEach((id, config) -> {
if (config == null) return;
// serverName is used both as the config name and target server name
plugin.registerResourcePackForServer(config, id, serverName, "server", plugin.getConfig().getBoolean("verify-resource-packs"), serverName, null);
});
return;
}
Comment on lines +43 to +46
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return; after handling a servers.<serverName> match prevents groups configs from ever being applied to dynamically-registered servers that also have a direct servers entry. ForcePackVelocity.loadResourcePacks() loads both groups and servers (it calls addResourcePacks(..., "groups") and then addResourcePacks(..., "servers")), so this introduces inconsistent behavior between startup/reload and dynamic registration. Consider removing the early return (register server packs, then still check groups), or update the initialization path if servers is meant to override groups.

Copilot uses AI. Check for mistakes.
}

// Check the "groups" configuration
VelocityConfig groups = plugin.getConfig().getConfig("groups");
if (groups == null) return;

for (String groupName : groups.getKeys()) {
VelocityConfig groupConfig = groups.getConfig(groupName);
List<String> servers = groupConfig.getStringList("servers");
Expand Down
Loading