From a9d26e179c1b36a12d053795c2f5520f7e8a3a8e Mon Sep 17 00:00:00 2001 From: carm Date: Sun, 19 Feb 2023 03:32:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(papi):=20=E6=8F=90=E4=BE=9B=E4=BE=BF?= =?UTF-8?q?=E6=8D=B7=E7=9A=84PlaceholderAPI=E5=8F=98=E9=87=8F=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E7=B1=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 24 +++++++++ base/color/pom.xml | 2 +- base/command/pom.xml | 2 +- base/conf/pom.xml | 2 +- base/database/pom.xml | 2 +- base/gui/pom.xml | 2 +- base/listener/pom.xml | 2 +- base/main/pom.xml | 2 +- base/messages/pom.xml | 21 ++++++++ base/storage/pom.xml | 2 +- base/utils/pom.xml | 2 +- collection/all/pom.xml | 2 +- collection/bom/pom.xml | 2 +- collection/common/pom.xml | 2 +- extension/gh-checker/pom.xml | 2 +- extension/papi/pom.xml | 2 +- .../lib/easyplugin/papi/EasyPlaceholder.java | 54 +++++++++++++++++-- .../papi/expansion/SectionExpansion.java | 40 ++++++++++++++ extension/vault/pom.xml | 2 +- pom.xml | 5 +- 20 files changed, 154 insertions(+), 20 deletions(-) create mode 100644 base/messages/pom.xml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fe26668..302003a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -108,3 +108,27 @@ jobs: git add -A git commit -m "API Document generated." git push origin HEAD:gh-pages --force + + central-deploy: + name: "Deploy Project (Central)" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: "Set up JDK" + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + cache: maven + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import + gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase + + - name: "Central Deploy" + run: mvn -B -Possrh deploy --file pom.xml -DskipTests + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USER }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_PASS }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} diff --git a/base/color/pom.xml b/base/color/pom.xml index ec863a0..cfe6444 100644 --- a/base/color/pom.xml +++ b/base/color/pom.xml @@ -6,7 +6,7 @@ cc.carm.lib easyplugin-parent - 1.4.20 + 1.5.0 ../../pom.xml diff --git a/base/command/pom.xml b/base/command/pom.xml index 5acbd45..6156543 100644 --- a/base/command/pom.xml +++ b/base/command/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/base/conf/pom.xml b/base/conf/pom.xml index 3357341..b2386c1 100644 --- a/base/conf/pom.xml +++ b/base/conf/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/base/database/pom.xml b/base/database/pom.xml index db45da4..b7498e9 100644 --- a/base/database/pom.xml +++ b/base/database/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/base/gui/pom.xml b/base/gui/pom.xml index d719f77..034ec6c 100644 --- a/base/gui/pom.xml +++ b/base/gui/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/base/listener/pom.xml b/base/listener/pom.xml index 582bb2c..9490a78 100644 --- a/base/listener/pom.xml +++ b/base/listener/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/base/main/pom.xml b/base/main/pom.xml index 77253df..a5de375 100644 --- a/base/main/pom.xml +++ b/base/main/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/base/messages/pom.xml b/base/messages/pom.xml new file mode 100644 index 0000000..80ce35f --- /dev/null +++ b/base/messages/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + cc.carm.lib + easyplugin-parent + 1.5.0 + ../../pom.xml + + + easyplugin-messages + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/base/storage/pom.xml b/base/storage/pom.xml index 345784f..0fb05ff 100644 --- a/base/storage/pom.xml +++ b/base/storage/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/base/utils/pom.xml b/base/utils/pom.xml index 84f6268..f65428a 100644 --- a/base/utils/pom.xml +++ b/base/utils/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/collection/all/pom.xml b/collection/all/pom.xml index e4783f9..7e86b53 100644 --- a/collection/all/pom.xml +++ b/collection/all/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/collection/bom/pom.xml b/collection/bom/pom.xml index 9557b8b..822108c 100644 --- a/collection/bom/pom.xml +++ b/collection/bom/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/collection/common/pom.xml b/collection/common/pom.xml index fb81e08..4867879 100644 --- a/collection/common/pom.xml +++ b/collection/common/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/extension/gh-checker/pom.xml b/extension/gh-checker/pom.xml index 38d7db6..b8914f3 100644 --- a/extension/gh-checker/pom.xml +++ b/extension/gh-checker/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/extension/papi/pom.xml b/extension/papi/pom.xml index 2765946..4207d87 100644 --- a/extension/papi/pom.xml +++ b/extension/papi/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/extension/papi/src/main/java/cc/carm/lib/easyplugin/papi/EasyPlaceholder.java b/extension/papi/src/main/java/cc/carm/lib/easyplugin/papi/EasyPlaceholder.java index ca6f40c..a05909a 100644 --- a/extension/papi/src/main/java/cc/carm/lib/easyplugin/papi/EasyPlaceholder.java +++ b/extension/papi/src/main/java/cc/carm/lib/easyplugin/papi/EasyPlaceholder.java @@ -9,8 +9,10 @@ import org.bukkit.plugin.java.JavaPlugin; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import java.util.function.Supplier; public class EasyPlaceholder extends PlaceholderExpansion { @@ -108,20 +110,66 @@ public class EasyPlaceholder extends PlaceholderExpansion { * 处理变量并返回对应内容。 * * @param identifier 该变量的标识符 - * @param handler 该组变量的处理器,返回值将会被转换为字符串。 + * @param handler 该变量的处理器,返回值将会被转换为字符串。 * @param aliases 该变量的别称 * @return {@link EasyPlaceholder} */ - public final EasyPlaceholder handle(String identifier, @NotNull PlaceholderHandler handler, @NotNull String... aliases) { + public final EasyPlaceholder handle(@NotNull String identifier, @NotNull PlaceholderHandler handler, + @NotNull String... aliases) { this.rootExpansion.handle(identifier, handler, aliases); return this; } + /** + * 处理变量并返回对应内容。 + * + * @param identifier 该变量的标识符 + * @param handler 该变量的处理器,返回值将会被转换为字符串。 + * @param paramsConsumer 用于提供该变量的可用参数 + * @param aliases 该变量的别称 + * @return {@link EasyPlaceholder} + */ + public final EasyPlaceholder handle(@NotNull String identifier, @NotNull PlaceholderHandler handler, + @NotNull Consumer> paramsConsumer, @NotNull String... aliases) { + this.rootExpansion.handle(identifier, handler, paramsConsumer, aliases); + return this; + } + + /** + * 处理变量并返回对应内容。 + * + * @param identifier 该变量的标识符 + * @param handler 该变量的处理器,返回值将会被转换为字符串。 + * @param availableParams 该变量的可用参数 + * @param aliases 该变量的别称 + * @return {@link EasyPlaceholder} + */ + public final EasyPlaceholder handle(@NotNull String identifier, @NotNull PlaceholderHandler handler, + @NotNull List availableParams, @NotNull String... aliases) { + this.rootExpansion.handle(identifier, handler, availableParams, aliases); + return this; + } + + /** + * 处理变量并返回对应内容。 + * + * @param identifier 该变量的标识符 + * @param handler 该变量的处理器,返回值将会被转换为字符串。 + * @param availableParams 该变量的可用参数 + * @param aliases 该变量的别称 + * @return {@link EasyPlaceholder} + */ + public final EasyPlaceholder handle(String identifier, @NotNull PlaceholderHandler handler, + @NotNull Supplier> availableParams, @NotNull String... aliases) { + this.rootExpansion.handle(identifier, handler, availableParams, aliases); + return this; + } + /** * 处理一组变量。 * * @param section 该组变量的标识符 - * @param consumer 该组变量的处理器 + * @param consumer 该组变量的处理器操作方法 *
在其中可调用 {@link SectionExpansion#handle(String, PlaceholderHandler, String...)} 方法处理子变量, *
或者调用 {@link SectionExpansion#handleSection(String, Consumer, String...)} 方法处理下一层组变量 * @param aliases 该变量的别称 diff --git a/extension/papi/src/main/java/cc/carm/lib/easyplugin/papi/expansion/SectionExpansion.java b/extension/papi/src/main/java/cc/carm/lib/easyplugin/papi/expansion/SectionExpansion.java index 0790793..97a26d7 100644 --- a/extension/papi/src/main/java/cc/carm/lib/easyplugin/papi/expansion/SectionExpansion.java +++ b/extension/papi/src/main/java/cc/carm/lib/easyplugin/papi/expansion/SectionExpansion.java @@ -61,11 +61,26 @@ public class SectionExpansion implements EasyExpansion { placeholder.getAliases().forEach(alias -> this.aliasesMap.put(alias.toLowerCase(), name)); } + /** + * 处理变量并返回对应内容。 + * + * @param identifier 该变量的标识符 + * @param handler 该变量的处理器,返回值将会被转换为字符串。 + * @param aliases 该变量的别称 + */ public final void handle(@NotNull String identifier, @NotNull PlaceholderHandler handler, @NotNull String... aliases) { handle(identifier, handler, Collections.emptyList(), aliases); } + /** + * 处理变量并返回对应内容。 + * + * @param identifier 该变量的标识符 + * @param handler 该变量的处理器,返回值将会被转换为字符串。 + * @param paramsConsumer 用于提供该变量的可用参数 + * @param aliases 该变量的别称 + */ public final void handle(@NotNull String identifier, @NotNull PlaceholderHandler handler, @NotNull Consumer> paramsConsumer, @NotNull String... aliases) { handle(identifier, handler, () -> { @@ -75,11 +90,27 @@ public class SectionExpansion implements EasyExpansion { }, aliases); } + /** + * 处理变量并返回对应内容。 + * + * @param identifier 该变量的标识符 + * @param handler 该变量的处理器,返回值将会被转换为字符串。 + * @param availableParams 该变量的可用参数 + * @param aliases 该变量的别称 + */ public final void handle(@NotNull String identifier, @NotNull PlaceholderHandler handler, @NotNull List availableParams, @NotNull String... aliases) { handle(identifier, handler, () -> availableParams, aliases); } + /** + * 处理变量并返回对应内容。 + * + * @param identifier 该变量的标识符 + * @param handler 该变量的处理器,返回值将会被转换为字符串。 + * @param availableParams 该变量的可用参数 + * @param aliases 该变量的别称 + */ public final void handle(@NotNull String identifier, @NotNull PlaceholderHandler handler, @NotNull Supplier> availableParams, @NotNull String... aliases) { register(new SubExpansion(this, identifier, aliases) { @@ -95,6 +126,15 @@ public class SectionExpansion implements EasyExpansion { }); } + /** + * 处理一组变量。 + * + * @param section 该组变量的标识符 + * @param consumer 该组变量的处理器操作方法 + *
在其中可调用 {@link SectionExpansion#handle(String, PlaceholderHandler, String...)} 方法处理子变量, + *
或者调用 {@link SectionExpansion#handleSection(String, Consumer, String...)} 方法处理下一层组变量 + * @param aliases 该变量的别称 + */ public final void handleSection(@NotNull String section, @NotNull Consumer consumer, @NotNull String... aliases) { SectionExpansion sectionExpansion = new SectionExpansion(getRoot(), section, aliases); diff --git a/extension/vault/pom.xml b/extension/vault/pom.xml index 8d27610..720b14d 100644 --- a/extension/vault/pom.xml +++ b/extension/vault/pom.xml @@ -5,7 +5,7 @@ easyplugin-parent cc.carm.lib - 1.4.20 + 1.5.0 ../../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 28008a8..a6f0093 100644 --- a/pom.xml +++ b/pom.xml @@ -15,12 +15,14 @@ cc.carm.lib easyplugin-parent pom - 1.4.20 + 1.5.0 + base/color base/utils base/main base/conf + base/messages base/gui base/command base/storage @@ -34,7 +36,6 @@ collection/all collection/bom collection/common - base/color