Implement default available slots provider for surf servers#9
Merged
Conversation
…rvers - add DefaultSurfQueueAvailableSlotsProvider to calculate available slots - integrate provider into PaperQueueTransfer and PaperSurfQueueInstance - create SurfQueueAvailableSlotsProvider interface for global access
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new API abstraction (SurfQueueAvailableSlotsProvider) to compute available player slots for a SurfServer, and wires a Paper default implementation into the Paper plugin so transfer logic no longer directly depends on Bukkit for slot calculation.
Changes:
- Added
SurfQueueAvailableSlotsProvidertosurf-queue-apias a global, platform-configurable slot resolution mechanism. - Implemented and registered
DefaultSurfQueueAvailableSlotsProviderin the Paper module. - Refactored
PaperQueueTransferto use the provider instead of directly querying Bukkit. - Bumped project version to
1.2.0.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| surf-queue-paper/src/main/kotlin/dev/slne/surf/queue/paper/queue/transfer/PaperQueueTransfer.kt | Uses the new global slots provider for transfer sizing (but currently leaves an unused Bukkit import). |
| surf-queue-paper/src/main/kotlin/dev/slne/surf/queue/paper/queue/DefaultSurfQueueAvailableSlotsProvider.kt | Adds the Paper default provider for available slots (currently uses Bukkit from a worker thread and can return negative slots). |
| surf-queue-paper/src/main/kotlin/dev/slne/surf/queue/paper/PaperSurfQueueInstance.kt | Registers the Paper default provider during plugin load. |
| surf-queue-api/src/main/kotlin/dev/slne/surf/queue/api/SurfQueueAvailableSlotsProvider.kt | Introduces the new provider interface and global accessor. |
| gradle.properties | Version bump 1.1.3 → 1.2.0. |
Comments suppressed due to low confidence (1)
surf-queue-paper/src/main/kotlin/dev/slne/surf/queue/paper/queue/transfer/PaperQueueTransfer.kt:14
org.bukkit.Bukkitis imported but no longer used in this file after switching slot calculation toSurfQueueAvailableSlotsProvider. Kotlin treats unused imports as compilation errors, so this will fail the build.
import dev.slne.surf.queue.api.SurfQueueAvailableSlotsProvider
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.withTimeout
import net.kyori.adventure.text.Component
import org.bukkit.Bukkit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new abstraction for determining available slots on a server and integrates it into the Paper implementation. The main goal is to decouple slot calculation logic from direct Bukkit API usage, making the codebase more modular and extensible.
New abstraction for available slots:
SurfQueueAvailableSlotsProviderinterface to the API, providing a global mechanism to determine available slots for a givenSurfServer.DefaultSurfQueueAvailableSlotsProviderobject for the Paper platform, using Bukkit APIs for the current server and fallback logic for others.Integration and refactoring:
DefaultSurfQueueAvailableSlotsProvideras the global provider during Paper plugin loading inPaperSurfQueueInstance.PaperQueueTransferto use the new provider for slot calculation instead of directly accessing Bukkit APIs, improving modularity and testability.Project versioning:
1.1.3to1.2.0ingradle.properties.