Skip to content

Commit a53dd09

Browse files
vLuckyyyJakubk15gemini-code-assist[bot]
authored
GH-118 Add multification-paper module with Paper platform support and examples (#118)
* Add `multification-paper` module with Paper platform support and examples. * Update GitHub workflows to refine CI/CD setup * ci: make gradlew executable in CI workflows * Refactor README examples for cleaner code and update Maven repository comments. * Update README.md Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com> * Clean up code examples in README, streamline viewer provider logic, and improve formatting. * Update examples/paper/src/main/java/com/eternalcode/example/paper/config/MessagesConfig.java Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --------- Co-authored-by: Jakub Kędziora <77227023+Jakubk15@users.noreply.github.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 101516d commit a53dd09

File tree

21 files changed

+717
-61
lines changed

21 files changed

+717
-61
lines changed

.github/workflows/gradle.yml

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Java CI with Gradle
1+
name: CI
22

33
on:
44
push:
@@ -8,29 +8,23 @@ on:
88

99
jobs:
1010
build:
11+
name: Build
1112
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
java:
15-
- 17
16-
fail-fast: false
1713
steps:
1814
- name: Checkout
19-
uses: actions/checkout@v4.3.1
20-
- name: 'Set up JDK ${{ matrix.java }}'
21-
uses: actions/setup-java@v4.8.0
22-
with:
23-
distribution: adopt
24-
java-version: '${{ matrix.java }}'
25-
- name: Cache Gradle
26-
uses: actions/cache@v4.3.0
15+
uses: actions/checkout@v5
16+
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v5
2719
with:
28-
path: ~/.gradle/caches
29-
key: >-
30-
${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*',
31-
'**/gradle-wrapper.properties') }}
32-
restore-keys: '${{ runner.os }}-gradle-'
33-
- name: Grant execute permission for gradlew
20+
distribution: 'temurin'
21+
java-version: 21
22+
23+
- name: Setup Gradle
24+
uses: gradle/actions/setup-gradle@v5
25+
26+
- name: Make gradlew executable
3427
run: chmod +x gradlew
35-
- name: Build the Jar
36-
run: './gradlew clean test build'
28+
29+
- name: Build with Gradle
30+
run: ./gradlew build

.github/workflows/publish-release.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
name: Publish Multification
2+
23
on:
34
release:
4-
branches: [ master ]
5+
types: [published]
6+
57
jobs:
68
publish:
9+
name: Publish
710
runs-on: ubuntu-latest
811
environment: deployment
912
steps:
1013
- name: Checkout
11-
uses: actions/checkout@v4
14+
uses: actions/checkout@v5
1215

13-
- name: Set up JDK
14-
uses: actions/setup-java@v4
16+
- name: Set up JDK 21
17+
uses: actions/setup-java@v5
1518
with:
1619
distribution: 'temurin'
17-
java-version: 17
18-
cache: 'gradle'
20+
java-version: 21
1921

20-
- name: Grant execute permission for gradlew
21-
run: chmod +x gradlew
22+
- name: Setup Gradle
23+
uses: gradle/actions/setup-gradle@v5
2224

25+
- name: Make gradlew executable
26+
run: chmod +x gradlew
27+
2328
- name: Publish with Gradle
2429
run: ./gradlew publish
2530
env:

README.md

Lines changed: 86 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<div align="center">
2-
2+
33
![Multification Banner](/assets/readme-banner.png)
4+
45
### Multification
6+
57
Powerful library for sending custom notifications based on adventure.
68

79
[![Patreon](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/donate/patreon-plural_vector.svg)](https://www.patreon.com/eternalcode)
@@ -15,7 +17,9 @@ Powerful library for sending custom notifications based on adventure.
1517

1618
## About
1719

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:
20+
Multification makes it simple to create customizable notifications and messages within large plugins that require
21+
handling a high volume of messages (while the setup may not be easy, **it’s worthwhile for extensive plugins**). It
22+
offers a range of features, including:
1923

2024
- 💭 Chat messages
2125
- 📕 Title & Subtitle
@@ -28,23 +32,55 @@ Multification makes it simple to create customizable notifications and messages
2832
- 🛠️ Formatter support
2933
- 🌎 Flexible messages providing (easy to implement i18n)
3034
- 📦 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)
35+
- 🚀 Cross-platform support (Bukkit, Paper)
3236

3337
Messages can be sent to any audience, such as players or the console.
3438

39+
## Supported Platforms
40+
41+
| Platform | Module | Java Version | Adventure API | Status |
42+
|-------------------|------------------------|--------------|-----------------------|------------------------|
43+
| **Paper** | `multification-paper` | Java 21 | Native (built-in) | ✅ Recommended |
44+
| **Bukkit/Spigot** | `multification-bukkit` | Java 8+ | External adapter | ✅ Supported |
45+
| **Velocity** | `multification-velocity` | Java 21+ | Native | ❌ Soon |
46+
| **Core** | `multification-core` | Java 8+ | Custom implementation | ✅ For custom platforms |
47+
48+
> **💡 Recommendation:** Use `multification-paper` for Paper servers (1.19.4+) to leverage native Adventure API without
49+
> external dependencies.
50+
3551
## Getting Started
3652

