Skip to content

Commit a97b4ac

Browse files
Release 1.1.0 (#16)
2 parents fd189b6 + 7e1bf8a commit a97b4ac

File tree

254 files changed

+3278
-1006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

254 files changed

+3278
-1006
lines changed

.github/badges/branches.svg

Lines changed: 1 addition & 0 deletions
Loading

.github/badges/jacoco.svg

Lines changed: 1 addition & 0 deletions
Loading

.github/workflows/coverage.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Compute Coverage
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- dev
8+
9+
jobs:
10+
generate_badge:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up JDK 18
16+
uses: actions/setup-java@v3
17+
with:
18+
distribution: temurin
19+
java-version: 18
20+
- name: Run Test Coverage
21+
run: ./gradlew jacocoTestReport
22+
- name: Generate JaCoCo Badge
23+
uses: cicirello/jacoco-badge-generator@v2
24+
with:
25+
generate-branches-badge: true
26+
jacoco-csv-file: >
27+
1.16-testing/build/reports/jacoco/test/jacocoTestReport.csv
28+
core/build/reports/jacoco/test/jacocoTestReport.csv
29+
paper/build/reports/jacoco/test/jacocoTestReport.csv
30+
- name: Log coverage percentage
31+
run: |
32+
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
33+
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
34+
35+
- name: Commit the badge (if it changed)
36+
run: |
37+
if [[ `git status --porcelain` ]]; then
38+
git config --global user.name 'Yannick Lamprecht'
39+
git config --global user.email '[email protected]'
40+
git add -A
41+
git commit -m "[skip ci] Autogenerated JaCoCo coverage badge"
42+
fi
43+
44+
- name: Pushing
45+
uses: CasperWA/push-protected@v2
46+
with:
47+
token: ${{ secrets.ACCESS_TOKEN }}
48+
branch: dev
49+
50+
- name: Upload JaCoCo coverage report
51+
uses: actions/upload-artifact@v3
52+
with:
53+
name: jacoco-report
54+
path: |
55+
1.16-testing/build/reports/jacoco/test/jacocoTestReport.csv
56+
core/build/reports/jacoco/test/jacocoTestReport.csv
57+
paper/build/reports/jacoco/test/jacocoTestReport.csv

1.16-testing/build.gradle.kts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
repositories {
2+
maven("https://eldonexus.de/repository/codemc-nms/")
3+
}
4+
5+
dependencies {
6+
testImplementation(project(":core"))
7+
implementation("com.destroystokyo.paper:paper-api:1.16.5-R0.1-20211218.081530-231")
8+
testImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
9+
testImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-toml")
10+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
11+
testImplementation("org.assertj:assertj-core:3.24.2")
12+
implementation(project(":testing"))
13+
testImplementation("com.github.seeseemelk", "MockBukkit-v1.19", "2.29.0")
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
*
4+
* Copyright (C) EldoriaRPG Team and Contributor
5+
*/
6+
package de.eldoria.jacksonbukkit.legacy;
7+
8+
import de.eldoria.jacksonbukkit.serializer.PotionEffectSerializer;
9+
import org.junit.jupiter.api.Test;
10+
11+
import static org.junit.jupiter.api.Assertions.assertTrue;
12+
13+
public class LegacyTest {
14+
15+
@Test
16+
public void testLegacyPotion() {
17+
assertTrue(PotionEffectSerializer.LEGACY);
18+
}
19+
20+
}

Readme.md

Lines changed: 106 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,152 @@
1-
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/eldoriarpg/jackson-bukkit/verify.yml?branch=main&style=for-the-badge&label=Building)
2-
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/eldoriarpg/jackson-bukkit/publish_to_nexus.yml?branch=main&style=for-the-badge&label=Publishing) \
3-
![Sonatype Nexus (Releases)](https://img.shields.io/nexus/maven-releases/de.eldoria/jackson-bukkit?label=Release&logo=Release&server=https%3A%2F%2Feldonexus.de&style=for-the-badge)
4-
![Sonatype Nexus (Development)](https://img.shields.io/nexus/maven-dev/de.eldoria/jackson-bukkit?label=DEV&logo=Release&server=https%3A%2F%2Feldonexus.de&style=for-the-badge)
5-
![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/de.eldoria/jackson-bukkit?color=orange&label=Snapshot&server=https%3A%2F%2Feldonexus.de&style=for-the-badge)
1+
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/eldoriarpg/jackson-bukkit/verify.yml?branch=main&style=flat-square&label=Building)
2+
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/eldoriarpg/jackson-bukkit/publish_to_nexus.yml?branch=main&style=flat-square&label=Publishing)
3+
4+
![Sonatype Nexus (Releases)](https://img.shields.io/nexus/maven-releases/de.eldoria.jacksonbukkit/jackson-bukkit?label=Release&logo=Release&server=https%3A%2F%2Feldonexus.de&style=flat-square)
5+
![Sonatype Nexus (Development)](https://img.shields.io/nexus/maven-dev/de.eldoria.jacksonbukkit/jackson-bukkit?label=DEV&logo=Release&server=https%3A%2F%2Feldonexus.de&style=flat-square)
6+
![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/de.eldoria.jacksonbukkit/jackson-bukkit?color=orange&label=Snapshot&server=https%3A%2F%2Feldonexus.de&style=flat-square)
7+
8+
![Times wasted](https://wakatime.com/badge/github/eldoriarpg/jackson-bukkit.svg?style=flat-square)
9+
![Last Commit](https://img.shields.io/github/last-commit/eldoriarpg/jackson-bukkit?style=flat-square)
10+
[![Discord](https://img.shields.io/discord/718502316940066927?label=Discord&logo=Discord&style=flat-square)](https://discord.com/invite/rfRuUge)
11+
![](https://img.shields.io/github/languages/top/eldoriarpg/jackson-bukkit?style=flat-square)
12+
13+
![Branches](.github/badges/branches.svg)
14+
![Jacoco](.github/badges/jacoco.svg)
615

716
### [Javadocs](https://eldoriarpg.github.io/jackson-bukkit/)
817

18+
This is a module supporting serialization of common bukkit objects and some more on Spigot and Paper servers.
19+
The library should always support every version between 1.13 and the latest minecraft version.
20+
We do not use any NMS, therefore it should not be required to update this library often.
21+
It might work on earlier versions as well, but we do not check for this.
22+
The library takes format changes into account between versions.
23+
It is therefore safe to read old data on a newer version.
24+
Reading new data on an older version is not explicitly supported.
25+
26+
We provide two modules for Bukkit/Spigot and one for Paper.
27+
To use the full feature set we recommend Paper.
28+
Make sure to use the Paper module when your plugin is running on paper.
29+
Switching from Spigot to Paper will always work, but going back might cause errors.
30+
31+
### Known and implemented changes
32+
33+
Those are the format changes we support when updating to a newer version.
34+
The deserializer detect the current used format automatically and will parse it into the requested type.
35+
When serializing the data the currently used serializer will be used.
36+
37+
#### General
38+
39+
- In 1.18 the type of PotionEffect changed from a numeric integer to a namespaced key.
40+
41+
#### Paper
42+
43+
- In 1.16 Paper added the `serializeAsBytes` method to item stacks. This method will be used by default when available.
44+
- In 1.16 Paper added Adventure. If you haven't shaded it yet, you are now able to serialize Components as Objects.
45+
- In 1.18.2 Paper included MiniMessages. If you haven't shaded it yet, Components will be serialized using MiniMessages from here on.
46+
- In 1.19 Paper added an alpha value to `Color`. The value will be automatically added.
47+
948
## Dependency
1049

1150
**Gradle**
1251

13-
``` kotlin
52+
```kts
1453
repositories {
1554
maven("https://eldonexus.de/repository/maven-public")
1655
}
1756

1857
dependencies {
19-
implementation("de.eldoria", "jackson-bukkit", "version")
58+
// Spigot server
59+
compileOnly("de.eldoria.jacksonbukkit", "spigot", "version")
60+
// Paper server
61+
compileOnly("de.eldoria.jacksonbukkit", "paper", "version")
2062
}
2163
```
2264

2365
**Maven**
2466

25-
``` xml
26-
<repository>
27-
<id>EldoNexus</id>
28-
<url>https://eldonexus.de/repository/maven-public/</url>
29-
</repository>
30-
31-
<dependency>
32-
<groupId>de.eldoria</groupId>
33-
<artifactId>jackson-bukkit</artifactId>
34-
<version>version</version>
35-
</dependency>
67+
<!-- @formatter:off -->
68+
69+
```xml
70+
71+
<repositories>
72+
<repository>
73+
<id>EldoNexus</id>
74+
<url>https://eldonexus.de/repository/maven-public/</url>
75+
</repository>
76+
</repositories>
77+
78+
<dependencies>
79+
<!-- Spigot Server -->
80+
<dependency>
81+
<groupId>de.eldoria.jacksonbukkit</groupId>
82+
<artifactId>spigot</artifactId>
83+
<version>version</version>
84+
</dependency>
85+
86+
<!-- Paper Server-->
87+
<dependency>
88+
<groupId>de.eldoria.jacksonbukkit</groupId>
89+
<artifactId>paper</artifactId>
90+
<version>version</version>
91+
</dependency>
92+
</dependencies>
3693
```
3794

95+
<!-- @formatter:on -->
96+
3897
## Module Creation
3998

40-
You can either create the `JacksonBukkit` and `JacksonPaper` module directly or use the builder for easy modification.
99+
You can either create the `JacksonBukkit` and `JacksonPaper` module directly or use the builder for easy modification.
41100
Usage of the builder is recommended.
42-
Builder for spigot and paper can both be accessed via the `JacksonBukkit` class.
101+
Builder for spigot and paper can both be accessed via the corresponding class.
43102

44103
### Creating a Spigot/Bukkit Module
45104

46105
```java
47-
ObjectMapper JSON=JsonMapper.builder()
48-
.addModule(JacksonBukkit.spigot().build())
49-
.build();
106+
ObjectMapper JSON = JsonMapper.builder()
107+
.addModule(JacksonBukkit.builder().build())
108+
.build();
50109
```
51110

52111
### Creating a Paper Module
53112

54113
```java
55-
ObjectMapper JSON=JsonMapper.builder()
56-
.addModule(JacksonBukkit.paper().build())
57-
.build();
114+
ObjectMapper JSON = JsonMapper.builder()
115+
.addModule(JacksonPaper.builer().build())
116+
.build();
58117
```
59118

119+
Of course, you can use TOML or YAML or whatever else jackson supports as well
120+
60121
### Difference between Paper and Bukkit module
61122

123+
The paper module tries to support all features available by paper.
124+
The deserializer will automatically detect the current format when a legacy format is used and convert it into the new format when saved.
125+
Therefore, a config created on 1.15 will contain the legacy map and once teh server is running on 1.16 the byte array will be used instead.
126+
62127
Paper serializes `ItemStack`s to a Base64 encoded byte array instead of using spigots serialization.
63-
This will only work on paper servers and not on spigot servers.
64-
The builder allows to use spigots serialization on paper servers as well, but this is not recommended.
128+
This will only work on paper servers on 1.16 or newer and not on spigot servers.
129+
The builder allows to use spigots serialization on paper servers as well, but this is not recommended.
130+
131+
When creating a [paper plugin](https://docs.papermc.io/paper/reference/paper-plugins) the `JacksonBukkit` module is no longer able to serialize `ItemStacks`.
132+
You need to use `JacksonPaper` in that case and make sure that you are not using legacy serialization.
65133

66-
When creating a paper plugin the `JacksonBukkit` module is no longer able to serialize `ItemStacks`.
67-
you need to use `JacksonPaper` in that case and make sure that you are not using legacy serialization.
134+
| Class | Paper | Spigot |
135+
|-----------|-------------------------------------------------------------------------|----------------|
136+
| Color | RGB or HEX RGB < 1.19 <= RGBA or HEX RGBA | RGB or HEX RGB |
137+
| ItemStack | legacy Map < 1.16 <= NBT byte array | Legacy Map |
138+
| Component | MiniMessage String when MiniMessages is present. Otherwise Json Object. | Nope c: |
68139

69140
### More customization
70141

71142
There are some more customizations
72143

73144
#### Color
74145

75-
Colors will be read and written to an object containing a value for red, green, blue and alpha by default.
146+
Colors will be read and written to an object containing a value for red, green, blue and alpha (Paper only) by default.
76147
By calling `ModuleBuilder#colorAsHex()` you can enable hex codes.
77-
This will attempt to read each color as a HEX string with RGBA or RGB format.
78-
It will also write colors as RGBA.
148+
This will attempt to read each color as a HEX string with RGBA (Paper) or RGB (Spigot) format.
149+
It will also write colors as RGBA (Paper) or RGB (Spigot).
79150

80151
**Warning:** As of now you can use either way, but not both at the same time. Mixing up format will cause errors.
81152

@@ -86,7 +157,7 @@ We support all classes implementing `ConfigurationSerializable`. To be precise w
86157
- Vector
87158
- BlockVector
88159
- Color (Can be serialized as object or as hex string)
89-
- ItemStack (Serialized as map for `JacksonBukkit`. Serialized as Base64 encoded bytes for `JacksonPaper`)
160+
- ItemStack (Serialized as map for `JacksonBukkit`. Serialized as Base64 encoded bytes for `JacksonPaper`, when possible)
90161
- PotionEffect
91162
- FireworkEffect
92163
- Pattern
@@ -98,4 +169,4 @@ We support all classes implementing `ConfigurationSerializable`. To be precise w
98169

99170
- NamespacedKey
100171
- OfflinePlayer
101-
- Inventory via `InventoryWrapper` class
172+
- Components (Paper only as MiniMessage string)

0 commit comments

Comments
 (0)