Repository navigation
Public API for other plugins, with events on Paper, Velocity and BungeeCord - #3
Merged
Merged
Conversation
…d BungeeCord New `api` module (com.friends:friends-api, Java 8, no dependencies): FriendsAPI (reads from memory, async actions returning a Result), Friend/FriendRequest snapshots, Status, and six events per platform: four cancellable "before" events (request, add, remove, status) and two exactly-once "after" events. - Java 8 because on Paper the API sits next to the bootstrap, where other plugins' class loaders can see it and Paper's class rewriter can read it. - Core: commands return a Result, accept a name or a UUID, ask plugins outside the lock and re-check after; hooks never run on the database thread. - Offline players' friend lists are cached for 30 s, dropped on any friendship change; a read that races a change is never kept. - Nulls and bad input never throw (empty, false or INVALID_ARGUMENT). - Tests: FriendsApiTest, MockBukkit on the shipped Paper jar, proxy event tests, and api-* e2e scenarios with a probe plugin on real servers. - Version 0.5.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
A public API so other plugins can read and act on friendships, plus events on every platform. Version bumped to 0.5.0.
New
apimodule (com.friends:friends-api, Java 8, no dependencies):FriendsAPI, obtained withFriendsAPI.get()(on Paper it is also a Bukkit service).isLoaded,getFriends,areFriends,getStatus,getServer, incoming/outgoing requests.CompletableFuture:loadFriends, and the actionssendRequest,acceptRequest,denyRequest,removeFriend,setBestFriend,setNickname,setStatus. Each action completes with aResultenum.Friend/FriendRequestsnapshots, andStatus(moved here fromcommon).Six events per platform (
com.friends.api.bukkit,.velocity,.bungee):FriendRequestSendEventFriendAddEventFriendAddedEventFriendRemoveEvent/f removealltoo)FriendRemovedEventFriendStatusChangeEvent/statuschangesDocs: full JavaDoc, enforced by the build (
-Xdoclint:all -Werror), and an "API for other plugins" section in the README.Why it's built this way
FriendsRuntime.falseorINVALID_ARGUMENT; database errors giveResult.ERROR.Reviewer notes
Resultsays what happened). The other player is still notified, and commands and API actions fire the same events.paper-api1.21.11:BookMetaimplements Adventure 4'sBook, which is sealed in Adventure 5. MockBukkit also ignores plugin.yml permission defaults, so the test grantsfriends.useitself.paper-api1.21.11-R0.1-SNAPSHOT (PaperMC repo), and compiles the smalltools/e2e/probetest plugin../gradlew :api:publishToMavenLocal.Testing
./gradlew buildwith MySQL 8.0.46 and Redis: every suite passes (1 skipped, a SQLite-only check).Real servers (
tools/e2e): 15/15 scenarios pass, all on 0.4.0 jars (the version bump came after):api-*scenarios with a probe plugin: Paper 1.20.6 and 26.3, BungeeCord, Velocity.Rerun after the bump:
api-1.8.8(also run separately on 0.4.0),api-26.3,api-bungeeandapi-velocitypass on 0.5.0. The probe sees the API, every event (async, never on the server thread), a cancelled/status away, and API reads and actions from its listeners and from the Paper server thread.🤖 Generated with Claude Code