Feat/150 add toast support#151
Conversation
…for player retrieval
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a comprehensive Toast notification system to the Surf API, enabling plugins to display customizable toast messages to players across both Bukkit and Velocity platforms. The implementation provides a builder DSL pattern for easy toast creation, direct API methods for programmatic usage, and convenient extension functions for simplified player interactions.
- Adds core toast interfaces (
Toast,ToastService,ToastStyle) with implementation classes - Implements platform-specific builders (
ToastBukkitBuilder,ToastVelocityBuilder) with DSL support - Extends API surfaces with toast creation and sending methods for both Bukkit and Velocity
- Includes comprehensive test command demonstrating all toast creation patterns
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| surf-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/toast/*.kt | Core toast API interfaces defining Toast, ToastService, and ToastStyle enum |
| surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/impl/toast/*.kt | Implementation classes for toast service and toast rendering via advancement packets |
| surf-api-bukkit/surf-api-bukkit-api/src/main/kotlin/dev/slne/surf/surfapi/bukkit/api/toast/ToastBukkitDsl.kt | Bukkit-specific toast builder DSL with Material support |
| surf-api-bukkit/surf-api-bukkit-api/src/main/kotlin/dev/slne/surf/surfapi/bukkit/api/SurfBukkitApi.kt | Extended Bukkit API interface with toast creation and sending methods |
| surf-api-bukkit/surf-api-bukkit-server/src/main/kotlin/dev/slne/surf/surfapi/bukkit/server/impl/SurfBukkitApiImpl.kt | Bukkit API implementation for toast methods with Material to ItemType conversion |
| surf-api-bukkit/surf-api-bukkit-api/src/main/kotlin/dev/slne/surf/surfapi/bukkit/api/util/bukkit-util.kt | Player extension functions for simplified toast sending |
| surf-api-velocity/surf-api-velocity-api/src/main/kotlin/dev/slne/surf/surfapi/velocity/api/toast/ToastVelocityDsl.kt | Velocity-specific toast builder DSL with ItemType support |
| surf-api-velocity/surf-api-velocity-api/src/main/kotlin/dev/slne/surf/surfapi/velocity/api/SurfVelocityApi.kt | Extended Velocity API interface with toast creation and sending methods |
| surf-api-velocity/surf-api-velocity-server/src/main/kotlin/dev/slne/surf/surfapi/velocity/server/impl/SurfVelocityApiImpl.kt | Velocity API implementation for toast methods |
| surf-api-velocity/surf-api-velocity-api/src/main/kotlin/dev/slne/surf/surfapi/velocity/api/util/velocity-util.kt | Velocity Player extension functions for simplified toast sending |
| surf-api-bukkit/surf-api-bukkit-plugin-test/src/main/kotlin/dev/slne/surf/surfapi/bukkit/test/command/subcommands/ToastTest.kt | New test command demonstrating all toast creation patterns |
| surf-api-bukkit/surf-api-bukkit-plugin-test/src/main/java/dev/slne/surf/surfapi/bukkit/test/command/SurfApiTestCommand.java | Registration of ToastTest command |
| gradle.properties, surf-api-gradle-plugin/build.gradle.kts | Version bumps for new release |
| surf-api-bukkit/surf-api-bukkit-api/api/surf-api-bukkit-api.api, surf-api-core/surf-api-core-api/api/surf-api-core-api.api, surf-api-velocity/surf-api-velocity-api/api/surf-api-velocity-api.api | Binary API compatibility files updated with new toast interfaces |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...rf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/impl/toast/ToastImpl.kt
Outdated
Show resolved
Hide resolved
...surf-api-bukkit-api/src/main/kotlin/dev/slne/surf/surfapi/bukkit/api/toast/ToastBukkitDsl.kt
Outdated
Show resolved
Hide resolved
...kit/surf-api-bukkit-api/src/main/kotlin/dev/slne/surf/surfapi/bukkit/api/util/bukkit-util.kt
Show resolved
Hide resolved
| }.mapValuesTo(mutableObject2ObjectMapOf(worlds.size)) { (_, def) -> def.await() } | ||
| } | ||
|
|
||
| override fun createToast(builder: ToastBukkitBuilder.() -> Unit): Toast = |
There was a problem hiding this comment.
Warum gibt es die Methoden hier nochmal wenn es den Toast Service gibt?
| val text: Component | ||
| val style: ToastStyle | ||
|
|
||
| fun send(player: UUID) |
There was a problem hiding this comment.
Hier dann ein Player Objekt
| override val style: ToastStyle | ||
| ) : Toast { | ||
| override fun send(player: UUID) { | ||
| val user = |
There was a problem hiding this comment.
Nms verwenden und kein packet Events
| override fun sendToast( | ||
| player: UUID, | ||
| toast: Toast | ||
| ) = toast.send(player) |
There was a problem hiding this comment.
Das hier andersrum -- die send Methode im Toast ruft dann diese Methode auf mit der Send implementation
| * | ||
| * @see ToastVelocityBuilder | ||
| */ | ||
| fun createToast(builder: ToastVelocityBuilder.() -> Unit): Toast |
There was a problem hiding this comment.
Braucht man nicht auf velocity
Co-authored-by: twisti <76837088+twisti-dev@users.noreply.github.com>
… feat/150-add-toast-support
resolves #150
This pull request introduces a new "Toast" notification system to the Surf API, enabling plugins to create and send customizable toast messages to players. The changes add new API interfaces, builder DSLs, utility functions, and test commands to support toast creation and delivery, along with necessary updates to core and Bukkit modules.
Toast Notification System Integration
Toast,ToastService, andToastStyleenum, allowing creation and sending of toast messages with customizable icons, text, and styles. [1] [2] [3]ToastBukkitBuilderandtoastfunction) in the Bukkit API for easy toast creation via lambda configuration. [1] [2]SurfBukkitApiwith new methods:createToast(both DSL and direct), andsendToastto deliver toasts to players. Also updated the implementation inSurfBukkitApiImpl. [1] [2] [3]Playerinstance, supporting both builder DSL and direct API calls. [1] [2]ToastTest) to demonstrate and verify toast functionality in the plugin test suite. [1] [2] [3]Other Changes
gradle.propertiesto reflect new release.These changes provide a flexible, extensible, and developer-friendly way to display toast notifications to players, improving user feedback and plugin interaction capabilities.