feat: 添加 api 功能
添加 api 功能
This commit is contained in:
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'cn.hamster3.plugin'
|
||||
version '1.0.0-SNAPSHOT'
|
||||
version '1.0.0'
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'java-library'
|
||||
|
@@ -1,11 +1,54 @@
|
||||
package cn.hamster3.plugin.core.bukkit.api;
|
||||
|
||||
import cn.hamster3.plugin.core.bukkit.HamsterCorePlugin;
|
||||
import cn.hamster3.plugin.core.common.api.CommonAPI;
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import net.kyori.adventure.platform.AudienceProvider;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class BukkitAPI extends CommonAPI {
|
||||
private BukkitAudiences audienceProvider;
|
||||
private HikariDataSource datasource;
|
||||
|
||||
public static BukkitAPI getInstance() {
|
||||
return (BukkitAPI) instance;
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
BukkitAPI api = new BukkitAPI();
|
||||
instance = api;
|
||||
api.audienceProvider = BukkitAudiences.create(HamsterCorePlugin.getInstance());
|
||||
HikariConfig hikariConfig = new HikariConfig();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull AudienceProvider getAudienceProvider() {
|
||||
return audienceProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HikariDataSource getDataSource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Connection getConnection() throws SQLException {
|
||||
return datasource.getConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportError(@NotNull String apiKey, @NotNull String projectID, @NotNull Throwable exception) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportFile(@NotNull String apiKey, @NotNull String projectID, @NotNull String filename, byte @NotNull [] bytes) {
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class PageManager {
|
||||
public class PageManager {
|
||||
private static final HashMap<String, PageConfig> PAGE_CONFIG = new HashMap<>();
|
||||
|
||||
public static PageConfig getPageConfig(Class<?> clazz) {
|
||||
|
@@ -12,8 +12,8 @@ dependencies {
|
||||
api 'net.kyori:adventure-api:4.11.0'
|
||||
// https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage
|
||||
api 'net.kyori:adventure-text-minimessage:4.11.0'
|
||||
// // https://mvnrepository.com/artifact/net.kyori/adventure-platform-api
|
||||
// implementation 'net.kyori:adventure-platform-api:4.1.2'
|
||||
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-api
|
||||
implementation 'net.kyori:adventure-platform-api:4.1.2'
|
||||
|
||||
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson
|
||||
api 'net.kyori:adventure-text-serializer-gson:4.11.0'
|
||||
|
@@ -1,5 +1,12 @@
|
||||
package cn.hamster3.plugin.core.common.api;
|
||||
|
||||
import net.kyori.adventure.platform.AudienceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class CommonAPI {
|
||||
protected static CommonAPI instance;
|
||||
@@ -8,10 +15,16 @@ public abstract class CommonAPI {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void reportError(String apiKey, String projectID, Throwable exception) {
|
||||
@NotNull
|
||||
public abstract AudienceProvider getAudienceProvider();
|
||||
|
||||
}
|
||||
@NotNull
|
||||
public abstract DataSource getDataSource();
|
||||
|
||||
public void reportFile(String apiKey, String projectID, String filename) {
|
||||
}
|
||||
@NotNull
|
||||
public abstract Connection getConnection() throws SQLException;
|
||||
|
||||
public abstract void reportError(@NotNull String apiKey, @NotNull String projectID, @NotNull Throwable exception);
|
||||
|
||||
public abstract void reportFile(@NotNull String apiKey, @NotNull String projectID, @NotNull String filename, byte @NotNull [] bytes);
|
||||
}
|
||||
|
Reference in New Issue
Block a user