-
-
Notifications
You must be signed in to change notification settings - Fork 26
feat: Support runtime server addition for Velocity proxy #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for dynamically registering servers at runtime and automatically applying appropriate resource packs to them based on configuration. The implementation introduces a new event listener for server registration events and refactors the resource pack registration logic to support both initial loading and dynamic server addition.
Changes:
- Added
ServerRegistrationListenerto handle runtime server registration events - Refactored resource pack registration logic into reusable methods (
getPackConfigs,processResourcePackConfig,createResourcePack,registerResourcePackForServer) - Updated build configuration to set Java 17 compatibility
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| velocity/src/main/java/com/convallyria/forcepack/velocity/listener/ServerRegistrationListener.java | New event listener that registers resource packs for dynamically added servers matching group configurations |
| velocity/src/main/java/com/convallyria/forcepack/velocity/ForcePackVelocity.java | Refactored resource pack registration logic into smaller, reusable methods to support both initial load and dynamic server addition; extracted common logic into helper methods |
| velocity/build.gradle.kts | Reorganized task configuration and added Java 17 compatibility settings |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @Subscribe | ||
| 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; | ||
|
|
||
| for (String groupName : groups.getKeys()) { | ||
| VelocityConfig groupConfig = groups.getConfig(groupName); | ||
| List<String> servers = groupConfig.getStringList("servers"); | ||
| boolean exact = groupConfig.getBoolean("exact-match"); | ||
|
|
||
| boolean matches = exact ? | ||
| servers.contains(serverName) : | ||
| servers.stream().anyMatch(serverName::contains); | ||
|
|
||
| if (matches) { | ||
| plugin.log("New server %s matches group %s, adding resource packs...", serverName, groupName); | ||
|
|
||
| final Map<String, VelocityConfig> configs = plugin.getPackConfigs(groupConfig, groupName); | ||
|
|
||
| configs.forEach((id, config) -> { | ||
| if (config == null) return; | ||
| plugin.registerResourcePackForServer(config, id, groupName, "group", plugin.getConfig().getBoolean("verify-resource-packs"), serverName, null); | ||
| }); | ||
| } | ||
| } | ||
| } |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ServerRegistrationListener only checks the "groups" configuration but not the "servers" configuration. According to the PR description, dynamic servers should be applied resource packs if they qualify for "groups/servers configs", but this implementation only handles groups. If a dynamically added server should also match entries in the "servers" section of the config, that logic is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR allows dynamically-added servers to be applied resource pack if they qualify for the groups/servers configs