WIP command passthrough
This commit is contained in:
parent
445bf425c2
commit
f63e03dd5c
|
@ -0,0 +1,52 @@
|
|||
package matterlink.command
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool
|
||||
import matterlink.bridge.ApiMessage
|
||||
import matterlink.bridge.MessageHandler
|
||||
import matterlink.config.cfg
|
||||
import net.minecraft.command.ICommandSender
|
||||
import net.minecraft.server.MinecraftServer
|
||||
import net.minecraft.util.text.ITextComponent
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler
|
||||
import javax.annotation.Nonnull
|
||||
|
||||
object MatterlinkCommandSender : IMinecraftCommandSender, ICommandSender {
|
||||
private var level: Int = 0
|
||||
|
||||
override fun execute(cmdString: String, level: Int): Boolean {
|
||||
return 0 < FMLCommonHandler.instance().minecraftServerInstance.commandManager.executeCommand(
|
||||
this,
|
||||
cmdString
|
||||
)
|
||||
}
|
||||
|
||||
override fun getName(): String {
|
||||
return "MatterLink"
|
||||
}
|
||||
|
||||
override fun getEntityWorld(): World {
|
||||
return FMLCommonHandler.instance().minecraftServerInstance.getWorld(0)
|
||||
}
|
||||
|
||||
override fun canUseCommand(permLevel: Int, commandName: String?): Boolean {
|
||||
//TODO: Implement actual permissions checking
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getServer(): MinecraftServer? {
|
||||
return FMLCommonHandler.instance().minecraftServerInstance
|
||||
}
|
||||
|
||||
override fun sendMessage(@Nonnull component: ITextComponent?) {
|
||||
MessageHandler.transmit(ApiMessage(
|
||||
username = cfg!!.relay.systemUser,
|
||||
text = component!!.unformattedComponentText
|
||||
))
|
||||
|
||||
}
|
||||
|
||||
override fun sendCommandFeedback(): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package matterlink.bridge.command
|
||||
|
||||
class PassthroughCommand(override val name: String) : IBridgeCommand {
|
||||
|
||||
override fun call(args: String): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override val help: String = "No help available for this command."
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package matterlink.command
|
||||
|
||||
interface IMinecraftCommandSender {
|
||||
/**
|
||||
* @param cmdString The command to execute with its arguments
|
||||
* @param level Privilege level to execute this command at, currently unused
|
||||
*
|
||||
* @return Any output of the command
|
||||
*/
|
||||
fun execute(cmdString: String, level: Int) : Boolean
|
||||
}
|
Loading…
Reference in New Issue