实现了多模块、多版本打包

This commit is contained in:
zhangyuheng 2024-08-05 15:45:59 +08:00
parent cabd3149ff
commit e0bd285e74
10 changed files with 33 additions and 32 deletions

View File

@ -20,7 +20,7 @@ jobs:
distribution: 'zulu' distribution: 'zulu'
cache: gradle cache: gradle
- name: "Build with Gradle" - name: "Build with Gradle"
run: ./gradlew shadowJar run: ./gradlew buildPlugin
- name: "Copy jar to staging" - name: "Copy jar to staging"
run: mkdir staging && cp build/libs/*.jar staging/ run: mkdir staging && cp build/libs/*.jar staging/
- name: "Build & test" - name: "Build & test"

View File

@ -4,7 +4,7 @@ plugins {
} }
group = "cn.lunadeer" group = "cn.lunadeer"
version = "1.44.4-beta" version = "1.44.6-beta"
java { java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21)) toolchain.languageVersion.set(JavaLanguageVersion.of(21))
@ -15,7 +15,7 @@ tasks.withType<JavaCompile> {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
subprojects { allprojects {
apply(plugin = "java") apply(plugin = "java")
apply(plugin = "com.github.johnrengelman.shadow") apply(plugin = "com.github.johnrengelman.shadow")
@ -37,19 +37,34 @@ subprojects {
implementation("org.yaml:snakeyaml:2.0") implementation("org.yaml:snakeyaml:2.0")
} }
tasks.processResources {
tasks.withType<ProcessResources> {
// replace @version@ in plugin.yml with project version // replace @version@ in plugin.yml with project version
filesMatching("**/plugin.yml") { filesMatching("**/plugin.yml") {
filter { filter {
it.replace("@version@", project.version.toString()) it.replace("@version@", rootProject.version.toString())
} }
} }
} }
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> { tasks.shadowJar {
archiveClassifier.set("") archiveClassifier.set("")
archiveVersion.set(project.version.toString()) archiveVersion.set(project.version.toString())
dependsOn(tasks.withType<ProcessResources>()) dependsOn(tasks.withType<ProcessResources>())
} }
} }
dependencies {
implementation(project(":core"))
implementation(project(":v1_20_1"))
implementation(project(":v1_21"))
}
tasks.shadowJar {
archiveClassifier.set("")
archiveVersion.set(project.version.toString())
}
tasks.register("buildPlugin") {
dependsOn(tasks.getByName("clean"))
dependsOn(tasks.getByName("shadowJar"))
}

View File

@ -11,16 +11,6 @@ tasks.withType<JavaCompile> {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
repositories {
mavenCentral()
mavenLocal()
maven("https://oss.sonatype.org/content/groups/public")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io")
maven("https://repo.mikeprimm.com/")
maven("https://ssl.lunadeer.cn:14454/repository/maven-snapshots/")
}
dependencies { dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
} }

View File

