Jump to content

Recommended Posts

Posted

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.

Posted
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.

Posted
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()"

  • Novality changed the title to [1.16.5] Executing a command as server console [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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.