diff --git a/.github/workflows/gradle-ci.yml b/.github/workflows/gradle-ci.yml
index a4f7b02..2c745d6 100644
--- a/.github/workflows/gradle-ci.yml
+++ b/.github/workflows/gradle-ci.yml
@@ -1,38 +1,24 @@
name: Java CI with Gradle
on:
- push:
- paths-ignore:
- - '**.md'
- - '.github/CODEOWNERS'
+ pull_request:
+
+concurrency:
+ cancel-in-progress: true
+ group: ci-${{ github.ref }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- with:
- submodules: 'true'
+ - uses: actions/checkout@v3
- - name: Set up JDK 17
- uses: actions/setup-java@v2
+ - name: Set up JDK
+ uses: actions/setup-java@v3
with:
- distribution: adopt
+ distribution: temurin
java-version: 17
cache: gradle
- - name: Grant execute permission for gradlew
- run: chmod +x gradlew
-
- # We build twice to include generated files lol
- - name: Build
+ - name: Run build
run: gradle build
-
- - name: Build another time :)
- run: gradle build
-
- - name: Upload build
- uses: actions/upload-artifact@v1
- with:
- name: build
- path: build/libs
diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml
index 9523d87..6c62de2 100644
--- a/.github/workflows/publish-packages.yml
+++ b/.github/workflows/publish-packages.yml
@@ -1,9 +1,10 @@
-name: Publish GitHub Packages
+name: Publish Packages
on:
push:
branches:
- master
+ - develop
paths-ignore:
- '**.md'
@@ -14,39 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- - name: Set up JDK
- uses: actions/setup-java@v3
+ - uses: MineInAbyss/publish-action@master
with:
- distribution: temurin
- java-version: 17
-
- - name: Set env variable from latest maven version
- run: >
- echo "RELEASE_VERSION=$( \
- curl https://repo.mineinabyss.com/releases/com/mineinabyss/protocolburrito/maven-metadata.xml | \
- grep -oP '(?!)[\d\.]*(?=)' \
- )" >> $GITHUB_ENV
-
- # We build twice to include generated files lol
- - name: Run gradle build to generate files
- run: gradle build
-
- - name: Run gradle build and publish
- run: gradle build publish -PmineinabyssMavenUsername=${{ secrets.MAVEN_PUBLISH_USERNAME }} -PmineinabyssMavenPassword=${{ secrets.MAVEN_PUBLISH_PASSWORD }}
-
- - name: Get version from gradle
- shell: bash
- id: extract_version
- run: |
- version=`gradle properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}'`
- echo "::set-output name=version::$version"
-
- - name: Create GitHub Release
- uses: marvinpinto/action-automatic-releases@latest
- with:
- repo_token: "${{ secrets.GITHUB_TOKEN }}"
- prerelease: false
- automatic_release_tag: v${{ steps.extract_version.outputs.version }}
- files: |
- protocolburrito-plugin/build/libs/protocolburrito-plugin*[0-9].jar
-
+ maven-metadata-url: https://repo.mineinabyss.com/releases/com/mineinabyss/protocolburrito/maven-metadata.xml
+ maven-username: ${{ secrets.MAVEN_PUBLISH_USERNAME }}
+ maven-password: ${{ secrets.MAVEN_PUBLISH_PASSWORD }}
+ release-files: |
+ ${{ github.workspace }}/publish/*.jar
diff --git a/build.gradle.kts b/build.gradle.kts
index e4d0d17..d79494d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,12 +1,10 @@
-val serverVersion: String by project
+import io.papermc.paperweight.util.registering
plugins {
- kotlin("jvm")
- id("com.mineinabyss.conventions.kotlin")
+ id("com.mineinabyss.conventions.kotlin.jvm")
id("com.mineinabyss.conventions.nms")
id("com.mineinabyss.conventions.publication")
id("com.mineinabyss.conventions.autoversion")
- id("com.github.johnrengelman.shadow") version "7.0.0"
}
repositories {
@@ -26,9 +24,11 @@ allprojects {
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}
+ val libs = rootProject.libs
+
dependencies {
compileOnly(kotlin("stdlib-jdk8"))
- compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT") {
+ compileOnly(libs.minecraft.plugin.protocollib) {
// this dep wasn't being resolved.
exclude(group = "com.comphenix.executors")
}
@@ -36,23 +36,28 @@ allprojects {
}
dependencies {
- compileOnly("org.spigotmc:spigot-api:$serverVersion")
api(project(":protocolburrito-api"))
}
-sourceSets["main"].java.srcDir(file("$rootDir/protocolburrito-generator/build/generated/burrito/main"))
+sourceSets["main"].java.srcDir(file("$buildDir/generated/burrito/main"))
tasks {
assemble {
dependsOn(reobfJar)
+ }
+ build {
dependsOn(project(":protocolburrito-plugin").tasks.build)
}
- shadowJar {
- archiveClassifier.set("")
+ val generateBurrito by registering {
+ mainClass.set("com.mineinabyss.protocolburrito.generation.MainKt")
+ classpath = project("protocolburrito-generator").sourceSets["main"].runtimeClasspath
+ outputs.dir("$buildDir/generated/burrito/main")
+ }
+ sourcesJar {
+ dependsOn(generateBurrito)
+ }
+ compileKotlin {
+ dependsOn(generateBurrito)
}
-//
-// sourcesJar {
-// from(sourceSets.main.get().allSource)
-// }
}
diff --git a/gradle.properties b/gradle.properties
index 9bf33e4..04365a7 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,6 +1,4 @@
-version=0.6
+version=0.7
group=com.mineinabyss
-kotlinVersion=1.7.10
-serverVersion=1.19.2-R0.1-SNAPSHOT
-idofrontVersion=0.14.7
+idofrontVersion=0.18.14
publishComponentName=java
diff --git a/gradle/burritoLibs.versions.toml b/gradle/burritoLibs.versions.toml
index 1a41dc9..d487eb0 100644
--- a/gradle/burritoLibs.versions.toml
+++ b/gradle/burritoLibs.versions.toml
@@ -3,4 +3,4 @@
[libraries]
kotlinpoet = "com.squareup:kotlinpoet:1.10.1"
reflections = "org.reflections:reflections:0.9.12"
-minecraft-plugin-protocollib = "com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT"
+minecraft-plugin-protocollib = "com.comphenix.protocol:ProtocolLib:5.0.0"
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index ae04661..fae0804 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/protocolburrito-api/build.gradle.kts b/protocolburrito-api/build.gradle.kts
index 60c1137..34dbcb9 100644
--- a/protocolburrito-api/build.gradle.kts
+++ b/protocolburrito-api/build.gradle.kts
@@ -1,8 +1,7 @@
plugins {
- id("com.mineinabyss.conventions.kotlin")
+ id("com.mineinabyss.conventions.kotlin.jvm")
id("com.mineinabyss.conventions.papermc")
id("com.mineinabyss.conventions.publication")
- id("com.mineinabyss.conventions.autoversion")
}
dependencies {
diff --git a/protocolburrito-generator/build.gradle.kts b/protocolburrito-generator/build.gradle.kts
index d125819..aa8a059 100644
--- a/protocolburrito-generator/build.gradle.kts
+++ b/protocolburrito-generator/build.gradle.kts
@@ -1,11 +1,8 @@
import io.papermc.paperweight.util.registering
-val serverVersion: String by project
-
plugins {
kotlin("jvm")
id("com.mineinabyss.conventions.nms")
- id("com.mineinabyss.conventions.autoversion")
}
repositories {
@@ -16,12 +13,11 @@ repositories {
dependencies {
implementation(kotlin("reflect"))
- implementation("io.papermc.paper:paper-server:userdev-$serverVersion")
+ implementation("io.papermc.paper:paper-server:userdev-${libs.versions.minecraft.get()}")
implementation(burritoLibs.minecraft.plugin.protocollib)
implementation(burritoLibs.kotlinpoet)
implementation(burritoLibs.reflections)
implementation(project(":protocolburrito-api"))
- implementation(kotlin("reflect"))
}
configurations {
@@ -29,14 +25,7 @@ configurations {
}
tasks {
- val generateBurrito by registering() {
- main = "com.mineinabyss.protocolburrito.generation.MainKt"
- classpath = files(configurations.runtimeClasspath, jar)
- }
reobfJar {
onlyIf { false }
}
- build {
- dependsOn(generateBurrito)
- }
}
diff --git a/protocolburrito-generator/src/main/kotlin/com/mineinabyss/protocolburrito/generation/ProtocolWrapperGenerator.kt b/protocolburrito-generator/src/main/kotlin/com/mineinabyss/protocolburrito/generation/ProtocolWrapperGenerator.kt
index ca5cc8c..112226f 100644
--- a/protocolburrito-generator/src/main/kotlin/com/mineinabyss/protocolburrito/generation/ProtocolWrapperGenerator.kt
+++ b/protocolburrito-generator/src/main/kotlin/com/mineinabyss/protocolburrito/generation/ProtocolWrapperGenerator.kt
@@ -6,7 +6,6 @@ import com.mineinabyss.protocolburrito.FieldHelpers
import com.mineinabyss.protocolburrito.WrappedCompanion
import com.mineinabyss.protocolburrito.WrappedPacket
import com.squareup.kotlinpoet.*
-import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import net.minecraft.network.protocol.Packet
import org.reflections.Reflections
import org.reflections.scanners.SubTypesScanner
@@ -16,89 +15,93 @@ import kotlin.reflect.KType
import kotlin.reflect.KVisibility
import kotlin.reflect.full.declaredMemberProperties
import kotlin.reflect.jvm.jvmErasure
-import kotlin.reflect.typeOf
val OUTPUT_DIR = File("build/generated/burrito/main/")
fun generateProtocolExtensions() {
val reflections = Reflections("net.minecraft.network.protocol.game", SubTypesScanner(false))
- reflections.getSubTypesOf(Packet::class.java).map { it.kotlin }.forEach { packetClass ->
- val indices = mutableMapOf()
- val props = packetClass.declaredMemberProperties.mapNotNull { field ->
- val type = field.returnType
- if (field.visibility == KVisibility.PUBLIC) return@mapNotNull null
- if (field.returnType.jvmErasure.visibility != KVisibility.PUBLIC) return@mapNotNull null
- if (field.returnType.arguments.any { it.type?.jvmErasure?.visibility != KVisibility.PUBLIC }) return@mapNotNull null
- val index = indices.getOrPut(type) { AtomicInteger(0) }
- PropertySpec.builder(field.name, type.asTypeName().copy(annotations = listOf())) //.let {
- .getter(
- FunSpec.getterBuilder()
- .addStatement("return %T.getField(handle, ${index.toInt()})", FieldHelpers::class)
+ reflections.getSubTypesOf(Packet::class.java)
+ .map { it.kotlin }
+ .filter { !it.isAbstract }
+ .forEach { packetClass ->
+ val indices = mutableMapOf()
+ val props = packetClass.declaredMemberProperties.mapNotNull { field ->
+ val type = field.returnType
+ if (field.visibility == KVisibility.PUBLIC) return@mapNotNull null
+ if (field.returnType.jvmErasure.visibility != KVisibility.PUBLIC) return@mapNotNull null
+ if (field.returnType.arguments.any { it.type?.jvmErasure?.visibility != KVisibility.PUBLIC }) return@mapNotNull null
+ val index = indices.getOrPut(type) { AtomicInteger(0) }
+ PropertySpec.builder(field.name, type.asTypeName().copy(annotations = listOf())) //.let {
+ .getter(
+ FunSpec.getterBuilder()
+ .addStatement("return %T.getField(handle, ${index.toInt()})", FieldHelpers::class)
+ .build()
+ )
+ .setter(
+ FunSpec.setterBuilder()
+ .addParameter(ParameterSpec.builder("value", type.asTypeName()).build())
+ .addCode("%T.setField(handle, ${index.toInt()}, value)", FieldHelpers::class)
+ .build()
+ )
+ .mutable(true)
+ .build().also {
+ index.getAndAdd(1)
+ }
+ }
+
+ val className = packetClass.simpleName + "Wrap"
+ val file = FileSpec.builder("com.mineinabyss.protocolburrito.packets", className)
+ .addType(
+ TypeSpec
+ .classBuilder(className)
+ .addSuperinterface(WrappedPacket::class)
+ .primaryConstructor(
+ // We specify any type to avoid issues if class names change
+ // Instead we get a packet from ProtocolLib's PacketType which should be
+ // consistent across versions.
+ PropertySpec.builder("handle", Any::class/*packetClass*/).build()
+ )
+// .addProperty("handle", packetClass)
+ .addProperties(props)
+ .addType(
+ TypeSpec
+ .companionObjectBuilder()
+ .addSuperinterface(WrappedCompanion::class)
+ .addProperty(
+ PropertySpec.builder("type", PacketType::class)
+ .addModifiers(KModifier.OVERRIDE)
+ .getter(
+ FunSpec.getterBuilder()
+ .addStatement(
+ "return %T.getPacketType(%T::class.java)",
+ PacketRegistry::class,
+ packetClass
+ ).build()
+ )
+ .build()
+ )
+ .addFunction(
+ FunSpec.builder("wrap")
+ .addModifiers(KModifier.OVERRIDE)
+ .addParameter("any", Any::class)
+ .addStatement("return $className(any as %T)", packetClass)
+ .build()
+ )
+ .build()
+ )
.build()
)
- .setter(
- FunSpec.setterBuilder()
- .addParameter(ParameterSpec.builder("value", type.asTypeName()).build())
- .addCode("%T.setField(handle, ${index.toInt()}, value)", FieldHelpers::class)
+ .addFunction(
+ FunSpec.builder("wrap")
+ .receiver(packetClass)
+ .addModifiers(KModifier.INLINE)
+ .addStatement("return $className(this)")
.build()
)
- .mutable(true)
- .build().also {
- index.getAndAdd(1)
- }
- }
+ .build()
- val className = packetClass.simpleName + "Wrap"
- val file = FileSpec.builder("com.mineinabyss.protocolburrito.packets", className)
- .addType(
- TypeSpec
- .classBuilder(className)
- .addSuperinterface(WrappedPacket::class)
- .primaryConstructor(
- // We specify any type to avoid issues if class names change
- // Instead we get a packet from ProtocolLib's PacketType which should be
- // consistent across versions.
- PropertySpec.builder("handle", Any::class/*packetClass*/).build()
- )
-// .addProperty("handle", packetClass)
- .addProperties(props)
- .addType(
- TypeSpec
- .companionObjectBuilder()
- .addSuperinterface(WrappedCompanion::class)
- .addProperty(
- PropertySpec.builder("type", PacketType::class)
- .addModifiers(KModifier.OVERRIDE)
- .getter(
- FunSpec.getterBuilder()
- .addStatement(
- "return %T.getPacketType(%T::class.java)", PacketRegistry::class, packetClass
- ).build()
- )
- .build()
- )
- .addFunction(
- FunSpec.builder("wrap")
- .addModifiers(KModifier.OVERRIDE)
- .addParameter("any", Any::class)
- .addStatement("return $className(any as %T)", packetClass)
- .build()
- )
- .build()
- )
- .build()
- )
- .addFunction(
- FunSpec.builder("wrap")
- .receiver(packetClass)
- .addModifiers(KModifier.INLINE)
- .addStatement("return $className(this)")
- .build()
- )
- .build()
-
- file.writeTo(OUTPUT_DIR)
- }
+ file.writeTo(OUTPUT_DIR)
+ }
}
fun TypeSpec.Builder.primaryConstructor(vararg properties: PropertySpec): TypeSpec.Builder {
diff --git a/protocolburrito-plugin/build.gradle.kts b/protocolburrito-plugin/build.gradle.kts
index 160372e..a8434fe 100644
--- a/protocolburrito-plugin/build.gradle.kts
+++ b/protocolburrito-plugin/build.gradle.kts
@@ -1,21 +1,13 @@
val idofrontVersion: String by project
plugins {
- id("com.mineinabyss.conventions.kotlin")
+ id("com.mineinabyss.conventions.kotlin.jvm")
id("com.mineinabyss.conventions.papermc")
id("com.mineinabyss.conventions.nms")
id("com.mineinabyss.conventions.copyjar")
- id("com.mineinabyss.conventions.autoversion")
-// id("de.nycode.spigot-dependency-loader") version "1.0.3"
}
dependencies {
implementation(project(":"))
implementation(libs.bundles.idofront.core)
}
-
-tasks {
- assemble {
- dependsOn(project(":protocolburrito-generator").tasks.assemble)
- }
-}
diff --git a/protocolburrito-plugin/src/main/resources/plugin.yml b/protocolburrito-plugin/src/main/resources/plugin.yml
index d7634b4..ce5f20e 100644
--- a/protocolburrito-plugin/src/main/resources/plugin.yml
+++ b/protocolburrito-plugin/src/main/resources/plugin.yml
@@ -2,7 +2,7 @@ name: ProtocolBurrito
version: ${plugin_version}
author: Offz
main: com.mineinabyss.protocolburrito.ProtocolBurritoPlugin
-api-version: 1.16
+api-version: '1.20'
depend: [ProtocolLib]
prefix: ProtocolBurrito
diff --git a/settings.gradle.kts b/settings.gradle.kts
index ee660a7..ad58b1b 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -11,12 +11,6 @@ pluginManagement {
maven("https://repo.papermc.io/repository/maven-public/")
}
- plugins {
- val kotlinVersion: String by settings
- kotlin("jvm") version kotlinVersion
- kotlin("plugin.serialization") version kotlinVersion
- }
-
resolutionStrategy.eachPlugin {
if (requested.id.id.startsWith("com.mineinabyss.conventions"))
useVersion(idofrontVersion)