From 439b6fa60750c6a0acc0b7ef9dff99e027348487 Mon Sep 17 00:00:00 2001 From: nitu2003 Date: Sat, 3 Apr 2021 17:16:15 +0800 Subject: [PATCH] Fix package visibility errors 1. Fix package visibility errors and renamed the package of test classes. 2. renamed LiteralArgumentBuilder(String) and LiteralArgumentBuilder(String, Function) to newLiteralArgBuilder(String) and newLiteralArgBuilder(String, Function) 3. bump version to v1.1 Signed-off-by: nitu2003 --- build.gradle.kts | 2 +- .../cn/taskeren/brigadierx/BrigadierX.kt | 28 +++++++++---------- .../brigadier}/ArgumentBuilderSample.kt | 6 +++- 3 files changed, 20 insertions(+), 16 deletions(-) rename src/test/kotlin/cn/taskeren/{brigadierx => sample/brigadier}/ArgumentBuilderSample.kt (91%) diff --git a/build.gradle.kts b/build.gradle.kts index ced853e..c6b45fb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "cn.taskeren.brigadierx" -version = "1.0-SNAPSHOT" +version = "1.1-SNAPSHOT" repositories { maven("http://maven.aliyun.com/nexus/content/groups/public/") diff --git a/src/main/kotlin/cn/taskeren/brigadierx/BrigadierX.kt b/src/main/kotlin/cn/taskeren/brigadierx/BrigadierX.kt index f4c0f92..113d7e8 100644 --- a/src/main/kotlin/cn/taskeren/brigadierx/BrigadierX.kt +++ b/src/main/kotlin/cn/taskeren/brigadierx/BrigadierX.kt @@ -13,12 +13,12 @@ import com.mojang.brigadier.context.CommandContext /** * LiteralArgumentBuilder 构造方法语法糖 */ -internal fun LiteralArgumentBuilder(name: String) = LiteralArgumentBuilder.literal(name) +fun newLiteralArgBuilder(name: String): LiteralArgumentBuilder = LiteralArgumentBuilder.literal(name) /** * LiteralArgumentBuilder 构造方法语法糖 */ -internal fun LiteralArgumentBuilder(name: String, func: LiteralArgumentBuilder.() -> Unit) = LiteralArgumentBuilder.literal(name).apply { func.invoke(this) } +fun newLiteralArgBuilder(name: String, func: LiteralArgumentBuilder.() -> Unit): LiteralArgumentBuilder = LiteralArgumentBuilder.literal(name).apply { func.invoke(this) } /** * 注册指令 @@ -27,8 +27,8 @@ internal fun LiteralArgumentBuilder(name: String, func: LiteralArgumentBuild * @param func 传入根命令,进行命令注册 * @return Dispatcher */ -internal fun CommandDispatcher.register(name: String, func: LiteralArgumentBuilder.() -> Unit): CommandDispatcher { - val rootCommand = LiteralArgumentBuilder(name) +fun CommandDispatcher.register(name: String, func: LiteralArgumentBuilder.() -> Unit): CommandDispatcher { + val rootCommand = newLiteralArgBuilder(name) func.invoke(rootCommand) this.register(rootCommand) return this @@ -40,26 +40,26 @@ internal fun CommandDispatcher.register(name: String, func: LiteralArgume * * ================================== */ -internal fun LiteralArgumentBuilder.literal(name: String): LiteralArgumentBuilder { - val subcommand = LiteralArgumentBuilder(name) +fun LiteralArgumentBuilder.literal(name: String): LiteralArgumentBuilder { + val subcommand = newLiteralArgBuilder(name) this.then(subcommand) return subcommand } -internal fun LiteralArgumentBuilder.literal(name: String, func: LiteralArgumentBuilder.() -> Unit): LiteralArgumentBuilder { +fun LiteralArgumentBuilder.literal(name: String, func: LiteralArgumentBuilder.() -> Unit): LiteralArgumentBuilder { val subcommand = LiteralArgumentBuilder.literal(name) func.invoke(subcommand) this.then(subcommand) return subcommand } -internal fun RequiredArgumentBuilder.literal(name: String): LiteralArgumentBuilder { +fun RequiredArgumentBuilder.literal(name: String): LiteralArgumentBuilder { val subcommand = LiteralArgumentBuilder.literal(name) this.then(subcommand) return subcommand } -internal fun RequiredArgumentBuilder.literal(name: String, func: LiteralArgumentBuilder.() -> Unit): LiteralArgumentBuilder { +fun RequiredArgumentBuilder.literal(name: String, func: LiteralArgumentBuilder.() -> Unit): LiteralArgumentBuilder { val subcommand = LiteralArgumentBuilder.literal(name) func.invoke(subcommand) this.then(subcommand) @@ -72,26 +72,26 @@ internal fun RequiredArgumentBuilder.literal(name: String, func: Li * * ================================== */ -internal fun LiteralArgumentBuilder.argument(name: String, type: ArgumentType): RequiredArgumentBuilder { +fun LiteralArgumentBuilder.argument(name: String, type: ArgumentType): RequiredArgumentBuilder { val rab = RequiredArgumentBuilder.argument(name, type) this.then(rab) return rab } -internal fun LiteralArgumentBuilder.argument(name: String, type: ArgumentType, func: RequiredArgumentBuilder.() -> Unit): RequiredArgumentBuilder { +fun LiteralArgumentBuilder.argument(name: String, type: ArgumentType, func: RequiredArgumentBuilder.() -> Unit): RequiredArgumentBuilder { val rab = RequiredArgumentBuilder.argument(name, type) func.invoke(rab) this.then(rab) return rab } -internal fun RequiredArgumentBuilder.argument(name: String, type: ArgumentType): RequiredArgumentBuilder { +fun RequiredArgumentBuilder.argument(name: String, type: ArgumentType): RequiredArgumentBuilder { val rab = RequiredArgumentBuilder.argument(name, type) this.then(rab) return rab } -internal fun RequiredArgumentBuilder.argument(name: String, type: ArgumentType, func: RequiredArgumentBuilder.() -> Unit): RequiredArgumentBuilder { +fun RequiredArgumentBuilder.argument(name: String, type: ArgumentType, func: RequiredArgumentBuilder.() -> Unit): RequiredArgumentBuilder { val rab = RequiredArgumentBuilder.argument(name, type) func.invoke(rab) this.then(rab) @@ -105,7 +105,7 @@ internal fun RequiredArgumentBuilder.argument(name: String, t * * ================================== */ -internal fun > ArgumentBuilder.executex(func: (CommandContext) -> Any) { +fun > ArgumentBuilder.executex(func: (CommandContext) -> Any) { this.executes { func.invoke(it) Command.SINGLE_SUCCESS diff --git a/src/test/kotlin/cn/taskeren/brigadierx/ArgumentBuilderSample.kt b/src/test/kotlin/cn/taskeren/sample/brigadier/ArgumentBuilderSample.kt similarity index 91% rename from src/test/kotlin/cn/taskeren/brigadierx/ArgumentBuilderSample.kt rename to src/test/kotlin/cn/taskeren/sample/brigadier/ArgumentBuilderSample.kt index fa8fad1..15974de 100644 --- a/src/test/kotlin/cn/taskeren/brigadierx/ArgumentBuilderSample.kt +++ b/src/test/kotlin/cn/taskeren/sample/brigadier/ArgumentBuilderSample.kt @@ -1,5 +1,9 @@ -package cn.taskeren.brigadierx +package cn.taskeren.sample.brigadier +import cn.taskeren.brigadierx.argument +import cn.taskeren.brigadierx.executex +import cn.taskeren.brigadierx.literal +import cn.taskeren.brigadierx.register import com.mojang.brigadier.CommandDispatcher import com.mojang.brigadier.arguments.IntegerArgumentType import com.mojang.brigadier.arguments.StringArgumentType