Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbefcd384b | ||
|
|
4fd54b9641 | ||
|
|
4ed6b8ec5a |
@@ -9,9 +9,11 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: Build with Maven
|
name: Build with Maven
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up JDK 25 and enable Maven cache
|
- name: Set up JDK 25 and enable Maven cache
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v5
|
||||||
@@ -28,8 +30,20 @@ jobs:
|
|||||||
- name: Build and package with Maven
|
- name: Build and package with Maven
|
||||||
run: mvn -B package
|
run: mvn -B package
|
||||||
|
|
||||||
|
- name: Determine version
|
||||||
|
id: set-version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/ver/}
|
||||||
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Upload built artifacts
|
- name: Upload built artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: maven-artifacts
|
name: maven-artifacts
|
||||||
path: target/spigot/*.jar
|
path: target/spigot/*.jar
|
||||||
|
|
||||||
|
- uses: akkuman/gitea-release-action@v1
|
||||||
|
with:
|
||||||
|
name: '${{ steps.set-version.outputs.version }} Release'
|
||||||
|
files: target/spigot/*.jar
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>xyz.fortern</groupId>
|
<groupId>xyz.fortern</groupId>
|
||||||
<artifactId>fortern-helper</artifactId>
|
<artifactId>fortern-helper</artifactId>
|
||||||
<version>1.3</version>
|
<version>1.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>fortern-helper</name>
|
<name>fortern-helper</name>
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package xyz.fortern.forternhelper.nms.v26_R2
|
||||||
|
|
||||||
|
import org.bukkit.entity.Villager
|
||||||
|
import xyz.fortern.forternhelper.reflection.NMSAdapter.PKG_NAME
|
||||||
|
import xyz.fortern.forternhelper.reflection.NMSHandler
|
||||||
|
import java.lang.reflect.Field
|
||||||
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
|
// 26.2
|
||||||
|
class NMSHandlerImpl : NMSHandler {
|
||||||
|
|
||||||
|
override fun setVillagerRestock(villager: Villager, restockToday: Int) {
|
||||||
|
val mcVillager = villagerGetHandlerMethod.invoke(villager)
|
||||||
|
villagerRestockTodayField.isAccessible = true
|
||||||
|
villagerRestockTodayField.set(mcVillager, restockToday)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val craftVillagerClass: Class<*>
|
||||||
|
private val villagerGetHandlerMethod: Method
|
||||||
|
private val mcVillagerClass: Class<*>
|
||||||
|
private val villagerRestockTodayField: Field
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
try {
|
||||||
|
craftVillagerClass = Class.forName("$PKG_NAME.entity.CraftVillager")
|
||||||
|
villagerGetHandlerMethod = craftVillagerClass.getMethod("getHandle")
|
||||||
|
mcVillagerClass = Class.forName("net.minecraft.world.entity.npc.villager.Villager")
|
||||||
|
villagerRestockTodayField = mcVillagerClass.getField("numberOfRestocksToday")
|
||||||
|
} catch (e: ReflectiveOperationException) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,6 +31,7 @@ object NMSAdapter {
|
|||||||
"1.21.9", "1.21.10" -> "v1_21_R6"
|
"1.21.9", "1.21.10" -> "v1_21_R6"
|
||||||
"1.21.11" -> "v1_21_R7"
|
"1.21.11" -> "v1_21_R7"
|
||||||
"26.1", "26.1.1", "26.1.2" -> "v26_R1"
|
"26.1", "26.1.1", "26.1.2" -> "v26_R1"
|
||||||
|
"26.2" -> "v26_R2"
|
||||||
else -> throw Exception("Unknown NMS version")
|
else -> throw Exception("Unknown NMS version")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user