garrettjoecox / scriptserver

A Minecraft server wrapper, allows for simple plugins in vanilla
GNU General Public License v3.0
68 stars 10 forks source link

Add `sendRaw` function to module #19

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello,

I'm noticing the need for sending a command directly to the console from time to time, rather then going through RCON. The reason for this is how the server is announcing in-game who's doing what.

[RCON] Did something [Server] Did something

A good majority of the plugins that alters and modifies system events, take into consideration that it's the [Server] doing it, not RCON, and therefor, doesn't work as expected.

I see the benefit of using RCON the way you have, but at the same time I don't see the benefit of excluding the option to write directly.

Proposing a simple, second function to the module in the terms of something like this

sendRaw(command) {
    return new Promise((resolve) => {
      this.spawn.stdin.write( command + '\n' );
    });
}

This is specially useful when, as I'm doing right now, solely trying to make a web-version of the server console, where handling the response is irrelevant, as the entire point is to mimic being in the server console directly, and the response will therefor just be a part of the regular logging behaviour.

Any thoughts?

garrettjoecox commented 6 years ago

For the use case of announcing to all players, I'd recommend using tellraw and @a, you can then specify the [server] prefix, or even your own prefix.

However, for the web console (something I've made in the past) this is a valid point, and I will take it into consideration. Just a heads up you can capture all of the raw console output using server.on('console')