8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Node.jsでMinecraftサーバーを実行する

Posted at

##サンプル

const proc = require('child_process');

// サーバーの実行
var server = proc.spawn(
    "java",
   ['-Xms1024M', '-Xmx1024M', '-jar', 'minecraft_server.jar', 'nogui'],
   { cwd: "C:/user/yuta/desktop/server" } // サーバーファイルのディレクトリ
);
// ログを表示する
server.stdout.on('data', function (log) {
   console.log(""+log);
});
server.stderr.on('data', function (log) {
   console.log(""+log);
});

// コマンドを実行する 以下ではhelpコマンドを実行している
server.stdin.write("help" + "\r");
8
9
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?