Posted July 26, 20214 yr I've looked far and wide across the internet for some sort of help, but I can't find any methods that allow me to send commands through console. Not much more needs to be said, this is quite a simple post. If someone could give me something, anything, that would be nice.
July 26, 20214 yr Author 7 hours ago, diesieben07 said: Some clarification is needed. Do you want to write a mod that executes a command as if it was entered in the server console? Do you want to write an external program that relays commands to the server console? One that executes commands as if it was entered in the server console.
July 26, 20214 yr Author 7 hours ago, poopoodice said: You can run servers and then execute commands there. That has nothing to do with what I asked?
July 26, 20214 yr Author 1 hour ago, diesieben07 said: MinecraftServer#getCommands().performCommand(source, command). command is the command you want to run, source is the CommandSource for it. To use the same one the console uses, use MinecraftServer#createCommandSourceStack. Thanks, but I'm having an issue grabbing the MinecraftServer variable. My code: MinecraftServer source = MinecraftServer.getServer(); source.getCommands().performCommand(source.createCommandSourceStack(), "say hi"); It doesn't seem to recognize "getServer()"
July 26, 20214 yr Author NEVERMIND. I found something that works for me: MinecraftServer source = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER); Topic SOLVED
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.