|
1 | 1 | <div align="center">
|
2 | 2 |
|
3 | 3 | 
|
4 |
| -# Supports cdn and okaeri configs |
| 4 | +# Multification |
| 5 | +#### Powerful library for sending custom notifications based on adventure. |
5 | 6 |
|
6 | 7 | [](https://www.patreon.com/eternalcode)
|
7 | 8 | [](https://eternalcode.pl/)
|
|
12 | 13 |
|
13 | 14 | </div>
|
14 | 15 |
|
15 |
| -# Introduction |
| 16 | +# About Multification |
16 | 17 |
|
17 |
| -Multification is a spigot-based library that allows you to easily create configurable notifications and messages inside your plugin. |
18 |
| -The library supports sending notifications via one or multiple options: |
19 |
| -- Customizable messages, |
20 |
| -- Action bar notifications, |
21 |
| -- Title and subtitle, |
22 |
| -- Bossbar notifications, |
23 |
| -- and sounds, |
| 18 | +Multification allows you to easily create configurable notifications and messages inside your plugin. |
| 19 | +The library provides a lot of features such as: |
24 | 20 |
|
25 |
| -messages can be sent to: |
26 |
| -- Multiple players, |
27 |
| -- One player, |
28 |
| -- Console |
| 21 | +- 💭 Chat messages |
| 22 | +- 📕 Title & Subtitle |
| 23 | +- 🎬 ActionBar |
| 24 | +- 🍫 BossBar |
| 25 | +- 🔊 Sounds |
| 26 | +- 🎨 Adventure support |
| 27 | +- 🌈 MiniMessage support (including gradients, hex colors, hover, click and more) |
| 28 | +- 📥 Placeholders |
| 29 | +- 🛠️ Formatter support |
| 30 | +- 🌎 Flexible messages providing (easy to implement i18n) |
| 31 | +- 📦 Configuration support (CDN, Okaeri Configs) |
| 32 | +- Cross-platform support (currently we support Bukkit, but it's easy to add support for other adventure-based platforms) |
29 | 33 |
|
30 |
| -Your messages can also contain placeholders :P |
| 34 | +Messages can be sent to any audience, such as players or the console. |
31 | 35 |
|
32 |
| -## Setup |
| 36 | +## Getting Started |
33 | 37 |
|
34 | 38 | To use the library, you need to add the following repository and dependency to your `build.gradle` file:
|
35 | 39 |
|
36 |
| -```gradle |
| 40 | +```kts |
| 41 | +maven("https://repo.eternalcode.pl/releases") |
| 42 | +``` |
| 43 | + |
| 44 | +```kts |
37 | 45 | implementation("com.eternalcode:multification-bukkit:1.1.4")
|
38 |
| -implementation("com.eternalcode:multification-cdn:1.1.4") |
39 | 46 | ```
|
40 | 47 |
|
| 48 | +> **Note:** If you want to use the library with other platforms, then you need to use the `multification-core` dependency. |
| 49 | +
|
41 | 50 | Then create a new instance of the `Multification` class and use it to send notifications:
|
42 | 51 |
|
43 | 52 | ```java
|
@@ -77,25 +86,109 @@ public class YourMultification extends BukkitMultification<MessagesConfig> {
|
77 | 86 | }
|
78 | 87 | ```
|
79 | 88 |
|
80 |
| -Then on enable, you can create a new instance of the `YourMultification` class and use it to send notifications: |
| 89 | +Then in init method such as `onEnable`, |
| 90 | +you can create a new instance of the `YourMultification` class and use it to send notifications: |
81 | 91 |
|
82 | 92 | ```java
|
83 |
| - private AudienceProvider audienceProvider = BukkitAudiences.create(this); |
84 |
| - MiniMessage miniMessage = MiniMessage.miniMessage(); |
85 |
| - |
86 |
| - MessagesConfig messagesConfig = new MessagesConfig(); |
87 |
| - YourMultification multification = new YourMultification(messagesConfig, audienceProvider, miniMessage); |
| 93 | +AudienceProvider audienceProvider = BukkitAudiences.create(this); |
| 94 | +MiniMessage miniMessage = MiniMessage.miniMessage(); |
| 95 | + |
| 96 | +MessagesConfig messagesConfig = new MessagesConfig(); |
| 97 | +YourMultification multification = new YourMultification(messagesConfig, audienceProvider, miniMessage); |
88 | 98 | ```
|
89 | 99 |
|
90 | 100 | After that, you can use the `multification` instance to send notifications:
|
91 | 101 |
|
92 | 102 | ```java
|
93 |
| - multification.create() |
94 |
| - .player(player.getUniqueId()) |
95 |
| - .notice(messages -> messages.yourMessage) |
96 |
| - .send(); |
| 103 | +multification.create() |
| 104 | + .player(player.getUniqueId()) |
| 105 | + .notice(messages -> messages.yourMessage) |
| 106 | + .send(); |
| 107 | +``` |
| 108 | + |
| 109 | +## Configuration Support |
| 110 | + |
| 111 | +Multification currently supports two configuration libraries: |
| 112 | +- [CDN](https://github.com/dzikoysk/cdn) _Simple and fast property-based configuration library for JVM apps_ |
| 113 | +- [Okaeri Configs](https://github.com/OkaeriPoland/okaeri-configs) _Simple Java/POJO config library written with love and Lombok_ |
| 114 | + |
| 115 | +To use the Multification library with one of the configuration libraries, you need to: |
| 116 | + |
| 117 | +### [CDN](https://github.com/dzikoysk/cdn) |
| 118 | + |
| 119 | +#### (CDN) 1. Add dependency to your `build.gradle` file: |
| 120 | +```gradle |
| 121 | +implementation("com.eternalcode:multification-cdn:1.1.4") |
| 122 | +implementation("net.dzikoysk:cdn:1.14.5") |
| 123 | +``` |
| 124 | + |
| 125 | +#### (CDN) 2. Create configuration class: |
| 126 | +```java |
| 127 | +public class MessagesConfig { |
| 128 | + @Description("# My first message") |
| 129 | + public Notice firstMessage = Notice.chat("<gradient:red:blue>Multification is awesome!"); |
| 130 | +} |
97 | 131 | ```
|
98 | 132 |
|
99 |
| -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 `BukkitNotice`. You can also use builder. After plugin deploy you can find messages in configuration file. |
| 133 | +#### (CDN) 3. Create a new instance of the `Cdn` with the `MultificationNoticeCdnComposer`: |
| 134 | +```java |
| 135 | +Cdn cdn = CdnFactory.createYamlLike() |
| 136 | + .getSettings() |
| 137 | + .withComposer(Notice.class, new MultificationNoticeCdnComposer(multification.getNoticeRegistry())) |
| 138 | + .build(); |
| 139 | +``` |
| 140 | + |
| 141 | +#### (CDN) 4. Load the configuration: |
| 142 | + |
| 143 | +To load and create the config file, use the following code in the init method such as `onEnable`: |
| 144 | + |
| 145 | +```java |
| 146 | +MessagesConfig messages = new MessagesConfig(); |
| 147 | +Resource resource = Source.of(this.dataFolder, "messages.yml"); |
| 148 | + |
| 149 | +cdn.load(resource, messages) |
| 150 | + .orThrow(cause -> cause); |
| 151 | + |
| 152 | +cdn.render(config, resource) |
| 153 | + .orThrow(cause -> cause); |
| 154 | +``` |
| 155 | + |
| 156 | +Checkout example with CDN! [example plugin](https://github.com/EternalCodeTeam/multification/tree/master/examples/bukkit). |
| 157 | + |
| 158 | +### [Okaeri Configs](https://github.com/OkaeriPoland/okaeri-configs) |
| 159 | + |
| 160 | +#### (Okaeri) 1. Add the following dependency to your `build.gradle` file: |
| 161 | + |
| 162 | +```gradle |
| 163 | +implementation("com.eternalcode:multification-okaeri:1.1.4") |
| 164 | +``` |
| 165 | + |
| 166 | +Probably also you will need to add additional dependencies for your platform, e.g. : |
| 167 | +```gradle |
| 168 | +implementation("eu.okaeri:okaeri-configs-serdes-commons:5.0.5") |
| 169 | +implementation("eu.okaeri:okaeri-configs-serdes-bukkit:5.0.5") |
| 170 | +implementation("eu.okaeri:okaeri-configs-yaml-bukkit:5.0.5") |
| 171 | +``` |
| 172 | +See [Okaeri Configs](https://github.com/OkaeriPoland/okaeri-configs) for more information. |
| 173 | + |
| 174 | +#### (Okaeri) 2. Create configuration class: |
| 175 | + |
| 176 | +```java |
| 177 | +public class MessagesConfig extends OkaeriConfig { |
| 178 | + @Comment("My first message") |
| 179 | + public Notice firstMessage = Notice.chat("<gradient:red:blue>Multification is awesome!"); |
| 180 | +} |
| 181 | +``` |
| 182 | + |
| 183 | +#### (Okaeri) 3. Load the configuration: |
| 184 | + |
| 185 | +```java |
| 186 | +MessagesConfig config = (MessagesConfig) ConfigManager.create(MessagesConfig.class) |
| 187 | + .withConfigurer(new MultificationSerdesPack(multification.getNoticeRegistry())) |
| 188 | + .withConfigurer(new SerdesCommons(), new YamlBukkitConfigurer(), new SerdesBukkit()) // specify configurers for your platform |
| 189 | + .withBindFile(new File(dataFolder, "messages.yml")) |
| 190 | + .withRemoveOrphans(true) // automatic removal of undeclared keys |
| 191 | + .saveDefaults() // save file if does not exists |
| 192 | + .load(true); |
| 193 | +``` |
100 | 194 |
|
101 |
| -### To see more examples open the [example plugin module](https://github.com/EternalCodeTeam/multification/tree/master/examples/bukkit). |
|
0 commit comments