37-
To use the library, you need to add the following repository and dependency to your `build.gradle` file:
53+
### For Paper Servers (Recommended)
54+
55+
Add the following repository and dependency to your `build.gradle.kts`:
3856

3957
```kts
40-
maven("https://repo.eternalcode.pl/releases")
58+
repositories {
59+
maven("https://repo.eternalcode.pl/releases")
60+
maven("https://repo.papermc.io/repository/maven-public/")
61+
}
62+
63+
dependencies {
64+
implementation("com.eternalcode:multification-paper:1.2.3")
65+
}
4166
```
4267

68+
### For Bukkit/Spigot Servers
69+
4370
```kts
44-
implementation("com.eternalcode:multification-bukkit:1.2.2")
71+
repositories {
72+
maven("https://repo.eternalcode.pl/releases")
73+
}
74+
75+
dependencies {
76+
implementation("com.eternalcode:multification-bukkit:1.2.3")
77+
}
4578
```
4679

47-
> **Note:** If you want to use the library with other platforms, then you need to use the `multification-core` dependency.
80+
> **Note:** For custom platforms or other Adventure-based servers, use `multification-core` and implement your own
81+
> platform adapter.
82+
83+
## Quick Example
4884

4985
Then create a new instance of the `Multification` class and use it to send notifications:
5086

