build: 支持 1.12.2 以及更低的版本
This commit is contained in:
@@ -20,8 +20,6 @@ subprojects {
|
||||
|
||||
configurations {
|
||||
shade
|
||||
api.extendsFrom apiShade
|
||||
implementation.extendsFrom implementationShade
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@@ -2,21 +2,37 @@ setArchivesBaseName("HamsterCore-Bukkit")
|
||||
|
||||
evaluationDependsOn(':hamster-core-common')
|
||||
|
||||
configurations {
|
||||
oldJar
|
||||
}
|
||||
|
||||
dependencies {
|
||||
apiShade(project(":hamster-core-common")) { transitive = false }
|
||||
api(project(":hamster-core-common")) { transitive = false }
|
||||
shade(project(":hamster-core-common")) { transitive = false }
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT'
|
||||
compileOnly('org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT') {
|
||||
exclude group: "com.google.code.gson"
|
||||
}
|
||||
|
||||
shade 'net.kyori:adventure-platform-bukkit:4.1.2'
|
||||
compileOnly('net.milkbowl.vault:VaultAPI:1.7') { transitive = false }
|
||||
compileOnly('org.black_ixx:playerpoints:2.1.3') { transitive = false }
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib-API:4.4.0") { transitive = false }
|
||||
|
||||
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
||||
//noinspection GradlePackageUpdate
|
||||
compileOnly 'com.google.code.gson:gson:2.8.0'
|
||||
|
||||
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-bukkit
|
||||
api 'net.kyori:adventure-platform-bukkit:4.1.2'
|
||||
oldJar 'net.kyori:adventure-platform-bukkit:4.1.2'
|
||||
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
|
||||
api 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||
oldJar 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
|
||||
compileOnly 'com.zaxxer:HikariCP:5.0.1'
|
||||
//noinspection GradlePackageUpdate
|
||||
oldJar 'com.zaxxer:HikariCP:4.0.3'
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -35,14 +51,26 @@ tasks.create("shadowJar", Jar) {
|
||||
},
|
||||
configurations.shade.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
},
|
||||
configurations.apiShade.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
},
|
||||
configurations.implementationShade.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
}
|
||||
])
|
||||
destinationDir(getRootProject().buildDir)
|
||||
}
|
||||
tasks.build.dependsOn(shadowJar)
|
||||
|
||||
tasks.create("oldJar", Jar) {
|
||||
dependsOn("jar")
|
||||
setClassifier("Old")
|
||||
from([
|
||||
tasks.jar.outputs.files.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
},
|
||||
configurations.shade.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
},
|
||||
configurations.oldJar.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
}
|
||||
])
|
||||
destinationDir(getRootProject().buildDir)
|
||||
}
|
||||
tasks.build.dependsOn(oldJar)
|
@@ -11,6 +11,9 @@ import cn.hamster3.mc.plugin.core.bukkit.listener.DebugListener;
|
||||
import cn.hamster3.mc.plugin.core.bukkit.page.listener.PageListener;
|
||||
import cn.hamster3.mc.plugin.core.bukkit.util.ItemStackAdapter;
|
||||
import cn.hamster3.mc.plugin.core.common.constant.CoreConstantObjects;
|
||||
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
||||
import cn.hamster3.mc.plugin.core.common.util.MessageTypeAdapter;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -36,7 +39,8 @@ public class HamsterCorePlugin extends JavaPlugin {
|
||||
saveDefaultConfig();
|
||||
reloadConfig();
|
||||
logger.info("已读取配置文件.");
|
||||
CoreConstantObjects.GSON = CoreConstantObjects.GSON.newBuilder()
|
||||
CoreConstantObjects.GSON = new GsonBuilder()
|
||||
.registerTypeAdapter(DisplayMessage.class, MessageTypeAdapter.INSTANCE)
|
||||
.registerTypeAdapter(ItemStack.class, ItemStackAdapter.INSTANCE)
|
||||
.create();
|
||||
CoreBukkitAPI.init();
|
||||
|
@@ -2,17 +2,27 @@ setArchivesBaseName("HamsterCore-BungeeCord")
|
||||
|
||||
evaluationDependsOn(':hamster-core-common')
|
||||
|
||||
configurations {
|
||||
oldJar
|
||||
}
|
||||
|
||||
dependencies {
|
||||
apiShade(project(":hamster-core-common")) { transitive = false }
|
||||
api(project(":hamster-core-common")) { transitive = false }
|
||||
shade(project(":hamster-core-common")) { transitive = false }
|
||||
|
||||
compileOnly 'net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT'
|
||||
|
||||
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-bungeecord
|
||||
apiShade 'net.kyori:adventure-platform-bungeecord:4.1.2'
|
||||
api 'net.kyori:adventure-platform-bungeecord:4.1.2'
|
||||
shade 'net.kyori:adventure-platform-bungeecord:4.1.2'
|
||||
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
|
||||
apiShade 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||
api 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||
shade 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
|
||||
implementationShade 'com.zaxxer:HikariCP:5.0.1'
|
||||
compileOnly 'com.zaxxer:HikariCP:5.0.1'
|
||||
shade 'com.zaxxer:HikariCP:5.0.1'
|
||||
//noinspection GradlePackageUpdate
|
||||
oldJar 'com.zaxxer:HikariCP:4.0.3'
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -31,14 +41,26 @@ tasks.create("shadowJar", Jar) {
|
||||
},
|
||||
configurations.shade.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
},
|
||||
configurations.apiShade.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
},
|
||||
configurations.implementationShade.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
}
|
||||
])
|
||||
destinationDir(getRootProject().buildDir)
|
||||
}
|
||||
tasks.build.dependsOn(shadowJar)
|
||||
|
||||
tasks.create("oldJar", Jar) {
|
||||
dependsOn("jar")
|
||||
setClassifier("Old")
|
||||
from([
|
||||
tasks.jar.outputs.files.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
},
|
||||
configurations.shade.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
},
|
||||
configurations.oldJar.collect {
|
||||
it.isDirectory() ? it : zipTree(it)
|
||||
}
|
||||
])
|
||||
destinationDir(getRootProject().buildDir)
|
||||
}
|
||||
tasks.build.dependsOn(oldJar)
|
||||
|
@@ -1,10 +1,11 @@
|
||||
package cn.hamster3.mc.plugin.core.common.constant;
|
||||
|
||||
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
||||
import com.google.gson.*;
|
||||
import cn.hamster3.mc.plugin.core.common.util.MessageTypeAdapter;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -53,19 +54,3 @@ class NamedThreadFactory implements ThreadFactory {
|
||||
}
|
||||
}
|
||||
|
||||
class MessageTypeAdapter implements JsonSerializer<DisplayMessage>, JsonDeserializer<DisplayMessage> {
|
||||
public static final MessageTypeAdapter INSTANCE = new MessageTypeAdapter();
|
||||
|
||||
private MessageTypeAdapter() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayMessage deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
return new DisplayMessage().fromJson(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(DisplayMessage src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return src.saveToJson();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package cn.hamster3.mc.plugin.core.common.util;
|
||||
|
||||
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
|
||||
import com.google.gson.*;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class MessageTypeAdapter implements JsonSerializer<DisplayMessage>, JsonDeserializer<DisplayMessage> {
|
||||
public static final MessageTypeAdapter INSTANCE = new MessageTypeAdapter();
|
||||
|
||||
private MessageTypeAdapter() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DisplayMessage deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
return new DisplayMessage().fromJson(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(DisplayMessage src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return src.saveToJson();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user