diff --git a/README.md b/README.md index 313f1d3..1977e7d 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ repositories { dependencies { // 对于 Bukkit 插件 - compileOnly "cn.hamster3.mc.plugin:core-bukkit:1.0.0" + compileOnly "cn.hamster3.mc.plugin:core-bukkit:+" // 对于 BungeeCord 插件 - compileOnly "cn.hamster3.mc.plugin:core-bungeecord:1.0.0" + compileOnly "cn.hamster3.mc.plugin:core-bungeecord:+" } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 30a71f0..4ebf216 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ version = "1.1.0-SNAPSHOT" subprojects { apply { - plugin("java") + plugin("java-library") plugin("maven-publish") plugin("com.github.johnrengelman.shadow") } @@ -24,51 +24,34 @@ subprojects { } dependencies { - // https://mvnrepository.com/artifact/org.jetbrains/annotations - compileOnly("org.jetbrains:annotations:23.0.0") - // https://mvnrepository.com/artifact/org.projectlombok/lombok - compileOnly("org.projectlombok:lombok:1.18.28") - annotationProcessor("org.projectlombok:lombok:1.18.28") + compileOnly("org.jetbrains:annotations:+") + compileOnly("org.projectlombok:lombok:+") + annotationProcessor("org.projectlombok:lombok:+") } java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 -// withJavadocJar() withSourcesJar() } tasks { - withType() { + withType { options.encoding = "UTF-8" } - withType() { + withType { from(rootProject.file("LICENSE")) duplicatesStrategy = DuplicatesStrategy.EXCLUDE } jar { archiveClassifier = "dev" } - javadoc { - options.jFlags("-Dfile.encoding=utf8") - options.encoding = "UTF-8" - options.quiet() - val o: StandardJavadocDocletOptions = options as StandardJavadocDocletOptions - o.addStringOption("Xdoclint:none", "-quiet") - o.links( - "https://javadoc.io/doc/org.jetbrains/annotations/23.0.0", - "https://javadoc.io/doc/com.google.code.gson/gson/2.8.0", - "http://milkbowl.github.io/VaultAPI", - "https://bukkit.windit.net/javadoc" - ) - } shadowJar { archiveClassifier = "" relocate("net.kyori", "cn.hamster3.mc.plugin.core.lib.net.kyori") relocate("com.zaxxer.hikari", "cn.hamster3.mc.plugin.core.lib.com.zaxxer.hikari") relocate("de.tr7zw.changeme.nbtapi", "cn.hamster3.mc.plugin.core.lib.de.tr7zw.nbtapi") relocate("de.tr7zw.annotations", "cn.hamster3.mc.plugin.core.lib.de.tr7zw.nbtapi.annotations") - destinationDirectory = rootProject.buildDir } build { dependsOn(shadowJar) diff --git a/core-bukkit/build.gradle.kts b/core-bukkit/build.gradle.kts index a994ab8..90c197f 100644 --- a/core-bukkit/build.gradle.kts +++ b/core-bukkit/build.gradle.kts @@ -1,41 +1,22 @@ evaluationDependsOn(":core-common") dependencies { - compileOnly("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT") - compileOnly("net.milkbowl.vault:VaultAPI:1.7") { - isTransitive = false - } - compileOnly("org.black_ixx:playerpoints:2.1.3") { - isTransitive = false - } + api(project(":core-common")) { isTransitive = false } + compileOnly("org.spigotmc:spigot-api:+") - implementation(project(":core-common")) { - isTransitive = false - } - implementation("de.tr7zw:item-nbt-api:2.11.2") - val adventureVersion = property("adventure_version") - // https://mvnrepository.com/artifact/net.kyori/adventure-platform-bungeecord - implementation("net.kyori:adventure-platform-bukkit:${adventureVersion}") { + implementation("de.tr7zw:item-nbt-api:+") + compileOnly("net.milkbowl.vault:VaultAPI:+") { isTransitive = false } + compileOnly("org.black_ixx:playerpoints:+") { isTransitive = false } + + api("net.kyori:adventure-platform-bukkit:4+") { exclude(group = "org.jetbrains") exclude(group = "com.google.code.gson") } - val adventureSerializerVersion = property("adventure_serializer_version") - // https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage - implementation("net.kyori:adventure-text-minimessage:${adventureSerializerVersion}") { + api("net.kyori:adventure-text-minimessage:4+") { + exclude(module = "adventure-api") exclude(group = "org.jetbrains") } - // https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson - implementation("net.kyori:adventure-text-serializer-gson:${adventureSerializerVersion}") { - exclude(group = "org.jetbrains") - exclude(group = "com.google.code.gson") - } - // https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-legacy - implementation("net.kyori:adventure-text-serializer-legacy:${adventureSerializerVersion}") { - exclude(group = "org.jetbrains") - } - - val hikariVersion = property("HikariCP_version") - implementation("com.zaxxer:HikariCP:${hikariVersion}") { + implementation("com.zaxxer:HikariCP:4+") { exclude(group = "org.slf4j") } } @@ -46,7 +27,10 @@ tasks { expand(project.properties) } } - withType() { + withType { archiveBaseName = "HamsterCore-Bukkit" } + shadowJar { + destinationDirectory = rootProject.buildDir + } } diff --git a/core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/api/CoreBukkitAPI.java b/core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/api/CoreBukkitAPI.java index 883cc3c..6690a97 100644 --- a/core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/api/CoreBukkitAPI.java +++ b/core-bukkit/src/main/java/cn/hamster3/mc/plugin/core/bukkit/api/CoreBukkitAPI.java @@ -99,22 +99,22 @@ public final class CoreBukkitAPI extends CoreAPI { } @Override - public Gson getGson() { + public @NotNull Gson getGson() { return gson; } @Override - public Gson getHumanGson() { + public @NotNull Gson getHumanGson() { return humanGson; } @Override - public ExecutorService getExecutorService() { + public @NotNull ExecutorService getExecutorService() { return executorService; } @Override - public ScheduledExecutorService getScheduledExecutorService() { + public @NotNull ScheduledExecutorService getScheduledExecutorService() { return scheduledExecutorService; } } diff --git a/core-bungeecord/build.gradle.kts b/core-bungeecord/build.gradle.kts index 136bf44..5fd9bb9 100644 --- a/core-bungeecord/build.gradle.kts +++ b/core-bungeecord/build.gradle.kts @@ -1,34 +1,18 @@ evaluationDependsOn(":core-common") dependencies { - compileOnly("net.md-5:bungeecord-api:1.20-R0.1-SNAPSHOT") + api(project(":core-common")) { isTransitive = false } + compileOnly("net.md-5:bungeecord-api:+") - implementation(project(":core-common")) { - isTransitive = false - } - val adventureVersion = property("adventure_version") - // https://mvnrepository.com/artifact/net.kyori/adventure-platform-bungeecord - implementation("net.kyori:adventure-platform-bungeecord:${adventureVersion}") { + api("net.kyori:adventure-platform-bungeecord:4+") { exclude(group = "org.jetbrains") exclude(group = "com.google.code.gson") } - val adventureSerializerVersion = property("adventure_serializer_version") - // https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage - implementation("net.kyori:adventure-text-minimessage:${adventureSerializerVersion}") { + api("net.kyori:adventure-text-minimessage:4+") { + exclude(module = "adventure-api") exclude(group = "org.jetbrains") } - // https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson - implementation("net.kyori:adventure-text-serializer-gson:${adventureSerializerVersion}") { - exclude(group = "org.jetbrains") - exclude(group = "com.google.code.gson") - } - // https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-legacy - implementation("net.kyori:adventure-text-serializer-legacy:${adventureSerializerVersion}") { - exclude(group = "org.jetbrains") - } - - val hikariVersion = property("HikariCP_version") - implementation("com.zaxxer:HikariCP:${hikariVersion}") { + implementation("com.zaxxer:HikariCP:4+") { exclude(group = "org.slf4j") } } @@ -39,7 +23,10 @@ tasks { expand(project.properties) } } - withType() { + withType { archiveBaseName = "HamsterCore-BungeeCord" } + shadowJar { + destinationDirectory = rootProject.buildDir + } } diff --git a/core-bungeecord/src/main/java/cn/hamster3/mc/plugin/core/bungee/api/CoreBungeeAPI.java b/core-bungeecord/src/main/java/cn/hamster3/mc/plugin/core/bungee/api/CoreBungeeAPI.java index 2781623..e071181 100644 --- a/core-bungeecord/src/main/java/cn/hamster3/mc/plugin/core/bungee/api/CoreBungeeAPI.java +++ b/core-bungeecord/src/main/java/cn/hamster3/mc/plugin/core/bungee/api/CoreBungeeAPI.java @@ -91,22 +91,22 @@ public final class CoreBungeeAPI extends CoreAPI { } @Override - public Gson getGson() { + public @NotNull Gson getGson() { return gson; } @Override - public Gson getHumanGson() { + public @NotNull Gson getHumanGson() { return humanGson; } @Override - public ExecutorService getExecutorService() { + public @NotNull ExecutorService getExecutorService() { return executorService; } @Override - public ScheduledExecutorService getScheduledExecutorService() { + public @NotNull ScheduledExecutorService getScheduledExecutorService() { return scheduledExecutorService; } } diff --git a/core-common/build.gradle.kts b/core-common/build.gradle.kts index 84d796c..833b241 100644 --- a/core-common/build.gradle.kts +++ b/core-common/build.gradle.kts @@ -1,32 +1,19 @@ @file:Suppress("VulnerableLibrariesLocal") dependencies { - // https://mvnrepository.com/artifact/com.google.code.gson/gson compileOnly("com.google.code.gson:gson:2.8.0") - val adventureVersion = property("adventure_version") - // https://mvnrepository.com/artifact/net.kyori/adventure-platform-api - implementation("net.kyori:adventure-platform-api:${adventureVersion}") { + api("net.kyori:adventure-platform-api:4+") { exclude(group = "org.jetbrains") } - val adventureSerializerVersion = property("adventure_serializer_version") - // https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage - implementation("net.kyori:adventure-text-minimessage:${adventureSerializerVersion}") { - exclude(group = "org.jetbrains") - } - // https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson - implementation("net.kyori:adventure-text-serializer-gson:${adventureSerializerVersion}") { + api("net.kyori:adventure-text-serializer-gson:4.13+") { exclude(group = "org.jetbrains") exclude(group = "com.google.code.gson") } - // https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-legacy - implementation("net.kyori:adventure-text-serializer-legacy:${adventureSerializerVersion}") { - exclude(group = "org.jetbrains") - } } tasks { - withType() { + withType { archiveBaseName = "HamsterCore-Common" } } diff --git a/core-common/src/main/java/cn/hamster3/mc/plugin/core/common/api/CoreAPI.java b/core-common/src/main/java/cn/hamster3/mc/plugin/core/common/api/CoreAPI.java index ffcc2a4..ed746d0 100644 --- a/core-common/src/main/java/cn/hamster3/mc/plugin/core/common/api/CoreAPI.java +++ b/core-common/src/main/java/cn/hamster3/mc/plugin/core/common/api/CoreAPI.java @@ -1,6 +1,7 @@ package cn.hamster3.mc.plugin.core.common.api; import com.google.gson.Gson; +import lombok.Getter; import net.kyori.adventure.platform.AudienceProvider; import org.jetbrains.annotations.NotNull; @@ -12,12 +13,9 @@ import java.util.concurrent.ScheduledExecutorService; @SuppressWarnings("unused") public abstract class CoreAPI { + @Getter protected static CoreAPI instance; - public static CoreAPI getInstance() { - return instance; - } - @NotNull public abstract AudienceProvider getAudienceProvider(); @@ -32,20 +30,24 @@ public abstract class CoreAPI { /** * @return GSON 工具 */ + @NotNull public abstract Gson getGson(); /** * @return GSON 工具,会使用格式化输出、且解析中包含null参数 */ + @NotNull public abstract Gson getHumanGson(); /** * @return 异步线程池 */ + @NotNull public abstract ExecutorService getExecutorService(); /** * @return 调度器线程池 */ + @NotNull public abstract ScheduledExecutorService getScheduledExecutorService(); } diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 1e44958..0000000 --- a/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -org.gradle.jvmargs=-Xmx2G -adventure_version=4.3.0 -adventure_serializer_version=4.14.0 -HikariCP_version=4.0.3