@ -18,11 +18,13 @@ public class RegisterEvents {
try { try {
switch (version) { switch (version) {
case v1_21: case v1_21:
XLogger.debug("Load API version: 1.21");
registerEvents("cn.lunadeer.dominion.events_v1_21.PlayerEvents"); registerEvents("cn.lunadeer.dominion.events_v1_21.PlayerEvents");
registerEvents("cn.lunadeer.dominion.events_v1_21.EnvironmentEvents"); registerEvents("cn.lunadeer.dominion.events_v1_21.EnvironmentEvents");
registerEvents("cn.lunadeer.dominion.events_v1_21.SelectPointEvents"); registerEvents("cn.lunadeer.dominion.events_v1_21.SelectPointEvents");
break; break;
case v1_20_1: case v1_20_1:
XLogger.debug("Load API version: 1.20.1");
registerEvents("cn.lunadeer.dominion.events_v1_20_1.PlayerEvents"); registerEvents("cn.lunadeer.dominion.events_v1_20_1.PlayerEvents");
registerEvents("cn.lunadeer.dominion.events_v1_20_1.EnvironmentEvents"); registerEvents("cn.lunadeer.dominion.events_v1_20_1.EnvironmentEvents");
registerEvents("cn.lunadeer.dominion.events_v1_20_1.SelectPointEvents"); registerEvents("cn.lunadeer.dominion.events_v1_20_1.SelectPointEvents");

View File

@ -11,10 +11,6 @@ tasks.withType<JavaCompile> {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies { dependencies {
compileOnly(project(":core")) compileOnly(project(":core"))
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")

View File

@ -162,10 +162,11 @@ public class EnvironmentEvents implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) // tnt_explode - armor stand @EventHandler(priority = EventPriority.HIGHEST) // tnt_explode - armor stand
public void onArmorStandExplodedByTnt(EntityDamageByEntityEvent event) { public void onArmorStandExplodedByTnt(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
Entity harmer = event.getDamager();
if (entity.getType() != EntityType.ARMOR_STAND) { if (entity.getType() != EntityType.ARMOR_STAND) {
return; return;
} }
if (entity.getType() != EntityType.MINECART_TNT && entity.getType() != EntityType.PRIMED_TNT) { if (harmer.getType() != EntityType.MINECART_TNT && harmer.getType() != EntityType.PRIMED_TNT) {
return; return;
} }
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation()); DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());

View File

@ -359,7 +359,7 @@ public class PlayerEvents implements Listener {
if (block == null) { if (block == null) {
return; return;
} }
if (!Tag.DOORS.isTagged(block.getType())) { if (!Tag.DOORS.isTagged(block.getType()) && !Tag.TRAPDOORS.isTagged(block.getType())) {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -11,10 +11,6 @@ tasks.withType<JavaCompile> {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies { dependencies {
compileOnly(project(":core")) compileOnly(project(":core"))
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")

View File

@ -162,10 +162,11 @@ public class EnvironmentEvents implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) // tnt_explode - armor stand @EventHandler(priority = EventPriority.HIGHEST) // tnt_explode - armor stand
public void onArmorStandExplodedByTnt(EntityDamageByEntityEvent event) { public void onArmorStandExplodedByTnt(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
Entity harmer = event.getDamager();
if (entity.getType() != EntityType.ARMOR_STAND) { if (entity.getType() != EntityType.ARMOR_STAND) {
return; return;
} }
if (entity.getType() != EntityType.TNT_MINECART && entity.getType() != EntityType.TNT) { if (harmer.getType() != EntityType.TNT_MINECART && harmer.getType() != EntityType.TNT) {
return; return;
} }
DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation()); DominionDTO dom = Cache.instance.getDominionByLoc(entity.getLocation());

View File

@ -52,8 +52,8 @@ public class PlayerEvents implements Listener {
} }
DominionDTO dom = Cache.instance.getPlayerCurrentDominion(bukkitPlayer); DominionDTO dom = Cache.instance.getPlayerCurrentDominion(bukkitPlayer);
if (!checkFlag(dom, Flag.ANCHOR, bukkitPlayer, null)) { if (!checkFlag(dom, Flag.ANCHOR, bukkitPlayer, null)) {
if (bukkitPlayer.getBedSpawnLocation() != null) { if (bukkitPlayer.getRespawnLocation() != null) {
event.setRespawnLocation(bukkitPlayer.getBedSpawnLocation()); event.setRespawnLocation(bukkitPlayer.getRespawnLocation());
} else { } else {
event.setRespawnLocation(bukkitPlayer.getWorld().getSpawnLocation()); event.setRespawnLocation(bukkitPlayer.getWorld().getSpawnLocation());
} }
@ -355,7 +355,7 @@ public class PlayerEvents implements Listener {
if (block == null) { if (block == null) {
return; return;
} }
if (!Tag.DOORS.isTagged(block.getType())) { if (!Tag.DOORS.isTagged(block.getType()) && !Tag.TRAPDOORS.isTagged(block.getType())) {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -617,7 +617,7 @@ public class PlayerEvents implements Listener {
Teleport.doTeleportSafely(player, to).thenAccept((success) -> { Teleport.doTeleportSafely(player, to).thenAccept((success) -> {
if (!success) { if (!success) {
Notification.warn(player, "传送失败,你将被传送到复活点"); Notification.warn(player, "传送失败,你将被传送到复活点");
Location bed = player.getBedSpawnLocation(); Location bed = player.getRespawnLocation();
if (bed == null) { if (bed == null) {
bed = player.getWorld().getSpawnLocation(); bed = player.getWorld().getSpawnLocation();
} }