Skip to content

Feat/150 add toast support#151

Merged
twisti-dev merged 16 commits intoversion/1.21.10from
feat/150-add-toast-support
Oct 24, 2025
Merged

Feat/150 add toast support#151
twisti-dev merged 16 commits intoversion/1.21.10from
feat/150-add-toast-support

Conversation

@TheBjoRedCraft
Copy link
Member

@TheBjoRedCraft TheBjoRedCraft commented Oct 19, 2025

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

  • Added new core API interfaces for toast notifications: Toast, ToastService, and ToastStyle enum, allowing creation and sending of toast messages with customizable icons, text, and styles. [1] [2] [3]
  • Implemented builder DSL (ToastBukkitBuilder and toast function) in the Bukkit API for easy toast creation via lambda configuration. [1] [2]
  • Extended SurfBukkitApi with new methods: createToast (both DSL and direct), and sendToast to deliver toasts to players. Also updated the implementation in SurfBukkitApiImpl. [1] [2] [3]
  • Added utility extension functions for sending toasts directly from a Player instance, supporting both builder DSL and direct API calls. [1] [2]
  • Introduced a new test command (ToastTest) to demonstrate and verify toast functionality in the plugin test suite. [1] [2] [3]

Other Changes

  • Version bump in gradle.properties to reflect new release.
  • Added protocol packet API for command suggestions response, supporting future toast-related features.

These changes provide a flexible, extensible, and developer-friendly way to display toast notifications to players, improving user feedback and plugin interaction capabilities.

@TheBjoRedCraft TheBjoRedCraft self-assigned this Oct 19, 2025
Copilot AI review requested due to automatic review settings October 19, 2025 10:41
Copy link
Contributor

Copilot AI left a 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 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.

}.mapValuesTo(mutableObject2ObjectMapOf(worlds.size)) { (_, def) -> def.await() }
}

override fun createToast(builder: ToastBukkitBuilder.() -> Unit): Toast =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warum gibt es die Methoden hier nochmal wenn es den Toast Service gibt?

val text: Component
val style: ToastStyle

fun send(player: UUID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hier dann ein Player Objekt

override val style: ToastStyle
) : Toast {
override fun send(player: UUID) {
val user =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nms verwenden und kein packet Events

override fun sendToast(
player: UUID,
toast: Toast
) = toast.send(player)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braucht man nicht auf velocity

@twisti-dev twisti-dev merged commit 8a945e9 into version/1.21.10 Oct 24, 2025
4 checks passed
@twisti-dev twisti-dev deleted the feat/150-add-toast-support branch October 24, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Toast (Advancement Pop-In) Support

2 participants