1
mirror of https://github.com/CarmJos/UltraDepository.git synced 2026-06-05 00:58:22 +08:00

Compare commits

...

9 Commits

Author SHA1 Message Date
carm 52a0d28249 [v1.1.7] 使用自定义存储却未重写方法时输出提示 2022-01-05 10:44:50 +08:00
carm 2f0a3d283b [v1.1.7] 默认采用中文介绍 2022-01-05 10:38:21 +08:00
carm 725ea4b4ee [v1.1.7] 默认采用中文介绍 2022-01-05 10:34:43 +08:00
carm e256278453 默认采用中文介绍 2022-01-05 10:34:24 +08:00
carm 66dafb39b5 添加EasyPlugin依赖介绍 2022-01-05 07:05:23 +08:00
carm 4640a8098d 添加EasyPlugin依赖介绍 2022-01-05 05:33:17 +08:00
carm 62c8350b8b 添加依赖方式介绍 2022-01-05 05:11:25 +08:00
carm d0361c260d 添加示例地址 2022-01-05 04:42:49 +08:00
carm fe256dc916 添加自定义存储的开发介绍 2022-01-05 04:39:27 +08:00
8 changed files with 213 additions and 24 deletions
+66
View File
@@ -11,6 +11,72 @@
# UltraDepository 帮助介绍文档
## 插件介绍目录
- 使用示例
- [仓库配置文件预设示例](../.examples/depositories)
- [用户数据示例](../.examples/userdata)
- [YAML格式](../.examples/userdata/uuid.yml)
- [JSON格式](../.examples/userdata/uuid.json)
- [MySQL格式](../.examples/userdata/database.sql)
- [开发](develop)
- [自定义存储源](develop/use-custome-storage.md)
## [开发文档](JAVADOC-README.md)
基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/UltraDepository) 。
## 依赖方式
### Maven 依赖
```xml
<project>
<repositories>
<repository>
<!--采用github依赖库,安全稳定,但需要配置 (推荐)-->
<id>UltraDepository</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/UltraDepository</url>
</repository>
<repository>
<!--采用我的私人依赖库,简单方便,但可能因为变故而无法使用-->
<id>carm-repo</id>
<name>Carm's Repo</name>
<url>https://repo.carm.cc/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>cc.carm.plugin</groupId>
<artifactId>ultradepository</artifactId>
<version>[LATEST RELEASE]</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
```
### Gradle 依赖
```groovy
repositories {
// 采用github依赖库,安全稳定,但需要配置 (推荐)
maven { url 'https://maven.pkg.github.com/CarmJos/EasyPlugin' }
// 采用我的私人依赖库,简单方便,但可能因为变故而无法使用
maven { url 'https://repo.carm.cc/repository/maven-public/' }
}
dependencies {
compileOnly "cc.carm.plugin:ultradepository:[LATEST RELEASE]"
}
```
@@ -0,0 +1,105 @@
# 开发 - 自定义存储源
在某些情况下,插件提供的几种存储方式并不能满足您的需求,此时您可以选择在您自己的插件中自定义本插件的存储源。
## 1. 修改 plugin.yml
您需要在您自己的插件中声明依赖了本插件,即在 `plugin.yml` 中添加以下内容:
```yaml
softdepend:
- UltraDepository
```
添加后,Bukkit会让您的插件在本插件之后加载,此时您就可以应用您的存储源。
## 2. 依赖本插件
请依据 [开发指南](../README.md) 中的依赖介绍部分完成对本插件的依赖。
## 3. 实现 DataStorage
您需要在您的插件中实现 DataStorage 类,并实现其中的功能,他看起来像是这样的:
```java
import cc.carm.plugin.ultradepository.data.UserData;
import cc.carm.plugin.ultradepository.storage.DataStorage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import java.util.UUID;
public class CustomStorage implements DataStorage {
@Override
public boolean initialize() {
//初始化存储,在这里可进行连接数据库、创建表等操作。
return true; //返回true代表初始化成功,若失败则插件将不再加载
}
@Override
public void shutdown() {
// 插件卸载时触发,一般用于释放连接池。
}
@Override
public @Nullable UserData loadData(@NotNull UUID uuid) throws Exception {
// 加载玩家数据部分
// 若抛出错误,则视为加载出错,会采用临时玩家数据的形式保证插件继续运行,同时在后台提示检查。
// 返回空则代表暂无该玩家数据,会自动视作新数据
return null;
}
@Override
public void saveUserData(@NotNull UserData data) throws Exception {
// 保存玩家数据部分
// 若抛出错误,则视为保存出错,将在后台提示检查。
}
}
```
您也可以 [点击这里](../../src/main/java/cc/carm/plugin/ultradepository/storage/impl) 参考本插件提供的其他已实现的存储方式,并在此基础上开发您的自定义存储。
> 若您需要JSON格式存储,可以直接继承 [`JSONStorage`](../../src/main/java/cc/carm/plugin/ultradepository/storage/impl/JSONStorage.java) ,并重写相关方法。
## 4. 应用您的存储
您需要在插件加载(`onLoad()`)时,应用您的自定义存储。
```java
import cc.carm.plugin.ultradepository.storage.DataStorage;
import cc.carm.plugin.ultradepository.storage.StorageMethod;
import cc.carm.plugin.ultradepository.storage.impl.CustomStorage;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.function.Supplier;
public class YourPlugin extends JavaPlugin {
@Override
public void onLoad() {
// 应用您的存储方式
StorageMethod.CUSTOM.setStorageSupplier(new Supplier<DataStorage>() {
@Override
public DataStorage get() {
return new CustomStorage();
}
});
// 简化后大概长这样(lamda)
StorageMethod.CUSTOM.setStorageSupplier(CustomStorage::new);
}
}
```
## 5. 修改本插件的 config.yml
您需要修改本插件的 `config.yml` 中的 `storage.method`**CUSTOM**
修改完成后,在插件下次启动时就将应用您实现的 **DataStorage** 从而完成自定义存储源。
+7 -7
View File
@@ -1,30 +1,30 @@
---
name: 问题提交
about: 提交并描述问题,帮助我们对其进行检查与修复。
about: 描述问题并提交,帮助我们对其进行检查与修复。
title: ''
labels: bug
assignees: ''
---
**问题简述**
### **问题简述**
用简短的话语描述一下大概问题。
**问题来源**
### **问题来源**
描述一下通过哪些操作才发现的问题,如:
1. 打开 '...'
2. 点击了 '....'
3. 出现了报错 '....'
**预期结果**(可选)
### **预期结果**(可选)
如果问题不发生,应该是什么情况
**问题截图/问题报错**
### **问题截图/问题报错**
如果有报错或输出,请提供截图。
**操作环境**
### *操作环境**
请在后台输入 `version` 并复制相关输出。
**其他补充**
### **其他补充**
如有其他补充,可以在这里描述。
+4 -4
View File
@@ -7,14 +7,14 @@ assignees: ''
---
**功能简述**
### **功能简述**
简单的描述一下你想要的功能
**需求来源**
### **需求来源**
简单的描述一下为什么需要这个功能。
**功能参考**(可选)
### **功能参考**(可选)
如果有相关功能的参考,如文本、截图,请提供给我们。
**附加内容**
### **附加内容**
如果有什么小细节需要重点注意,请在这里告诉我们。
+6 -1
View File
@@ -61,6 +61,7 @@
## 插件依赖
- **[必须]** 插件本体基于 [Spigot-API](https://hub.spigotmc.org/stash/projects/SPIGOT) 、 [BukkitAPI](http://bukkit.org/) 实现。
- **[自带]** 插件功能基于 [EasyPlugin](https://github.com/CarmJos/EasyPlugin) 实现。
- **[自带]** 数据部分基于 [EasySQL](https://github.com/CarmJos/EasySQL) 实现。
- 本插件连接池使用 [BeeCP](https://github.com/Chris2018998/BeeCP) ,更轻量、快速。
- **[推荐]** 变量部分基于 [PlaceholderAPI](https://www.spigotmc.org/resources/6245/) 实现。
@@ -213,10 +214,14 @@
文件名即仓库的ID,**强烈推荐使用纯英文**,部分符号可能会影响正常读取,请避免使用。
随本项目预设了几个常用的仓库类型,可以 [在这里](.examples/depositories) 找到您需要的直接使用或加以修改后使用。
随本项目预设了几个常用的仓库类型,可以 [在这里](.examples/depositories) 找到您需要的仓库配置加以修改后使用。
您也可以 [点击这里](.examples/depositories/full-example.yml) 查看一份*详细的仓库配置示例*,以制作您自己的仓库。
## 开发
详细开发介绍请 [点击这里](.documentation/README.md) , JavaDoc(最新Release) 请 [点击这里](https://carmjos.github.io/UltraDepository) 。
## 使用统计
[![bStats](https://bstats.org/signatures/bukkit/UltraDepository.svg)](https://bstats.org/plugin/bukkit/UltraDepository/13777)
+1 -1
View File
@@ -15,7 +15,7 @@
<groupId>cc.carm.plugin</groupId>
<artifactId>ultradepository</artifactId>
<packaging>jar</packaging>
<version>1.1.6</version>
<version>1.1.7</version>
<name>UltraDepository</name>
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
@@ -2,6 +2,7 @@ package cc.carm.plugin.ultradepository;
import cc.carm.lib.easyplugin.EasyPlugin;
import cc.carm.lib.easyplugin.gui.GUI;
import cc.carm.lib.easyplugin.i18n.EasyPluginMessageProvider;
import cc.carm.lib.easyplugin.utils.MessageUtils;
import cc.carm.plugin.ultradepository.command.DepositoryCommand;
import cc.carm.plugin.ultradepository.configuration.PluginConfig;
@@ -30,6 +31,9 @@ public class UltraDepository extends EasyPlugin {
private static EconomyManager economyManager;
private static DepositoryManager depositoryManager;
public UltraDepository() {
super(new EasyPluginMessageProvider.zh_CN());
}
@Override
public void load() {
@@ -145,14 +149,18 @@ public class UltraDepository extends EasyPlugin {
@Override
public void outputInfo() {
log("&6 _ _ _ _ &e _____ _ _ ");
log("&6| | | | | | &e| __ \\ (_) | ");
log("&6| | | | | |_ _ __ __ _ &e| | | | ___ _ __ ___ ___ _| |_ ___ _ __ _ _ ");
log("&6| | | | | __| '__/ _` |&e| | | |/ _ \\ '_ \\ / _ \\/ __| | __/ _ \\| '__| | | |");
log("&6| |__| | | |_| | | (_| |&e| |__| | __/ |_) | (_) \\__ \\ | || (_) | | | |_| |");
log("&6 \\____/|_|\\__|_| \\__,_|&e|_____/ \\___| .__/ \\___/|___/_|\\__\\___/|_| \\__, |");
log("&6 &e| | __/ |");
log("&6 &e|_| |___/ ");
log(" &fView more information at&6 https://github.com/CarmJos/UltraDepository");
log(" ",
"&6 _ _ _ _ &e _____ _ _ ",
"&6| | | | | | &e| __ \\ (_) | ",
"&6| | | | | |_ _ __ __ _ &e| | | | ___ _ __ ___ ___ _| |_ ___ _ __ _ _ ",
"&6| | | | | __| '__/ _` |&e| | | |/ _ \\ '_ \\ / _ \\/ __| | __/ _ \\| '__| | | |",
"&6| |__| | | |_| | | (_| |&e| |__| | __/ |_) | (_) \\__ \\ | || (_) | | | |_| |",
"&6 \\____/|_|\\__|_| \\__,_|&e|_____/ \\___| .__/ \\___/|___/_|\\__\\___/|_| \\__, |",
"&6 &e| | __/ |",
"&6 &e|_| |___/ ",
"&f请访问项目主页查看详细插件介绍 &8/ &fView GitHub to get more information",
"&8-> &6https://github.com/CarmJos/UltraDepository",
" "
);
}
}
@@ -1,5 +1,6 @@
package cc.carm.plugin.ultradepository.storage.impl;
import cc.carm.plugin.ultradepository.UltraDepository;
import cc.carm.plugin.ultradepository.data.UserData;
import cc.carm.plugin.ultradepository.storage.DataStorage;
import org.jetbrains.annotations.NotNull;
@@ -13,6 +14,10 @@ public class CustomStorage implements DataStorage {
@Override
@TestOnly
public boolean initialize() {
UltraDepository.getInstance().error("您选择使用自定义存储,但并没有应用成功。");
UltraDepository.getInstance().error("请访问 https://github.com/CarmJos/UltraDepository/blob/master/.documentation 获取相关帮助!");
UltraDepository.getInstance().error("You are using CustomStorage, but not overwrite the methods.");
UltraDepository.getInstance().error("Please view https://github.com/CarmJos/UltraDepository/blob/master/.documentation to get more information.");
return false;
}