This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to generate wrappers from paper-userdev
- Loading branch information
Showing
18 changed files
with
148 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
version=0.2 | ||
version=0.3 | ||
group=com.mineinabyss | ||
kotlinVersion=1.6.10 | ||
serverVersion=1.18.2-R0.1-SNAPSHOT | ||
idofrontVersion=0.9.82 | ||
|
||
# Workaround for Kapt not working on jdk 16 | ||
org.gradle.jvmargs=--illegal-access=permit | ||
kapt.use.worker.api=false | ||
idofrontVersion=0.9.83 | ||
publishComponentName=java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
plugins { | ||
kotlin("jvm") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
id("com.mineinabyss.conventions.kotlin") | ||
id("com.mineinabyss.conventions.papermc") | ||
id("com.mineinabyss.conventions.publication") | ||
} | ||
|
||
dependencies { | ||
compileOnly("org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT") | ||
compileOnly(libs.kotlin.reflect) | ||
} |
19 changes: 15 additions & 4 deletions
19
protocolburrito-api/src/main/kotlin/com/mineinabyss/protocolburrito/FieldHelpers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
package com.mineinabyss.protocolburrito | ||
|
||
object FieldHelpers { | ||
fun <T : Any> getField(forObject: Any, type: Class<T>, index: Int): T { | ||
inline fun <reified T : Any> getField(forObject: Any, index: Int): T = | ||
getField(T::class.java, forObject, index) | ||
|
||
fun <T : Any> getField(type: Class<T>, forObject: Any, index: Int): T { | ||
var id = 0 | ||
return forObject::class.java.fields.first { it.type.kotlin == type && index == id++ }.get(forObject) as T | ||
return forObject::class.java.declaredFields.first { it.type.kotlin.javaObjectType == type && index == id++ } | ||
.also { | ||
it.isAccessible = true | ||
}.get(forObject) as T | ||
} | ||
|
||
fun <T : Any> setField(forObject: Any, type: Class<T>, index: Int, value: T) { | ||
inline fun <reified T : Any> setField(forObject: Any, index: Int, value: T?) = | ||
setField(T::class.java, forObject, index, value) | ||
|
||
fun <T : Any> setField(type: Class<T>, forObject: Any, index: Int, value: T?) { | ||
var id = 0 | ||
forObject::class.java.fields.first { it.type == type && index == id++ }.set(forObject, value) | ||
forObject::class.java.declaredFields.first { it.type.kotlin.javaObjectType == type && index == id++ }.also { | ||
it.isAccessible = true | ||
}.set(forObject, value) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
protocolburrito-api/src/main/kotlin/com/mineinabyss/protocolburrito/WrappedCompanion.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.mineinabyss.protocolburrito | ||
|
||
import com.comphenix.protocol.PacketType | ||
import com.comphenix.protocol.injector.packet.PacketRegistry | ||
|
||
interface WrappedCompanion { | ||
val type: PacketType | ||
|
||
fun wrap(any: Any): Any | ||
} |
12 changes: 1 addition & 11 deletions
12
protocolburrito-api/src/main/kotlin/com/mineinabyss/protocolburrito/WrappedPacket.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,3 @@ | ||
package com.mineinabyss.protocolburrito | ||
|
||
import com.comphenix.protocol.PacketType | ||
import com.comphenix.protocol.events.PacketContainer | ||
|
||
abstract class WrappedPacket( | ||
val handle: PacketContainer, | ||
val packetType: PacketType? = null, | ||
) { | ||
init { | ||
require(packetType == null || handle.type == packetType) { "${handle.handle} is not a packet of type $packetType" } | ||
} | ||
} | ||
interface WrappedPacket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
...nerator/src/main/kotlin/com/mineinabyss/protocolburrito/generation/AnnotationProcessor.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.