Skip to content

Commit 207a013

Browse files
committed
Del-warp command suggestion improved.
Signed-off-by: Pavel Erokhin (MairwunNx) <[email protected]>
1 parent 51bdd30 commit 207a013

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.mairwunnx.projectessentials.warps.commands
22

3+
import com.mairwunnx.projectessentials.core.api.v1.extensions.getPlayer
4+
import com.mairwunnx.projectessentials.core.api.v1.extensions.isPlayerSender
5+
import com.mairwunnx.projectessentials.core.api.v1.extensions.playerName
6+
import com.mairwunnx.projectessentials.core.api.v1.permissions.hasPermission
37
import com.mairwunnx.projectessentials.warps.warpsConfiguration
48
import com.mojang.brigadier.arguments.StringArgumentType
59
import com.mojang.brigadier.builder.LiteralArgumentBuilder
@@ -29,9 +33,19 @@ inline val delWarpLiteral: LiteralArgumentBuilder<CommandSource>
2933
get() = LiteralArgumentBuilder.literal<CommandSource>("del-warp").then(
3034
Commands.argument(
3135
"warp", StringArgumentType.string()
32-
).suggests { _, builder ->
36+
).suggests { ctx, builder ->
3337
ISuggestionProvider.suggest(
34-
warpsConfiguration.warps.asSequence().map { it.name }.toList(), builder
38+
if (ctx.isPlayerSender()) {
39+
if (hasPermission(ctx.getPlayer()!!, "ess.warp.remove.other", 4)) {
40+
warpsConfiguration.warps.asSequence().map { it.name }.toList()
41+
} else {
42+
warpsConfiguration.warps.asSequence().filter {
43+
it.owner == ctx.playerName()
44+
}.map { it.name }.toList()
45+
}
46+
} else {
47+
warpsConfiguration.warps.asSequence().map { it.name }.toList()
48+
}, builder
3549
)
3650
}.executes { DelWarpCommand.process(it) }
3751
)

0 commit comments

Comments
 (0)