Skip to content

Commit

Permalink
Feature/initial impl (#1)
Browse files Browse the repository at this point in the history
* Add vector

* make vector static

* Setup tests

* add BlockVector

* add color de-serializer

* test dummy

* add unit test utils

* Implement vector tests

* migrate to color record

* implement blockvector deserialization test

* remove toml list in block vector test

* add deserialization test for color

* fix block vector

* Add potion effect type

* implement test for color de-serialization

* Fix tests

* Add firework effect

* Add pattern

* implemented bounding box de-serializer

* implemented attribute modifier de-serializer

* Add unit tests for location

* Fix merge

* Add player serialization

* add inventory like de-serializer

* Add readme and publishing

* Final cleanup

---------

Co-authored-by: Florian Fülling <[email protected]>
  • Loading branch information
yannicklamprecht and rainbowdashlabs authored Mar 17, 2023
1 parent 79b1bab commit 14aff41
Show file tree
Hide file tree
Showing 148 changed files with 3,266 additions and 3 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: RainbowDashLabs
patreon: eldoriaplugins
open_collective: # Replace with a single Open Collective username
ko_fi: eldoriaplugins
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
31 changes: 31 additions & 0 deletions .github/workflows/javadocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Javadocs

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 18
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 18
- name: Build Javadocs
run: |
echo "Building javadocs with gradle"
./gradlew clean javadoc
echo "Moving to javadocs directory:"
cd build/docs/javadoc
echo "Creating .nojekyll to have Github pages deploy html as is:"
touch .nojekyll
- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: build/docs/javadoc # The folder the action should deploy.
30 changes: 30 additions & 0 deletions .github/workflows/publish_to_nexus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish to Nexus

on:
push:
branches:
- main
- dev*
- feature/*
- fix/*
jobs:
build:
environment: build
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
- name: Set up JDK 18
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 18
- name: Build with Gradle
run: ./gradlew --build-cache build
- name: Test with Gradle
run: ./gradlew test
- name: Publish to eldonexus
run: ./gradlew publishMavenPublicationToEldoNexusRepository
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
19 changes: 19 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Verify state

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]
- name: Set up JDK 18
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 18
- name: Build with Gradle
run: ./gradlew --build-cache build
- name: Test with Gradle
run: ./gradlew test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
*.iml
# *.ipr

# CMake
Expand Down
File renamed without changes.
68 changes: 68 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/eldoriarpg/jackson-bukkit/verify.yml?branch=main&style=for-the-badge&label=Building)
![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) \
![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)
![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)
![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)

### [Javadocs](https://rainbowdashlabs.github.io/jackson-bukkit/)

## Dependency

**Gradle**

``` kotlin
repositories {
maven("https://eldonexus.de/repository/maven-public")
}

dependencies {
compileOnly("de.eldoria", "jackson-bukkit", "version")
}
```

**Maven**

``` xml
<repository>
<id>EldoNexus</id>
<url>https://eldonexus.de/repository/maven-public/</url>
</repository>

<dependency>
<groupId>de.eldoria</groupId>
<artifactId>jackson-bukkit</artifactId>
<version>version</version>
</dependency>
```

## Usage

Simply add the JacksonBukkit module to the builder of your choice.

```java
ObjectMapper JSON = JsonMapper.builder()
.addModule(new JacksonBukkit())
.build();

```

## Supported Classes

We support all classes implementing `ConfigurationSerializable`. To be precise we support the following classes:

- Vector
- BlockVector
- Color
- ItemStack (Serialized as Base64 encoded bytes as recommended by [paper](https://jd.papermc.io/paper/1.19/org/bukkit/inventory/ItemStack.html#serializeAsBytes()))
- PotionEffect
- FireworkEffect
- Pattern
- BoundingBox
- AttributeModifier
- Location

**Additional Support for:**

- NamespacedKey
- OfflinePlayer
- Inventory via InventoryWrapper class
82 changes: 80 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import org.gradle.internal.impldep.org.apache.commons.codec.CharEncoding

plugins {
java
`maven-publish`
`java-library`
id("com.diffplug.spotless") version "6.16.0"
id("de.chojo.publishdata") version "1.2.4"
id("io.papermc.paperweight.userdev") version "1.5.3"
}

group = "de.eldoria"
Expand All @@ -16,11 +19,26 @@ repositories {
}

dependencies {
compileOnly("org.spigotmc", "spigot-api", "1.16.5-R0.1-SNAPSHOT")

testImplementation("org.spigotmc", "spigot-api", "1.16.5-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT")

implementation(platform("com.fasterxml.jackson:jackson-bom:2.14.2"))

api("com.fasterxml.jackson.core", "jackson-core")

// minecraft testing
testImplementation("com.github.seeseemelk", "MockBukkit-v1.19", "2.29.0")

// jackson testing
implementation("com.fasterxml.jackson.core:jackson-databind")
testImplementation("com.fasterxml.jackson.core:jackson-databind")
testImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
testImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-toml")

// junit and stuff
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
testImplementation("org.mockito:mockito-core:5.2.0")
}

spotless {
Expand All @@ -39,6 +57,10 @@ java {
}

tasks {
assemble {
dependsOn(reobfJar)
}

compileJava {
options.encoding = "UTF-8"
}
Expand All @@ -53,4 +75,60 @@ tasks {
events("passed", "skipped", "failed")
}
}
javadoc {
val options = options as StandardJavadocDocletOptions
options.encoding = CharEncoding.UTF_8
options.links(
"https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-core/latest/",
"https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-annotations/latest",
"https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/latest",
"https://jd.papermc.io/paper/1.19/",
)
}
}

publishData {
useEldoNexusRepos()
publishComponent("java")
}

publishing {
publications.create<MavenPublication>("maven") {
publishData.configurePublication(this)
pom {
url.set("https://github.com/eldoriarpg/schematicbrushreborn")
developers {
developer {
name.set("Florian Fülling")
url.set("https://github.com/rainbowdashlabs")
organization.set("EldoriaRPG")
organizationUrl.set("https://github.com/eldoriarpg")
}
developer {
name.set("Yannick Lamprecht")
url.set("https://github.com/yannicklamprecht")
}
}
licenses {
license {
name.set("MIT")
url.set("https://github.com/eldoriarpg/bukkit-jackson/blob/main/LICENSE.md")
}
}
}
}

repositories {
maven {
authentication {
credentials(PasswordCredentials::class) {
username = System.getenv("NEXUS_USERNAME")
password = System.getenv("NEXUS_PASSWORD")
}
}

setUrl(publishData.getRepository())
name = "EldoNexus"
}
}
}
7 changes: 7 additions & 0 deletions create_test_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
touch $PWD/src/test/resources/json/$1.json
touch $PWD/src/test/resources/json/$1_list.json
touch $PWD/src/test/resources/yaml/$1.yaml
touch $PWD/src/test/resources/yaml/$1_list.yaml
touch $PWD/src/test/resources/toml/$1.toml
touch $PWD/src/test/resources/toml/$1_list.toml
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pluginManagement{
mavenLocal()
gradlePluginPortal()
maven("https://eldonexus.de/repository/maven-public/")
maven("https://repo.papermc.io/repository/maven-public/")
}
}
Loading

0 comments on commit 14aff41

Please sign in to comment.