1
mirror of https://github.com/CarmJos/UltraDepository.git synced 2026-06-04 16:48:21 +08:00

Compare commits

...

15 Commits

Author SHA1 Message Date
carm e95ca412f8 [v1.1.3] 版本更新
- [U] 当物品不足时发送提示
- [A] 使用bStats进行数据统计
2021-12-31 02:23:50 +08:00
carm 539d0d08dc [v1.1.2] 采用Map的形式序列化用户数据。 2021-12-30 20:39:12 +08:00
carm 92b9c45911 [v1.1.2] 采用Map的形式序列化用户数据。 2021-12-30 20:38:58 +08:00
carm bfbf55c9fc 修改示例配置位置 2021-12-30 07:20:37 +08:00
carm 564ca28f4a 默认采用file方式存储数据。 2021-12-30 07:13:34 +08:00
carm 4b533e44b3 折叠效果预览,默认采用file方式存储数据。 2021-12-30 07:12:35 +08:00
carm 5c9ef858c8 修改玩家数据文件示例 2021-12-30 07:00:13 +08:00
carm d046aa931e 完善以文件方式存储玩家数据的功能 2021-12-30 06:59:14 +08:00
carm 2ab03912df 修改示例配置文件的位置 2021-12-30 05:12:49 +08:00
carm aed1c3cf20 添加详细示例仓库配置文件 2021-12-30 05:10:44 +08:00
carm 1650f2f4a5 添加详细示例仓库配置文件 2021-12-30 05:10:03 +08:00
carm aefd0aac46 添加示例仓库配置文件 2021-12-30 04:54:57 +08:00
carm 090aa36e34 修复一些情况下日期不更新的问题。 2021-12-30 04:10:59 +08:00
carm a0c369b370 修改权限默认值 2021-12-30 04:06:19 +08:00
carm 36540b1000 规定API版本 2021-12-30 03:53:59 +08:00
30 changed files with 843 additions and 110 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
# UltraBackpack Javadoc # UltraDepository Javadoc
基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/UltraBackpack) 。 基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/UltraDepository) 。
## 如何实现? ## 如何实现?
+11 -12
View File
@@ -1,17 +1,16 @@
```text ```text
_ _ _ _ ____ _ _ _ _ _ _ _____ _ _
| | | | | | | _ \ | | | | | | | | | | | __ \ (_) |
| | | | | |_ _ __ __ _| |_) | __ _ ___| | ___ __ __ _ ___| | __ | | | | | |_ _ __ __ _| | | | ___ _ __ ___ ___ _| |_ ___ _ __ _ _
| | | | | __| '__/ _` | _ < / _` |/ __| |/ / '_ \ / _` |/ __| |/ / | | | | | __| '__/ _` | | | |/ _ \ '_ \ / _ \/ __| | __/ _ \| '__| | | |
| |__| | | |_| | | (_| | |_) | (_| | (__| <| |_) | (_| | (__| < | |__| | | |_| | | (_| | |__| | __/ |_) | (_) \__ \ | || (_) | | | |_| |
\____/|_|\__|_| \__,_|____/ \__,_|\___|_|\_\ .__/ \__,_|\___|_|\_\ \____/|_|\__|_| \__,_|_____/ \___| .__/ \___/|___/_|\__\___/|_| \__, |
| | | | __/ |
|_| |_| |___/
``` ```
# UltraBackpack 帮助介绍文档
# UltraDepository 帮助介绍文档
## [开发文档](JAVADOC-README.md) ## [开发文档](JAVADOC-README.md)
基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/UltraBackpack) 。 基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/UltraDepository) 。
## 文档目录
+34
View File
@@ -0,0 +1,34 @@
# UltraDepository 预设仓库配置
## 详细示例
您可以 [点击这里](full-example.yml) 查看一份详细的示例。
## 使用须知
预设配置基于 MineCraft 1.16 实现,更低版本可能无法使用。
## 如何使用?
1. 下载并安装 UltraDepository 插件。
2. 启动服务器,配置 `config.yml` 中的一些基础设置。
3. 下载你想要的示例仓库配置文件,并放入 `插件配置目录/depositories` 下。
4. 重启服务器,即可令对应的配置文件生效!
## 预设配置截图
### 渔夫仓库 ([fishman.yml](files/fishman.yml))
![fishman](images/fishman.png)
### 矿工仓库 ([miner.yml](files/miner.yml))
![miner](images/miner.png)
### 农夫仓库 ([farmer.yml](files/farmer.yml))
![farmer](images/farmer.png)
### 猎人仓库 ([hunter.yml](files/hunter.yml))
![hunter](images/hunter.png)
+129
View File
@@ -0,0 +1,129 @@
name: "&a&l农夫仓库"
capacity:
default: 500 # 若为0则默认不可以使用该仓库
permissions:
- "ud.farmer.vip:1000"
gui:
title: "&a&l农夫仓库"
lines: 6
items:
"INFO":
material: CHEST
data: 0
slot: 49
name: "&2&l背包信息"
lore:
- " "
- "&f仓库最大容量&a %UltraDepository_capacity_farmer%"
- "&f仓库已用容量&a %UltraDepository_used_farmer%"
- "&f仓库剩余容量&a %UltraDepository_usable_farmer%"
- " "
items:
"WHEAT_SEEDS":
slot: 10
price: 0.1
limit: 500
name: "&a&l小麦种子"
"MELON_SEEDS":
slot: 11
price: 0.1
limit: 500
name: "&8&l西瓜种子"
"PUMPKIN_SEEDS":
slot: 12
price: 0.1
limit: 500
name: "&f&l南瓜种子"
"BEETROOT_SEEDS":
slot: 13
price: 0.1
limit: 500
name: "&7&l甜菜种子"
"NETHER_WART":
slot: 14
price: 0.1
limit: 500
name: "&c&l地狱疣"
"COCOA_BEANS":
slot: 15
price: 0.1
limit: 500
name: "&6&l可可豆"
"SWEET_BERRIES":
slot: 16
price: 0.1
limit: 500
name: "&c&l树莓"
"BEETROOT":
slot: 19
price: 0.1
limit: 500
name: "&c&l甜菜根"
"CARROT":
slot: 20
price: 0.1
limit: 500
name: "&6&l胡萝卜"
"POTATO":
slot: 21
price: 0.1
limit: 500
name: "&e&l土豆"
"WHEAT":
slot: 22
price: 0.1
limit: 500
name: "&e&l小麦"
"MELON_SLICE":
slot: 23
price: 0.1
limit: 500
name: "&c&l西瓜片"
"PUMPKIN":
slot: 24
price: 0.1
limit: 500
name: "&6&l南瓜"
"CACTUS":
slot: 25
price: 0.1
limit: 500
name: "&2&l仙人掌"
"POISONOUS_POTATO":
slot: 28
price: 0.1
limit: 500
name: "&a&l毒土豆"
"KELP":
slot: 29
price: 0.1
limit: 500
name: "&2&l海带"
"SUGAR_CANE":
slot: 30
price: 0.1
limit: 500
name: "&a&l甘蔗"
"BAMBOO":
slot: 31
price: 0.1
limit: 500
name: "&a&l竹子"
"VINE":
slot: 32
price: 0.1
limit: 500
name: "&2&l藤蔓"
"CHORUS_FRUIT":
slot: 33
price: 0.1
limit: 500
name: "&d&l紫颂果"
"CHORUS_PLANT":
slot: 34
price: 0.1
limit: 500
name: "&5&l紫颂植株"
+64
View File
@@ -0,0 +1,64 @@
name: "&b&l渔夫仓库"
capacity:
default: 500 # 若为0则默认不可以使用该仓库
permissions:
- "ud.fishman.vip:1000"
gui:
title: "&b&l渔夫仓库"
lines: 4
items:
"INFO":
material: CHEST
data: 0
slot: 31
name: "&9&l背包信息"
lore:
- " "
- "&f仓库最大容量&b %UltraDepository_capacity_fishman%"
- "&f仓库已用容量&b %UltraDepository_used_fishman%"
- "&f仓库剩余容量&b %UltraDepository_usable_fishman%"
- " "
items:
"INK_SAC":
slot: 11
price: 0.1
limit: 500
name: "&8&l墨囊"
lore:
- " "
- "&f抓住墨鱼!"
"TROPICAL_FISH":
slot: 12
price: 0.1
limit: 500
name: "&(#EE7942)&l小丑鱼"
lore:
- " "
- "&f不是小丑!"
"SALMON":
slot: 13
price: 0.1
limit: 500
name: "&c&l鲑鱼"
lore:
- " "
- "&f肉质鲜美!"
"COD":
slot: 14
price: 0.1
limit: 500
name: "&f&l鳕鱼"
lore:
- " "
- "&f十分美味!"
"PUFFERFISH":
slot: 15
price: 0.1
limit: 500
name: "&6&L河豚"
lore:
- " "
- "&f小心有毒!"
+130
View File
@@ -0,0 +1,130 @@
name: "&5&l猎人仓库"
capacity:
default: 500 # 若为0则默认不可以使用该仓库
permissions:
- "ud.hunter.vip:1000"
gui:
title: "&5&l猎人仓库"
lines: 6
items:
"INFO":
material: CHEST
data: 0
slot: 49
name: "&5&l背包信息"
lore:
- " "
- "&f仓库最大容量&d %UltraDepository_capacity_hunter%"
- "&f仓库已用容量&d %UltraDepository_used_hunter%"
- "&f仓库剩余容量&d %UltraDepository_usable_hunter%"
- " "
items:
"CHICKEN":
slot: 10
price: 0.1
limit: 500
name: "&6&l鸡肉"
"PORKCHOP":
slot: 11
price: 0.1
limit: 500
name: "&c&l猪肉"
"BEEF":
slot: 12
price: 0.1
limit: 500
name: "&c&l牛肉"
"MUTTON":
slot: 13
price: 0.1
limit: 500
name: "&6&l羊肉"
"RABBIT":
slot: 14
price: 0.1
limit: 500
name: "&f&l兔肉"
"RABBIT_HIDE":
slot: 15
price: 0.1
limit: 500
name: "&f&l兔子皮"
"LEATHER":
slot: 16
price: 0.1
limit: 500
name: "&c&l皮革"
"EGG":
slot: 19
price: 0.1
limit: 500
name: "&f&l鸡蛋"
"RABBIT_FOOT":
slot: 20
price: 0.1
limit: 500
name: "&f&l兔子脚"
"FEATHER":
slot: 21
price: 0.1
limit: 500
name: "&f&l羽毛"
"GOLD_NUGGET":
slot: 22
price: 0.1
limit: 500
name: "&e&l金粒"
"GHAST_TEAR":
slot: 23
price: 0.1
limit: 500
name: "&7&l恶魂之泪"
"BLAZE_ROD":
slot: 24
price: 0.1
limit: 500
name: "&e&l烈焰棒"
"MAGMA_CREAM":
slot: 25
price: 0.1
limit: 500
name: "&c&l岩浆球"
"SLIME_BALL":
slot: 28
price: 0.1
limit: 500
name: "&a&l粘液球"
"BONE":
slot: 29
price: 0.1
limit: 500
name: "&f&l骨头"
"SPIDER_EYE":
slot: 30
price: 0.1
limit: 500
name: "&4&l蜘蛛眼"
"GUNPOWDER":
slot: 31
price: 0.1
limit: 500
name: "&7&l火药"
"ROTTEN_FLESH":
slot: 32
price: 0.1
limit: 500
name: "&2&l腐肉"
"STRING":
slot: 33
price: 0.1
limit: 500
name: "&f&l线"
"ENDER_PEARL":
slot: 34
price: 0.1
limit: 500
name: "&5&l末影珍珠"
+136
View File
@@ -0,0 +1,136 @@
name: "&e&l矿工仓库"
capacity:
default: 5000 # 若为0则默认不可以使用该仓库
permissions:
- "ud.miner.vip:10000"
gui:
title: "&e&l矿工仓库"
lines: 6
items:
"INFO":
material: CHEST
data: 0
slot: 49
name: "&e&l背包信息"
lore:
- " "
- "&f仓库最大容量&6 %UltraDepository_capacity_miner%"
- "&f仓库已用容量&6 %UltraDepository_used_miner%"
- "&f仓库剩余容量&6 %UltraDepository_usable_miner%"
- " "
items:
"COBBLESTONE":
slot: 11
price: 0.1
limit: 500
name: "&f&l圆石"
lore:
- " "
- "&f方块!"
"IRON_ORE":
slot: 12
price: 0.1
limit: 500
name: "&f&l铁矿"
lore:
- " "
- "&f升级!"
"GOLD_ORE":
slot: 13
price: 0.1
limit: 500
name: "&e&l金矿"
lore:
- " "
- "&f财富!"
"COAL":
slot: 14
price: 0.1
limit: 500
name: "&8&l煤炭"
lore:
- " "
- "&f燃料!"
"FLINT":
slot: 15
price: 0.1
limit: 500
name: "&7&l燧石"
lore:
- " "
- "&f点火!"
"IRON_INGOT":
slot: 20
price: 0.1
limit: 500
name: "&f&l铁锭"
lore:
- " "
- "&f制造!"
"GOLD_INGOT":
slot: 21
price: 0.1
limit: 500
name: "&e&l金锭"
lore:
- " "
- "&f高贵!"
"LAPIS_LAZULI":
slot: 22
price: 0.1
limit: 500
name: "&9&l青金石"
lore:
- " "
- "&f附魔!"
"DIAMOND":
slot: 23
price: 10
limit: 1500
name: "&b&l钻石"
lore:
- " "
- "&f钻石!"
"EMERALD":
slot: 24
price: 10
limit: 1500
name: "&a&l绿宝石"
lore:
- " "
- "&f交易!"
"CLAY_BALL":
slot: 30
price: 0.1
limit: 500
name: "&7&l黏土"
lore:
- " "
- "&f塑形!"
"REDSTONE":
slot: 29
price: 0.1
limit: 500
name: "&c&l红石"
lore:
- " "
- "&f电路!"
"GLOWSTONE_DUST":
slot: 32
price: 0.5
limit: 1500
name: "&6&l萤石"
lore:
- " "
- "&f发光!"
"QUARTZ":
slot: 33
price: 0.5
limit: 1500
name: "&f&l石英"
lore:
- " "
- "&f美丽!"
+48
View File
@@ -0,0 +1,48 @@
name: "&b&l示例仓库" # 仓库名,用于消息显示
capacity: # 容量配置
default: 500 # 若为0则默认不可以使用该仓库
permissions: # 特殊权限对应的仓库容量,格式为 "权限:容量
- "UltraDepository.vip:1000"
- "UltraDepository.mvp:1500"
gui: # GUI额外配置
title: "&b&l示例仓库 &7| 界面" #示例仓库的GUI标题
lines: 4 # GUI的行数,支持 1-6行。
items:
"TEST":
material: CHEST # 物品图标的类型
data: 0 # 物品图标的数据值
slot: 31 # 在GUI中显示的格子
name: "&9&l测试图标"
lore:
# 支持使用变量
- "你好 %player_name% !"
actions: # 物品点击操作
- "[CHAT] Hello!" #以玩家身份发送Hello,支持PlaceholderAPI变量
- "[CHAT] /help" #若内容以"/"开头,则会以玩家身份执行指令,支持PlaceholderAPI变量
- "[CONSOLE] say HELLO WORLD" #以后台身份执行指令,不需要加"/",支持PlaceholderAPI变量
- "[MESSAGE] &(#FFBBBBB)Test %player_name%" # 向玩家发送消息,支持PlaceholderAPI变量和RGB颜色
- "[SOUND] ENTITY_EXPERIENCE_ORB_PICKUP:0.5" # 向玩家发送声音,可以规定音量大小和音调,格式为 <声音>:[音量]:[音调]
- "[CLOSE]" # 为玩家关闭界面
- "[LEFT:CLOSE]" #限制只有 鼠标左键 才触发CLOSE
- "[SHIFT_LEFT:CLOSE]" #限制只有 按住Shift+鼠标左键 才触发CLOSE
- "[RIGHT:CLOSE]" #限制只有 鼠标右键 才触发CLOSE
- "[SHIFT_RIGHT:CLOSE]" #限制只有 按住Shift+鼠标右键 才触发CLOSE
- "[MIDDLE:CLOSE]" #限制只有 鼠标中键 才触发CLOSE
- "[DROP:CLOSE]" #限制只有 丢弃建 才触发CLOSE
- "[CONTROL_DROP:CLOSE]" #限制只有 按住Ctrl+丢弃键 才触发CLOSE
- "[DOUBLE_CLICK:CLOSE]" #限制只有 鼠标双击物品 才触发CLOSE
- "[NUMBER_KEY:CLOSE]" #限制只有 数字键切换 才触发CLOSE
items:
"INK_SAC": #物品ID,若需要限制数据ID则可以加“:”,如 "INK_SANK:4"
slot: 11 # 物品在GUI中显示的槽位
price: 0.1 # 物品单价
limit: 500 # 物品每日售出限制
name: "&8&l墨囊" # 物品显示的名字
lore: # 物品的lore
- " "
- "&f抓住墨鱼!"
Binary file not shown.

After

Width:  |  Height:  |  Size: 621 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 810 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 KiB

-28
View File
@@ -1,28 +0,0 @@
name: "&c&l矿业仓库"
capacity:
default: 0 # 若为0则默认不可以使用该仓库
permissions:
- "ub.miner.vip:5000"
gui:
title: "&c&l矿业仓库"
lines: 6
items:
"CLOSE":
material: RED_STONE
data: 0
slot: 0
name: "关闭界面"
lore:
- "点击后您将关闭本界面。"
actions:
- "[LEFT:CLOSE]"
- "[SHIFT_LEFT:CLOSE]"
items:
"DIAMOND":
slot: 5
price: 10
limit: 100
name: "&b&l钻石"
+41
View File
@@ -0,0 +1,41 @@
{
"farmer": {},
"hunter": {
"CHICKEN:0": {
"amount": 3
},
"FEATHER:0": {
"amount": 2
}
},
"miner": {
"COAL:0": {
"amount": 9,
"sold": 10
},
"LAPIS_LAZULI:0": {
"amount": 9
},
"REDSTONE:0": {
"sold": 129
},
"COBBLESTONE:0": {
"amount": 12
},
"CLAY_BALL:0": {
"amount": 112
},
"DIAMOND:0": {
"amount": 975,
"sold": 1500
}
},
"fishman": {
"COD:0": {
"amount": 3
},
"PUFFERFISH:0": {
"amount": 64
}
}
}
+12
View File
@@ -0,0 +1,12 @@
date: 20211230 # 用于判断售出数据的所在日期
depositories:
hunter:
RABBIT_HIDE:0:
amount: 1
miner:
GOLD_INGOT:0:
amount: 52
DIAMOND:0:
sold: 30
amount: 351
+20 -19
View File
@@ -26,24 +26,33 @@
## 效果预览 ## 效果预览
### 收集物品 <details>
<summary>收集物品</summary>
![collect](.documentation/images/collect-message.jpg) ![collect](.documentation/images/collect-message.jpg)
### 仓库界面 (可自定义配置) </details>
<details>
<summary>仓库界面 (可自定义配置)</summary>
![item-gui](.documentation/images/item-in-gui.png) ![item-gui](.documentation/images/item-in-gui.png)
### 出售界面 </details>
<details>
<summary>出售界面</summary>
![sell-gui](.documentation/images/sell-gui.png) ![sell-gui](.documentation/images/sell-gui.png)
![sell-message](.documentation/images/sell-message.png) ![sell-message](.documentation/images/sell-message.png)
</details>
## 插件依赖 ## 插件依赖
- **[必须]** 插件本体基于 [Spigot-API](https://hub.spigotmc.org/stash/projects/SPIGOT)、[BukkitAPI](http://bukkit.org/) 实现。 - **[必须]** 插件本体基于 [Spigot-API](https://hub.spigotmc.org/stash/projects/SPIGOT)、[BukkitAPI](http://bukkit.org/) 实现。
- **[自带]** 数据部分基于 [EasySQL](https://github.com/CarmJos/EasySQL) 实现。 - **[自带]** 数据部分基于 [EasySQL](https://github.com/CarmJos/EasySQL) 实现。
- 本插件连接池使用 [BeeCP](https://github.com/Chris2018998/BeeCP) ,更轻量、快速。 - 本插件连接池使用 [BeeCP](https://github.com/Chris2018998/BeeCP) ,更轻量、快速。
- **[推荐]** 变量部分基于 [PlaceholderAPI](https://www.spigotmc.org/resources/6245/) 实现。 - **[推荐]** 变量部分基于 [PlaceholderAPI](https://www.spigotmc.org/resources/6245/) 实现。
- **[推荐]** 经济部分基于 [VaultAPI](https://github.com/MilkBowl/VaultAPI) 实现。 - **[推荐]** 经济部分基于 [VaultAPI](https://github.com/MilkBowl/VaultAPI) 实现。
@@ -65,7 +74,6 @@
<details> <details>
<summary>展开查看所有玩家指令</summary> <summary>展开查看所有玩家指令</summary>
```text ```text
# open [仓库ID] # open [仓库ID]
@ 玩家指令 (UltraDepository.use) @ 玩家指令 (UltraDepository.use)
@@ -107,6 +115,7 @@
- 若不填写仓库,则售出所有仓库内所有物品。 - 若不填写仓库,则售出所有仓库内所有物品。
- 该指令受到玩家每日售出数量的限制。 - 该指令受到玩家每日售出数量的限制。
``` ```
</details> </details>
## 插件变量 ([PlaceholderAPI](https://www.spigotmc.org/resources/6245/)) ## 插件变量 ([PlaceholderAPI](https://www.spigotmc.org/resources/6245/))
@@ -178,31 +187,23 @@
## 配置文件 ## 配置文件
### [插件配置文件](src/main/resources/config.yml) (config.yml) ### 插件配置文件 ([config.yml](src/main/resources/config.yml))
详见源文件。 详见源文件。
### [消息配置文件](src/main/resources/messages.yml) (messages.yml) ### 消息配置文件 ([messages.yml](src/main/resources/messages.yml))
详见源文件。 详见源文件。
### 仓库配置文件 (depositories/<ID>.yml) ### 仓库配置文件 ([depositories/<仓库ID>.yml](.examples/depositories/full-example.yml))
所有仓库配置均为单独的配置文件,存放于 `插件配置目录/depositories` 下,便于管理。 所有仓库配置均为单独的配置文件,存放于 `插件配置目录/depositories` 下,便于管理。
文件名即仓库的ID理论上可以随便取,但**强烈推荐**使用纯英文,部分符号可能会影响正常读取,请避免使用。 文件名即仓库的ID,**强烈推荐使用纯英文**,部分符号可能会影响正常读取,请避免使用。
这里准备了几个常用的仓库类型,可以 [在这里](.examples/depositories) 找到您需要的直接使用或加以修改后使用。 随本项目预设了几个常用的仓库类型,可以 [在这里](.examples/depositories) 找到您需要的直接使用或加以修改后使用。
您也可以查看下方的示例,看到所有相关的配置,以制作您自己的仓库。 您也可以 [点击这里](.examples/depositories/full-example.yml) 查看一份*详细的仓库配置示例*,以制作您自己的仓库。
<details>
<summary>展开查看示例仓库配置</summary>
```yaml
```
</details>
## 支持与捐赠 ## 支持与捐赠
+22 -1
View File
@@ -14,7 +14,7 @@
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<artifactId>ultradepository</artifactId> <artifactId>ultradepository</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.0.0</version> <version>1.1.3</version>
<name>UltraDepository</name> <name>UltraDepository</name>
<description>超级仓库插件,支持设定不同物品的存储仓库。</description> <description>超级仓库插件,支持设定不同物品的存储仓库。</description>
@@ -91,6 +91,13 @@
<dependencies> <dependencies>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>cc.carm.lib</groupId> <groupId>cc.carm.lib</groupId>
<artifactId>easysql-beecp</artifactId> <artifactId>easysql-beecp</artifactId>
@@ -207,6 +214,20 @@
</execution> </execution>
</executions> </executions>
<configuration> <configuration>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>cc.carm.plugin.ultradepository.lib.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>cc.carm.lib.easysql</pattern>
<shadedPattern>cc.carm.plugin.ultradepository.lib.easysql</shadedPattern>
</relocation>
<relocation>
<pattern>cn.beecp</pattern>
<shadedPattern>cc.carm.plugin.ultradepository.lib.beecp</shadedPattern>
</relocation>
</relocations>
<filters> <filters>
<filter> <filter>
<artifact>*:*</artifact> <artifact>*:*</artifact>
@@ -15,6 +15,8 @@ import cc.carm.plugin.ultradepository.storage.MySQLStorage;
import cc.carm.plugin.ultradepository.util.ColorParser; import cc.carm.plugin.ultradepository.util.ColorParser;
import cc.carm.plugin.ultradepository.util.MessageUtil; import cc.carm.plugin.ultradepository.util.MessageUtil;
import cc.carm.plugin.ultradepository.util.SchedulerUtils; import cc.carm.plugin.ultradepository.util.SchedulerUtils;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand; import org.bukkit.command.PluginCommand;
@@ -27,6 +29,7 @@ import org.jetbrains.annotations.Nullable;
public class Main extends JavaPlugin { public class Main extends JavaPlugin {
private static Main instance; private static Main instance;
private static Metrics metrics;
private static SchedulerUtils scheduler; private static SchedulerUtils scheduler;
private static DataStorage storage; private static DataStorage storage;
@@ -94,6 +97,15 @@ public class Main extends JavaPlugin {
log("检测到未安装PlaceholderAPI,跳过变量注册。"); log("检测到未安装PlaceholderAPI,跳过变量注册。");
} }
if (PluginConfig.METRICS.get()) {
log("启用统计数据...");
metrics = new Metrics(this, 13776);
metrics.addCustomChart(new SingleLineChart(
"active_depositories",
() -> getDepositoryManager().getDepositories().size())
);
}
initialized = true; initialized = true;
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。"); log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
@@ -11,9 +11,14 @@ import org.bukkit.Material;
public class PluginConfig { public class PluginConfig {
public static final ConfigValue<Boolean> DEBUG = new ConfigValue<>( public static final ConfigValue<Boolean> DEBUG = new ConfigValue<>(
"debug", Boolean.class "debug", Boolean.class, false
); );
public static final ConfigValue<Boolean> METRICS = new ConfigValue<>(
"metrics", Boolean.class, true
);
public static final ConfigValue<String> STORAGE_METHOD = new ConfigValue<>( public static final ConfigValue<String> STORAGE_METHOD = new ConfigValue<>(
"storage.method", String.class "storage.method", String.class
); );
@@ -4,11 +4,13 @@ import cc.carm.plugin.ultradepository.Main;
import cc.carm.plugin.ultradepository.configuration.depository.Depository; import cc.carm.plugin.ultradepository.configuration.depository.Depository;
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem; import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
import cc.carm.plugin.ultradepository.storage.DataStorage; import cc.carm.plugin.ultradepository.storage.DataStorage;
import cc.carm.plugin.ultradepository.util.DateUtil; import cc.carm.plugin.ultradepository.util.DateIntUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.sql.Date; import java.sql.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@@ -60,6 +62,7 @@ public class UserData {
} }
public @NotNull DepositoryItemData getItemData(@NotNull DepositoryItem itemType) { public @NotNull DepositoryItemData getItemData(@NotNull DepositoryItem itemType) {
checkoutDate();
return getDepositoryData(itemType.getDepository()).getItemData(itemType); return getDepositoryData(itemType.getDepository()).getItemData(itemType);
} }
@@ -70,7 +73,6 @@ public class UserData {
} }
public @Nullable Integer getItemSold(@NotNull String depositoryID, @NotNull String typeID) { public @Nullable Integer getItemSold(@NotNull String depositoryID, @NotNull String typeID) {
checkoutDate();
DepositoryItemData data = getItemData(depositoryID, typeID); DepositoryItemData data = getItemData(depositoryID, typeID);
if (data == null) return null; if (data == null) return null;
return data.getSold(); return data.getSold();
@@ -118,12 +120,16 @@ public class UserData {
public Date getDate() { public Date getDate() {
return new Date(DateUtil.getDateMillis(this.date)); return new Date(DateIntUtil.getDateMillis(getDateInt()));
}
public int getDateInt() {
return this.date;
} }
public boolean isCurrentDay() { public boolean isCurrentDay() {
return this.date == DateUtil.getCurrentDate(); return this.date == DateIntUtil.getCurrentDate();
} }
@@ -132,7 +138,7 @@ public class UserData {
Main.debug("Date is not change, skip clear sold amount."); Main.debug("Date is not change, skip clear sold amount.");
return; return;
} }
this.date = DateUtil.getCurrentDate(); //更新日期 this.date = DateIntUtil.getCurrentDate(); //更新日期
Main.debug("Date changed, clear sold."); Main.debug("Date changed, clear sold.");
getDepositories().values().stream() getDepositories().values().stream()
.flatMap(value -> value.getContents().values().stream()) .flatMap(value -> value.getContents().values().stream())
@@ -144,4 +150,21 @@ public class UserData {
this.storage.saveUserData(this); this.storage.saveUserData(this);
} }
public Map<String, Map<String, Map<String, Integer>>> serializeToMap() {
Map<String, Map<String, Map<String, Integer>>> values = new LinkedHashMap<>();
getDepositories().forEach((depositoryID, depositoryData) -> {
Map<String, Map<String, Integer>> depositoryDataMap = new LinkedHashMap<>();
depositoryData.getContents().forEach((itemType, itemData) -> {
Map<String, Integer> itemDataMap = new HashMap<>();
if (itemData.getAmount() > 0) itemDataMap.put("amount", itemData.getAmount());
if (itemData.getSold() > 0) itemDataMap.put("sold", itemData.getSold());
if (!itemDataMap.isEmpty()) depositoryDataMap.put(itemType, itemDataMap);
});
if (!depositoryDataMap.isEmpty()) values.put(depositoryID, depositoryDataMap);
});
return values;
}
} }
@@ -3,6 +3,7 @@ package cc.carm.plugin.ultradepository.listener;
import cc.carm.plugin.ultradepository.Main; import cc.carm.plugin.ultradepository.Main;
import cc.carm.plugin.ultradepository.configuration.PluginConfig; import cc.carm.plugin.ultradepository.configuration.PluginConfig;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@@ -65,7 +66,6 @@ public class CollectListener implements Listener {
UUID thrower = event.getItem().getThrower(); UUID thrower = event.getItem().getThrower();
if (thrower != null && thrower.equals(player.getUniqueId())) return; if (thrower != null && thrower.equals(player.getUniqueId())) return;
ItemStack item = event.getItem().getItemStack(); ItemStack item = event.getItem().getItemStack();
Main.debug("Picked up " + item.getType().name() + " " + item.getAmount()); Main.debug("Picked up " + item.getType().name() + " " + item.getAmount());
if (Main.getDepositoryManager().collectItem(player, item)) { if (Main.getDepositoryManager().collectItem(player, item)) {
@@ -7,6 +7,7 @@ import cc.carm.plugin.ultradepository.configuration.depository.Depository;
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem; import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
import cc.carm.plugin.ultradepository.data.UserData; import cc.carm.plugin.ultradepository.data.UserData;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@@ -2,7 +2,7 @@ package cc.carm.plugin.ultradepository.manager;
import cc.carm.plugin.ultradepository.Main; import cc.carm.plugin.ultradepository.Main;
import cc.carm.plugin.ultradepository.data.UserData; import cc.carm.plugin.ultradepository.data.UserData;
import cc.carm.plugin.ultradepository.util.DateUtil; import cc.carm.plugin.ultradepository.util.DateIntUtil;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -33,7 +33,7 @@ public class UserManager {
} catch (Exception e) { } catch (Exception e) {
Main.error("无法正常加载玩家数据,玩家操作将不会被保存,请检查数据配置!"); Main.error("无法正常加载玩家数据,玩家操作将不会被保存,请检查数据配置!");
Main.error("Could not load user's data, please check the data configuration!"); Main.error("Could not load user's data, please check the data configuration!");
return new UserData(userUUID, Main.getStorage(), new HashMap<>(), DateUtil.getCurrentDate()); return new UserData(userUUID, Main.getStorage(), new HashMap<>(), DateIntUtil.getCurrentDate());
} }
} }
@@ -1,13 +1,19 @@
package cc.carm.plugin.ultradepository.storage; package cc.carm.plugin.ultradepository.storage;
import cc.carm.plugin.ultradepository.Main; import cc.carm.plugin.ultradepository.Main;
import cc.carm.plugin.ultradepository.configuration.depository.Depository;
import cc.carm.plugin.ultradepository.configuration.depository.DepositoryItem;
import cc.carm.plugin.ultradepository.configuration.values.ConfigValue; import cc.carm.plugin.ultradepository.configuration.values.ConfigValue;
import cc.carm.plugin.ultradepository.data.DepositoryData;
import cc.carm.plugin.ultradepository.data.DepositoryItemData;
import cc.carm.plugin.ultradepository.data.UserData; import cc.carm.plugin.ultradepository.data.UserData;
import cc.carm.plugin.ultradepository.util.DateUtil; import cc.carm.plugin.ultradepository.util.DateIntUtil;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.sql.Date; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
@@ -21,7 +27,12 @@ public class FileStorage implements DataStorage {
@Override @Override
public boolean initialize() { public boolean initialize() {
return false; dataContainer = new File(Main.getInstance().getDataFolder(), FILE_PATH.get());
if (!dataContainer.exists()) {
return dataContainer.mkdir();
} else {
return dataContainer.isDirectory();
}
} }
@Override @Override
@@ -29,18 +40,77 @@ public class FileStorage implements DataStorage {
// 似乎没什么需要做的? // 似乎没什么需要做的?
} }
public File getDataContainer() {
return dataContainer;
}
@Override @Override
public @NotNull UserData loadData(@NotNull UUID uuid) { public @NotNull UserData loadData(@NotNull UUID uuid) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Main.debug("正通过 FileStorage 加载 " + uuid + " 的用户数据..."); Main.debug("正通过 FileStorage 加载 " + uuid + " 的用户数据...");
return new UserData(uuid, this, new HashMap<>(), DateUtil.getCurrentDate()); File userDataFile = new File(getDataContainer(), uuid + ".yml");
if (!userDataFile.exists()) {
Main.debug("当前文件夾内不存在玩家 " + uuid + " 的数据,视作新档。");
return new UserData(uuid, this, new HashMap<>(), DateIntUtil.getCurrentDate());
}
YamlConfiguration userDataConfig = YamlConfiguration.loadConfiguration(userDataFile);
int dateInt = userDataConfig.getInt("date", DateIntUtil.getCurrentDate());
UserData userData = new UserData(uuid, this, new HashMap<>(), dateInt);
ConfigurationSection depositoriesSection = userDataConfig.getConfigurationSection("depositories");
if (depositoriesSection != null) {
for (String depositoryID : depositoriesSection.getKeys(false)) {
Depository depository = Main.getDepositoryManager().getDepository(depositoryID);
if (depository == null) continue;
ConfigurationSection depositorySection = depositoriesSection.getConfigurationSection(depositoryID);
if (depositorySection == null) continue;
DepositoryData depositoryData = DepositoryData.emptyContents(depository, userData);
for (String itemTypeID : depositorySection.getKeys(false)) {
DepositoryItem item = depository.getItems().get(itemTypeID);
if (item == null) continue;
ConfigurationSection itemSection = depositorySection.getConfigurationSection(itemTypeID);
if (itemSection == null) continue;
depositoryData.getContents().put(item.getTypeID(), new DepositoryItemData(
item, depositoryData,
itemSection.getInt("amount", 0),
itemSection.getInt("sold", 0)
));
}
if (!depositoryData.getContents().isEmpty()) userData.setDepository(depositoryData);
}
}
Main.debug("通过 FileStorage 加载 " + uuid + " 的用户数据完成,"
+ "耗时 " + (System.currentTimeMillis() - start) + "ms。");
return userData;
} }
@Override @Override
public void saveUserData(@NotNull UserData data) { public void saveUserData(@NotNull UserData data) throws IOException {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Main.debug("正通过 FileStorage 保存 " + data.getUserUUID() + " 的用户数据..."); Main.debug("正通过 FileStorage 保存 " + data.getUserUUID() + " 的用户数据...");
YamlConfiguration userDataConfig = new YamlConfiguration();
userDataConfig.set("date", data.getDateInt());
try {
userDataConfig.createSection("depositories", data.serializeToMap());
userDataConfig.save(new File(getDataContainer(), data.getUserUUID() + ".yml"));
} catch (IOException ioException) {
Main.error("在保存玩家 #" + data.getUserUUID() + " 的数据时出现异常。");
Main.error("Error occurred when saving #" + data.getUserUUID() + " data.");
throw ioException;
}
Main.debug( Main.debug(
"通过 FileStorage 保存 " + data.getUserUUID() + " 的用户数据完成," + "通过 FileStorage 保存 " + data.getUserUUID() + " 的用户数据完成," +
"耗时 " + (System.currentTimeMillis() - start) + "ms。" "耗时 " + (System.currentTimeMillis() - start) + "ms。"
@@ -12,13 +12,12 @@ import cc.carm.plugin.ultradepository.configuration.values.ConfigValue;
import cc.carm.plugin.ultradepository.data.DepositoryData; import cc.carm.plugin.ultradepository.data.DepositoryData;
import cc.carm.plugin.ultradepository.data.DepositoryItemData; import cc.carm.plugin.ultradepository.data.DepositoryItemData;
import cc.carm.plugin.ultradepository.data.UserData; import cc.carm.plugin.ultradepository.data.UserData;
import cc.carm.plugin.ultradepository.util.DateUtil; import cc.carm.plugin.ultradepository.util.DateIntUtil;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.Date; import java.sql.Date;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -126,23 +125,27 @@ public class MySQLStorage implements DataStorage {
if (resultSet != null && resultSet.next()) { if (resultSet != null && resultSet.next()) {
String dataJSON = resultSet.getString("data"); String dataJSON = resultSet.getString("data");
Date date = resultSet.getDate("day"); Date date = resultSet.getDate("day");
UserData data = new UserData(uuid, this, new HashMap<>(), DateUtil.getDateInt(date)); UserData data = new UserData(uuid, this, new HashMap<>(), DateIntUtil.getDateInt(date));
JsonElement dataElement = PARSER.parse(dataJSON); JsonElement dataElement = PARSER.parse(dataJSON);
if (dataElement.isJsonObject()) { if (dataElement.isJsonObject()) {
for (Map.Entry<String, JsonElement> entry : dataElement.getAsJsonObject().entrySet()) { for (Map.Entry<String, JsonElement> entry : dataElement.getAsJsonObject().entrySet()) {
Depository depository = Main.getDepositoryManager().getDepository(entry.getKey()); Depository depository = Main.getDepositoryManager().getDepository(entry.getKey());
if (depository == null) continue; if (depository == null) continue;
DepositoryData contentsData = parseContentsData(depository, data, entry.getValue()); DepositoryData contentsData = parseContentsData(depository, data, entry.getValue());
if (contentsData != null) data.setDepository(contentsData); if (contentsData != null) data.setDepository(contentsData);
} }
} }
Main.debug("通过 MySQLStorage 加载 " + uuid + " 的用户数据完成," Main.debug("通过 MySQLStorage 加载 " + uuid + " 的用户数据完成,"
+ "耗时 " + (System.currentTimeMillis() - start) + "ms。"); + "耗时 " + (System.currentTimeMillis() - start) + "ms。");
return data; return data;
} }
Main.debug("当前库内不存在玩家 " + uuid + " 的数据,视作新档。"); Main.debug("当前库内不存在玩家 " + uuid + " 的数据,视作新档。");
return new UserData(uuid, this, new HashMap<>(), DateUtil.getCurrentDate()); return new UserData(uuid, this, new HashMap<>(), DateIntUtil.getCurrentDate());
} catch (Exception exception) { } catch (Exception exception) {
throw new Exception(exception); throw new Exception(exception);
} }
@@ -153,15 +156,13 @@ public class MySQLStorage implements DataStorage {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Main.debug("正通过 MySQLStorage 保存 " + data.getUserUUID() + " 的用户数据..."); Main.debug("正通过 MySQLStorage 保存 " + data.getUserUUID() + " 的用户数据...");
JsonObject dataObject = new JsonObject();
data.getDepositories().forEach((id, contents) -> dataObject.add(id, serializeContentsData(contents)));
try { try {
getSQLManager().createReplace(SQLTables.USER_DATA.getName()) getSQLManager().createReplace(SQLTables.USER_DATA.getName())
.setColumnNames("uuid", "data", "day") .setColumnNames("uuid", "data", "day")
.setParams(data.getUserUUID(), GSON.toJson(dataObject), data.getDate()) .setParams(data.getUserUUID(), GSON.toJson(data.serializeToMap()), data.getDate())
.execute(); .execute();
} catch (SQLException exception) { } catch (SQLException exception) {
Main.error("在保存玩家 #" + data.getUserUUID() + " 的数据时出现异常。"); Main.error("在保存玩家 #" + data.getUserUUID() + " 的数据时出现异常。");
Main.error("Error occurred when saving #" + data.getUserUUID() + " data."); Main.error("Error occurred when saving #" + data.getUserUUID() + " data.");
@@ -191,10 +192,13 @@ public class MySQLStorage implements DataStorage {
private DepositoryData parseContentsData(Depository source, UserData owner, JsonObject contentsObject) { private DepositoryData parseContentsData(Depository source, UserData owner, JsonObject contentsObject) {
DepositoryData data = DepositoryData.emptyContents(source, owner); DepositoryData data = DepositoryData.emptyContents(source, owner);
for (Map.Entry<String, JsonElement> entry : contentsObject.entrySet()) { for (Map.Entry<String, JsonElement> entry : contentsObject.entrySet()) {
DepositoryItem item = source.getItems().get(entry.getKey()); DepositoryItem item = source.getItems().get(entry.getKey());
if (item == null) continue; if (item == null) continue;
DepositoryItemData itemData = parseItemData(item, data, entry.getValue()); DepositoryItemData itemData = parseItemData(item, data, entry.getValue());
if (itemData != null) data.getContents().put(item.getTypeID(), itemData); if (itemData != null) data.getContents().put(item.getTypeID(), itemData);
} }
return data; return data;
} }
@@ -207,26 +211,8 @@ public class MySQLStorage implements DataStorage {
int amount = itemObject.has("amount") ? itemObject.get("amount").getAsInt() : 0; int amount = itemObject.has("amount") ? itemObject.get("amount").getAsInt() : 0;
int sold = itemObject.has("sold") ? itemObject.get("sold").getAsInt() : 0; int sold = itemObject.has("sold") ? itemObject.get("sold").getAsInt() : 0;
if (amount == 0 && sold == 0) return null; if (amount == 0 && sold == 0) return null;
else return new DepositoryItemData(source, owner, amount, sold);
}
@Nullable return new DepositoryItemData(source, owner, amount, sold);
private JsonObject serializeContentsData(@Nullable DepositoryData contentsData) {
if (contentsData == null) return null;
JsonObject contentsObject = new JsonObject();
contentsData.getContents().entrySet().stream()
// 只存取有数值的部分,减少数据量
.filter(entry -> entry.getValue().getSold() > 0 || entry.getValue().getAmount() > 0)
.forEach(entry -> contentsObject.add(entry.getKey(), serializeItemData(entry.getValue())));
return contentsObject;
}
@NotNull
private JsonObject serializeItemData(@NotNull DepositoryItemData itemData) {
JsonObject itemObject = new JsonObject();
if (itemData.getAmount() > 0) itemObject.addProperty("amount", itemData.getAmount());
if (itemData.getSold() > 0) itemObject.addProperty("sold", itemData.getSold());
return itemObject;
} }
} }
@@ -59,7 +59,11 @@ public class DepositoryGUI extends GUI {
return new GUIItem(factory.toItemStack()) { return new GUIItem(factory.toItemStack()) {
@Override @Override
public void onClick(ClickType type) { public void onClick(ClickType type) {
if (itemData.getAmount() < 1) return; if (itemData.getAmount() < 1) {
PluginMessages.NO_ENOUGH_ITEM.send(player);
return;
}
if (type == ClickType.LEFT) { if (type == ClickType.LEFT) {
player.closeInventory(); player.closeInventory();
if (itemData.getAmount() >= 1) { if (itemData.getAmount() >= 1) {
@@ -71,7 +75,6 @@ public class DepositoryGUI extends GUI {
} else { } else {
PluginMessages.NO_ENOUGH_ITEM.send(player); PluginMessages.NO_ENOUGH_ITEM.send(player);
} }
} else if (type == ClickType.RIGHT) { } else if (type == ClickType.RIGHT) {
player.closeInventory(); player.closeInventory();
if (hasEmptySlot(player)) { if (hasEmptySlot(player)) {
@@ -84,7 +87,6 @@ public class DepositoryGUI extends GUI {
} else { } else {
PluginMessages.NO_SPACE.send(player); PluginMessages.NO_SPACE.send(player);
} }
} }
} }
}; };
@@ -4,7 +4,7 @@ import java.sql.Date;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
public class DateUtil { public class DateIntUtil {
private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyyMMdd"); private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyyMMdd");
+6 -1
View File
@@ -6,12 +6,17 @@ version: ${project.version}
debug: false debug: false
# 统计数据设定
# 改选项用于帮助开发者统计插件版本与使用情况,且绝不会影响性能与使用体验。
# 当然,您也可以选择在这里关闭,或在plugins/bStats下的配置文件中关闭。
metrics: true
# 存储相关配置 # 存储相关配置
# 注意:存储配置不会通过重载指令生效,如有修改请重新启动服务器。 # 注意:存储配置不会通过重载指令生效,如有修改请重新启动服务器。
storage: storage:
# 存储方式,可选 [ file | mysql ] # 存储方式,可选 [ file | mysql ]
method: mysql method: file
# 选择 file 存储方式时的存储路径 # 选择 file 存储方式时的存储路径
# 默认为相对路径,相对于插件生成的配置文件夹下的路径 # 默认为相对路径,相对于插件生成的配置文件夹下的路径
+2 -1
View File
@@ -7,6 +7,8 @@ website: ${project.url}
author: CarmJos author: CarmJos
api-version: 1.13
softdepend: softdepend:
- PlaceholderAPI - PlaceholderAPI
- Vault - Vault
@@ -32,7 +34,6 @@ permissions:
"UltraDepository.auto.enable": "UltraDepository.auto.enable":
description: "用于判断是否启用了自动收集功能" description: "用于判断是否启用了自动收集功能"
default: op
"UltraDepository.admin": "UltraDepository.admin":
description: "超级仓库的管理权限" description: "超级仓库的管理权限"
+41
View File
@@ -0,0 +1,41 @@
import com.google.gson.Gson;
import org.junit.Test;
import java.util.*;
public class GsonMapTest {
private static final Gson GSON = new Gson();
@Test
public void test() {
Map<String, Map<String, Map<String, Integer>>> values = new LinkedHashMap<>();
for (int u = 0; u < 3; u++) {
Map<String, Map<String, Integer>> depositoryDataMap = new LinkedHashMap<>();
for (int i = 0; i < 5; i++) {
Map<String, Integer> itemDataMap = new HashMap<>();
int amount = Math.max(0, new Random().nextInt(15));
int sold = Math.max(0, new Random().nextInt(15));
if (amount > 0) itemDataMap.put("amount", amount);
if (sold > 0) itemDataMap.put("sold", sold);
if (!itemDataMap.isEmpty()) {
depositoryDataMap.put(UUID.randomUUID().toString().substring(0, 4), itemDataMap);
}
}
if (!depositoryDataMap.isEmpty()) {
values.put(UUID.randomUUID().toString().substring(0, 8), depositoryDataMap);
}
}
System.out.println(values.size());
String jsonValues = GSON.toJson(values);
System.out.println(jsonValues);
}
}