Merge remote-tracking branch 'origin/master'

This commit is contained in:
2023-10-13 04:25:24 +08:00
9 changed files with 49 additions and 110 deletions

View File

@@ -16,9 +16,9 @@ repositories {
dependencies { dependencies {
// 对于 Bukkit 插件 // 对于 Bukkit 插件
compileOnly "cn.hamster3.mc.plugin:core-bukkit:1.0.0" compileOnly "cn.hamster3.mc.plugin:core-bukkit:+"
// 对于 BungeeCord 插件 // 对于 BungeeCord 插件
compileOnly "cn.hamster3.mc.plugin:core-bungeecord:1.0.0" compileOnly "cn.hamster3.mc.plugin:core-bungeecord:+"
} }
``` ```

View File

@@ -9,7 +9,7 @@ version = "1.1.0-SNAPSHOT"
subprojects { subprojects {
apply { apply {
plugin("java") plugin("java-library")
plugin("maven-publish") plugin("maven-publish")
plugin("com.github.johnrengelman.shadow") plugin("com.github.johnrengelman.shadow")
} }
@@ -24,51 +24,34 @@ subprojects {
} }
dependencies { dependencies {
// https://mvnrepository.com/artifact/org.jetbrains/annotations compileOnly("org.jetbrains:annotations:+")
compileOnly("org.jetbrains:annotations:23.0.0") compileOnly("org.projectlombok:lombok:+")
// https://mvnrepository.com/artifact/org.projectlombok/lombok annotationProcessor("org.projectlombok:lombok:+")
compileOnly("org.projectlombok:lombok:1.18.28")
annotationProcessor("org.projectlombok:lombok:1.18.28")
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
// withJavadocJar()
withSourcesJar() withSourcesJar()
} }
tasks { tasks {
withType<JavaCompile>() { withType<JavaCompile> {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
withType<Jar>() { withType<Jar> {
from(rootProject.file("LICENSE")) from(rootProject.file("LICENSE"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
} }
jar { jar {
archiveClassifier = "dev" 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 { shadowJar {
archiveClassifier = "" archiveClassifier = ""
relocate("net.kyori", "cn.hamster3.mc.plugin.core.lib.net.kyori") 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("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.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") relocate("de.tr7zw.annotations", "cn.hamster3.mc.plugin.core.lib.de.tr7zw.nbtapi.annotations")
destinationDirectory = rootProject.buildDir
} }
build { build {
dependsOn(shadowJar) dependsOn(shadowJar)

View File

@@ -1,41 +1,22 @@
evaluationDependsOn(":core-common") evaluationDependsOn(":core-common")
dependencies { dependencies {
compileOnly("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT") api(project(":core-common")) { isTransitive = false }
compileOnly("net.milkbowl.vault:VaultAPI:1.7") { compileOnly("org.spigotmc:spigot-api:+")
isTransitive = false
}
compileOnly("org.black_ixx:playerpoints:2.1.3") {
isTransitive = false
}
implementation(project(":core-common")) { implementation("de.tr7zw:item-nbt-api:+")
isTransitive = false compileOnly("net.milkbowl.vault:VaultAPI:+") { isTransitive = false }
} compileOnly("org.black_ixx:playerpoints:+") { isTransitive = false }
implementation("de.tr7zw:item-nbt-api:2.11.2")
val adventureVersion = property("adventure_version") api("net.kyori:adventure-platform-bukkit:4+") {
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-bungeecord
implementation("net.kyori:adventure-platform-bukkit:${adventureVersion}") {
exclude(group = "org.jetbrains") exclude(group = "org.jetbrains")
exclude(group = "com.google.code.gson") exclude(group = "com.google.code.gson")
} }
val adventureSerializerVersion = property("adventure_serializer_version") api("net.kyori:adventure-text-minimessage:4+") {
// https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage exclude(module = "adventure-api")
implementation("net.kyori:adventure-text-minimessage:${adventureSerializerVersion}") {
exclude(group = "org.jetbrains") exclude(group = "org.jetbrains")
} }
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson implementation("com.zaxxer:HikariCP:4+") {
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}") {
exclude(group = "org.slf4j") exclude(group = "org.slf4j")
} }
} }
@@ -46,7 +27,10 @@ tasks {
expand(project.properties) expand(project.properties)
} }
} }
withType<Jar>() { withType<Jar> {
archiveBaseName = "HamsterCore-Bukkit" archiveBaseName = "HamsterCore-Bukkit"
} }
shadowJar {
destinationDirectory = rootProject.buildDir
}
} }

View File

@@ -99,22 +99,22 @@ public final class CoreBukkitAPI extends CoreAPI {
} }
@Override @Override
public Gson getGson() { public @NotNull Gson getGson() {
return gson; return gson;
} }
@Override @Override
public Gson getHumanGson() { public @NotNull Gson getHumanGson() {
return humanGson; return humanGson;
} }
@Override @Override
public ExecutorService getExecutorService() { public @NotNull ExecutorService getExecutorService() {
return executorService; return executorService;
} }
@Override @Override
public ScheduledExecutorService getScheduledExecutorService() { public @NotNull ScheduledExecutorService getScheduledExecutorService() {
return scheduledExecutorService; return scheduledExecutorService;
} }
} }

View File

@@ -1,34 +1,18 @@
evaluationDependsOn(":core-common") evaluationDependsOn(":core-common")
dependencies { 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")) { api("net.kyori:adventure-platform-bungeecord:4+") {
isTransitive = false
}
val adventureVersion = property("adventure_version")
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-bungeecord
implementation("net.kyori:adventure-platform-bungeecord:${adventureVersion}") {
exclude(group = "org.jetbrains") exclude(group = "org.jetbrains")
exclude(group = "com.google.code.gson") exclude(group = "com.google.code.gson")
} }
val adventureSerializerVersion = property("adventure_serializer_version") api("net.kyori:adventure-text-minimessage:4+") {
// https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage exclude(module = "adventure-api")
implementation("net.kyori:adventure-text-minimessage:${adventureSerializerVersion}") {
exclude(group = "org.jetbrains") exclude(group = "org.jetbrains")
} }
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson implementation("com.zaxxer:HikariCP:4+") {
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}") {
exclude(group = "org.slf4j") exclude(group = "org.slf4j")
} }
} }
@@ -39,7 +23,10 @@ tasks {
expand(project.properties) expand(project.properties)
} }
} }
withType<Jar>() { withType<Jar> {
archiveBaseName = "HamsterCore-BungeeCord" archiveBaseName = "HamsterCore-BungeeCord"
} }
shadowJar {
destinationDirectory = rootProject.buildDir
}
} }

