我已经为此进行了很多搜索,但尚未找到明确的解决方案。我发现的最接近的是:
import shutil
from os.path import join
import os
import time
import sys
minecraft_dir = ('server diectory')
world_dir = ('server world driectory')
def server_command(cmd):
os.system('screen -S -X stuff "{}\015"'.format(cmd))
on = "1"
while True:
command=input()
command=command.lower()
if on == "1":
if command==("start"):
os.chdir(minecraft_dir)
os.system('"C:\Program Files\Java\jre1.8.0_111\bin\java.exe" -Xms4G -Xmx4G -jar craftbukkit-1.10.2.jar nogui java')
print("Server started.")
on = "0"
else:
server_command(command)
当我启动这个程序并输入“开始”时,CMD 会闪烁并立即关闭。相反,我希望 CMD 保持打开状态,同时运行我的世界服务器。我不确定为什么会发生这种情况或问题是什么,任何帮助将不胜感激。
ps 我已根据需要对其进行了编辑(例如删除了不必要的备份脚本),但它以前不起作用。原文链接为:https ://github.com/tschuy/minecraft-server-control