-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/150 add toast support #151
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2ab007b
feat: add toast support with builder and API methods
TheBjoRedCraft 59d51ee
fix: update version to 1.21.10-2.40.2
TheBjoRedCraft 06bc92c
feat: integrate buildText method for toast message customization
TheBjoRedCraft 913c24f
feat: refactor toast API to use core package and enhance send functio…
TheBjoRedCraft dc863b0
feat: update toast API to use Bukkit and Velocity builders for enhanc…
TheBjoRedCraft ba61c7f
feat: enhance toast sending functionality by integrating surfCoreApi …
TheBjoRedCraft effcbe3
feat: refactor toast implementation to streamline packet creation and…
TheBjoRedCraft a2f3c48
feat: enhance ToastTest with multi-line support for improved message …
TheBjoRedCraft 755c7f6
feat: undo deletetion of inventory test class
TheBjoRedCraft 36132d9
feat: remove unused buildText function in Toast implementation for cl…
TheBjoRedCraft 2bf12e8
feat: add missing getSize method to CustomBlockData
TheBjoRedCraft a62fa38
Update gradle.properties
TheBjoRedCraft 84a7f67
feat: downgrade version from 1.5.4 to 1.5.3 in build configuration
TheBjoRedCraft 41abdb7
Merge remote-tracking branch 'origin/feat/150-add-toast-support' into…
TheBjoRedCraft 10c8223
feat: replace ToastBukkitBuilder with ToastBuilder for consistency ac…
TheBjoRedCraft ea56856
feat: update toast creation to use ToastBuilder for consistency
TheBjoRedCraft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
44 changes: 44 additions & 0 deletions
44
...n-test/src/main/kotlin/dev/slne/surf/surfapi/bukkit/test/command/subcommands/ToastTest.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package dev.slne.surf.surfapi.bukkit.test.command.subcommands | ||
|
|
||
| import com.github.retrooper.packetevents.protocol.item.type.ItemTypes | ||
| import dev.jorel.commandapi.CommandAPICommand | ||
| import dev.jorel.commandapi.kotlindsl.playerExecutor | ||
| import dev.slne.surf.surfapi.bukkit.api.surfBukkitApi | ||
| import dev.slne.surf.surfapi.bukkit.api.util.send | ||
| import dev.slne.surf.surfapi.bukkit.api.util.sendToast | ||
| import dev.slne.surf.surfapi.core.api.messages.adventure.buildText | ||
| import dev.slne.surf.surfapi.core.api.toast.ToastStyle | ||
| import dev.slne.surf.surfapi.core.api.toast.toast | ||
| import org.bukkit.Material | ||
|
|
||
| class ToastTest(name: String) : CommandAPICommand(name) { | ||
| init { | ||
| playerExecutor { player, _ -> | ||
| player.sendToast { | ||
| icon(ItemTypes.DIAMOND) | ||
|
|
||
| text { | ||
| info("Dsl-Extension Test") | ||
| } | ||
|
|
||
| style(ToastStyle.TASK) | ||
| } | ||
|
|
||
| player.sendToast(toast { | ||
| icon(ItemTypes.GOLD_INGOT) | ||
|
|
||
| text { | ||
| info("Toast-Builder-Dsl Test") | ||
| appendNewline() | ||
| info("With multiple lines!") | ||
| } | ||
|
|
||
| style(ToastStyle.CHALLENGE) | ||
| }) | ||
|
|
||
| surfBukkitApi.createToast(Material.NETHERITE_AXE, buildText { | ||
| info("Direct API Call Test") | ||
| }, ToastStyle.GOAL).send(player) | ||
| } | ||
| } | ||
| } |
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
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
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
13 changes: 13 additions & 0 deletions
13
...-api-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/toast/Toast.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package dev.slne.surf.surfapi.core.api.toast | ||
|
|
||
| import com.github.retrooper.packetevents.protocol.item.type.ItemType | ||
| import net.kyori.adventure.text.Component | ||
| import java.util.* | ||
|
|
||
| interface Toast { | ||
| val icon: ItemType | ||
| val text: Component | ||
| val style: ToastStyle | ||
|
|
||
| fun send(player: UUID) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hier dann ein Player Objekt |
||
| } | ||
34 changes: 34 additions & 0 deletions
34
...i-core/surf-api-core-api/src/main/kotlin/dev/slne/surf/surfapi/core/api/toast/ToastDsl.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package dev.slne.surf.surfapi.core.api.toast | ||
|
|
||
| import com.github.retrooper.packetevents.protocol.item.type.ItemType | ||
| import com.github.retrooper.packetevents.protocol.item.type.ItemTypes | ||
| import dev.slne.surf.surfapi.core.api.messages.builder.SurfComponentBuilder | ||
|
|
||
| class ToastBuilder { | ||
| private var icon: ItemType = ItemTypes.STONE | ||
| private var text: SurfComponentBuilder.() -> Unit = {} | ||
| private var style: ToastStyle = ToastStyle.TASK | ||
|
|
||
| fun icon(itemType: ItemType) { | ||
| this.icon = itemType | ||
| } | ||
|
|
||
| fun text(block: SurfComponentBuilder.() -> Unit) { | ||
| this.text = block | ||
| } | ||
|
|
||
| fun style(style: ToastStyle) { | ||
| this.style = style | ||
| } | ||
|
|
||
| fun build() = ToastService.INSTANCE.createToast( | ||
| icon, | ||
| SurfComponentBuilder().apply(text).build(), | ||
| style | ||
| ) | ||
| } | ||
|
|
||
| fun toast(block: ToastBuilder.() -> Unit): Toast { | ||
| return ToastBuilder().apply(block).build() | ||
| } | ||
|
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.