Skip to content

Commit 9509dd2

Browse files
committed
Del-home command literal added.
Signed-off-by: Pavel Erokhin (MairwunNx) <MairwunNx@gmail.com>
1 parent 3231d1a commit 9509dd2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/main/kotlin/com/mairwunnx/projectessentials/home/commands/CommandLiterals.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,22 @@ inline val setHomeLiteral: LiteralArgumentBuilder<CommandSource>
3636
"home", StringArgumentType.string()
3737
).executes { SetHomeCommand.process(it) }
3838
).executes { SetHomeCommand.process(it) }
39+
40+
inline val delHomeLiteral: LiteralArgumentBuilder<CommandSource>
41+
get() = literal<CommandSource>("del-home").then(
42+
Commands.argument(
43+
"home", StringArgumentType.string()
44+
).suggests { ctx, builder ->
45+
ISuggestionProvider.suggest(
46+
getConfigurationByName<HomeConfiguration>(
47+
"home"
48+
).take().let { model ->
49+
if (ctx.isPlayerSender()) {
50+
model.users.asSequence().find {
51+
it.name == ctx.getPlayer()!!.name.string || it.uuid == ctx.getPlayer()!!.uniqueID.toString()
52+
}?.homes?.asSequence()?.map { it.home }?.toList() ?: emptyList<String>()
53+
} else emptyList<String>()
54+
}, builder
55+
)
56+
}.executes { DelHomeCommand.process(it) }
57+
).executes { DelHomeCommand.process(it) }

0 commit comments

Comments
 (0)