@@ -21,16 +21,35 @@ public ServerRegistrationListener(ForcePackVelocity plugin) {
2121 public void onServerRegistered (ServerRegisteredEvent event ) {
2222 RegisteredServer registeredServer = event .registeredServer ();
2323 String serverName = registeredServer .getServerInfo ().getName ();
24- VelocityConfig groups = plugin .getConfig ().getConfig ("groups" );
25-
26- if (groups == null ) return ;
2724
2825 // Check if we already have packs for this server
2926 boolean hasPack = plugin .getResourcePacks ().stream ()
3027 .anyMatch (pack -> pack .getServer ().equals (serverName ));
3128
3229 if (hasPack ) return ;
3330
31+ // Check the "servers" configuration first
32+ VelocityConfig servers = plugin .getConfig ().getConfig ("servers" );
33+ if (servers != null ) {
34+ VelocityConfig serverConfig = servers .getConfig (serverName );
35+ if (serverConfig != null ) {
36+ plugin .log ("New server %s matches servers configuration, adding resource packs..." , serverName );
37+
38+ final Map <String , VelocityConfig > configs = plugin .getPackConfigs (serverConfig , serverName );
39+
40+ configs .forEach ((id , config ) -> {
41+ if (config == null ) return ;
42+ // serverName is used both as the config name and target server name
43+ plugin .registerResourcePackForServer (config , id , serverName , "server" , plugin .getConfig ().getBoolean ("verify-resource-packs" ), serverName , null );
44+ });
45+ return ;
46+ }
47+ }
48+
49+ // Check the "groups" configuration
50+ VelocityConfig groups = plugin .getConfig ().getConfig ("groups" );
51+ if (groups == null ) return ;
52+
3453 for (String groupName : groups .getKeys ()) {
3554 VelocityConfig groupConfig = groups .getConfig (groupName );
3655 List <String > servers = groupConfig .getStringList ("servers" );
0 commit comments