File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
src/main/kotlin/com/mairwunnx/projectessentials/spawn/helpers Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.mairwunnx.projectessentials.spawn.helpers
2
+
3
+ import com.mairwunnx.projectessentials.core.api.v1.MESSAGE_MODULE_PREFIX
4
+ import com.mairwunnx.projectessentials.core.api.v1.extensions.getPlayer
5
+ import com.mairwunnx.projectessentials.core.api.v1.messaging.MessagingAPI
6
+ import com.mairwunnx.projectessentials.core.api.v1.permissions.hasPermission
7
+ import com.mojang.brigadier.context.CommandContext
8
+ import net.minecraft.command.CommandSource
9
+
10
+ inline fun validateAndExecute (
11
+ context : CommandContext <CommandSource >,
12
+ node : String ,
13
+ opLevel : Int ,
14
+ crossinline action : (isServer: Boolean ) -> Unit
15
+ ) = context.getPlayer()?.let {
16
+ if (hasPermission(it, node, opLevel)) {
17
+ action(false )
18
+ } else {
19
+ MessagingAPI .sendMessage(
20
+ context.getPlayer()!! , " ${MESSAGE_MODULE_PREFIX } spawn.restricted"
21
+ )
22
+ }
23
+ } ? : run { action(true ) }
You can’t perform that action at this time.
0 commit comments