https://github.com/rchomczyk/honey
A message library, which focuses on being extensible and flexible.
https://github.com/rchomczyk/honey
adventure bukkit bukkit-api dispatcher java kyori message minecraft minimessage notification paper papermc placeholders spigot spigot-api
Last synced: 6 months ago
JSON representation
A message library, which focuses on being extensible and flexible.
- Host: GitHub
- URL: https://github.com/rchomczyk/honey
- Owner: rchomczyk
- License: mit
- Created: 2024-08-14T18:39:20.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-23T15:45:57.000Z (11 months ago)
- Last Synced: 2024-11-23T16:32:20.330Z (11 months ago)
- Topics: adventure, bukkit, bukkit-api, dispatcher, java, kyori, message, minecraft, minimessage, notification, paper, papermc, placeholders, spigot, spigot-api
- Language: Java
- Homepage:
- Size: 1.23 MB
- Stars: 6
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## honey (*miód*)
A message library, which focuses on simplicity and flexibility.
### Intent
*honey* was created to allow for developers to create easily customizable messages for end users, by giving them flexibility with placeholders.
### Get started
You can build dependency and append it to your local .m2 directory, by using:
`./gradlew publishToMavenLocal`
### Use case (honey)
A showcase of how to use *honey*, can be found in [honey-test-plugin](honey-test-plugin) module.
#### With use of formatter
*MessageFormatter* provides all functionality that honey offers, it comes with reflective placeholder
evaluation and sanitization to make them harmless, while used with minimessage without any additional
hasle on developer side.```java
AdventureMessageDispatcher.createTitle()
.viewer(event.getPlayer())
.title(it -> it.template(formatter, "Hello!"))
.subtitle(it -> it.template(formatter, "It is a pleasure to see you there {{player.getName}}"))
.variable("player", event.getPlayer())
.times(2, 4, 2)
.dispatch();AdventureMessageDispatcher.createChat()
.viewer(Bukkit.getServer())
.template(formatter, "{{player.getName}} has joined the server!")
.variable("player", event.getPlayer())
.dispatch();AdventureMessageDispatcher.createActionBar()
.viewer(event.getPlayer())
.template(formatter, "Honey is great, isn't it?")
.dispatch();
```#### Without formatter
*MessageDispatcher* provides a way to send messages without the need of using placeholders.
```java
AdventureMessageDispatcher.createChat()
.viewer(Bukkit.getServer())
.template(Component.text("Somebody joined to the server!").color(NamedTextColor.RED))
.dispatch();AdventureMessageDispatcher.createActionBar()
.viewer(event.getPlayer())
.template(Component.text("Honey is great, isn't it?"))
.dispatch();
```### Use case (honey-kt-extesion)
```kotlin
AdventureMessageDispatcher.createChat()
.viewer(event.player)
.template(Component.text("Hello!"))
.dispatch()AdventureMessageDispatcher.createActionBar()
.viewer(event.player)
.template(Component.text("This is an action bar message!"))
.dispatch()player.createChat()
.template(Component.text("A custom chat message"))
.dispatch()player.createActionBar()
.template(Component.text("This is a custom action bar"))
.dispatch()AdventureMessageDispatcher.createTitle()
.viewer(event.player)
.title { it.template(Component.text("Hello!")) }
.subtitle { it.template(Component.text("It's great to see you!")) }
.times(2, 4, 2)
.dispatch()
```### Synchronous vs asynchronous message dispatching
- [dispatch](https://github.com/rchomczyk/honey/tree/main/honey-common/src/dev/shiza/honey/message/dispatcher/MessageBaseDispatcher.java#L71)
This method immediately delivers the message synchronously. It calls the deliver function with the rendered message and the viewer, and the action is completed immediately.- [dispatchAsync](https://github.com/rchomczyk/honey/tree/main/honey-common/src/dev/shiza/honey/message/dispatcher/MessageBaseDispatcher.java#L76)
This method delivers the message asynchronously. It returns a CompletableFuture that performs the message rendering in the background and then delivers the result once it's ready. It allows non-blocking behavior and handles exceptions asynchronously.