|
1 | 1 | package com.mairwunnx.projectessentials.warps.commands |
2 | 2 |
|
| 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 |
3 | 7 | import com.mairwunnx.projectessentials.warps.warpsConfiguration |
4 | 8 | import com.mojang.brigadier.arguments.StringArgumentType |
5 | 9 | import com.mojang.brigadier.builder.LiteralArgumentBuilder |
@@ -29,9 +33,19 @@ inline val delWarpLiteral: LiteralArgumentBuilder<CommandSource> |
29 | 33 | get() = LiteralArgumentBuilder.literal<CommandSource>("del-warp").then( |
30 | 34 | Commands.argument( |
31 | 35 | "warp", StringArgumentType.string() |
32 | | - ).suggests { _, builder -> |
| 36 | + ).suggests { ctx, builder -> |
33 | 37 | 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 |
35 | 49 | ) |
36 | 50 | }.executes { DelWarpCommand.process(it) } |
37 | 51 | ) |
0 commit comments