Skip to content

Commit ffa9816

Browse files
CitralFloRollcziJakubk15
authored
GH-55 Add README.md
* Bump down version and remove <pride> in example which is not supported in official release * Add ReadMe and banner. * Update banner. Revert unrelated changes. * Update README.md Co-authored-by: Jakubk15 <[email protected]> * Update README.md Co-authored-by: Jakubk15 <[email protected]> * Update README.md Co-authored-by: Jakubk15 <[email protected]> * Update README.md Co-authored-by: Jakubk15 <[email protected]> * Update README * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: Rollczi <[email protected]> Co-authored-by: Jakubk15 <[email protected]>
1 parent e75448c commit ffa9816

File tree

3 files changed

+194
-1
lines changed

3 files changed

+194
-1
lines changed

README.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
<div align="center">
2+
3+
![Multification Banner](/assets/readme-banner.png)
4+
### Multification
5+
Powerful library for sending custom notifications based on adventure.
6+
7+
[![Patreon](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/donate/patreon-plural_vector.svg)](https://www.patreon.com/eternalcode)
8+
[![Website](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/documentation/website_vector.svg)](https://eternalcode.pl/)
9+
[![Discord](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/social/discord-plural_vector.svg)](https://discord.gg/FQ7jmGBd6c)
10+
11+
[![Gradle](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/built-with/gradle_vector.svg)](https://gradle.org/)
12+
[![Java](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/built-with/java17_vector.svg)](https://www.java.com/)
13+
14+
</div>
15+
16+
## About
17+
18+
Multification makes it simple to create customizable notifications and messages within large plugins that require handling a high volume of messages (while the setup may not be easy, **it’s worthwhile for extensive plugins**). It offers a range of features, including:
19+
20+
- 💭 Chat messages
21+
- 📕 Title & Subtitle
22+
- 🎬 ActionBar
23+
- 🍫 BossBar
24+
- 🔊 Sounds
25+
- 🎨 Adventure support
26+
- 🌈 MiniMessage support (including gradients, hex colors, hover, click and more)
27+
- 📥 Placeholders
28+
- 🛠️ Formatter support
29+
- 🌎 Flexible messages providing (easy to implement i18n)
30+
- 📦 Configuration support (CDN, Okaeri Configs)
31+
- Cross-platform support (currently we support Bukkit, but it's easy to add support for other adventure-based platforms)
32+
33+
Messages can be sent to any audience, such as players or the console.
34+
35+
## Getting Started
36+
37+
To use the library, you need to add the following repository and dependency to your `build.gradle` file:
38+
39+
```kts
40+
maven("https://repo.eternalcode.pl/releases")
41+
```
42+
43+
```kts
44+
implementation("com.eternalcode:multification-bukkit:1.1.4")
45+
```
46+
47+
> **Note:** If you want to use the library with other platforms, then you need to use the `multification-core` dependency.
48+
49+
Then create a new instance of the `Multification` class and use it to send notifications:
50+
51+
```java
52+
public class YourMultification extends BukkitMultification<MessagesConfig> {
53+
54+
private final MessagesConfig messagesConfig;
55+
private final AudienceProvider audienceProvider;
56+
private final MiniMessage miniMessage;
57+
58+
public YourMultification(MessagesConfig messagesConfig, AudienceProvider audienceProvider, MiniMessage miniMessage) {
59+
this.messagesConfig = messagesConfig;
60+
this.audienceProvider = audienceProvider;
61+
this.miniMessage = miniMessage;
62+
}
63+
64+
@Override
65+
protected @NotNull TranslationProvider<MessagesConfig> translationProvider() {
66+
return locale -> this.messagesConfig;
67+
}
68+
69+
@Override
70+
protected @NotNull ComponentSerializer<Component, Component, String> serializer() {
71+
return this.miniMessage;
72+
}
73+
74+
@Override
75+
protected @NotNull AudienceConverter<CommandSender> audienceConverter() {
76+
return commandSender -> {
77+
if (commandSender instanceof Player player) {
78+
return this.audienceProvider.player(player.getUniqueId());
79+
}
80+
81+
return this.audienceProvider.console();
82+
};
83+
}
84+
85+
}
86+
```
87+
88+
Then in init method such as `onEnable`,
89+
you can create a new instance of the `YourMultification` class and use it to send notifications:
90+
91+
```java
92+
AudienceProvider audienceProvider = BukkitAudiences.create(this);
93+
MiniMessage miniMessage = MiniMessage.miniMessage();
94+
95+
MessagesConfig messagesConfig = new MessagesConfig();
96+
YourMultification multification = new YourMultification(messagesConfig, audienceProvider, miniMessage);
97+
```
98+
99+
After that, you can use the `multification` instance to send notifications:
100+
101+
```java
102+
multification.create()
103+
.player(player.getUniqueId())
104+
.notice(messages -> messages.yourMessage)
105+
.send();
106+
```
107+
108+
## Configuration Support
109+
110+
Multification currently supports two configuration libraries:
111+
- [CDN](https://github.com/dzikoysk/cdn) _Simple and fast property-based configuration library for JVM apps_
112+
- [Okaeri Configs](https://github.com/OkaeriPoland/okaeri-configs) _Simple Java/POJO config library written with love and Lombok_
113+
114+
To use the Multification library with one of the configuration libraries, you need to:
115+
116+
### [CDN](https://github.com/dzikoysk/cdn)
117+
118+
#### (CDN) 1. Add dependency to your `build.gradle` file:
119+
```gradle
120+
implementation("com.eternalcode:multification-cdn:1.1.4")
121+
implementation("net.dzikoysk:cdn:1.14.5")
122+
```
123+
124+
#### (CDN) 2. Create configuration class:
125+
```java
126+
public class MessagesConfig {
127+
@Description("# My first message")
128+
public Notice firstMessage = Notice.chat("<gradient:red:blue>Multification is awesome!");
129+
}
130+
```
131+
132+
#### (CDN) 3. Create a new instance of the `Cdn` with the `MultificationNoticeCdnComposer`:
133+
```java
134+
Cdn cdn = CdnFactory.createYamlLike()
135+
.getSettings()
136+
.withComposer(Notice.class, new MultificationNoticeCdnComposer(multification.getNoticeRegistry()))
137+
.build();
138+
```
139+
140+
#### (CDN) 4. Load the configuration:
141+
142+
To load and create the config file, use the following code in the init method such as `onEnable`:
143+
144+
```java
145+
MessagesConfig messages = new MessagesConfig();
146+
Resource resource = Source.of(this.dataFolder, "messages.yml");
147+
148+
cdn.load(resource, messages)
149+
.orThrow(cause -> cause);
150+
151+
cdn.render(config, resource)
152+
.orThrow(cause -> cause);
153+
```
154+
155+
Checkout example with CDN! [example plugin](https://github.com/EternalCodeTeam/multification/tree/master/examples/bukkit).
156+
157+
### [Okaeri Configs](https://github.com/OkaeriPoland/okaeri-configs)
158+
159+
#### (Okaeri) 1. Add the following dependency to your `build.gradle` file:
160+
161+
```gradle
162+
implementation("com.eternalcode:multification-okaeri:1.1.4")
163+
```
164+
165+
Probably also you will need to add additional dependencies for your platform, e.g. :
166+
```gradle
167+
implementation("eu.okaeri:okaeri-configs-serdes-commons:5.0.5")
168+
implementation("eu.okaeri:okaeri-configs-serdes-bukkit:5.0.5")
169+
implementation("eu.okaeri:okaeri-configs-yaml-bukkit:5.0.5")
170+
```
171+
See [Okaeri Configs](https://github.com/OkaeriPoland/okaeri-configs) for more information.
172+
173+
#### (Okaeri) 2. Create configuration class:
174+
175+
```java
176+
public class MessagesConfig extends OkaeriConfig {
177+
@Comment("My first message")
178+
public Notice firstMessage = Notice.chat("<gradient:red:blue>Multification is awesome!");
179+
}
180+
```
181+
182+
#### (Okaeri) 3. Load the configuration:
183+
184+
```java
185+
MessagesConfig config = (MessagesConfig) ConfigManager.create(MessagesConfig.class)
186+
.withConfigurer(new MultificationSerdesPack(multification.getNoticeRegistry()))
187+
.withConfigurer(new SerdesCommons(), new YamlBukkitConfigurer(), new SerdesBukkit()) // specify configurers for your platform
188+
.withBindFile(new File(dataFolder, "messages.yml"))
189+
.withRemoveOrphans(true) // automatic removal of undeclared keys
190+
.saveDefaults() // save file if does not exists
191+
.load(true);
192+
```
193+

assets/readme-banner.png

126 KB
Loading

examples/bukkit/src/main/java/com/eternalcode/example/bukkit/config/MessagesConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class MessagesConfig {
2222
public Notice senderGiveCommandMessage = Notice.title("<green>You have given <yellow>{amount}x {item}</yellow> to <yellow>{player}</yellow>.");
2323
public Notice receiverGiveCommandMessage = BukkitNotice.builder()
2424
.title("<green>You have received <yellow>{amount}x {item}</yellow> from <yellow>{player}</yellow>.")
25-
.subtitle("<pride:gay>Remember to say thank you!</pride>")
25+
.subtitle("<pride:pride>Remember to say thank you!</pride>")
2626
.sound(Sound.ENTITY_ITEM_PICKUP)
2727
.build();
2828

0 commit comments

Comments
 (0)