0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RCONでPythonからMinecraftサーバーを停止させる

Posted at

RCONでPythonからMinecraftサーバーを停止させる

起動中にサーバーを停止したいとのことでRCONでPyからサーバーを停止させてみた

前提条件

  • Pythonを導入していること
  • Minecraftサーバーを設置していること

MCRCONのインストール

pip install mcrcon

server.properties

  • server.properties
enable-rcon=true
rcon.password=(設定するパスワード)
rcon.port=25575

停止用スクリプト

  • stop.py
from mcrcon import MCRcon

# アドレス、パスワード、ポートの定義
ADDRESS = "localhost"
PASSWORD = "(設定したパスワード)"
PORT = 25575

def main(address, password, port):
  with MCRcon(address, password, port) as rcon:
    # stopコマンドを送信する
    rcon.command("stop")

if __name__ == '__main__':
  main(ADDRESS, PASSWORD, PORT)
  

stop.py実行用batファイル

  • stop.bat
python stop.py
pause
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?