diff --git a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt index fa4fea1..310cd47 100644 --- a/1.10.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.10.2/src/main/kotlin/matterlink/MatterLink.kt @@ -63,7 +63,7 @@ object MatterLink : IMatterLink() { override fun log(level: String, formatString: String, vararg data: Any) = logger.log(Level.toLevel(level, Level.INFO), formatString, *data) - override fun commandSenderFor(user: String, userId: String, server: String) = MatterLinkCommandSender(user, userId, server) + override fun commandSenderFor(user: String, userId: String, server: String, op: Boolean) = MatterLinkCommandSender(user, userId, server, op) override val mcVersion: String = MCVERSION override val modVersion: String = MODVERSION diff --git a/1.10.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt b/1.10.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt index dd3724a..614212a 100644 --- a/1.10.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt +++ b/1.10.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt @@ -13,7 +13,7 @@ import net.minecraft.world.World import net.minecraftforge.fml.common.FMLCommonHandler import javax.annotation.Nonnull -class MatterLinkCommandSender(user: String, userId: String, server: String) : IMinecraftCommandSender(user, userId, server), ICommandSender { +class MatterLinkCommandSender(user: String, userId: String, server: String, op: Boolean) : IMinecraftCommandSender(user, userId, server, op), ICommandSender { private var level: Int = 0 override fun execute(cmdString: String): Boolean { diff --git a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt index 6dc65f4..494d40b 100644 --- a/1.11.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.11.2/src/main/kotlin/matterlink/MatterLink.kt @@ -63,7 +63,7 @@ object MatterLink : IMatterLink() { override fun log(level: String, formatString: String, vararg data: Any) = logger.log(Level.toLevel(level, Level.INFO), formatString, *data) - override fun commandSenderFor(user: String, userId: String, server: String) = MatterLinkCommandSender(user, userId, server) + override fun commandSenderFor(user: String, userId: String, server: String, op: Boolean) = MatterLinkCommandSender(user, userId, server, op) override val mcVersion: String = MCVERSION override val modVersion: String = MODVERSION diff --git a/1.11.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt b/1.11.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt index d9a843a..af8fd33 100644 --- a/1.11.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt +++ b/1.11.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt @@ -13,7 +13,7 @@ import net.minecraft.world.World import net.minecraftforge.fml.common.FMLCommonHandler import javax.annotation.Nonnull -class MatterLinkCommandSender(user: String, userId: String, server: String) : IMinecraftCommandSender(user, userId, server), ICommandSender { +class MatterLinkCommandSender(user: String, userId: String, server: String, op: Boolean) : IMinecraftCommandSender(user, userId, server, op), ICommandSender { override fun execute(cmdString: String): Boolean { return 0 < FMLCommonHandler.instance().minecraftServerInstance.commandManager.executeCommand( diff --git a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt index 6c6a494..1d1e203 100644 --- a/1.12.2/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.12.2/src/main/kotlin/matterlink/MatterLink.kt @@ -65,7 +65,7 @@ object MatterLink : IMatterLink() { override fun log(level: String, formatString: String, vararg data: Any) = logger.log(Level.toLevel(level, Level.INFO), formatString, *data) - override fun commandSenderFor(user: String, userId: String, server: String) = MatterLinkCommandSender(user, userId, server) + override fun commandSenderFor(user: String, userId: String, server: String, op: Boolean) = MatterLinkCommandSender(user, userId, server, op) override val mcVersion: String = MCVERSION override val modVersion: String = MODVERSION diff --git a/1.12.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt b/1.12.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt index 36d933c..e813999 100644 --- a/1.12.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt +++ b/1.12.2/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt @@ -9,8 +9,7 @@ import net.minecraft.world.World import net.minecraftforge.fml.common.FMLCommonHandler import javax.annotation.Nonnull -class MatterLinkCommandSender(user: String, userId: String, server: String) : IMinecraftCommandSender(user, userId, server), ICommandSender { - +class MatterLinkCommandSender(user: String, userId: String, server: String, op: Boolean) : IMinecraftCommandSender(user, userId, server, op), ICommandSender { override fun execute(cmdString: String): Boolean { return 0 < FMLCommonHandler.instance().minecraftServerInstance.commandManager.executeCommand( this, diff --git a/1.7.10/src/main/kotlin/matterlink/MatterLink.kt b/1.7.10/src/main/kotlin/matterlink/MatterLink.kt index d98daab..1fb0bdb 100644 --- a/1.7.10/src/main/kotlin/matterlink/MatterLink.kt +++ b/1.7.10/src/main/kotlin/matterlink/MatterLink.kt @@ -65,7 +65,7 @@ class MatterLink : IMatterLink() { override fun log(level: String, formatString: String, vararg data: Any) = logger.log(Level.toLevel(level, Level.INFO), formatString, *data) - override fun commandSenderFor(user: String, userId: String, server: String) = MatterLinkCommandSender(user, userId, server) + override fun commandSenderFor(user: String, userId: String, server: String, op: Boolean) = MatterLinkCommandSender(user, userId, server, op) override val mcVersion: String = MCVERSION override val modVersion: String = MODVERSION diff --git a/1.7.10/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt b/1.7.10/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt index 53c8eae..1be5ef7 100644 --- a/1.7.10/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt +++ b/1.7.10/src/main/kotlin/matterlink/command/MatterLinkCommandSender.kt @@ -8,7 +8,7 @@ import net.minecraft.util.ChunkCoordinates import net.minecraft.util.IChatComponent import net.minecraft.world.World -class MatterLinkCommandSender(user: String, userId: String, server: String) : IMinecraftCommandSender(user, userId, server), ICommandSender { +class MatterLinkCommandSender(user: String, userId: String, server: String, op: Boolean) : IMinecraftCommandSender(user, userId, server, op), ICommandSender { private var level: Int = 0 diff --git a/core/src/main/kotlin/matterlink/IMatterLink.kt b/core/src/main/kotlin/matterlink/IMatterLink.kt index 4d5d353..3304fce 100644 --- a/core/src/main/kotlin/matterlink/IMatterLink.kt +++ b/core/src/main/kotlin/matterlink/IMatterLink.kt @@ -13,7 +13,7 @@ abstract class IMatterLink { abstract val modVersion: String abstract val forgeVersion: String - abstract fun commandSenderFor(user: String, userId: String, server: String): IMinecraftCommandSender + abstract fun commandSenderFor(user: String, userId: String, server: String, op: Boolean): IMinecraftCommandSender abstract fun wrappedSendToPlayers(msg: String) diff --git a/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt b/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt index a62ddd8..1d5a16f 100644 --- a/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt +++ b/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt @@ -14,7 +14,8 @@ data class CustomCommand( override val help: String = "", val allowArgs: Boolean = true, val timeout: Int = 20, - val defaultCommand: Boolean? = null + val defaultCommand: Boolean? = null, + val execOp: Boolean? = null ) : IBridgeCommand { val alias: String get() = BridgeCommandRegistry.getName(this)!! @@ -41,8 +42,9 @@ data class CustomCommand( CommandType.EXECUTE -> { //uses a new commandsender for each user // TODO: cache CommandSenders - val commandSender = instance.commandSenderFor(user, userId, server) - commandSender.execute("$execute $args") || commandSender.reply.isNotBlank() + val commandSender = instance.commandSenderFor(user, userId, server, execOp ?: false) + val cmd = "$execute $args" + commandSender.execute(cmd) || commandSender.reply.isNotBlank() } CommandType.RESPONSE -> { MessageHandlerInst.transmit(ApiMessage() @@ -58,7 +60,7 @@ data class CustomCommand( */ override fun validate(): Boolean { val typeCheck = when (type) { - CommandType.EXECUTE -> execute?.isNotBlank() ?: false + CommandType.EXECUTE -> execute != null CommandType.RESPONSE -> response?.isNotBlank() ?: false } if (!typeCheck) return false diff --git a/core/src/main/kotlin/matterlink/bridge/command/IBridgeCommand.kt b/core/src/main/kotlin/matterlink/bridge/command/IBridgeCommand.kt index ead5f7e..1f9b076 100644 --- a/core/src/main/kotlin/matterlink/bridge/command/IBridgeCommand.kt +++ b/core/src/main/kotlin/matterlink/bridge/command/IBridgeCommand.kt @@ -1,6 +1,7 @@ package matterlink.bridge.command import matterlink.config.PermissionConfig +import matterlink.instance interface IBridgeCommand { val help: String @@ -9,7 +10,10 @@ interface IBridgeCommand { fun execute(alias: String, user: String, userId: String, server: String, args: String): Boolean fun canExecute(userId: String, server: String): Boolean { - return getPermLevel(userId, server) >= permLevel + instance.info("this: $this canExecute: $userId server: $server permLevel: $permLevel") + val canExec = getPermLevel(userId, server) >= permLevel + instance.info("return $canExec") + return canExec } fun validate() = true diff --git a/core/src/main/kotlin/matterlink/bridge/command/IMinecraftCommandSender.kt b/core/src/main/kotlin/matterlink/bridge/command/IMinecraftCommandSender.kt index 3fd72f5..221cf92 100644 --- a/core/src/main/kotlin/matterlink/bridge/command/IMinecraftCommandSender.kt +++ b/core/src/main/kotlin/matterlink/bridge/command/IMinecraftCommandSender.kt @@ -3,7 +3,7 @@ package matterlink.bridge.command import matterlink.api.ApiMessage import matterlink.bridge.MessageHandlerInst -abstract class IMinecraftCommandSender(val user: String, val userId: String, val server: String) { +abstract class IMinecraftCommandSender(val user: String, val userId: String, val server: String, val op: Boolean) { /** * @param cmdString The command to execute with its arguments * @@ -14,8 +14,8 @@ abstract class IMinecraftCommandSender(val user: String, val userId: String, val val accountName = "$user (id=$userId server=$server)" fun canExecute(commandName: String): Boolean { + if(op) return true val command = BridgeCommandRegistry[commandName] ?: return false - return command.canExecute(userId, server) } diff --git a/gradle.properties b/gradle.properties index 0e476e6..f0dc865 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ mod_name = MatterLink -mod_version = 1.5.8 +mod_version = 1.5.9 forgelin_version = 1.6.0 curse_id = 287323 curse_release_type = beta \ No newline at end of file