Skip to content

Commit 8def801

Browse files
committed
isAllowed added to VanillaCommandBase.kt.
Signed-off-by: Pavel Erokhin (MairwunNx) <MairwunNx@gmail.com>
1 parent 2cbefd4 commit 8def801

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
package com.mairwunnx.projectessentials.core.impl.vanilla.commands
22

33
import com.mairwunnx.projectessentials.core.api.v1.commands.CommandAPI
4+
import com.mairwunnx.projectessentials.core.api.v1.permissions.hasPermission
45
import com.mojang.brigadier.CommandDispatcher
56
import net.minecraft.command.CommandSource
7+
import net.minecraft.entity.player.ServerPlayerEntity
8+
import org.apache.logging.log4j.LogManager
69

710
abstract class VanillaCommandBase(val name: String) {
811
open fun register(dispatcher: CommandDispatcher<CommandSource>) {
912
CommandAPI.removeCommand(name)
13+
LogManager.getLogger().info("Native command replacing implementation for $name")
14+
}
15+
16+
companion object {
17+
@JvmStatic
18+
fun isAllowed(source: CommandSource, node: String, opLevel: Int) =
19+
if (source.entity is ServerPlayerEntity) {
20+
hasPermission(source.asPlayer(), "native.$node", opLevel)
21+
} else true
1022
}
1123
}

0 commit comments

Comments
 (0)