File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
src/main/kotlin/com/mairwunnx/projectessentials/home/commands Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ package com.mairwunnx.projectessentials.home.commands
2+
3+ import com.mairwunnx.projectessentials.core.api.v1.configuration.ConfigurationAPI.getConfigurationByName
4+ import com.mairwunnx.projectessentials.core.api.v1.extensions.getPlayer
5+ import com.mairwunnx.projectessentials.core.api.v1.extensions.isPlayerSender
6+ import com.mairwunnx.projectessentials.home.configurations.HomeConfiguration
7+ import com.mojang.brigadier.arguments.StringArgumentType
8+ import com.mojang.brigadier.builder.LiteralArgumentBuilder
9+ import com.mojang.brigadier.builder.LiteralArgumentBuilder.literal
10+ import net.minecraft.command.CommandSource
11+ import net.minecraft.command.Commands
12+ import net.minecraft.command.ISuggestionProvider
13+
14+ val homeLiteral: LiteralArgumentBuilder <CommandSource > =
15+ literal<CommandSource >(" home" ).then(
16+ Commands .argument(
17+ " home" , StringArgumentType .string()
18+ ).suggests { ctx, builder ->
19+ ISuggestionProvider .suggest(
20+ getConfigurationByName<HomeConfiguration >(
21+ " home"
22+ ).take().let { model ->
23+ if (ctx.isPlayerSender()) {
24+ model.users.asSequence().find {
25+ it.name == ctx.getPlayer()!! .name.string || it.uuid == ctx.getPlayer()!! .uniqueID.toString()
26+ }?.homes?.asSequence()?.map { it.home }?.toList() ? : emptyList<String >()
27+ } else emptyList<String >()
28+ }, builder
29+ )
30+ }
31+ )
You can’t perform that action at this time.
0 commit comments