1
mirror of https://github.com/CarmJos/EasyPlugin.git synced 2024-09-19 19:25:45 +00:00

feat(utils): 独立基本类到单独项目中,便于使用。

This commit is contained in:
Carm Jos 2022-12-13 00:29:20 +08:00
parent d9b0689e63
commit 437d0ffb32
20 changed files with 83 additions and 29 deletions

View File

@ -36,8 +36,14 @@
### 主要部分 (`/base`)
- Utils [`easyplugin-utils`](base/utils)
- 通用工具类模块该模块中的内容支持在Bungee、Bukkit使用。
- 本模块提供
- `ColorParser` 支持RGB颜色与RGB渐变色的颜色解析器。
- `EasyCooldown` 快速创造一个冷却时间的管理器。
- `JarResourceUtils` 快速读取Jar包内容的工具类。
- Main [`easyplugin-main`](base/main)
- 主要接口模块,提供了方便的插件入口类与相关工具类。
- 主要接口模块,提供了方便的插件入口类与相关工具类。
- Command [`easyplugin-command`](base/command)
- 指令接口模块便于快速进行子指令的实现并提供单独的TabComplete方法。
- 随本项目提供了 `SimpleCompleter` 类,用于快速创建补全的内容列表。

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -22,7 +22,7 @@
<packaging>jar</packaging>
<name>EasyPlugin-Main</name>
<description>轻松插件主要接口模块,包含便的插件入口类与相关工具类。</description>
<description>轻松插件主要接口模块,包含便的插件入口类与相关工具类。</description>
<url>https://github.com/CarmJos/EasyPlugin</url>
<developers>
@ -53,6 +53,13 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>easyplugin-utils</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

51
base/utils/pom.xml Normal file
View File

@ -0,0 +1,51 @@
<?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">
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.source>${project.jdk.version}</maven.compiler.source>
<maven.compiler.target>${project.jdk.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties>
<artifactId>easyplugin-utils</artifactId>
<name>EasyPlugin-Utils</name>
<description>轻松插件工具类模块该模块中的内容支持在Bungee、Bukkit使用。</description>
<url>https://github.com/CarmJos/EasyPlugin</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>The MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/CarmJos/EasyPlugin/issues</url>
</issueManagement>
<ciManagement>
<system>GitHub Actions</system>
<url>https://github.com/CarmJos/EasyPlugin/actions/workflows/maven.yml</url>
</ciManagement>
</project>

View File

@ -1,12 +1,10 @@
package cc.carm.lib.easyplugin.utils;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.text.NumberFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Function;
@ -82,7 +80,7 @@ public class EasyCooldown<P, K> {
return numberFormatter.format((double) cooldownMillis / 1000D);
}
public static NumberFormat createFormatter(Consumer<NumberFormat> consumer) {
public static NumberFormat createFormatter(@NotNull Consumer<NumberFormat> consumer) {
NumberFormat format = NumberFormat.getInstance();
consumer.accept(format);
return format;
@ -92,13 +90,4 @@ public class EasyCooldown<P, K> {
return createFormatter((f) -> f.setMaximumFractionDigits(2));
}
public static EasyCooldown<Player, UUID> playerCooldown(Function<Player, Long> durationProvider) {
return new EasyCooldown<Player, UUID>(Player::getUniqueId) {
@Override
public long getDuration(@NotNull Player provider) {
return durationProvider.apply(provider);
}
};
}
}

View File

@ -6,7 +6,7 @@ import java.util.regex.Matcher;
import static cc.carm.lib.easyplugin.utils.ColorParser.*;
public class ColorTest {
public class ColorParseTest {
@Test

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.4.17</version>
<version>1.4.18</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -15,8 +15,9 @@
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-parent</artifactId>
<packaging>pom</packaging>
<version>1.4.17</version>
<version>1.4.18</version>
<modules>
<module>base/utils</module>
<module>base/main</module>
<module>base/conf</module>