View File

@@ -91,22 +91,22 @@ public final class CoreBungeeAPI extends CoreAPI {
} }
@Override @Override
public Gson getGson() { public @NotNull Gson getGson() {
return gson; return gson;
} }
@Override @Override
public Gson getHumanGson() { public @NotNull Gson getHumanGson() {
return humanGson; return humanGson;
} }
@Override @Override
public ExecutorService getExecutorService() { public @NotNull ExecutorService getExecutorService() {
return executorService; return executorService;
} }
@Override @Override
public ScheduledExecutorService getScheduledExecutorService() { public @NotNull ScheduledExecutorService getScheduledExecutorService() {
return scheduledExecutorService; return scheduledExecutorService;
} }
} }

View File

@@ -1,32 +1,19 @@
@file:Suppress("VulnerableLibrariesLocal") @file:Suppress("VulnerableLibrariesLocal")
dependencies { dependencies {
// https://mvnrepository.com/artifact/com.google.code.gson/gson
compileOnly("com.google.code.gson:gson:2.8.0") compileOnly("com.google.code.gson:gson:2.8.0")
val adventureVersion = property("adventure_version") api("net.kyori:adventure-platform-api:4+") {
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-api
implementation("net.kyori:adventure-platform-api:${adventureVersion}") {
exclude(group = "org.jetbrains") exclude(group = "org.jetbrains")
} }
val adventureSerializerVersion = property("adventure_serializer_version") api("net.kyori:adventure-text-serializer-gson:4.13+") {
// 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}") {
exclude(group = "org.jetbrains") exclude(group = "org.jetbrains")
exclude(group = "com.google.code.gson") 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 { tasks {
withType<Jar>() { withType<Jar> {
archiveBaseName = "HamsterCore-Common" archiveBaseName = "HamsterCore-Common"
} }
} }

View File

@@ -1,6 +1,7 @@
package cn.hamster3.mc.plugin.core.common.api; package cn.hamster3.mc.plugin.core.common.api;
import com.google.gson.Gson; import com.google.gson.Gson;
import lombok.Getter;
import net.kyori.adventure.platform.AudienceProvider; import net.kyori.adventure.platform.AudienceProvider;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -12,12 +13,9 @@ import java.util.concurrent.ScheduledExecutorService;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public abstract class CoreAPI { public abstract class CoreAPI {
@Getter
protected static CoreAPI instance; protected static CoreAPI instance;
public static CoreAPI getInstance() {
return instance;
}
@NotNull @NotNull
public abstract AudienceProvider getAudienceProvider(); public abstract AudienceProvider getAudienceProvider();
@@ -32,20 +30,24 @@ public abstract class CoreAPI {
/** /**
* @return GSON 工具 * @return GSON 工具
*/ */
@NotNull
public abstract Gson getGson(); public abstract Gson getGson();
/** /**
* @return GSON 工具会使用格式化输出、且解析中包含null参数 * @return GSON 工具会使用格式化输出、且解析中包含null参数
*/ */
@NotNull
public abstract Gson getHumanGson(); public abstract Gson getHumanGson();
/** /**
* @return 异步线程池 * @return 异步线程池
*/ */
@NotNull
public abstract ExecutorService getExecutorService(); public abstract ExecutorService getExecutorService();
/** /**
* @return 调度器线程池 * @return 调度器线程池
*/ */
@NotNull
public abstract ScheduledExecutorService getScheduledExecutorService(); public abstract ScheduledExecutorService getScheduledExecutorService();
} }

View File

@@ -1,4 +0,0 @@
org.gradle.jvmargs=-Xmx2G
adventure_version=4.3.0
adventure_serializer_version=4.14.0
HikariCP_version=4.0.3