diff --git a/README.md b/README.md new file mode 100644 index 0000000..f86b8ab --- /dev/null +++ b/README.md @@ -0,0 +1,101 @@ +
+ +![](/assets/readme-banner.png) +# Supports cdn and okaeri configs + +[![Patreon](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/donate/patreon-plural_vector.svg)](https://www.patreon.com/eternalcode) +[![Website](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/documentation/website_vector.svg)](https://eternalcode.pl/) +[![Discord](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/social/discord-plural_vector.svg)](https://discord.gg/FQ7jmGBd6c) + +[![Gradle](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/built-with/gradle_vector.svg)](https://gradle.org/) +[![Java](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/built-with/java17_vector.svg)](https://www.java.com/) + +
+ +# Introduction + +Multification is a spigot-library that allows you to easily create configurable notifications and messages inside your minecraft plugin. +The library supports sending notifications via one or multiple options: +- customizable messages, +- action bar notifications, +- title and subtitle, +- boss bar notifications, +- and sounds, + +messages can be sent to: +- multiple players, +- one player, +- or the console. + +Your messages can also contain placeholders :P + +## Setup + +To use the library, you need to add the following repository and dependency to your `build.gradle` file: + +```gradle +implementation("com.eternalcode:multification-bukkit:1.1.4") +implementation("com.eternalcode:multification-cdn:1.1.4") +``` + +Then create a new instance of the `Multification` class and use it to send notifications: + +```java +public class YourMultification extends BukkitMultification { + + private final MessagesConfig messagesConfig; + private final AudienceProvider audienceProvider; + private final MiniMessage miniMessage; + + public YourMultification(MessagesConfig messagesConfig, AudienceProvider audienceProvider, MiniMessage miniMessage) { + this.messagesConfig = messagesConfig; + this.audienceProvider = audienceProvider; + this.miniMessage = miniMessage; + } + + @Override + protected @NotNull TranslationProvider translationProvider() { + return locale -> this.messagesConfig; + } + + @Override + protected @NotNull ComponentSerializer serializer() { + return this.miniMessage; + } + + @Override + protected @NotNull AudienceConverter audienceConverter() { + return commandSender -> { + if (commandSender instanceof Player player) { + return this.audienceProvider.player(player.getUniqueId()); + } + + return this.audienceProvider.console(); + }; + } + +} +``` + +Then on enable, you can create a new instance of the `YourMultification` class and use it to send notifications: + +```java + private AudienceProvider audienceProvider = BukkitAudiences.create(this); + MiniMessage miniMessage = MiniMessage.miniMessage(); + + MessagesConfig messagesConfig = new MessagesConfig(); + YourMultification multification = new YourMultification(messagesConfig, audienceProvider, miniMessage); +``` + +After that, you can use the `multification` instance to send notifications: + +```java + multification.create() + .player(player.getUniqueId()) + .notice(messages -> messages.yourMessage) + .send(); +``` + +Setting up configuration is easy both in cdn and okaeri configs. To add messages to the configuration, create variable in config with class `Notice` or `BukktiNotice`. You can also use builder. After plugin deploy you can find messages in configuration file. + +### To see more examples open the [example plugin module](https://github.com/EternalCodeTeam/multification/tree/master/examples/bukkit). diff --git a/assets/readme-banner.png b/assets/readme-banner.png new file mode 100644 index 0000000..4d8bf20 Binary files /dev/null and b/assets/readme-banner.png differ diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index bdbdbba..f38b71d 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -2,7 +2,7 @@ object Versions { const val ADVENTURE_PLATFORM_BUKKIT = "4.3.3" - const val ADVENTURE_API = "4.18.0-SNAPSHOT" + const val ADVENTURE_API = "4.17.0" const val CDN = "1.14.5" const val MOCKITO_CORE = "5.14.2" diff --git a/examples/bukkit/src/main/java/com/eternalcode/example/bukkit/config/MessagesConfig.java b/examples/bukkit/src/main/java/com/eternalcode/example/bukkit/config/MessagesConfig.java index aad9e63..30d346e 100644 --- a/examples/bukkit/src/main/java/com/eternalcode/example/bukkit/config/MessagesConfig.java +++ b/examples/bukkit/src/main/java/com/eternalcode/example/bukkit/config/MessagesConfig.java @@ -22,7 +22,7 @@ public class MessagesConfig { public Notice senderGiveCommandMessage = Notice.title("You have given {amount}x {item} to {player}."); public Notice receiverGiveCommandMessage = BukkitNotice.builder() .title("You have received {amount}x {item} from {player}.") - .subtitle("Remember to say thank you!") + .subtitle("Remember to say thank you!") .sound(Sound.ENTITY_ITEM_PICKUP) .build();