You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+41-8Lines changed: 41 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,25 +35,58 @@ dependencies {
35
35
</dependency>
36
36
```
37
37
38
-
## Usage
38
+
## Module Creation
39
39
40
-
Simply add the JacksonBukkit module to the builder of your choice.
40
+
You can either create the `JacksonBukkit` and `JacksonPaper` module directly or use the builder for easy modification.
41
+
Usage of the builder is recommended.
42
+
Builder for spigot and paper can both be accessed via the `JacksonBukkit` class.
43
+
44
+
### Creating a Spigot/Bukkit Module
41
45
42
46
```java
43
-
ObjectMapperJSON=JsonMapper.builder()
44
-
.addModule(newJacksonBukkit())
45
-
.build();
47
+
ObjectMapperJSON=JsonMapper.builder()
48
+
.addModule(JacksonBukkit.spigot().build())
49
+
.build();
50
+
```
51
+
52
+
### Creating a Paper Module
46
53
54
+
```java
55
+
ObjectMapperJSON=JsonMapper.builder()
56
+
.addModule(JacksonBukkit.paper().build())
57
+
.build();
47
58
```
48
59
60
+
### Difference between Paper and Bukkit module
61
+
62
+
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.
65
+
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.
68
+
69
+
### More customization
70
+
71
+
There are some more customizations
72
+
73
+
#### Color
74
+
75
+
Colors will be read and written to an object containing a value for red, green, blue and alpha by default.
76
+
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.
79
+
80
+
**Warning:** As of now you can use either way, but not both at the same time. Mixing up format will cause errors.
81
+
49
82
## Supported Classes
50
83
51
84
We support all classes implementing `ConfigurationSerializable`. To be precise we support the following classes:
52
85
53
86
- Vector
54
87
- BlockVector
55
-
- Color
56
-
- ItemStack (Serialized as Base64 encoded bytes as recommended by [paper](https://jd.papermc.io/paper/1.19/org/bukkit/inventory/ItemStack.html#serializeAsBytes()))
88
+
- Color (Can be serialized as object or as hex string)
89
+
- ItemStack (Serialized as map for `JacksonBukkit`. Serialized as Base64 encoded bytes for `JacksonPaper`)
57
90
- PotionEffect
58
91
- FireworkEffect
59
92
- Pattern
@@ -65,4 +98,4 @@ We support all classes implementing `ConfigurationSerializable`. To be precise w
0 commit comments