mirror of
https://github.com/CarmJos/UltraDepository.git
synced 2026-06-04 16:48:21 +08:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c841a7b1b3 | |||
| dc57e822b5 | |||
| 54cc9c070b | |||
| fa07564548 | |||
| 7138d20357 |
@@ -17,18 +17,18 @@
|
||||
|
||||
## 预设配置截图
|
||||
|
||||
### 渔夫仓库 ([fishman.yml](files/fishman.yml))
|
||||
### 渔夫仓库 ([fishman.yml](../../src/main/resources/depositories/fishman.yml))
|
||||
|
||||

|
||||
|
||||
### 矿工仓库 ([miner.yml](files/miner.yml))
|
||||
### 矿工仓库 ([miner.yml](../../src/main/resources/depositories/miner.yml))
|
||||
|
||||

|
||||
|
||||
### 农夫仓库 ([farmer.yml](files/farmer.yml))
|
||||
### 农夫仓库 ([farmer.yml](../../src/main/resources/depositories/farmer.yml))
|
||||
|
||||

|
||||
|
||||
### 猎人仓库 ([hunter.yml](files/hunter.yml))
|
||||
### 猎人仓库 ([hunter.yml](../../src/main/resources/depositories/hunter.yml))
|
||||
|
||||

|
||||
@@ -1,7 +1,7 @@
|
||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||
|
||||
name: Project Deploy
|
||||
name: Deploy & Upload
|
||||
|
||||
on:
|
||||
# 支持手动触发构建
|
||||
@@ -27,13 +27,23 @@ jobs:
|
||||
server-username: MAVEN_USERNAME
|
||||
server-password: MAVEN_TOKEN
|
||||
|
||||
- name: "Maven Deploy With Javadoc"
|
||||
- name: "Maven Deploy"
|
||||
run: mvn -B deploy --file pom.xml -DskipTests
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ github.repository_owner }}
|
||||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
|
||||
- name: "Copy Javadoc to Location"
|
||||
- name: "Release Asset Upload"
|
||||
id: upload-release-asset
|
||||
uses: shogo82148/actions-upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ github.event.release.upload_url }}
|
||||
asset_path: asset/*.jar
|
||||
asset_content_type: application/java-archive
|
||||
|
||||
- name: "Javadoc Deploy Staging"
|
||||
run: |
|
||||
rm -rf docs
|
||||
mkdir -vp docs
|
||||
@@ -44,10 +54,10 @@ jobs:
|
||||
id: sitemap
|
||||
uses: cicirello/generate-sitemap@v1
|
||||
with:
|
||||
base-url-path: https://carmjos.github.io/EasySQL
|
||||
base-url-path: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
|
||||
path-to-root: docs
|
||||
|
||||
- name: "Output stats"
|
||||
- name: "Output Javadoc stats"
|
||||
run: |
|
||||
echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}"
|
||||
echo "url-count = ${{ steps.sitemap.outputs.url-count }}"
|
||||
@@ -65,11 +75,11 @@ jobs:
|
||||
git config --global user.name 'CarmJos'
|
||||
git config --global user.email 'carm@carm.cc'
|
||||
|
||||
- name: "Commit documentations"
|
||||
- name: "Commit Javadocs"
|
||||
run: |
|
||||
cd docs
|
||||
git init
|
||||
git remote add origin git@github.com:CarmJos/UltraDepository.git
|
||||
git remote add origin git@github.com:${{ github.repository }}.git
|
||||
git checkout -b gh-pages
|
||||
git add -A
|
||||
git commit -m "API Document generated."
|
||||
@@ -77,4 +87,4 @@ jobs:
|
||||
- name: "Push javadocs"
|
||||
run: |
|
||||
cd docs
|
||||
git push origin HEAD:gh-pages --force
|
||||
git push origin HEAD:gh-pages --force
|
||||
@@ -2,3 +2,4 @@
|
||||
/target/
|
||||
./*.iml
|
||||
*.iml
|
||||
asset/
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
进入仓库后的物品玩家可以选择拿出或直接按量出售,且每日的出售数量上限和每件物品的价格可以自定义。
|
||||
|
||||
插件支持针对不同的权限配置仓库的容量,由此可以制作付费享用的”农业仓库“、”战斗仓库“、”伐木仓库“...
|
||||
插件支持针对不同的权限配置仓库的容量,由此可以制作付费享用的”作物仓库“、”药剂师仓库“、”伐木仓库“...
|
||||
|
||||
综上,该插件不但提供了一种功能特权,对其合理配置之后也将大大为玩家带来便利。
|
||||
|
||||
@@ -218,7 +218,7 @@
|
||||
|
||||
文件名即仓库的ID,**强烈推荐使用纯英文**。以`.`开头的仓库配置不会被加载。部分符号可能会影响正常读取,请避免使用。
|
||||
|
||||
随本项目预设了几个常用的仓库类型,可以 [在这里](.examples/depositories) 找到您需要的仓库配置加以修改后使用。
|
||||
随本项目预设了几个常用的仓库类型,可以 [在这里](.examples/depositories) 直接下载您需要的仓库配置加以修改后使用。
|
||||
|
||||
您也可以 [点击这里](src/main/resources/depositories/.example-depository.yml) 查看一份*详细的仓库配置示例*,以制作您自己的仓库。
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<groupId>cc.carm.plugin</groupId>
|
||||
<artifactId>ultradepository</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.2.5</version>
|
||||
<version>1.3.2</version>
|
||||
|
||||
<name>UltraDepository</name>
|
||||
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
||||
@@ -244,6 +244,8 @@
|
||||
</executions>
|
||||
|
||||
<configuration>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
<outputDirectory>${project.basedir}/asset/</outputDirectory>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
|
||||
@@ -95,4 +95,8 @@ public class PluginMessages extends MessagesRoot {
|
||||
"&f数目输入错误,请输入正确的数字!"
|
||||
);
|
||||
|
||||
public static final EasyMessage LOAD_FAILED = new EasyMessage(
|
||||
"&c您的背包数据未被正确加载,请重新进入!"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cc.carm.plugin.ultradepository.listener;
|
||||
|
||||
import cc.carm.plugin.ultradepository.UltraDepository;
|
||||
import cc.carm.plugin.ultradepository.configuration.PluginMessages;
|
||||
import cc.carm.plugin.ultradepository.data.UserData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -20,8 +21,8 @@ public class UserListener implements Listener {
|
||||
return;
|
||||
}
|
||||
UUID uuid = event.getUniqueId();
|
||||
UltraDepository.getInstance().debug("尝试加载玩家 " + event.getName() + " 的数据...");
|
||||
UltraDepository.getUserManager().getDataCache().put(uuid, UltraDepository.getUserManager().loadData(uuid));
|
||||
UltraDepository.getUserManager().getDataCache()
|
||||
.put(uuid, UltraDepository.getUserManager().loadData(uuid));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@@ -36,7 +37,7 @@ public class UserListener implements Listener {
|
||||
UserData data = UltraDepository.getUserManager().getData(e.getPlayer().getUniqueId());
|
||||
if (data == null) {
|
||||
e.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
e.setKickMessage(UltraDepository.getInstance().getName() + " 数据未被正确加载,请重新进入。");
|
||||
e.setKickMessage(PluginMessages.LOAD_FAILED.get(e.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +45,8 @@ public class UserListener implements Listener {
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
UUID playerUUID = player.getUniqueId();
|
||||
UltraDepository.getInstance().getScheduler().runAsync(() -> UltraDepository.getUserManager().unloadData(playerUUID, true));
|
||||
UltraDepository.getInstance().getScheduler()
|
||||
.runAsync(() -> UltraDepository.getUserManager().unloadData(playerUUID, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import cc.carm.plugin.ultradepository.configuration.PluginMessages;
|
||||
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
|
||||
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
|
||||
import cc.carm.plugin.ultradepository.event.DepositoryCollectItemEvent;
|
||||
import cc.carm.plugin.ultradepository.util.JarUtil;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -18,6 +19,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -45,10 +47,14 @@ public class DepositoryManager {
|
||||
File folder = new File(UltraDepository.getInstance().getDataFolder(), "depositories");
|
||||
if (!folder.exists()) {
|
||||
folder.mkdir();
|
||||
|
||||
UltraDepository.getInstance().saveResource(
|
||||
"depositories/.example-depository.yml", false
|
||||
);
|
||||
|
||||
try {
|
||||
JarUtil.copyFolderFromJar(
|
||||
"depositories", UltraDepository.getInstance().getDataFolder(),
|
||||
JarUtil.CopyOption.COPY_IF_NOT_EXIST
|
||||
);
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
|
||||
} else if (folder.isDirectory()) {
|
||||
folder.delete();
|
||||
|
||||
@@ -32,7 +32,7 @@ public class UserManager {
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
DataStorage storage = UltraDepository.getStorage();
|
||||
UltraDepository.getInstance().debug("正通过 " + storage.getClass().getSimpleName() + " 加载 " + userUUID + " 的用户数据...");
|
||||
UltraDepository.getInstance().debug("正通过 " + storage.getClass().getSimpleName() + " 加载 " + userUUID + " 的用户数据...(" + System.currentTimeMillis() + ")");
|
||||
UserData data = UltraDepository.getStorage().loadData(userUUID);
|
||||
|
||||
if (data == null) {
|
||||
@@ -64,7 +64,7 @@ public class UserManager {
|
||||
long start = System.currentTimeMillis();
|
||||
DataStorage storage = UltraDepository.getStorage();
|
||||
|
||||
UltraDepository.getInstance().debug("正通过 " + storage.getClass().getSimpleName() + " 保存 " + data.getUserUUID() + " 的用户数据...");
|
||||
UltraDepository.getInstance().debug("正通过 " + storage.getClass().getSimpleName() + " 保存 " + data.getUserUUID() + " 的用户数据...(" + System.currentTimeMillis() + ")");
|
||||
storage.saveUserData(data);
|
||||
|
||||
UltraDepository.getInstance().debug("通过 " + storage.getClass().getSimpleName() + " 保存 " + data.getUserUUID() + " 的用户数据完成," +
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cc.carm.plugin.ultradepository.storage;
|
||||
|
||||
import cc.carm.plugin.ultradepository.data.UserData;
|
||||
import cc.carm.plugin.ultradepository.manager.UserManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -8,14 +9,38 @@ import java.util.UUID;
|
||||
|
||||
public interface DataStorage {
|
||||
|
||||
|
||||
/**
|
||||
* 在插件加载存储源时执行。
|
||||
*
|
||||
* @return 是否初始化成功
|
||||
*/
|
||||
boolean initialize();
|
||||
|
||||
/**
|
||||
* 在插件被卸载时执行。
|
||||
*/
|
||||
void shutdown();
|
||||
|
||||
/**
|
||||
* 用于加载用户数据的方法。<b>该方法将会被异步运行!</b>
|
||||
* <br>该方法一般无需自行执行,见 {@link UserManager#loadData(UUID)}
|
||||
* <br>
|
||||
* <br>若不存在该用户的数据,请返回 null 。
|
||||
* <br>若加载出现任何错误,请抛出异常。
|
||||
*
|
||||
* @param uuid 用户UUID
|
||||
* @throws Exception 当出现任何错误时抛出
|
||||
*/
|
||||
@Nullable
|
||||
UserData loadData(@NotNull UUID uuid) throws Exception;
|
||||
|
||||
/**
|
||||
* 用于保存用户数据的方法。 <b>该方法将会被异步运行!</b>
|
||||
* <br>该方法一般无需自行执行,见 {@link UserManager#saveData(UserData)}
|
||||
*
|
||||
* @param data 用户数据
|
||||
* @throws Exception 当出现任何错误时抛出
|
||||
*/
|
||||
void saveUserData(@NotNull UserData data) throws Exception;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user