mirror of
https://github.com/CarmJos/UltraDepository.git
synced 2026-06-04 08:38:25 +08:00
完成出售GUI,插件更名
This commit is contained in:
@@ -9,19 +9,19 @@
|
|||||||
|_|
|
|_|
|
||||||
```
|
```
|
||||||
|
|
||||||
# UltraBackpack
|
# UltraDepository
|
||||||
|
|
||||||
[](https://github.com/CarmJos/UltraBackpack/releases)
|
[](https://github.com/CarmJos/UltraDepository/releases)
|
||||||
[](https://opensource.org/licenses/GPL-3.0)
|
[](https://opensource.org/licenses/GPL-3.0)
|
||||||
[](https://github.com/CarmJos/UltraBackpack/actions/workflows/maven.yml)
|
[](https://github.com/CarmJos/UltraDepository/actions/workflows/maven.yml)
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
超级背包插件,支持设定不同物品的存储背包。
|
超级仓库插件,支持设定不同物品的存储仓库。
|
||||||
|
|
||||||
本插件基于Spigot实现,**理论上支持全版本**。
|
本插件基于Spigot实现,**理论上支持全版本**。
|
||||||
|
|
||||||
本插件由 [墨豆Mordo](https://www.zimrs.cn) 请求本人开发,经过授权后开源。
|
本插件由 [墨豆Mordo](https://www.zimrs.cn) 赞助本人开发,经过授权后开源。
|
||||||
|
|
||||||
## 效果预览
|
## 效果预览
|
||||||
|
|
||||||
@@ -32,43 +32,43 @@
|
|||||||
- **[自带]** 数据部分基于 [EasySQL](https://github.com/CarmJos/EasySQL) 实现。
|
- **[自带]** 数据部分基于 [EasySQL](https://github.com/CarmJos/EasySQL) 实现。
|
||||||
- **[可选]** 变量部分基于 [PlaceholderAPI](https://www.spigotmc.org/resources/6245/) 实现。
|
- **[可选]** 变量部分基于 [PlaceholderAPI](https://www.spigotmc.org/resources/6245/) 实现。
|
||||||
|
|
||||||
详细依赖列表可见 [Dependencies](https://github.com/CarmJos/UltraBackpack/network/dependencies) 。
|
详细依赖列表可见 [Dependencies](https://github.com/CarmJos/UltraDepository/network/dependencies) 。
|
||||||
|
|
||||||
## 特殊优势
|
## 特殊优势
|
||||||
|
|
||||||
## 插件指令
|
## 插件指令
|
||||||
|
|
||||||
指令主指令为 /UltraBackpack (/ub | /backpack)
|
指令主指令为 /UltraDepository (/ud | /Depository)
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>展开查看所有子指令</summary>
|
<summary>展开查看所有子指令</summary>
|
||||||
|
|
||||||
```text
|
```text
|
||||||
# sell <背包ID> <物品ID> <数量>
|
# sell <背包ID> <物品ID> <数量>
|
||||||
@ 玩家指令 (UltraBackpack.Command.Sell)
|
@ 玩家指令 (UltraDepository.Command.Sell)
|
||||||
- 售出对应数量的对应物品。
|
- 售出对应数量的对应物品。
|
||||||
- 该指令受到玩家每日售出数量的限制。
|
- 该指令受到玩家每日售出数量的限制。
|
||||||
|
|
||||||
# sellAll [背包ID] [物品ID]
|
# sellAll [背包ID] [物品ID]
|
||||||
@ 玩家指令 (UltraBackpack.Command.SellAll)
|
@ 玩家指令 (UltraDepository.Command.SellAll)
|
||||||
- 售出所有相关物品。
|
- 售出所有相关物品。
|
||||||
- 该指令受到玩家每日售出数量的限制。
|
- 该指令受到玩家每日售出数量的限制。
|
||||||
|
|
||||||
|
|
||||||
# info <玩家> [背包ID] [物品ID]
|
# info <玩家> [背包ID] [物品ID]
|
||||||
@ 管理指令 (UltraBackpack.admin)
|
@ 管理指令 (UltraDepository.admin)
|
||||||
- 得到玩家的相关物品信息。
|
- 得到玩家的相关物品信息。
|
||||||
|
|
||||||
# add <玩家> <背包ID> <物品ID> <数量>
|
# add <玩家> <背包ID> <物品ID> <数量>
|
||||||
@ 管理指令 (UltraBackpack.admin)
|
@ 管理指令 (UltraDepository.admin)
|
||||||
- 为玩家添加对应背包中对于物品的数量。
|
- 为玩家添加对应背包中对于物品的数量。
|
||||||
|
|
||||||
# remove <玩家> <背包ID> <物品ID> <数量>
|
# remove <玩家> <背包ID> <物品ID> <数量>
|
||||||
@ 管理指令 (UltraBackpack.admin)
|
@ 管理指令 (UltraDepository.admin)
|
||||||
- 为玩家减少对应背包中对于物品的数量。
|
- 为玩家减少对应背包中对于物品的数量。
|
||||||
|
|
||||||
# sell <玩家> [背包ID] [物品ID] [数量]
|
# sell <玩家> [背包ID] [物品ID] [数量]
|
||||||
@ 管理指令 (UltraBackpack.admin)
|
@ 管理指令 (UltraDepository.admin)
|
||||||
- 为玩家售出相关物品。
|
- 为玩家售出相关物品。
|
||||||
- 若不填写数量,则售出所有对应背包的对应物品。
|
- 若不填写数量,则售出所有对应背包的对应物品。
|
||||||
- 若不填写物品,则售出对应背包内所有物品。
|
- 若不填写物品,则售出对应背包内所有物品。
|
||||||
@@ -86,23 +86,23 @@
|
|||||||
<summary>展开查看所有变量</summary>
|
<summary>展开查看所有变量</summary>
|
||||||
|
|
||||||
```text
|
```text
|
||||||
# %UltraBackpack_amount_<背包ID>_<物品ID>%
|
# %UltraDepository_amount_<背包ID>_<物品ID>%
|
||||||
- 得到对应背包内对应物品的数量
|
- 得到对应背包内对应物品的数量
|
||||||
|
|
||||||
# %UltraBackpack_price_<背包ID>_<物品ID>%
|
# %UltraDepository_price_<背包ID>_<物品ID>%
|
||||||
- 得到对应背包内对应物品的价格
|
- 得到对应背包内对应物品的价格
|
||||||
|
|
||||||
# %UltraBackpack_sold_<背包ID>_<物品ID>%
|
# %UltraDepository_sold_<背包ID>_<物品ID>%
|
||||||
- 得到对应背包内对应物品的今日售出数量
|
- 得到对应背包内对应物品的今日售出数量
|
||||||
|
|
||||||
# %UltraBackpack_limit_<背包ID>_<物品ID>%
|
# %UltraDepository_limit_<背包ID>_<物品ID>%
|
||||||
- 得到对应背包内对应物品的每日售出限制
|
- 得到对应背包内对应物品的每日售出限制
|
||||||
|
|
||||||
# %UltraBackpack_remain_<背包ID>_<物品ID>%
|
# %UltraDepository_remain_<背包ID>_<物品ID>%
|
||||||
- 得到对应背包内对应物品的剩余可售出数量
|
- 得到对应背包内对应物品的剩余可售出数量
|
||||||
- $剩余可售出数量 = $每日售出限制 - $今日售出数量
|
- $剩余可售出数量 = $每日售出限制 - $今日售出数量
|
||||||
|
|
||||||
# %UltraBackpack_capacity_<背包ID>%
|
# %UltraDepository_capacity_<背包ID>%
|
||||||
- 得到对应背包的容量
|
- 得到对应背包的容量
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -112,17 +112,17 @@
|
|||||||
|
|
||||||
## 配置文件
|
## 配置文件
|
||||||
|
|
||||||
### [插件配置文件](ultrabackpack-plugin/src/main/resources/config.yml) (config.yml)
|
### [插件配置文件](src/main/resources/config.yml) (config.yml)
|
||||||
|
|
||||||
详见源文件。
|
详见源文件。
|
||||||
|
|
||||||
### [消息配置文件](ultrabackpack-plugin/src/main/resources/messages.yml) (messages.yml)
|
### [消息配置文件](src/main/resources/messages.yml) (messages.yml)
|
||||||
|
|
||||||
详见源文件。
|
详见源文件。
|
||||||
|
|
||||||
### 背包类型配置文件 (backpacks/<ID>.yml)
|
### 背包类型配置文件 (depositories/<ID>.yml)
|
||||||
|
|
||||||
所有 背包类均为单独的配置文件,存放于 `插件配置目录/backpacks` 下,便于管理。
|
所有 背包类均为单独的配置文件,存放于 `插件配置目录/depositories` 下,便于管理。
|
||||||
|
|
||||||
文件名即背包的ID,理论上可以随便取,但强烈推荐使用纯英文,部分符号可能会影响正常读取,请避免使用。
|
文件名即背包的ID,理论上可以随便取,但强烈推荐使用纯英文,部分符号可能会影响正常读取,请避免使用。
|
||||||
|
|
||||||
|
|||||||
@@ -12,17 +12,13 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>ultrabackpack-parent</artifactId>
|
<artifactId>ultradepository</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<modules>
|
|
||||||
<module>ultrabackpack-api</module>
|
|
||||||
<module>ultrabackpack-plugin</module>
|
|
||||||
</modules>
|
|
||||||
|
|
||||||
<name>UltraBackpack</name>
|
<name>UltraDepository</name>
|
||||||
<description>超级背包插件,支持设定不同物品的存储背包。</description>
|
<description>超级仓库插件,支持设定不同物品的存储仓库。</description>
|
||||||
<url>https://github.com/CarmJos/UltraBackpack</url>
|
<url>https://github.com/CarmJos/UltraDepository</url>
|
||||||
|
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
@@ -45,20 +41,20 @@
|
|||||||
|
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>GitHub Issues</system>
|
<system>GitHub Issues</system>
|
||||||
<url>https://github.com/CarmJos/UltraBackpack/issues</url>
|
<url>https://github.com/CarmJos/UltraDepository/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>GitHub Actions</system>
|
<system>GitHub Actions</system>
|
||||||
<url>https://github.com/CarmJos/UltraBackpack/actions/workflows/maven.yml</url>
|
<url>https://github.com/CarmJos/UltraDepository/actions/workflows/maven.yml</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
<downloadUrl>https://github.com/CarmJos/UltraBackpack/releases</downloadUrl>
|
<downloadUrl>https://github.com/CarmJos/UltraDepository/releases</downloadUrl>
|
||||||
<repository>
|
<repository>
|
||||||
<id>github</id>
|
<id>github</id>
|
||||||
<name>GitHub Packages</name>
|
<name>GitHub Packages</name>
|
||||||
<url>https://maven.pkg.github.com/CarmJos/UltraBackpack</url>
|
<url>https://maven.pkg.github.com/CarmJos/UltraDepository</url>
|
||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
@@ -72,7 +68,7 @@
|
|||||||
<repository>
|
<repository>
|
||||||
<id>github</id>
|
<id>github</id>
|
||||||
<name>GitHub Packages</name>
|
<name>GitHub Packages</name>
|
||||||
<url>https://maven.pkg.github.com/CarmJos/UltraBackpack</url>
|
<url>https://maven.pkg.github.com/CarmJos/UltraDepository</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
@@ -95,6 +91,13 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cc.carm.lib</groupId>
|
||||||
|
<artifactId>easysql-beecp</artifactId>
|
||||||
|
<version>0.2.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
@@ -135,91 +138,87 @@
|
|||||||
<useSystemClassLoader>false</useSystemClassLoader>
|
<useSystemClassLoader>false</useSystemClassLoader>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<configuration>
|
||||||
|
<classifier>javadoc</classifier>
|
||||||
|
<links>
|
||||||
|
<link>https://javadoc.io/doc/org.jetbrains/annotations/</link>
|
||||||
|
</links>
|
||||||
|
<detectJavaApiLink>false</detectJavaApiLink>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
<docencoding>UTF-8</docencoding>
|
||||||
|
<locale>zh_CN</locale>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-javadocs</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<compilerArgument>-parameters</compilerArgument>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<artifact>*:*</artifact>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||||
|
<exclude>META-INF/*.txt</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
<configuration>
|
|
||||||
<classifier>javadoc</classifier>
|
|
||||||
<links>
|
|
||||||
<link>https://javadoc.io/doc/org.jetbrains/annotations/</link>
|
|
||||||
</links>
|
|
||||||
<detectJavaApiLink>false</detectJavaApiLink>
|
|
||||||
<encoding>UTF-8</encoding>
|
|
||||||
<charset>UTF-8</charset>
|
|
||||||
<docencoding>UTF-8</docencoding>
|
|
||||||
<locale>zh_CN</locale>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>attach-javadocs</id>
|
|
||||||
<goals>
|
|
||||||
<goal>jar</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
<encoding>UTF-8</encoding>
|
|
||||||
<compilerArgument>-parameters</compilerArgument>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
<version>3.2.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>jar-no-fork</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.3</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<filters>
|
|
||||||
<filter>
|
|
||||||
<artifact>*:*</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
|
||||||
<exclude>META-INF/*.txt</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
|
|||||||
+26
-28
@@ -1,20 +1,19 @@
|
|||||||
package cc.carm.plugin.ultrabackpack;
|
package cc.carm.plugin.ultrastorehouse;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.api.UltraBackpackAPI;
|
import cc.carm.plugin.ultrastorehouse.configuration.PluginConfig;
|
||||||
import cc.carm.plugin.ultrabackpack.api.util.ColorParser;
|
import cc.carm.plugin.ultrastorehouse.hooker.PAPIExpansion;
|
||||||
import cc.carm.plugin.ultrabackpack.api.util.MessageUtil;
|
import cc.carm.plugin.ultrastorehouse.listener.CollectListener;
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.PluginConfig;
|
import cc.carm.plugin.ultrastorehouse.listener.UserListener;
|
||||||
import cc.carm.plugin.ultrabackpack.hooker.UBExpansion;
|
import cc.carm.plugin.ultrastorehouse.manager.DepositoryManager;
|
||||||
import cc.carm.plugin.ultrabackpack.listener.CollectListener;
|
import cc.carm.plugin.ultrastorehouse.manager.ConfigManager;
|
||||||
import cc.carm.plugin.ultrabackpack.listener.UserListener;
|
import cc.carm.plugin.ultrastorehouse.manager.EconomyManager;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.BackpackManager;
|
import cc.carm.plugin.ultrastorehouse.manager.UserManager;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.ConfigManager;
|
import cc.carm.plugin.ultrastorehouse.storage.DataStorage;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.EconomyManager;
|
import cc.carm.plugin.ultrastorehouse.storage.FileStorage;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.UserManager;
|
import cc.carm.plugin.ultrastorehouse.storage.MySQLStorage;
|
||||||
import cc.carm.plugin.ultrabackpack.storage.FileStorage;
|
import cc.carm.plugin.ultrastorehouse.util.ColorParser;
|
||||||
import cc.carm.plugin.ultrabackpack.storage.MySQLStorage;
|
import cc.carm.plugin.ultrastorehouse.util.MessageUtil;
|
||||||
import cc.carm.plugin.ultrabackpack.storage.UBStorage;
|
import cc.carm.plugin.ultrastorehouse.util.SchedulerUtils;
|
||||||
import cc.carm.plugin.ultrabackpack.util.SchedulerUtils;
|
|
||||||
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;
|
||||||
@@ -29,15 +28,16 @@ public class Main extends JavaPlugin {
|
|||||||
private static Main instance;
|
private static Main instance;
|
||||||
private static SchedulerUtils scheduler;
|
private static SchedulerUtils scheduler;
|
||||||
|
|
||||||
private static UBStorage storage;
|
private static DataStorage storage;
|
||||||
|
|
||||||
private static UserManager userManager;
|
private static UserManager userManager;
|
||||||
private static EconomyManager economyManager;
|
private static EconomyManager economyManager;
|
||||||
private static BackpackManager backpackManager;
|
private static DepositoryManager depositoryManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
scheduler = new SchedulerUtils(this);
|
||||||
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ public class Main extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log("加载背包管理器...");
|
log("加载背包管理器...");
|
||||||
backpackManager = new BackpackManager();
|
depositoryManager = new DepositoryManager();
|
||||||
|
|
||||||
|
|
||||||
log("注册监听器...");
|
log("注册监听器...");
|
||||||
@@ -85,13 +85,11 @@ public class Main extends JavaPlugin {
|
|||||||
|
|
||||||
if (MessageUtil.hasPlaceholderAPI()) {
|
if (MessageUtil.hasPlaceholderAPI()) {
|
||||||
log("注册变量...");
|
log("注册变量...");
|
||||||
new UBExpansion(this).register();
|
new PAPIExpansion(this).register();
|
||||||
} else {
|
} else {
|
||||||
log("检测到未安装PlaceholderAPI,跳过变量注册。");
|
log("检测到未安装PlaceholderAPI,跳过变量注册。");
|
||||||
}
|
}
|
||||||
|
|
||||||
UltraBackpackAPI.initialize(getUserManager());
|
|
||||||
|
|
||||||
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -113,12 +111,12 @@ public class Main extends JavaPlugin {
|
|||||||
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SchedulerUtils getScheduler() {
|
public static DataStorage getStorage() {
|
||||||
return scheduler;
|
return storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UBStorage getStorage() {
|
public static SchedulerUtils getScheduler() {
|
||||||
return storage;
|
return scheduler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserManager getUserManager() {
|
public static UserManager getUserManager() {
|
||||||
@@ -129,8 +127,8 @@ public class Main extends JavaPlugin {
|
|||||||
return economyManager;
|
return economyManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BackpackManager getBackpackManager() {
|
public static DepositoryManager getBackpackManager() {
|
||||||
return backpackManager;
|
return depositoryManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package cc.carm.plugin.ultrastorehouse.command;
|
||||||
|
|
||||||
|
public class BackpackCommand {
|
||||||
|
}
|
||||||
@@ -0,0 +1,194 @@
|
|||||||
|
package cc.carm.plugin.ultrastorehouse.configuration;
|
||||||
|
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.message.ConfigMessage;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.message.ConfigMessageList;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.values.ConfigStringCast;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.values.ConfigValue;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
public class PluginConfig {
|
||||||
|
|
||||||
|
public static final ConfigValue<Boolean> DEBUG = new ConfigValue<>(
|
||||||
|
"debug", Boolean.class
|
||||||
|
);
|
||||||
|
|
||||||
|
public static final ConfigValue<String> STORAGE_METHOD = new ConfigValue<>(
|
||||||
|
"storage.method", String.class
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 收集配置
|
||||||
|
*/
|
||||||
|
public static class Collect {
|
||||||
|
|
||||||
|
public static final ConfigValue<Boolean> PICKUP = new ConfigValue<>(
|
||||||
|
"collect.pickup", Boolean.class, true
|
||||||
|
);
|
||||||
|
|
||||||
|
public static final ConfigValue<Boolean> KILL = new ConfigValue<>(
|
||||||
|
"collect.kill", Boolean.class, true
|
||||||
|
);
|
||||||
|
|
||||||
|
public static final ConfigValue<Boolean> BREAK = new ConfigValue<>(
|
||||||
|
"collect.break", Boolean.class, true
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用配置
|
||||||
|
*/
|
||||||
|
public static class General {
|
||||||
|
/**
|
||||||
|
* 针对每一件物品的额外介绍
|
||||||
|
* 将添加到背包界面内的物品上,避免重复配置
|
||||||
|
*/
|
||||||
|
public static final ConfigMessageList ADDITIONAL_LORE = new ConfigMessageList(
|
||||||
|
"general.additional-lore", new String[]{
|
||||||
|
"%(item_name)", "%(amount)", "%(price)", "%(sold)", "%(limit)"
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示玩家点击行为的介绍
|
||||||
|
* 将添加到背包界面内的物品上,避免重复配置
|
||||||
|
*/
|
||||||
|
public static final ConfigMessageList CLICK_LORE = new ConfigMessageList(
|
||||||
|
"general.click-lore", new String[]{
|
||||||
|
"%(item_name)", "%(amount)", "%(price)"
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 售出界面的配置
|
||||||
|
*/
|
||||||
|
public static class SellGUI {
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigMessage TITLE = new ConfigMessage(
|
||||||
|
"general.sell-gui.title", "&a&l出售",
|
||||||
|
new String[]{
|
||||||
|
"%(item_name)", "%(backpack_name)"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
public static class Items {
|
||||||
|
|
||||||
|
public static class Add {
|
||||||
|
|
||||||
|
public static final ConfigStringCast<Material> TYPE = new ConfigStringCast<>(
|
||||||
|
"general.sell-gui.items.add.type",
|
||||||
|
Material::matchMaterial, Material.STONE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigValue<Integer> DATA = new ConfigValue<>(
|
||||||
|
"general.sell-gui.items.add.data", Integer.class, 0
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigMessage NAME = new ConfigMessage(
|
||||||
|
"general.sell-gui.items.add.name", "&a添加物品 %(amount) 个",
|
||||||
|
new String[]{
|
||||||
|
"%(item_name)", "%(amount)"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigMessageList LORE = new ConfigMessageList(
|
||||||
|
"general.sell-gui.items.add.lore", null,
|
||||||
|
new String[]{
|
||||||
|
"%(item_name)", "%(amount)"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Remove {
|
||||||
|
|
||||||
|
public static final ConfigStringCast<Material> TYPE = new ConfigStringCast<>(
|
||||||
|
"general.sell-gui.items.remove.type",
|
||||||
|
Material::matchMaterial, Material.STONE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigValue<Integer> DATA = new ConfigValue<>(
|
||||||
|
"general.sell-gui.items.remove.data", Integer.class, 0
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigMessage NAME = new ConfigMessage(
|
||||||
|
"general.sell-gui.items.remove.name", "&c減少物品 %(amount) 个",
|
||||||
|
new String[]{
|
||||||
|
"%(item_name)", "%(amount)"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigMessageList LORE = new ConfigMessageList(
|
||||||
|
"general.sell-gui.items.remove.lore", null,
|
||||||
|
new String[]{
|
||||||
|
"%(item_name)", "%(amount)"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Confirm {
|
||||||
|
|
||||||
|
public static final ConfigStringCast<Material> TYPE = new ConfigStringCast<>(
|
||||||
|
"general.sell-gui.items.confirm.type",
|
||||||
|
Material::matchMaterial, Material.EMERALD
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigValue<Integer> DATA = new ConfigValue<>(
|
||||||
|
"general.sell-gui.items.confirm.data", Integer.class, 0
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigMessage NAME = new ConfigMessage(
|
||||||
|
"general.sell-gui.items.confirm.name", "&2确认售出",
|
||||||
|
new String[]{
|
||||||
|
"%(item_name)", "%(amount)", "%(money)"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigMessageList LORE = new ConfigMessageList(
|
||||||
|
"general.sell-gui.items.confirm.lore", null,
|
||||||
|
new String[]{
|
||||||
|
"%(item_name)", "%(amount)", "%(money)"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Cancel {
|
||||||
|
|
||||||
|
public static final ConfigStringCast<Material> TYPE = new ConfigStringCast<>(
|
||||||
|
"general.sell-gui.items.cancel.type",
|
||||||
|
Material::matchMaterial, Material.REDSTONE
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigValue<Integer> DATA = new ConfigValue<>(
|
||||||
|
"general.sell-gui.items.cancel.data", Integer.class, 0
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
public static final ConfigMessage NAME = new ConfigMessage(
|
||||||
|
"general.sell-gui.items.cancel.name", "&4取消售出"
|
||||||
|
);
|
||||||
|
|
||||||
|
public static final ConfigMessageList LORE = new ConfigMessageList(
|
||||||
|
"general.sell-gui.items.cancel.lore"
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package cc.carm.plugin.ultrastorehouse.configuration;
|
||||||
|
|
||||||
|
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.message.ConfigMessageList;
|
||||||
|
|
||||||
|
public class PluginMessages {
|
||||||
|
|
||||||
|
public static final ConfigMessageList SOLD = new ConfigMessageList(
|
||||||
|
"item-sold", new String[0], new String[]{
|
||||||
|
"%(item)", "%(amount)", "%(money)"
|
||||||
|
});
|
||||||
|
public static final ConfigMessageList COLLECTED = new ConfigMessageList(
|
||||||
|
"item-collected", new String[0], new String[]{
|
||||||
|
"%(item)", "%(amount)", "%(backpack)"
|
||||||
|
});
|
||||||
|
}
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.backpack;
|
package cc.carm.plugin.ultrastorehouse.configuration.depository;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -8,12 +8,12 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BackpackCapacity {
|
public class DepositoryCapacity {
|
||||||
|
|
||||||
int defaultCapacity;
|
int defaultCapacity;
|
||||||
Map<String, Integer> permissions;
|
Map<String, Integer> permissions;
|
||||||
|
|
||||||
public BackpackCapacity(int defaultCapacity, List<String> permissionStrings) {
|
public DepositoryCapacity(int defaultCapacity, List<String> permissionStrings) {
|
||||||
this.defaultCapacity = defaultCapacity;
|
this.defaultCapacity = defaultCapacity;
|
||||||
Map<String, Integer> permissions = new HashMap<>();
|
Map<String, Integer> permissions = new HashMap<>();
|
||||||
permissionStrings.stream()
|
permissionStrings.stream()
|
||||||
@@ -29,7 +29,7 @@ public class BackpackCapacity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BackpackCapacity(int defaultCapacity, Map<String, Integer> permissions) {
|
public DepositoryCapacity(int defaultCapacity, Map<String, Integer> permissions) {
|
||||||
this.defaultCapacity = defaultCapacity;
|
this.defaultCapacity = defaultCapacity;
|
||||||
this.permissions = permissions;
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
+6
-6
@@ -1,6 +1,6 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.backpack;
|
package cc.carm.plugin.ultrastorehouse.configuration.depository;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.api.util.ItemStackFactory;
|
import cc.carm.plugin.ultrastorehouse.util.ItemStackFactory;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BackpackItem {
|
public class DepositoryItem {
|
||||||
|
|
||||||
final @NotNull Material material;
|
final @NotNull Material material;
|
||||||
final int data;
|
final int data;
|
||||||
@@ -21,9 +21,9 @@ public class BackpackItem {
|
|||||||
@Nullable String name;
|
@Nullable String name;
|
||||||
@Nullable List<String> lore;
|
@Nullable List<String> lore;
|
||||||
|
|
||||||
public BackpackItem(@NotNull Material material, int data,
|
public DepositoryItem(@NotNull Material material, int data,
|
||||||
int slot, int price, int limit,
|
int slot, int price, int limit,
|
||||||
@Nullable String name, @Nullable List<String> lore) {
|
@Nullable String name, @Nullable List<String> lore) {
|
||||||
this.material = material;
|
this.material = material;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
+12
-13
@@ -1,25 +1,25 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.backpack;
|
package cc.carm.plugin.ultrastorehouse.configuration.depository;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.gui.GUIConfiguration;
|
import cc.carm.plugin.ultrastorehouse.configuration.gui.GUIConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BackpackConfiguration {
|
public class ItemDepository {
|
||||||
|
|
||||||
final String identifier;
|
final String identifier;
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
GUIConfiguration guiConfiguration;
|
GUIConfiguration guiConfiguration;
|
||||||
BackpackCapacity capacity;
|
DepositoryCapacity capacity;
|
||||||
|
|
||||||
Map<String, BackpackItem> items;
|
Map<String, DepositoryItem> items;
|
||||||
|
|
||||||
|
|
||||||
public BackpackConfiguration(String identifier, String name,
|
public ItemDepository(String identifier, String name,
|
||||||
GUIConfiguration guiConfiguration,
|
GUIConfiguration guiConfiguration,
|
||||||
BackpackCapacity capacity,
|
DepositoryCapacity capacity,
|
||||||
Map<String, BackpackItem> items) {
|
Map<String, DepositoryItem> items) {
|
||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.guiConfiguration = guiConfiguration;
|
this.guiConfiguration = guiConfiguration;
|
||||||
@@ -34,18 +34,17 @@ public class BackpackConfiguration {
|
|||||||
public @NotNull String getName() {
|
public @NotNull String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull GUIConfiguration getGUIConfiguration() {
|
public @NotNull GUIConfiguration getGUIConfiguration() {
|
||||||
return this.guiConfiguration;
|
return this.guiConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull BackpackCapacity getCapacity() {
|
public @NotNull DepositoryCapacity getCapacity() {
|
||||||
return this.capacity;
|
return this.capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull Map<String, BackpackItem> getItems() {
|
public @NotNull Map<String, DepositoryItem> getItems() {
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.file;
|
package cc.carm.plugin.ultrastorehouse.configuration.file;
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.gui;
|
package cc.carm.plugin.ultrastorehouse.configuration.gui;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.util.gui.GUIItem;
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUIItem;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.gui;
|
package cc.carm.plugin.ultrastorehouse.configuration.gui;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.api.util.MessageUtil;
|
import cc.carm.plugin.ultrastorehouse.util.MessageUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
+6
-5
@@ -1,8 +1,9 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.gui;
|
package cc.carm.plugin.ultrastorehouse.configuration.gui;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.util.gui.GUI;
|
import cc.carm.plugin.ultrastorehouse.util.ColorParser;
|
||||||
import cc.carm.plugin.ultrabackpack.util.gui.GUIItem;
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUI;
|
||||||
import cc.carm.plugin.ultrabackpack.util.gui.GUIType;
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUIItem;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUIType;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
public class GUIConfiguration {
|
public class GUIConfiguration {
|
||||||
@@ -19,7 +20,7 @@ public class GUIConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return ColorParser.parse(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLines() {
|
public int getLines() {
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package cc.carm.plugin.ultrastorehouse.configuration.message;
|
||||||
|
|
||||||
|
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.MessageUtil;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.values.ConfigValue;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.manager.ConfigManager;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConfigMessage extends ConfigValue<String> {
|
||||||
|
|
||||||
|
String[] messageParams;
|
||||||
|
|
||||||
|
public ConfigMessage(String configSection) {
|
||||||
|
this(configSection, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigMessage(String configSection, String defaultValue) {
|
||||||
|
this(configSection, defaultValue, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigMessage(String configSection, String defaultValue, String[] messageParams) {
|
||||||
|
super(ConfigManager.getMessageConfig(), configSection, String.class, defaultValue);
|
||||||
|
this.messageParams = messageParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(CommandSender sender, Object[] values) {
|
||||||
|
if (messageParams != null) {
|
||||||
|
return get(sender, messageParams, values);
|
||||||
|
} else {
|
||||||
|
return get(sender, new String[0], new Object[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(CommandSender sender, String[] params, Object[] values) {
|
||||||
|
List<String> messages = MessageUtil.setPlaceholders(sender, Collections.singletonList(get()), params, values);
|
||||||
|
return messages != null && !messages.isEmpty() ? messages.get(0) : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(CommandSender sender) {
|
||||||
|
MessageUtil.send(sender, get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendWithPlaceholders(CommandSender sender) {
|
||||||
|
MessageUtil.sendWithPlaceholders(sender, get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendWithPlaceholders(CommandSender sender, String[] params, Object[] values) {
|
||||||
|
MessageUtil.sendWithPlaceholders(sender, Collections.singletonList(get()), params, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
package cc.carm.plugin.ultrastorehouse.configuration.message;
|
||||||
|
|
||||||
|
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.MessageUtil;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.values.ConfigValueList;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.manager.ConfigManager;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConfigMessageList extends ConfigValueList<String> {
|
||||||
|
|
||||||
|
String[] messageParams;
|
||||||
|
|
||||||
|
public ConfigMessageList(String configSection) {
|
||||||
|
super(ConfigManager.getMessageConfig(), configSection, String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigMessageList(String configSection, String[] defaultValue) {
|
||||||
|
this(configSection, defaultValue, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigMessageList(String configSection, String[] defaultValue, String[] messageParams) {
|
||||||
|
super(ConfigManager.getMessageConfig(), configSection, String.class, defaultValue);
|
||||||
|
this.messageParams = messageParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> get(@Nullable CommandSender sender) {
|
||||||
|
return MessageUtil.setPlaceholders(sender, get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> get(@Nullable CommandSender sender, Object[] values) {
|
||||||
|
if (messageParams != null) {
|
||||||
|
return get(sender, messageParams, values);
|
||||||
|
} else {
|
||||||
|
return get(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> get(@Nullable CommandSender sender, String[] params, Object[] values) {
|
||||||
|
return MessageUtil.setPlaceholders(sender, get(), params, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(@Nullable CommandSender sender) {
|
||||||
|
MessageUtil.send(sender, get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendWithPlaceholders(@Nullable CommandSender sender) {
|
||||||
|
MessageUtil.sendWithPlaceholders(sender, get());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendWithPlaceholders(@Nullable CommandSender sender, Object[] values) {
|
||||||
|
if (messageParams != null) {
|
||||||
|
sendWithPlaceholders(sender, messageParams, values);
|
||||||
|
} else {
|
||||||
|
sendWithPlaceholders(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendWithPlaceholders(@Nullable CommandSender sender, String[] params, Object[] values) {
|
||||||
|
MessageUtil.sendWithPlaceholders(sender, get(), params, values);
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.values;
|
package cc.carm.plugin.ultrastorehouse.configuration.values;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.file.FileConfig;
|
import cc.carm.plugin.ultrastorehouse.configuration.file.FileConfig;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.ConfigManager;
|
import cc.carm.plugin.ultrastorehouse.manager.ConfigManager;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.values;
|
package cc.carm.plugin.ultrastorehouse.configuration.values;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.file.FileConfig;
|
import cc.carm.plugin.ultrastorehouse.configuration.file.FileConfig;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.ConfigManager;
|
import cc.carm.plugin.ultrastorehouse.manager.ConfigManager;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.values;
|
package cc.carm.plugin.ultrastorehouse.configuration.values;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.file.FileConfig;
|
import cc.carm.plugin.ultrastorehouse.configuration.file.FileConfig;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.ConfigManager;
|
import cc.carm.plugin.ultrastorehouse.manager.ConfigManager;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
public class ConfigValue<V> {
|
public class ConfigValue<V> {
|
||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.values;
|
package cc.carm.plugin.ultrastorehouse.configuration.values;
|
||||||
|
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.file.FileConfig;
|
import cc.carm.plugin.ultrastorehouse.configuration.file.FileConfig;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.ConfigManager;
|
import cc.carm.plugin.ultrastorehouse.manager.ConfigManager;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.values;
|
package cc.carm.plugin.ultrastorehouse.configuration.values;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.file.FileConfig;
|
import cc.carm.plugin.ultrastorehouse.configuration.file.FileConfig;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.ConfigManager;
|
import cc.carm.plugin.ultrastorehouse.manager.ConfigManager;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package cc.carm.plugin.ultrastorehouse.data;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class DepositoryData {
|
||||||
|
|
||||||
|
private final Map<@NotNull String, @NotNull ItemData> contents;
|
||||||
|
|
||||||
|
public DepositoryData(Map<@NotNull String, @NotNull ItemData> contents) {
|
||||||
|
this.contents = contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull Map<String, ItemData> getContents() {
|
||||||
|
return this.contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemData getItemData(@NotNull String itemType) {
|
||||||
|
return getContents().get(itemType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DepositoryData emptyContents(Set<String> itemTypes) {
|
||||||
|
return new DepositoryData(itemTypes.stream().collect(Collectors.toMap(
|
||||||
|
item -> item, item -> ItemData.emptyItemData(), (a, b) -> b
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+12
-5
@@ -1,11 +1,11 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.api.data;
|
package cc.carm.plugin.ultrastorehouse.data;
|
||||||
|
|
||||||
public class UBItemData {
|
public class ItemData {
|
||||||
|
|
||||||
int amount;
|
int amount;
|
||||||
int sold;
|
int sold;
|
||||||
|
|
||||||
public UBItemData(int amount, int sold) {
|
public ItemData(int amount, int sold) {
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
this.sold = sold;
|
this.sold = sold;
|
||||||
}
|
}
|
||||||
@@ -30,8 +30,15 @@ public class UBItemData {
|
|||||||
this.sold = 0;
|
this.sold = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UBItemData emptyItemData() {
|
public static ItemData emptyItemData() {
|
||||||
return new UBItemData(0, 0);
|
return new ItemData(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "UBItemData{" +
|
||||||
|
"amount=" + amount +
|
||||||
|
", sold=" + sold +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+56
-43
@@ -1,10 +1,9 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.data;
|
package cc.carm.plugin.ultrastorehouse.data;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import cc.carm.plugin.ultrabackpack.api.data.UBContentsData;
|
import cc.carm.plugin.ultrastorehouse.configuration.depository.DepositoryItem;
|
||||||
import cc.carm.plugin.ultrabackpack.api.data.UBItemData;
|
import cc.carm.plugin.ultrastorehouse.configuration.depository.ItemDepository;
|
||||||
import cc.carm.plugin.ultrabackpack.api.data.UBUserData;
|
import cc.carm.plugin.ultrastorehouse.storage.DataStorage;
|
||||||
import cc.carm.plugin.ultrabackpack.storage.UBStorage;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -13,135 +12,149 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UserData implements UBUserData {
|
public class UserData {
|
||||||
|
|
||||||
public final UUID userUUID;
|
public final UUID userUUID;
|
||||||
|
|
||||||
UBStorage storage;
|
DataStorage storage;
|
||||||
Map<String, UBContentsData> backpacks;
|
Map<String, DepositoryData> backpacks;
|
||||||
|
|
||||||
Date day;
|
Date day;
|
||||||
|
|
||||||
public UserData(UUID userUUID, UBStorage storage,
|
public UserData(UUID userUUID, DataStorage storage,
|
||||||
Map<String, UBContentsData> backpacks, Date day) {
|
Map<String, DepositoryData> backpacks, Date day) {
|
||||||
this.userUUID = userUUID;
|
this.userUUID = userUUID;
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
this.backpacks = backpacks;
|
this.backpacks = backpacks;
|
||||||
this.day = day;
|
this.day = day;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull UUID getUserUUID() {
|
public @NotNull UUID getUserUUID() {
|
||||||
return this.userUUID;
|
return this.userUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull Map<String, UBContentsData> getBackpacks() {
|
public @NotNull Map<String, DepositoryData> getBackpacks() {
|
||||||
return this.backpacks;
|
return this.backpacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable UBContentsData getBackpack(String backpackID) {
|
public @Nullable DepositoryData getBackpackData(String backpackID) {
|
||||||
if (!Main.getBackpackManager().hasBackpack(backpackID)) return null;
|
ItemDepository configuration = Main.getBackpackManager().getDepository(backpackID);
|
||||||
if (!getBackpacks().containsKey(backpackID)) {
|
if (configuration == null) return null;
|
||||||
getBackpacks().put(backpackID, UBContentsData.emptyContents());
|
return getBackpackData(configuration);
|
||||||
}
|
|
||||||
return getBackpacks().get(backpackID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public @NotNull DepositoryData getBackpackData(ItemDepository backpack) {
|
||||||
|
if (!getBackpacks().containsKey(backpack.getIdentifier())) {
|
||||||
|
getBackpacks().put(backpack.getIdentifier(), DepositoryData.emptyContents(backpack.getItems().keySet()));
|
||||||
|
}
|
||||||
|
return getBackpacks().get(backpack.getIdentifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public @NotNull Set<String> getBackpackIDs() {
|
public @NotNull Set<String> getBackpackIDs() {
|
||||||
return getBackpacks().keySet();
|
return getBackpacks().keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable UBItemData getItemData(@NotNull String backpackID, @NotNull String typeID) {
|
public @Nullable ItemData getItemData(@NotNull String backpackID, @NotNull String typeID) {
|
||||||
UBContentsData data = getBackpack(backpackID);
|
DepositoryData data = getBackpackData(backpackID);
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
if (!Main.getBackpackManager().hasItem(backpackID, typeID)) return null;
|
if (!Main.getBackpackManager().hasItem(backpackID, typeID)) return null;
|
||||||
UBItemData itemData = data.getItemData(typeID);
|
ItemData itemData = data.getItemData(typeID);
|
||||||
if (itemData == null) {
|
if (itemData == null) {
|
||||||
itemData = UBItemData.emptyItemData();
|
itemData = ItemData.emptyItemData();
|
||||||
data.getContents().put(typeID, itemData);
|
data.getContents().put(typeID, itemData);
|
||||||
}
|
}
|
||||||
return itemData;
|
return itemData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NotNull ItemData getItemData(@NotNull ItemDepository backpack, @NotNull DepositoryItem itemType) {
|
||||||
|
DepositoryData data = getBackpackData(backpack);
|
||||||
|
ItemData itemData = data.getItemData(itemType.getTypeID());
|
||||||
|
if (itemData == null) {
|
||||||
|
itemData = ItemData.emptyItemData();
|
||||||
|
data.getContents().put(itemType.getTypeID(), itemData);
|
||||||
|
}
|
||||||
|
return itemData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Integer getItemAmount(@NotNull String backpackID, @NotNull String typeID) {
|
public @Nullable Integer getItemAmount(@NotNull String backpackID, @NotNull String typeID) {
|
||||||
UBItemData data = getItemData(backpackID, typeID);
|
ItemData data = getItemData(backpackID, typeID);
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
return data.getAmount();
|
return data.getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Integer getItemSold(@NotNull String backpackID, @NotNull String typeID) {
|
public @Nullable Integer getItemSold(@NotNull String backpackID, @NotNull String typeID) {
|
||||||
checkoutDate();
|
checkoutDate();
|
||||||
UBItemData data = getItemData(backpackID, typeID);
|
ItemData data = getItemData(backpackID, typeID);
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
return data.getSold();
|
return data.getSold();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Integer setItemAmount(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
public @Nullable Integer setItemAmount(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
||||||
UBItemData data = getItemData(backpackID, typeID);
|
ItemData data = getItemData(backpackID, typeID);
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
data.setAmount(amount);
|
data.setAmount(amount);
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Integer setItemSold(@NotNull String backpackID, @NotNull String typeID, int soldAmount) {
|
public @Nullable Integer setItemSold(@NotNull String backpackID, @NotNull String typeID, int soldAmount) {
|
||||||
UBItemData data = getItemData(backpackID, typeID);
|
ItemData data = getItemData(backpackID, typeID);
|
||||||
if (data == null) return null;
|
if (data == null) return null;
|
||||||
data.setSold(soldAmount);
|
data.setSold(soldAmount);
|
||||||
return soldAmount;
|
return soldAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Integer addItemAmount(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
public @Nullable Integer addItemAmount(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
||||||
Integer current = getItemAmount(backpackID, typeID);
|
Integer current = getItemAmount(backpackID, typeID);
|
||||||
if (current == null) return null;
|
if (current == null) return null;
|
||||||
return setItemAmount(backpackID, typeID, current + amount);
|
return setItemAmount(backpackID, typeID, current + amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Integer addItemSold(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
public @Nullable Integer addItemSold(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
||||||
Integer current = getItemSold(backpackID, typeID);
|
Integer current = getItemSold(backpackID, typeID);
|
||||||
if (current == null) return null;
|
if (current == null) return null;
|
||||||
return setItemSold(backpackID, typeID, current + amount);
|
return setItemSold(backpackID, typeID, current + amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Integer removeItemAmount(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
public @Nullable Integer removeItemAmount(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
||||||
return addItemAmount(backpackID, typeID, -amount);
|
return addItemAmount(backpackID, typeID, -amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable Integer removeItemSold(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
public @Nullable Integer removeItemSold(@NotNull String backpackID, @NotNull String typeID, int amount) {
|
||||||
return addItemSold(backpackID, typeID, -amount);
|
return addItemSold(backpackID, typeID, -amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Date getDate() {
|
public Date getDate() {
|
||||||
return this.day;
|
return this.day;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCurrentDay() {
|
public boolean isCurrentDay() {
|
||||||
return this.day.equals(new Date(System.currentTimeMillis()));
|
return this.day.equals(new Date(System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkoutDate() {
|
public void checkoutDate() {
|
||||||
if (isCurrentDay()) return;
|
if (isCurrentDay()) return;
|
||||||
this.day = new Date(System.currentTimeMillis()); //更新日期
|
this.day = new Date(System.currentTimeMillis()); //更新日期
|
||||||
getBackpacks().values().stream()
|
getBackpacks().values().stream()
|
||||||
.flatMap(value -> value.getContents().values().stream())
|
.flatMap(value -> value.getContents().values().stream())
|
||||||
.forEach(UBItemData::clearSold);
|
.forEach(ItemData::clearSold);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void save() throws Exception {
|
public void save() throws Exception {
|
||||||
this.storage.saveUserData(this);
|
this.storage.saveUserData(this);
|
||||||
}
|
}
|
||||||
+15
-15
@@ -1,6 +1,6 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.hooker;
|
package cc.carm.plugin.ultrastorehouse.hooker;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -8,19 +8,19 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class UBExpansion extends PlaceholderExpansion {
|
public class PAPIExpansion extends PlaceholderExpansion {
|
||||||
|
|
||||||
private static final List<String> PLACEHOLDERS = Arrays.asList(
|
private static final List<String> PLACEHOLDERS = Arrays.asList(
|
||||||
"%UltraBackpack_amount_<BackpackID>_<ItemTypeID>%",
|
"%UltraDepository_amount_<BackpackID>_<ItemTypeID>%",
|
||||||
"%UltraBackpack_sold_<BackpackID>_<ItemTypeID>%",
|
"%UltraDepository_sold_<BackpackID>_<ItemTypeID>%",
|
||||||
"%UltraBackpack_price_<BackpackID>_<ItemTypeID>%",
|
"%UltraDepository_price_<BackpackID>_<ItemTypeID>%",
|
||||||
"%UltraBackpack_remain_<BackpackID>_<ItemTypeID>%",
|
"%UltraDepository_remain_<BackpackID>_<ItemTypeID>%",
|
||||||
"%UltraBackpack_capacity_<BackpackID>%"
|
"%UltraDepository_capacity_<BackpackID>%"
|
||||||
);
|
);
|
||||||
|
|
||||||
Main main;
|
Main main;
|
||||||
|
|
||||||
public UBExpansion(Main main) {
|
public PAPIExpansion(Main main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,36 +62,36 @@ public class UBExpansion extends PlaceholderExpansion {
|
|||||||
case "amount": {
|
case "amount": {
|
||||||
if (args.length < 3) return "参数不足";
|
if (args.length < 3) return "参数不足";
|
||||||
Integer amount = Main.getUserManager().getData(player).getItemAmount(args[2], args[3]);
|
Integer amount = Main.getUserManager().getData(player).getItemAmount(args[2], args[3]);
|
||||||
if (amount == null) return "背包或物品不存在";
|
if (amount == null) return "仓库或物品不存在";
|
||||||
else return amount.toString();
|
else return amount.toString();
|
||||||
}
|
}
|
||||||
case "sold": {
|
case "sold": {
|
||||||
if (args.length < 3) return "参数不足";
|
if (args.length < 3) return "参数不足";
|
||||||
Integer sold = Main.getUserManager().getData(player).getItemSold(args[2], args[3]);
|
Integer sold = Main.getUserManager().getData(player).getItemSold(args[2], args[3]);
|
||||||
if (sold == null) return "背包或物品不存在";
|
if (sold == null) return "仓库或物品不存在";
|
||||||
else return sold.toString();
|
else return sold.toString();
|
||||||
}
|
}
|
||||||
case "remain": {
|
case "remain": {
|
||||||
if (args.length < 3) return "参数不足";
|
if (args.length < 3) return "参数不足";
|
||||||
|
|
||||||
Integer sold = Main.getUserManager().getData(player).getItemSold(args[2], args[3]);
|
Integer sold = Main.getUserManager().getData(player).getItemSold(args[2], args[3]);
|
||||||
if (sold == null) return "背包或物品不存在";
|
if (sold == null) return "仓库或物品不存在";
|
||||||
|
|
||||||
Integer limit = Main.getBackpackManager().getItemSellLimit(args[2], args[3]);
|
Integer limit = Main.getBackpackManager().getItemSellLimit(args[2], args[3]);
|
||||||
if (limit == null) return "背包或物品不存在";
|
if (limit == null) return "仓库或物品不存在";
|
||||||
|
|
||||||
return Integer.toString(limit - sold);
|
return Integer.toString(limit - sold);
|
||||||
}
|
}
|
||||||
case "limit": {
|
case "limit": {
|
||||||
if (args.length < 3) return "参数不足";
|
if (args.length < 3) return "参数不足";
|
||||||
Integer limit = Main.getBackpackManager().getItemSellLimit(args[2], args[3]);
|
Integer limit = Main.getBackpackManager().getItemSellLimit(args[2], args[3]);
|
||||||
if (limit == null) return "背包或物品不存在";
|
if (limit == null) return "仓库或物品不存在";
|
||||||
else return limit.toString();
|
else return limit.toString();
|
||||||
}
|
}
|
||||||
case "price": {
|
case "price": {
|
||||||
if (args.length < 3) return "参数不足";
|
if (args.length < 3) return "参数不足";
|
||||||
Double price = Main.getBackpackManager().getItemPrice(args[2], args[3]);
|
Double price = Main.getBackpackManager().getItemPrice(args[2], args[3]);
|
||||||
if (price == null) return "背包或物品不存在";
|
if (price == null) return "仓库或物品不存在";
|
||||||
else return price.toString();
|
else return price.toString();
|
||||||
}
|
}
|
||||||
case "version": {
|
case "version": {
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.hooker;
|
package cc.carm.plugin.ultrastorehouse.hooker;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.economy.EconomyResponse;
|
import net.milkbowl.vault.economy.EconomyResponse;
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.listener;
|
package cc.carm.plugin.ultrastorehouse.listener;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.PluginConfig;
|
import cc.carm.plugin.ultrastorehouse.configuration.PluginConfig;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
+4
-5
@@ -1,8 +1,7 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.listener;
|
package cc.carm.plugin.ultrastorehouse.listener;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import cc.carm.plugin.ultrabackpack.api.data.UBUserData;
|
import cc.carm.plugin.ultrastorehouse.data.UserData;
|
||||||
import cc.carm.plugin.ultrabackpack.data.UserData;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@@ -46,7 +45,7 @@ public class UserListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
UUID playerUUID = player.getUniqueId();
|
UUID playerUUID = player.getUniqueId();
|
||||||
UBUserData userData = Main.getUserManager().getData(player);
|
UserData userData = Main.getUserManager().getData(player);
|
||||||
Main.getScheduler().runAsync(() -> {
|
Main.getScheduler().runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
userData.save();
|
userData.save();
|
||||||
+8
-8
@@ -1,12 +1,12 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.manager;
|
package cc.carm.plugin.ultrastorehouse.manager;
|
||||||
|
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.file.FileConfig;
|
import cc.carm.plugin.ultrastorehouse.configuration.file.FileConfig;
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.gui.GUIActionConfiguration;
|
import cc.carm.plugin.ultrastorehouse.configuration.gui.GUIActionConfiguration;
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.gui.GUIActionType;
|
import cc.carm.plugin.ultrastorehouse.configuration.gui.GUIActionType;
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.gui.GUIConfiguration;
|
import cc.carm.plugin.ultrastorehouse.configuration.gui.GUIConfiguration;
|
||||||
import cc.carm.plugin.ultrabackpack.util.gui.GUIItem;
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUIItem;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -24,7 +24,7 @@ public class ConfigManager {
|
|||||||
|
|
||||||
public static void initConfig() {
|
public static void initConfig() {
|
||||||
ConfigManager.config = new FileConfig(Main.getInstance(), "config.yml");
|
ConfigManager.config = new FileConfig(Main.getInstance(), "config.yml");
|
||||||
ConfigManager.messageConfig = new FileConfig(Main.getInstance(), "messages.yml");
|
ConfigManager.messageConfig = new FileConfig(Main.getInstance(), "src/main/resources/messages.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileConfig getPluginConfig() {
|
public static FileConfig getPluginConfig() {
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
package cc.carm.plugin.ultrastorehouse.manager;
|
||||||
|
|
||||||
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.depository.DepositoryItem;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.depository.ItemDepository;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.data.UserData;
|
||||||
|
import com.google.common.collect.HashMultimap;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class DepositoryManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录仓库ID对应的仓库实例
|
||||||
|
*/
|
||||||
|
public HashMap<@NotNull String, @NotNull ItemDepository> depositories;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用于记录储存每个物品ID所对应的背包ID
|
||||||
|
*/
|
||||||
|
public HashMultimap<@NotNull String, @NotNull String> itemMap;
|
||||||
|
|
||||||
|
public DepositoryManager() {
|
||||||
|
this.depositories = new HashMap<>();
|
||||||
|
this.itemMap = HashMultimap.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull HashMap<@NotNull String, @NotNull ItemDepository> getDepositories() {
|
||||||
|
return depositories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDepository(@NotNull String depositoryID) {
|
||||||
|
return getDepositories().containsKey(depositoryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasItem(@NotNull String depositoryID, @NotNull String itemTypeID) {
|
||||||
|
ItemDepository configuration = getDepository(depositoryID);
|
||||||
|
if (configuration == null) return false;
|
||||||
|
return hasItem(configuration, itemTypeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasItem(@NotNull ItemDepository depository, @NotNull String itemTypeID) {
|
||||||
|
return depository.getItems().containsKey(itemTypeID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public @Nullable ItemDepository getDepository(@NotNull String depositoryID) {
|
||||||
|
return getDepositories().get(depositoryID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<ItemDepository> getItemDepositories(ItemStack itemStack) {
|
||||||
|
return getItemDepositories(itemStack.getType(), itemStack.getDurability());
|
||||||
|
}
|
||||||
|
|
||||||
|
public @Nullable Set<ItemDepository> getItemDepositories(Material material, int data) {
|
||||||
|
return Optional.ofNullable(itemMap.get(getItemTypeID(material, data)))
|
||||||
|
.map(set -> set.stream().map(this::getDepository).collect(Collectors.toSet()))
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<ItemDepository> getPlayerUsableDepository(Player player, ItemStack itemStack) {
|
||||||
|
String typeID = getItemTypeID(itemStack);
|
||||||
|
return getItemDepositories(itemStack).stream().filter(configuration -> {
|
||||||
|
int currentAmount = Optional.ofNullable(Main.getUserManager().getData(player)
|
||||||
|
.getItemAmount(configuration.getIdentifier(), typeID)).orElse(0);
|
||||||
|
int depositoryCapacity = configuration.getCapacity().getPlayerCapacity(player);
|
||||||
|
return currentAmount + itemStack.getAmount() <= depositoryCapacity;
|
||||||
|
}).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getItemTypeID(Material material, int data) {
|
||||||
|
return material.name() + ":" + data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull String getItemTypeID(ItemStack itemStack) {
|
||||||
|
return getItemTypeID(itemStack.getType(), itemStack.getDurability());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<ItemStack> collectItem(Player player, Collection<ItemStack> items) {
|
||||||
|
if (!Main.getUserManager().isCollectEnabled(player)) return new ArrayList<>();
|
||||||
|
else return items.stream().filter(item -> collectItem(player, item)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean collectItem(Player player, ItemStack item) {
|
||||||
|
if (!Main.getUserManager().isCollectEnabled(player)) return false;
|
||||||
|
Set<ItemDepository> usableDepositories = getPlayerUsableDepository(player, item);
|
||||||
|
if (usableDepositories.size() < 1) return false;
|
||||||
|
ItemDepository depository = usableDepositories.stream().findFirst().orElse(null);
|
||||||
|
|
||||||
|
String typeID = getItemTypeID(item);
|
||||||
|
UserData data = Main.getUserManager().getData(player);
|
||||||
|
int itemAmount = item.getAmount();
|
||||||
|
data.addItemAmount(depository.getIdentifier(), typeID, itemAmount);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得某背包配置中的某件物品单价,最低为0。
|
||||||
|
*
|
||||||
|
* @param depositoryID 背包ID
|
||||||
|
* @param itemTypeID 物品ID
|
||||||
|
* @return 若为空,则该背包或该物品不存在。
|
||||||
|
*/
|
||||||
|
public @Nullable Double getItemPrice(@NotNull String depositoryID, @NotNull String itemTypeID) {
|
||||||
|
ItemDepository configuration = getDepository(depositoryID);
|
||||||
|
if (configuration == null) return null;
|
||||||
|
DepositoryItem item = configuration.getItems().get(itemTypeID);
|
||||||
|
if (item == null) return null;
|
||||||
|
return item.getPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得某背包配置中的某件物品每日售出限制,最低为0。
|
||||||
|
*
|
||||||
|
* @param depositoryID 背包ID
|
||||||
|
* @param itemTypeID 物品ID
|
||||||
|
* @return 若为空,则该背包或该物品不存在。
|
||||||
|
*/
|
||||||
|
public @Nullable Integer getItemSellLimit(@NotNull String depositoryID, @NotNull String itemTypeID) {
|
||||||
|
ItemDepository configuration = getDepository(depositoryID);
|
||||||
|
if (configuration == null) return null;
|
||||||
|
DepositoryItem item = configuration.getItems().get(itemTypeID);
|
||||||
|
if (item == null) return null;
|
||||||
|
return item.getLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得某背包配置中的某件物品每日售出限制,最低为0。
|
||||||
|
*
|
||||||
|
* @param depository 背包
|
||||||
|
* @param itemTypeID 物品ID
|
||||||
|
* @return 若为空,则该背包或该物品不存在。
|
||||||
|
*/
|
||||||
|
public @Nullable Integer getItemSellLimit(@NotNull ItemDepository depository, @NotNull String itemTypeID) {
|
||||||
|
DepositoryItem item = depository.getItems().get(itemTypeID);
|
||||||
|
if (item == null) return null;
|
||||||
|
return item.getLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+7
-5
@@ -1,6 +1,6 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.manager;
|
package cc.carm.plugin.ultrastorehouse.manager;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.hooker.VaultHooker;
|
import cc.carm.plugin.ultrastorehouse.hooker.VaultHooker;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class EconomyManager {
|
public class EconomyManager {
|
||||||
@@ -27,9 +27,11 @@ public class EconomyManager {
|
|||||||
return hooker;
|
return hooker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sell(Player player, double price, int amount) {
|
public double sell(Player player, double price, int amount) {
|
||||||
if (!isInitialized()) return;
|
if (!isInitialized()) return 0D;
|
||||||
getHooker().addMoney(player, price * amount);
|
double money = price * amount;
|
||||||
|
getHooker().addMoney(player, money);
|
||||||
|
return money;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+6
-10
@@ -1,8 +1,7 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.manager;
|
package cc.carm.plugin.ultrastorehouse.manager;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import cc.carm.plugin.ultrabackpack.api.manager.UBUserManager;
|
import cc.carm.plugin.ultrastorehouse.data.UserData;
|
||||||
import cc.carm.plugin.ultrabackpack.data.UserData;
|
|
||||||
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;
|
||||||
@@ -11,7 +10,8 @@ import java.sql.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UserManager implements UBUserManager {
|
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||||
|
public class UserManager {
|
||||||
|
|
||||||
private final HashMap<UUID, UserData> dataCache = new HashMap<>();
|
private final HashMap<UUID, UserData> dataCache = new HashMap<>();
|
||||||
|
|
||||||
@@ -19,28 +19,24 @@ public class UserManager implements UBUserManager {
|
|||||||
return dataCache;
|
return dataCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable UserData getData(@NotNull UUID userUUID) {
|
public @Nullable UserData getData(@NotNull UUID userUUID) {
|
||||||
return getDataCache().get(userUUID);
|
return getDataCache().get(userUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull UserData getData(@NotNull Player player) {
|
public @NotNull UserData getData(@NotNull Player player) {
|
||||||
return getDataCache().get(player.getUniqueId());
|
return getDataCache().get(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull UserData loadData(@NotNull UUID userUUID) {
|
public @NotNull UserData loadData(@NotNull UUID userUUID) {
|
||||||
try {
|
try {
|
||||||
return Main.getStorage().loadData(userUUID);
|
return Main.getStorage().loadData(userUUID);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Main.error("无法正常加载玩家数据,玩家操作将不会被保存,请检查数据配置!");
|
Main.error("无法正常加载玩家数据,玩家操作将不会被保存,请检查数据配置!");
|
||||||
Main.error("Error occurred when loading user's data, please check the configuration!");
|
Main.error("Could not load user's data, please check the data configuration!");
|
||||||
return new UserData(userUUID, Main.getStorage(), new HashMap<>(), new Date(System.currentTimeMillis()));
|
return new UserData(userUUID, Main.getStorage(), new HashMap<>(), new Date(System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isCollectEnabled(Player player) {
|
public boolean isCollectEnabled(Player player) {
|
||||||
return player.hasPermission("UltraBackpack.use") &&
|
return player.hasPermission("UltraBackpack.use") &&
|
||||||
player.hasPermission("UltraBackpack.auto") &&
|
player.hasPermission("UltraBackpack.auto") &&
|
||||||
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.storage;
|
package cc.carm.plugin.ultrastorehouse.storage;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.data.UserData;
|
import cc.carm.plugin.ultrastorehouse.data.UserData;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface UBStorage {
|
public interface DataStorage {
|
||||||
|
|
||||||
|
|
||||||
boolean initialize();
|
boolean initialize();
|
||||||
+5
-5
@@ -1,8 +1,8 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.storage;
|
package cc.carm.plugin.ultrastorehouse.storage;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.values.ConfigValue;
|
import cc.carm.plugin.ultrastorehouse.configuration.values.ConfigValue;
|
||||||
import cc.carm.plugin.ultrabackpack.data.UserData;
|
import cc.carm.plugin.ultrastorehouse.data.UserData;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -10,7 +10,7 @@ import java.sql.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class FileStorage implements UBStorage {
|
public class FileStorage implements DataStorage {
|
||||||
|
|
||||||
private static final ConfigValue<String> FILE_PATH = new ConfigValue<>(
|
private static final ConfigValue<String> FILE_PATH = new ConfigValue<>(
|
||||||
"storage.file-path", String.class, "data"
|
"storage.file-path", String.class, "data"
|
||||||
+21
-23
@@ -1,15 +1,15 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.storage;
|
package cc.carm.plugin.ultrastorehouse.storage;
|
||||||
|
|
||||||
import cc.carm.lib.easysql.EasySQL;
|
import cc.carm.lib.easysql.EasySQL;
|
||||||
import cc.carm.lib.easysql.api.SQLManager;
|
import cc.carm.lib.easysql.api.SQLManager;
|
||||||
import cc.carm.lib.easysql.api.action.query.PreparedQueryAction;
|
import cc.carm.lib.easysql.api.action.query.PreparedQueryAction;
|
||||||
import cc.carm.lib.easysql.api.action.query.SQLQuery;
|
import cc.carm.lib.easysql.api.action.query.SQLQuery;
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import cc.carm.plugin.ultrabackpack.api.data.UBContentsData;
|
import cc.carm.plugin.ultrastorehouse.data.DepositoryData;
|
||||||
import cc.carm.plugin.ultrabackpack.api.data.UBItemData;
|
import cc.carm.plugin.ultrastorehouse.data.ItemData;
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.PluginConfig;
|
import cc.carm.plugin.ultrastorehouse.configuration.PluginConfig;
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.values.ConfigValue;
|
import cc.carm.plugin.ultrastorehouse.configuration.values.ConfigValue;
|
||||||
import cc.carm.plugin.ultrabackpack.data.UserData;
|
import cc.carm.plugin.ultrastorehouse.data.UserData;
|
||||||
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;
|
||||||
@@ -24,7 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MySQLStorage implements UBStorage {
|
public class MySQLStorage implements DataStorage {
|
||||||
|
|
||||||
private static final ConfigValue<String> DRIVER_NAME = new ConfigValue<>(
|
private static final ConfigValue<String> DRIVER_NAME = new ConfigValue<>(
|
||||||
"storage.mysql.driver", String.class, "com.mysql.jdbc.Driver"
|
"storage.mysql.driver", String.class, "com.mysql.jdbc.Driver"
|
||||||
@@ -120,7 +120,7 @@ public class MySQLStorage implements UBStorage {
|
|||||||
Main.debug("正通过 MySQLStorage 加载 " + uuid + " 的用户数据...");
|
Main.debug("正通过 MySQLStorage 加载 " + uuid + " 的用户数据...");
|
||||||
try (SQLQuery query = createAction(uuid).execute()) {
|
try (SQLQuery query = createAction(uuid).execute()) {
|
||||||
ResultSet resultSet = query.getResultSet();
|
ResultSet resultSet = query.getResultSet();
|
||||||
Map<String, UBContentsData> dataMap = new HashMap<>();
|
Map<String, DepositoryData> dataMap = new HashMap<>();
|
||||||
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");
|
||||||
@@ -128,7 +128,7 @@ public class MySQLStorage implements UBStorage {
|
|||||||
if (dataElement.isJsonObject()) {
|
if (dataElement.isJsonObject()) {
|
||||||
dataElement.getAsJsonObject().entrySet().forEach(entry -> {
|
dataElement.getAsJsonObject().entrySet().forEach(entry -> {
|
||||||
String backpackID = entry.getKey();
|
String backpackID = entry.getKey();
|
||||||
UBContentsData contentsData = parseContentsData(entry.getValue());
|
DepositoryData contentsData = parseContentsData(entry.getValue());
|
||||||
if (contentsData != null) dataMap.put(backpackID, contentsData);
|
if (contentsData != null) dataMap.put(backpackID, contentsData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -139,8 +139,6 @@ public class MySQLStorage implements UBStorage {
|
|||||||
Main.debug("当前库内不存在玩家 " + uuid + " 的数据,视作新档。");
|
Main.debug("当前库内不存在玩家 " + uuid + " 的数据,视作新档。");
|
||||||
return new UserData(uuid, this, new HashMap<>(), new Date(System.currentTimeMillis()));
|
return new UserData(uuid, this, new HashMap<>(), new Date(System.currentTimeMillis()));
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
Main.error("在加载玩家 #" + uuid + " 的数据时出现异常。");
|
|
||||||
Main.error("Error occurred when loading #" + uuid + " data.");
|
|
||||||
throw new Exception(exception);
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,34 +179,34 @@ public class MySQLStorage implements UBStorage {
|
|||||||
.setLimit(1).build();
|
.setLimit(1).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private UBContentsData parseContentsData(JsonElement contentsElement) {
|
private DepositoryData parseContentsData(JsonElement contentsElement) {
|
||||||
return contentsElement.isJsonObject() ? parseContentsData(contentsElement.getAsJsonObject()) : null;
|
return contentsElement.isJsonObject() ? parseContentsData(contentsElement.getAsJsonObject()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UBContentsData parseContentsData(JsonObject contentsObject) {
|
private DepositoryData parseContentsData(JsonObject contentsObject) {
|
||||||
Map<String, UBItemData> contents = new HashMap<>();
|
Map<String, ItemData> contents = new HashMap<>();
|
||||||
for (Map.Entry<String, JsonElement> entry : contentsObject.entrySet()) {
|
for (Map.Entry<String, JsonElement> entry : contentsObject.entrySet()) {
|
||||||
String itemType = entry.getKey();
|
String itemType = entry.getKey();
|
||||||
UBItemData data = parseItemData(entry.getValue());
|
ItemData data = parseItemData(entry.getValue());
|
||||||
contents.put(itemType, data);
|
contents.put(itemType, data);
|
||||||
}
|
}
|
||||||
return new UBContentsData(contents);
|
return new DepositoryData(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UBItemData parseItemData(JsonElement itemElement) {
|
private ItemData parseItemData(JsonElement itemElement) {
|
||||||
return itemElement.isJsonObject() ? parseItemData(itemElement.getAsJsonObject()) : null;
|
return itemElement.isJsonObject() ? parseItemData(itemElement.getAsJsonObject()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UBItemData parseItemData(JsonObject itemObject) {
|
private ItemData parseItemData(JsonObject itemObject) {
|
||||||
if (!itemObject.has("amount") || !itemObject.has("sold")) {
|
if (!itemObject.has("amount") || !itemObject.has("sold")) {
|
||||||
return UBItemData.emptyItemData();
|
return ItemData.emptyItemData();
|
||||||
} else {
|
} else {
|
||||||
return new UBItemData(itemObject.get("amount").getAsInt(), itemObject.get("sold").getAsInt());
|
return new ItemData(itemObject.get("amount").getAsInt(), itemObject.get("sold").getAsInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private JsonObject serializeContentsData(@Nullable UBContentsData contentsData) {
|
private JsonObject serializeContentsData(@Nullable DepositoryData contentsData) {
|
||||||
if (contentsData == null) return null;
|
if (contentsData == null) return null;
|
||||||
JsonObject contentsObject = new JsonObject();
|
JsonObject contentsObject = new JsonObject();
|
||||||
contentsData.getContents().forEach((typeID, item) -> contentsObject.add(typeID, serializeItemData(item)));
|
contentsData.getContents().forEach((typeID, item) -> contentsObject.add(typeID, serializeItemData(item)));
|
||||||
@@ -216,7 +214,7 @@ public class MySQLStorage implements UBStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private JsonObject serializeItemData(@NotNull UBItemData itemData) {
|
private JsonObject serializeItemData(@NotNull ItemData itemData) {
|
||||||
JsonObject itemObject = new JsonObject();
|
JsonObject itemObject = new JsonObject();
|
||||||
itemObject.addProperty("amount", itemData.getAmount());
|
itemObject.addProperty("amount", itemData.getAmount());
|
||||||
itemObject.addProperty("sold", itemData.getSold());
|
itemObject.addProperty("sold", itemData.getSold());
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package cc.carm.plugin.ultrastorehouse.ui;
|
||||||
|
|
||||||
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.PluginConfig;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.depository.DepositoryItem;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.depository.ItemDepository;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.data.ItemData;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.data.UserData;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.ItemStackFactory;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUI;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUIItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
public class DepositoryGUI extends GUI {
|
||||||
|
|
||||||
|
Player player;
|
||||||
|
UserData userData;
|
||||||
|
ItemDepository configuration;
|
||||||
|
|
||||||
|
public DepositoryGUI(Player player, ItemDepository configuration) {
|
||||||
|
super(configuration.getGUIConfiguration().getGUIType(), configuration.getGUIConfiguration().getTitle());
|
||||||
|
|
||||||
|
this.player = player;
|
||||||
|
this.userData = Main.getUserManager().getData(player);
|
||||||
|
this.configuration = configuration;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupItems() {
|
||||||
|
configuration.getGUIConfiguration().setupItems(this);
|
||||||
|
for (DepositoryItem depositoryItem : configuration.getItems().values()) {
|
||||||
|
setItem(depositoryItem.getSlot(), new GUIItem(depositoryItem.getDisplayItem()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private GUIItem createGUIItem(DepositoryItem item) {
|
||||||
|
ItemStackFactory factory = new ItemStackFactory(item.getDisplayItem());
|
||||||
|
ItemData itemData = userData.getItemData(configuration, item);
|
||||||
|
List<String> additionalLore = PluginConfig.General.ADDITIONAL_LORE.get(player, new Object[]{
|
||||||
|
item.getName(), itemData.getAmount(), item.getPrice(), itemData.getSold(), item.getLimit()
|
||||||
|
});
|
||||||
|
additionalLore.forEach(factory::addLore);
|
||||||
|
List<String> clickLore = PluginConfig.General.CLICK_LORE.get(player, new Object[]{
|
||||||
|
item.getName(), itemData.getAmount(), item.getPrice()
|
||||||
|
});
|
||||||
|
clickLore.forEach(factory::addLore);
|
||||||
|
|
||||||
|
return new GUIItem(factory.toItemStack()) {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickType type) {
|
||||||
|
if (itemData.getAmount() < 1) return;
|
||||||
|
if (type == ClickType.LEFT) {
|
||||||
|
SellItemGUI.open(player, userData, itemData, configuration, item);
|
||||||
|
} else if (type == ClickType.RIGHT) {
|
||||||
|
if (hasEmptySlot(player)) {
|
||||||
|
int pickupAmount = Math.min(itemData.getAmount(), item.getMaterial().getMaxStackSize());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasEmptySlot(Player player) {
|
||||||
|
return IntStream.range(0, 36)
|
||||||
|
.mapToObj(i -> player.getInventory().getItem(i))
|
||||||
|
.anyMatch(i -> i == null || i.getType() == Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
package cc.carm.plugin.ultrastorehouse.ui;
|
||||||
|
|
||||||
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.data.ItemData;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.ItemStackFactory;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.PluginConfig;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.PluginMessages;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.depository.ItemDepository;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.configuration.depository.DepositoryItem;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.data.UserData;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUI;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUIItem;
|
||||||
|
import cc.carm.plugin.ultrastorehouse.util.gui.GUIType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cc.carm.plugin.ultrastorehouse.configuration.PluginConfig.General.SellGUI.Items.*;
|
||||||
|
|
||||||
|
public class SellItemGUI extends GUI {
|
||||||
|
|
||||||
|
final Player player;
|
||||||
|
final UserData userData;
|
||||||
|
final ItemData itemData;
|
||||||
|
final ItemDepository configuration;
|
||||||
|
final DepositoryItem item;
|
||||||
|
|
||||||
|
ItemStack itemDisplay;
|
||||||
|
|
||||||
|
int currentAmount;
|
||||||
|
|
||||||
|
public SellItemGUI(Player player, UserData userData, ItemData itemData,
|
||||||
|
ItemDepository configuration, DepositoryItem item) {
|
||||||
|
super(GUIType.FOUR_BY_NINE, PluginConfig.General.SellGUI.TITLE.get(player, new String[]{
|
||||||
|
configuration.getName(), item.getName()
|
||||||
|
}));
|
||||||
|
this.player = player;
|
||||||
|
this.userData = userData;
|
||||||
|
this.itemData = itemData;
|
||||||
|
this.configuration = configuration;
|
||||||
|
this.item = item;
|
||||||
|
this.itemDisplay = item.getDisplayItem();
|
||||||
|
|
||||||
|
load(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void load(int amount) {
|
||||||
|
this.currentAmount = Math.max(1, amount); // 不可小于1
|
||||||
|
loadIcon();
|
||||||
|
loadButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadIcon() {
|
||||||
|
ItemStackFactory factory = new ItemStackFactory(this.itemDisplay);
|
||||||
|
List<String> additionalLore = PluginConfig.General.ADDITIONAL_LORE.get(player, new Object[]{
|
||||||
|
getItemName(), getRemainAmount(), getItemPrice(), getSoldAmount(), getSellLimit()
|
||||||
|
});
|
||||||
|
additionalLore.forEach(factory::addLore);
|
||||||
|
setItem(4, new GUIItem(factory.toItemStack()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadButtons() {
|
||||||
|
if (getCurrentAmount() > 1000) setItem(0, getRemoveItem(1000));
|
||||||
|
if (getCurrentAmount() > 100) setItem(1, getRemoveItem(100));
|
||||||
|
if (getCurrentAmount() > 10) setItem(2, getRemoveItem(10));
|
||||||
|
if (getCurrentAmount() > 1) setItem(3, getRemoveItem(1));
|
||||||
|
if (getAddableAmount() > 1) setItem(5, getAddItem(1));
|
||||||
|
if (getAddableAmount() > 10) setItem(6, getAddItem(10));
|
||||||
|
if (getAddableAmount() > 100) setItem(7, getAddItem(100));
|
||||||
|
if (getAddableAmount() > 1000) setItem(8, getAddItem(1000));
|
||||||
|
|
||||||
|
if (getCurrentAmount() >= 1) setItem(getConfirmItem(), 27, 28, 29, 30);
|
||||||
|
setItem(getCancelItem(), 32, 33, 34, 35);
|
||||||
|
}
|
||||||
|
|
||||||
|
private GUIItem getAddItem(int amount) {
|
||||||
|
ItemStackFactory factory = new ItemStackFactory(Add.TYPE.get());
|
||||||
|
factory.setDurability(Add.DATA.get());
|
||||||
|
factory.setDisplayName(Add.NAME.get(player, new Object[]{
|
||||||
|
getItemName(), getCurrentAmount()
|
||||||
|
}));
|
||||||
|
factory.setLore(Add.LORE.get(player, new Object[]{
|
||||||
|
getItemName(), getCurrentAmount()
|
||||||
|
}));
|
||||||
|
|
||||||
|
return new GUIItem(factory.toItemStack()) {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickType type) {
|
||||||
|
load(getCurrentAmount() + amount);
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private GUIItem getRemoveItem(int amount) {
|
||||||
|
ItemStackFactory factory = new ItemStackFactory(Remove.TYPE.get());
|
||||||
|
factory.setDurability(Remove.DATA.get());
|
||||||
|
factory.setDisplayName(Remove.NAME.get(player, new Object[]{
|
||||||
|
getItemName(), getCurrentAmount()
|
||||||
|
}));
|
||||||
|
factory.setLore(Remove.LORE.get(player, new Object[]{
|
||||||
|
getItemName(), getCurrentAmount()
|
||||||
|
}));
|
||||||
|
return new GUIItem(factory.toItemStack()) {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickType type) {
|
||||||
|
load(getCurrentAmount() - amount);
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private GUIItem getConfirmItem() {
|
||||||
|
ItemStackFactory factory = new ItemStackFactory(Confirm.TYPE.get());
|
||||||
|
factory.setDurability(Confirm.DATA.get());
|
||||||
|
factory.setDisplayName(Confirm.NAME.get(player, new Object[]{
|
||||||
|
getItemName(), getCurrentAmount(), getTotalMoney()
|
||||||
|
}));
|
||||||
|
factory.setLore(Confirm.LORE.get(player, new Object[]{
|
||||||
|
getItemName(), getCurrentAmount(), getTotalMoney()
|
||||||
|
}));
|
||||||
|
return new GUIItem(factory.toItemStack()) {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickType type) {
|
||||||
|
int amount = Math.min(getCurrentAmount(), Math.min(getRemainAmount(), getSellLimit() - getSoldAmount()));
|
||||||
|
if (amount > 0) {
|
||||||
|
double money = Main.getEconomyManager().sell(player, getItemPrice(), amount);
|
||||||
|
PluginMessages.SOLD.sendWithPlaceholders(player, new Object[]{
|
||||||
|
getItemName(), amount, money
|
||||||
|
});
|
||||||
|
}
|
||||||
|
player.closeInventory();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private GUIItem getCancelItem() {
|
||||||
|
ItemStackFactory factory = new ItemStackFactory(Cancel.TYPE.get());
|
||||||
|
factory.setDurability(Cancel.DATA.get());
|
||||||
|
factory.setDisplayName(Cancel.NAME.get());
|
||||||
|
factory.setLore(Cancel.LORE.get());
|
||||||
|
return new GUIItem(factory.toItemStack()) {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickType type) {
|
||||||
|
player.closeInventory();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getItemName() {
|
||||||
|
return this.item.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCurrentAmount() {
|
||||||
|
return currentAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getItemPrice() {
|
||||||
|
return this.item.getPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSellLimit() {
|
||||||
|
return this.item.getLimit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getTotalMoney() {
|
||||||
|
return getCurrentAmount() * getItemPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getRemainAmount() {
|
||||||
|
return this.itemData.getAmount();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSoldAmount() {
|
||||||
|
return this.itemData.getSold();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getAddableAmount() {
|
||||||
|
return Math.min(getRemainAmount(), getSellLimit() - getSoldAmount()) - getCurrentAmount();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void open(Player player, UserData userData, ItemData itemData,
|
||||||
|
ItemDepository configuration, DepositoryItem item) {
|
||||||
|
if (!Main.getEconomyManager().isInitialized()) return;
|
||||||
|
SellItemGUI gui = new SellItemGUI(player, userData, itemData, configuration, item);
|
||||||
|
gui.openGUI(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
package cc.carm.plugin.ultrabackpack.api.util;
|
package cc.carm.plugin.ultrastorehouse.util;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.api.util;
|
package cc.carm.plugin.ultrastorehouse.util;
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
+5
-2
@@ -1,6 +1,5 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.api.util;
|
package cc.carm.plugin.ultrastorehouse.util;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.api.util.ColorParser;
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -52,6 +51,10 @@ public class MessageUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<String> setPlaceholders(@Nullable CommandSender sender, List<String> messages, String[] params, Object[] values) {
|
||||||
|
return setPlaceholders(sender, setCustomParams(messages, params, values));
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> setCustomParams(List<String> messages, String param, Object value) {
|
public static List<String> setCustomParams(List<String> messages, String param, Object value) {
|
||||||
return setCustomParams(messages, new String[]{param}, new Object[]{value});
|
return setCustomParams(messages, new String[]{param}, new Object[]{value});
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.util;
|
package cc.carm.plugin.ultrastorehouse.util;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.util.gui;
|
package cc.carm.plugin.ultrastorehouse.util.gui;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import cc.carm.plugin.ultrabackpack.api.util.ColorParser;
|
import cc.carm.plugin.ultrastorehouse.util.ColorParser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.util.gui;
|
package cc.carm.plugin.ultrastorehouse.util.gui;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.util.gui;
|
package cc.carm.plugin.ultrastorehouse.util.gui;
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
import cc.carm.plugin.ultrastorehouse.Main;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.util.gui;
|
package cc.carm.plugin.ultrastorehouse.util.gui;
|
||||||
|
|
||||||
public enum GUIType {
|
public enum GUIType {
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
item-collected:
|
||||||
|
- "&f您收集了 &e%(item)&7x%(amount) &f,已自动放入到您的 &6%(depository) &f中。"
|
||||||
|
|
||||||
|
item-sold:
|
||||||
|
- "&f您出售了 &e%(item)&7x%(amount) &f,共赚取 &6%(money) &f元。"
|
||||||
|
|
||||||
|
no-space:
|
||||||
|
- "&f您背包内没有足够的空间取出物品!"
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
main: cc.carm.plugin.ultradepository.Main
|
||||||
|
name: UltraDepository
|
||||||
|
|
||||||
|
version: ${project.version}
|
||||||
|
description: ${project.parent.description}
|
||||||
|
website: ${project.parent.url}
|
||||||
|
|
||||||
|
author: CarmJos
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
|
||||||
|
"UltraDepository.use":
|
||||||
|
description: "超级仓库的基本使用权限"
|
||||||
|
default: true
|
||||||
|
|
||||||
|
"UltraDepository.auto":
|
||||||
|
description: "超级仓库的自动收集权限"
|
||||||
|
|
||||||
|
"UltraDepository.auto.enable":
|
||||||
|
description: "用于判断是否启用了自动收集功能"
|
||||||
|
|
||||||
|
"UltraDepository.admin":
|
||||||
|
description: "超级仓库的管理权限"
|
||||||
|
default: op
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
import cc.carm.plugin.ultrabackpack.configuration.gui.GUIActionType;
|
import cc.carm.plugin.ultrastorehouse.configuration.gui.GUIActionType;
|
||||||
import cc.carm.plugin.ultrabackpack.manager.ConfigManager;
|
import cc.carm.plugin.ultrastorehouse.manager.ConfigManager;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public class ActionReadTest {
|
|||||||
|
|
||||||
String prefix = actionString.substring(prefixStart + 1, prefixEnd);
|
String prefix = actionString.substring(prefixStart + 1, prefixEnd);
|
||||||
ClickType clickType = null;
|
ClickType clickType = null;
|
||||||
GUIActionType actionType = null;
|
GUIActionType actionType;
|
||||||
if (prefix.contains(":")) {
|
if (prefix.contains(":")) {
|
||||||
String[] args = prefix.split(":");
|
String[] args = prefix.split(":");
|
||||||
clickType = ConfigManager.readClickType(args[0]);
|
clickType = ConfigManager.readClickType(args[0]);
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>ultrabackpack-parent</artifactId>
|
|
||||||
<groupId>cc.carm.plugin</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>ultrabackpack-api</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>UltraBackpack-API</name>
|
|
||||||
<description>超级背包插件的公开接口部分。</description>
|
|
||||||
<url>https://github.com/CarmJos/UltraBackpack</url>
|
|
||||||
|
|
||||||
<developers>
|
|
||||||
<developer>
|
|
||||||
<id>CarmJos</id>
|
|
||||||
<name>Carm Jos</name>
|
|
||||||
<email>carm@carm.cc</email>
|
|
||||||
<url>https://www.carm.cc</url>
|
|
||||||
<roles>
|
|
||||||
<role>Main Developer</role>
|
|
||||||
</roles>
|
|
||||||
</developer>
|
|
||||||
</developers>
|
|
||||||
|
|
||||||
<licenses>
|
|
||||||
<license>
|
|
||||||
<name>GNU General Public License v3.0</name>
|
|
||||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
|
||||||
</license>
|
|
||||||
</licenses>
|
|
||||||
|
|
||||||
<issueManagement>
|
|
||||||
<system>GitHub Issues</system>
|
|
||||||
<url>https://github.com/CarmJos/UltraBackpack/issues</url>
|
|
||||||
</issueManagement>
|
|
||||||
|
|
||||||
<ciManagement>
|
|
||||||
<system>GitHub Actions</system>
|
|
||||||
<url>https://github.com/CarmJos/UltraBackpack/actions/workflows/maven.yml</url>
|
|
||||||
</ciManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cc.carm.lib</groupId>
|
|
||||||
<artifactId>easysql-api</artifactId>
|
|
||||||
<version>0.2.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.api;
|
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.api.manager.UBUserManager;
|
|
||||||
|
|
||||||
public class UltraBackpackAPI {
|
|
||||||
|
|
||||||
private static UBUserManager userManager;
|
|
||||||
|
|
||||||
public static void initialize(UBUserManager userManager) {
|
|
||||||
UltraBackpackAPI.userManager = userManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UBUserManager getUserManager() {
|
|
||||||
return userManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-29
@@ -1,29 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.api.data;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class UBContentsData {
|
|
||||||
|
|
||||||
private final Map<@NotNull String, @NotNull UBItemData> contents;
|
|
||||||
|
|
||||||
public UBContentsData(Map<@NotNull String, @NotNull UBItemData> contents) {
|
|
||||||
this.contents = contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull Map<String, UBItemData> getContents() {
|
|
||||||
return this.contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable UBItemData getItemData(@NotNull String itemType) {
|
|
||||||
return getContents().get(itemType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UBContentsData emptyContents() {
|
|
||||||
return new UBContentsData(new HashMap<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.api.data;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.sql.Date;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface UBUserData {
|
|
||||||
|
|
||||||
|
|
||||||
@NotNull UUID getUserUUID();
|
|
||||||
|
|
||||||
@Nullable UBContentsData getBackpack(String backpackID);
|
|
||||||
|
|
||||||
@NotNull Set<String> getBackpackIDs();
|
|
||||||
|
|
||||||
@Nullable UBItemData getItemData(@NotNull String backpackID, @NotNull String typeID);
|
|
||||||
|
|
||||||
@Nullable Integer getItemAmount(@NotNull String backpackID, @NotNull String typeID);
|
|
||||||
|
|
||||||
@Nullable Integer getItemSold(@NotNull String backpackID, @NotNull String typeID);
|
|
||||||
|
|
||||||
@Nullable Integer setItemAmount(@NotNull String backpackID, @NotNull String typeID, int amount);
|
|
||||||
|
|
||||||
@Nullable Integer setItemSold(@NotNull String backpackID, @NotNull String typeID, int amount);
|
|
||||||
|
|
||||||
@Nullable Integer addItemAmount(@NotNull String backpackID, @NotNull String typeID, int amount);
|
|
||||||
|
|
||||||
@Nullable Integer addItemSold(@NotNull String backpackID, @NotNull String typeID, int amount);
|
|
||||||
|
|
||||||
@Nullable Integer removeItemAmount(@NotNull String backpackID, @NotNull String typeID, int amount);
|
|
||||||
|
|
||||||
@Nullable Integer removeItemSold(@NotNull String backpackID, @NotNull String typeID, int amount);
|
|
||||||
|
|
||||||
Date getDate();
|
|
||||||
|
|
||||||
boolean isCurrentDay();
|
|
||||||
|
|
||||||
void checkoutDate();
|
|
||||||
|
|
||||||
void save() throws Exception;
|
|
||||||
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.api.manager;
|
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.api.data.UBUserData;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public interface UBUserManager {
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
UBUserData getData(@NotNull UUID userUUID);
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
UBUserData getData(@NotNull Player player);
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
UBUserData loadData(@NotNull UUID userUUID);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
|
|
||||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
|
||||||
<maven.deploy.skip>true</maven.deploy.skip>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<artifactId>ultrabackpack-parent</artifactId>
|
|
||||||
<groupId>cc.carm.plugin</groupId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>ultrabackpack-plugin</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>UltraBackpack-Plugin</name>
|
|
||||||
<description>超级背包插件的插件主体。</description>
|
|
||||||
<url>https://github.com/CarmJos/UltraBackpack</url>
|
|
||||||
|
|
||||||
<developers>
|
|
||||||
<developer>
|
|
||||||
<id>CarmJos</id>
|
|
||||||
<name>Carm Jos</name>
|
|
||||||
<email>carm@carm.cc</email>
|
|
||||||
<url>https://www.carm.cc</url>
|
|
||||||
</developer>
|
|
||||||
</developers>
|
|
||||||
|
|
||||||
<licenses>
|
|
||||||
<license>
|
|
||||||
<name>GNU General Public License v3.0</name>
|
|
||||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
|
||||||
</license>
|
|
||||||
</licenses>
|
|
||||||
|
|
||||||
<issueManagement>
|
|
||||||
<system>GitHub Issues</system>
|
|
||||||
<url>https://github.com/CarmJos/UltraBackpack/issues</url>
|
|
||||||
</issueManagement>
|
|
||||||
|
|
||||||
<ciManagement>
|
|
||||||
<system>GitHub Actions</system>
|
|
||||||
<url>https://github.com/CarmJos/UltraBackpack/actions/workflows/maven.yml</url>
|
|
||||||
</ciManagement>
|
|
||||||
|
|
||||||
<distributionManagement>
|
|
||||||
<downloadUrl>https://github.com/CarmJos/UltraBackpack/releases</downloadUrl>
|
|
||||||
</distributionManagement>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
|
|
||||||
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.parent.groupId}</groupId>
|
|
||||||
<artifactId>ultrabackpack-api</artifactId>
|
|
||||||
<version>${project.parent.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>cc.carm.lib</groupId>
|
|
||||||
<artifactId>easysql-beecp</artifactId>
|
|
||||||
<version>0.2.3</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.command;
|
|
||||||
|
|
||||||
public class BackpackCommand {
|
|
||||||
}
|
|
||||||
-139
@@ -1,139 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration;
|
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.api.util.ItemStackFactory;
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.values.ConfigSectionCast;
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.values.ConfigValue;
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.values.ConfigValueList;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PluginConfig {
|
|
||||||
|
|
||||||
public static final ConfigValue<Boolean> DEBUG = new ConfigValue<>(
|
|
||||||
"debug", Boolean.class
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final ConfigValue<String> STORAGE_METHOD = new ConfigValue<>(
|
|
||||||
"storage.method", String.class
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 收集配置
|
|
||||||
*/
|
|
||||||
public static class Collect {
|
|
||||||
|
|
||||||
public static final ConfigValue<Boolean> PICKUP = new ConfigValue<>(
|
|
||||||
"collect.pickup", Boolean.class, true
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final ConfigValue<Boolean> KILL = new ConfigValue<>(
|
|
||||||
"collect.kill", Boolean.class, true
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final ConfigValue<Boolean> BREAK = new ConfigValue<>(
|
|
||||||
"collect.break", Boolean.class, true
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用配置
|
|
||||||
*/
|
|
||||||
public static class General {
|
|
||||||
/**
|
|
||||||
* 针对每一件物品的额外介绍
|
|
||||||
* 将添加到背包界面内的物品上,避免重复配置
|
|
||||||
*/
|
|
||||||
public static final ConfigValueList<String> ADDITIONAL_LORE = new ConfigValueList<>(
|
|
||||||
"general.additional-lore", String.class
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提示玩家点击行为的介绍
|
|
||||||
* 将添加到背包界面内的物品上,避免重复配置
|
|
||||||
*/
|
|
||||||
public static final ConfigValueList<String> CLICK_LORE = new ConfigValueList<>(
|
|
||||||
"general.click-lore", String.class
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 售出界面的配置
|
|
||||||
*/
|
|
||||||
public static class SellGUI {
|
|
||||||
|
|
||||||
|
|
||||||
public static final ConfigValue<String> TITLE = new ConfigValue<>(
|
|
||||||
"general.sell-gui.title", String.class
|
|
||||||
);
|
|
||||||
|
|
||||||
public static class Items {
|
|
||||||
|
|
||||||
public static final ConfigSectionCast<ItemStack> ADD = new ConfigSectionCast<>(
|
|
||||||
"general.sell-gui.items.add",
|
|
||||||
section -> {
|
|
||||||
ItemStackFactory factory = new ItemStackFactory(
|
|
||||||
Material.matchMaterial(section.getString("type", "STONE")),
|
|
||||||
1, section.getInt("data", 0)
|
|
||||||
);
|
|
||||||
String name = section.getString("name");
|
|
||||||
List<String> lore = section.getStringList("lore");
|
|
||||||
if (name != null) factory.setDisplayName(name);
|
|
||||||
if (!lore.isEmpty()) factory.setLore(lore);
|
|
||||||
return factory.toItemStack();
|
|
||||||
}, new ItemStack(Material.STONE)
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final ConfigSectionCast<ItemStack> REMOVE = new ConfigSectionCast<>(
|
|
||||||
"general.sell-gui.items.remove",
|
|
||||||
section -> {
|
|
||||||
ItemStackFactory factory = new ItemStackFactory(
|
|
||||||
Material.matchMaterial(section.getString("type", "STONE")),
|
|
||||||
1, section.getInt("data", 0)
|
|
||||||
);
|
|
||||||
String name = section.getString("name");
|
|
||||||
List<String> lore = section.getStringList("lore");
|
|
||||||
if (name != null) factory.setDisplayName(name);
|
|
||||||
if (!lore.isEmpty()) factory.setLore(lore);
|
|
||||||
return factory.toItemStack();
|
|
||||||
}, new ItemStack(Material.STONE)
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final ConfigSectionCast<ItemStack> CONFIRM = new ConfigSectionCast<>(
|
|
||||||
"general.sell-gui.items.confirm",
|
|
||||||
section -> {
|
|
||||||
ItemStackFactory factory = new ItemStackFactory(
|
|
||||||
Material.matchMaterial(section.getString("type", "STONE")),
|
|
||||||
1, section.getInt("data", 0)
|
|
||||||
);
|
|
||||||
String name = section.getString("name");
|
|
||||||
List<String> lore = section.getStringList("lore");
|
|
||||||
if (name != null) factory.setDisplayName(name);
|
|
||||||
if (!lore.isEmpty()) factory.setLore(lore);
|
|
||||||
return factory.toItemStack();
|
|
||||||
}, new ItemStack(Material.STONE)
|
|
||||||
);
|
|
||||||
|
|
||||||
public static final ConfigSectionCast<ItemStack> CANCEL = new ConfigSectionCast<>(
|
|
||||||
"general.sell-gui.items.cancel",
|
|
||||||
section -> {
|
|
||||||
ItemStackFactory factory = new ItemStackFactory(
|
|
||||||
Material.matchMaterial(section.getString("type", "STONE")),
|
|
||||||
1, section.getInt("data", 0)
|
|
||||||
);
|
|
||||||
String name = section.getString("name");
|
|
||||||
List<String> lore = section.getStringList("lore");
|
|
||||||
if (name != null) factory.setDisplayName(name);
|
|
||||||
if (!lore.isEmpty()) factory.setLore(lore);
|
|
||||||
return factory.toItemStack();
|
|
||||||
}, new ItemStack(Material.STONE)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration;
|
|
||||||
|
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.message.ConfigMessageList;
|
|
||||||
|
|
||||||
public class PluginMessages {
|
|
||||||
|
|
||||||
public static final ConfigMessageList NO_SPACE = new ConfigMessageList("no-space");
|
|
||||||
}
|
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.message;
|
|
||||||
|
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.values.ConfigValue;
|
|
||||||
import cc.carm.plugin.ultrabackpack.manager.ConfigManager;
|
|
||||||
import cc.carm.plugin.ultrabackpack.api.util.MessageUtil;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
public class ConfigMessage extends ConfigValue<String> {
|
|
||||||
|
|
||||||
public ConfigMessage(String configSection) {
|
|
||||||
this(configSection, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfigMessage(String configSection, String defaultValue) {
|
|
||||||
super(ConfigManager.getMessageConfig(), configSection, String.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void send(CommandSender sender) {
|
|
||||||
MessageUtil.send(sender, get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendWithPlaceholders(CommandSender sender) {
|
|
||||||
MessageUtil.sendWithPlaceholders(sender, get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendWithPlaceholders(CommandSender sender, String[] params, Object[] values) {
|
|
||||||
MessageUtil.sendWithPlaceholders(sender, Collections.singletonList(get()), params, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.configuration.message;
|
|
||||||
|
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.values.ConfigValueList;
|
|
||||||
import cc.carm.plugin.ultrabackpack.manager.ConfigManager;
|
|
||||||
import cc.carm.plugin.ultrabackpack.api.util.MessageUtil;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public class ConfigMessageList extends ConfigValueList<String> {
|
|
||||||
|
|
||||||
public ConfigMessageList(String configSection) {
|
|
||||||
super(ConfigManager.getMessageConfig(), configSection, String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfigMessageList(String configSection, String[] defaultValue) {
|
|
||||||
super(ConfigManager.getMessageConfig(), configSection, String.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void send(@Nullable CommandSender sender) {
|
|
||||||
MessageUtil.send(sender, get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendWithPlaceholders(@Nullable CommandSender sender) {
|
|
||||||
MessageUtil.sendWithPlaceholders(sender, get());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendWithPlaceholders(@Nullable CommandSender sender, String[] params, Object[] values) {
|
|
||||||
MessageUtil.sendWithPlaceholders(sender, get(), params, values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-139
@@ -1,139 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.manager;
|
|
||||||
|
|
||||||
import cc.carm.plugin.ultrabackpack.Main;
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.backpack.BackpackConfiguration;
|
|
||||||
import cc.carm.plugin.ultrabackpack.configuration.backpack.BackpackItem;
|
|
||||||
import cc.carm.plugin.ultrabackpack.data.UserData;
|
|
||||||
import com.google.common.collect.HashMultimap;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class BackpackManager {
|
|
||||||
|
|
||||||
public HashMap<@NotNull String, @NotNull BackpackConfiguration> backpacks;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用于记录储存每个物品ID所对应的背包ID
|
|
||||||
*/
|
|
||||||
public HashMultimap<@NotNull String, @NotNull String> itemMap;
|
|
||||||
|
|
||||||
public BackpackManager() {
|
|
||||||
this.backpacks = new HashMap<>();
|
|
||||||
this.itemMap = HashMultimap.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull HashMap<@NotNull String, @NotNull BackpackConfiguration> getBackpacks() {
|
|
||||||
return backpacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasBackpack(@NotNull String backpackID) {
|
|
||||||
return getBackpacks().containsKey(backpackID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasItem(@NotNull String backpackID, @NotNull String itemTypeID) {
|
|
||||||
BackpackConfiguration configuration = getBackpack(backpackID);
|
|
||||||
if (configuration == null) return false;
|
|
||||||
return configuration.getItems().containsKey(itemTypeID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable BackpackConfiguration getBackpack(@NotNull String backpackID) {
|
|
||||||
return getBackpacks().get(backpackID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<BackpackConfiguration> getItemBackpacks(ItemStack itemStack) {
|
|
||||||
return getItemBackpacks(itemStack.getType(), itemStack.getDurability());
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Set<BackpackConfiguration> getItemBackpacks(Material material, int data) {
|
|
||||||
return Optional.ofNullable(itemMap.get(getItemTypeID(material, data)))
|
|
||||||
.map(set -> set.stream().map(this::getBackpack).collect(Collectors.toSet()))
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<BackpackConfiguration> getPlayerUsableBackpack(Player player, ItemStack itemStack) {
|
|
||||||
String typeID = getItemTypeID(itemStack);
|
|
||||||
return getItemBackpacks(itemStack).stream().filter(configuration -> {
|
|
||||||
int currentAmount = Optional.ofNullable(Main.getUserManager().getData(player)
|
|
||||||
.getItemAmount(configuration.getIdentifier(), typeID)).orElse(0);
|
|
||||||
int backpackCapacity = configuration.getCapacity().getPlayerCapacity(player);
|
|
||||||
return currentAmount + itemStack.getAmount() <= backpackCapacity;
|
|
||||||
}).collect(Collectors.toSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull String getItemTypeID(Material material, int data) {
|
|
||||||
return material.name() + ":" + data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull String getItemTypeID(ItemStack itemStack) {
|
|
||||||
return getItemTypeID(itemStack.getType(), itemStack.getDurability());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<ItemStack> collectItem(Player player, Collection<ItemStack> items) {
|
|
||||||
if (!Main.getUserManager().isCollectEnabled(player)) return new ArrayList<>();
|
|
||||||
else return items.stream().filter(item -> collectItem(player, item)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean collectItem(Player player, ItemStack item) {
|
|
||||||
if (!Main.getUserManager().isCollectEnabled(player)) return false;
|
|
||||||
Set<BackpackConfiguration> usableBackpacks = getPlayerUsableBackpack(player, item);
|
|
||||||
if (usableBackpacks.size() < 1) return false;
|
|
||||||
BackpackConfiguration configuration = usableBackpacks.stream().findFirst().orElse(null);
|
|
||||||
|
|
||||||
String typeID = getItemTypeID(item);
|
|
||||||
UserData data = Main.getUserManager().getData(player);
|
|
||||||
int itemAmount = item.getAmount();
|
|
||||||
data.addItemAmount(configuration.getIdentifier(), typeID, itemAmount);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得某背包配置中的某件物品单价,最低为0。
|
|
||||||
*
|
|
||||||
* @param backpackID 背包ID
|
|
||||||
* @param itemTypeID 物品ID
|
|
||||||
* @return 若为空,则该背包或该物品不存在。
|
|
||||||
*/
|
|
||||||
public @Nullable Double getItemPrice(@NotNull String backpackID, @NotNull String itemTypeID) {
|
|
||||||
BackpackConfiguration configuration = getBackpack(backpackID);
|
|
||||||
if (configuration == null) return null;
|
|
||||||
BackpackItem item = configuration.getItems().get(itemTypeID);
|
|
||||||
if (item == null) return null;
|
|
||||||
return item.getPrice();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得某背包配置中的某件物品每日售出限制,最低为0。
|
|
||||||
*
|
|
||||||
* @param backpackID 背包ID
|
|
||||||
* @param itemTypeID 物品ID
|
|
||||||
* @return 若为空,则该背包或该物品不存在。
|
|
||||||
*/
|
|
||||||
public @Nullable Integer getItemSellLimit(@NotNull String backpackID, @NotNull String itemTypeID) {
|
|
||||||
BackpackConfiguration configuration = getBackpack(backpackID);
|
|
||||||
if (configuration == null) return null;
|
|
||||||
BackpackItem item = configuration.getItems().get(itemTypeID);
|
|
||||||
if (item == null) return null;
|
|
||||||
return item.getLimit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得某背包配置中的某件物品每日售出限制,最低为0。
|
|
||||||
*
|
|
||||||
* @param backpack 背包
|
|
||||||
* @param itemTypeID 物品ID
|
|
||||||
* @return 若为空,则该背包或该物品不存在。
|
|
||||||
*/
|
|
||||||
public @Nullable Integer getItemSellLimit(@NotNull BackpackConfiguration backpack, @NotNull String itemTypeID) {
|
|
||||||
BackpackItem item = backpack.getItems().get(itemTypeID);
|
|
||||||
if (item == null) return null;
|
|
||||||
return item.getLimit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.ui;
|
|
||||||
|
|
||||||
public class BackpackGUI {
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package cc.carm.plugin.ultrabackpack.ui;
|
|
||||||
|
|
||||||
public class SellItemGUI {
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
COLLECT: "&f您收集了 &e%(item)&7x%(amount) &f,已自动放入到您的 &6%(backpack) &f中。"
|
|
||||||
SELL: "&f您出售了 &e%(item)&7x%(amount) &f,共赚取 &6%(money) &f元。"
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
main: cc.carm.plugin.ultrabackpack.Main
|
|
||||||
name: UltraBackpack
|
|
||||||
|
|
||||||
version: ${project.version}
|
|
||||||
description: ${project.parent.description}
|
|
||||||
website: ${project.parent.url}
|
|
||||||
|
|
||||||
author: CarmJos
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
|
|
||||||
"UltraBackpack.use":
|
|
||||||
description: "超级背包的基本使用权限"
|
|
||||||
default: true
|
|
||||||
|
|
||||||
"UltraBackpack.auto":
|
|
||||||
description: "超级背包的自动收集权限"
|
|
||||||
|
|
||||||
"UltraBackpack.auto.enable":
|
|
||||||
description: "用于判断是否启用了自动收集功能"
|
|
||||||
|
|
||||||
"UltraBackpack.admin":
|
|
||||||
description: "超级背包的管理权限"
|
|
||||||
default: op
|
|
||||||
Reference in New Issue
Block a user