@@ -55,7 +91,10 @@ public class YourMultification extends BukkitMultification<MessagesConfig> {
5591
private final AudienceProvider audienceProvider;
5692
private final MiniMessage miniMessage;
5793

58-
public YourMultification(MessagesConfig messagesConfig, AudienceProvider audienceProvider, MiniMessage miniMessage) {
94+
public YourMultification(
95+
MessagesConfig messagesConfig,
96+
AudienceProvider audienceProvider,
97+
MiniMessage miniMessage) {
5998
this.messagesConfig = messagesConfig;
6099
this.audienceProvider = audienceProvider;
61100
this.miniMessage = miniMessage;
@@ -73,15 +112,14 @@ public class YourMultification extends BukkitMultification<MessagesConfig> {
73112

74113
@Override
75114
protected @NotNull AudienceConverter<CommandSender> audienceConverter() {
76-
return commandSender -> {
115+
return commandSender -> {
77116
if (commandSender instanceof Player player) {
78117
return this.audienceProvider.player(player.getUniqueId());
79118
}
80119

81120
return this.audienceProvider.console();
82121
};
83122
}
84-
85123
}
86124
```
87125

@@ -100,28 +138,32 @@ After that, you can use the `multification` instance to send notifications:
100138

101139
```java
102140
multification.create()
103-
.player(player.getUniqueId())
104-
.notice(messages -> messages.yourMessage)
105-
.send();
141+
.player(player.getUniqueId())
142+
.notice(messages ->messages.yourMessage)
143+
.send();
106144
```
107145

108146
## Configuration Support
109147

110148
Multification currently supports two configuration libraries:
149+
111150
- [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_
151+
- [Okaeri Configs](https://github.com/OkaeriPoland/okaeri-configs) _Simple Java/POJO config library written with love
152+
and Lombok_
113153

114154
To use the Multification library with one of the configuration libraries, you need to:
115155

116156
### [CDN](https://github.com/dzikoysk/cdn)
117157

118158
#### (CDN) 1. Add dependency to your `build.gradle` file:
159+
119160
```gradle
120161
implementation("com.eternalcode:multification-cdn:1.1.4")
121162
implementation("net.dzikoysk:cdn:1.14.5")
122163
```
123164

124165
#### (CDN) 2. Create configuration class:
166+
125167
```java
126168
public class MessagesConfig {
127169
@Description("# My first message")
@@ -130,11 +172,12 @@ public class MessagesConfig {
130172
```
131173

132174
#### (CDN) 3. Create a new instance of the `Cdn` with the `MultificationNoticeCdnComposer`:
175+
133176
```java
134177
Cdn cdn = CdnFactory.createYamlLike()
135-
.getSettings()
136-
.withComposer(Notice.class, new MultificationNoticeCdnComposer(multification.getNoticeRegistry()))
137-
.build();
178+
.getSettings()
179+
.withComposer(Notice.class, new MultificationNoticeCdnComposer(multification.getNoticeRegistry()))
180+
.build();
138181
```
139182

140183
#### (CDN) 4. Load the configuration:
@@ -145,14 +188,12 @@ To load and create the config file, use the following code in the init method su
145188
MessagesConfig messages = new MessagesConfig();
146189
Resource resource = Source.of(this.dataFolder, "messages.yml");
147190

148-
cdn.load(resource, messages)
149-
.orThrow(cause -> cause);
150-
151-
cdn.render(config, resource)
152-
.orThrow(cause -> cause);
191+
cdn.load(resource, messages).orThrow(cause ->cause);
192+
cdn.render(config, resource).orThrow(cause ->cause);
153193
```
154194

155-
Checkout example with CDN! [example plugin](https://github.com/EternalCodeTeam/multification/tree/master/examples/bukkit).
195+
Checkout example with
196+
CDN! [example plugin](https://github.com/EternalCodeTeam/multification/tree/master/examples/bukkit).
156197

157198
### [Okaeri Configs](https://github.com/OkaeriPoland/okaeri-configs)
158199

@@ -163,11 +204,13 @@ implementation("com.eternalcode:multification-okaeri:1.1.4")
163204
```
164205

165206
Probably also you will need to add additional dependencies for your platform, e.g. :
207+
166208
```gradle
167209
implementation("eu.okaeri:okaeri-configs-serdes-commons:5.0.5")
168210
implementation("eu.okaeri:okaeri-configs-serdes-bukkit:5.0.5")
169211
implementation("eu.okaeri:okaeri-configs-yaml-bukkit:5.0.5")
170212
```
213+
171214
See [Okaeri Configs](https://github.com/OkaeriPoland/okaeri-configs) for more information.
172215

173216
#### (Okaeri) 2. Create configuration class:
@@ -183,11 +226,25 @@ public class MessagesConfig extends OkaeriConfig {
183226

184227
```java
185228
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);
229+
.withConfigurer(new MultificationSerdesPack(multification.getNoticeRegistry()))
230+
.withConfigurer(new SerdesCommons(), new YamlBukkitConfigurer(), new SerdesBukkit()) // specify configurers for your platform
231+
.withBindFile(new File(dataFolder, "messages.yml"))
232+
.withRemoveOrphans(true) // automatic removal of undeclared keys
233+
.saveDefaults() // save file if does not exists
234+
.load(true);
192235
```
193236

237+
## 📄 License
238+
239+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
240+
241+
## 🔗 Links
242+
243+
- [GitHub Repository](https://github.com/EternalCodeTeam/multification)
244+
- [Discord Community](https://discord.gg/FQ7jmGBd6c)
245+
- [EternalCode Website](https://eternalcode.pl/)
246+
- [Issue Tracker](https://github.com/EternalCodeTeam/multification/issues)
247+
248+
---
249+
250+
Made with ❤️ by [EternalCodeTeam](https://github.com/EternalCodeTeam)

buildSrc/src/main/kotlin/multification-repositories.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
repositories {
66
mavenCentral()
77

8-
maven("https://papermc.io/repo/repository/maven-public/") // paper, adventure, velocity
8+
maven("https://repo.papermc.io/repository/maven-public/") // paper, adventure, velocity
99
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") // spigot
1010
maven("https://repo.panda-lang.org/releases/") // expressible
1111
maven("https://repo.stellardrift.ca/repository/snapshots/")

examples/paper/build.gradle.kts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
plugins {
2+
id("java")
3+
id("com.gradleup.shadow") version "9.0.0-beta4"
4+
id("net.minecrell.plugin-yml.paper") version "0.6.0"
5+
id("xyz.jpenilla.run-paper") version "2.3.1"
6+
}
7+
8+
version = "1.0.0-SNAPSHOT"
9+
10+
java {
11+
sourceCompatibility = JavaVersion.VERSION_21
12+
targetCompatibility = JavaVersion.VERSION_21
13+
}
14+
15+
repositories {
16+
mavenCentral()
17+
maven("https://repo.papermc.io/repository/maven-public/")
18+
maven("https://repo.panda-lang.org/releases/")
19+
}
20+
21+
dependencies {
22+
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
23+
24+
implementation("dev.rollczi:litecommands-bukkit:3.4.1")
25+
// implementation("com.eternalcode:multification-paper:1.2.3") // <-- uncomment in your project
26+
// implementation("com.eternalcode:multification-cdn:1.2.3") // <-- uncomment in your project
27+
28+
implementation(project(":multification-paper")) // don't use this line in your build.gradle
29+
implementation(project(":multification-cdn")) // don't use this line in your build.gradle
30+
}
31+
32+
val pluginName = "ExamplePaperPlugin"
33+
val packageName = "com.eternalcode.example.paper"
34+
35+
paper {
36+
main = "$packageName.$pluginName"
37+
apiVersion = "1.21"
38+
author = "EternalCode"
39+
name = pluginName
40+
version = "${project.version}"
41+
}
42+
43+
tasks.shadowJar {
44+
archiveFileName.set("$pluginName v${project.version}.jar")
45+
46+
listOf(
47+
"dev.rollczi.litecommands",
48+
"panda.std",
49+
"panda.utilities",
50+
).forEach { relocate(it, "$packageName.libs.$it") }
51+
}
52+
53+
sourceSets.test {
54+
java.setSrcDirs(emptyList<String>())
55+
resources.setSrcDirs(emptyList<String>())
56+
}
57+
58+
tasks.runServer {
59+
minecraftVersion("1.21.11")
60+
}

0 commit comments

Comments
 (0)