Skip to content

Commit

Permalink
v1.6-2 Bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
Hikari committed Oct 7, 2024
1 parent a3814a1 commit 01c9075
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ test*.py
.idea/
backup/
hsl-config.json
*.run.bat
71 changes: 34 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,49 @@
[![Telegram](https://img.shields.io/badge/Chat-Telegram-27A7E7)](https://t.me/hikariserverlauncher)
[![QQ](https://img.shields.io/badge/Chat-QQ-27A7E7)](https://qm.qq.com/q/bUTqWXnwje)
# Hikari Server Launcher
Hikari Server Launcher 是一个简单、轻量级的,易用的Minecraft服务器安装工具。
Hikari Server Launcher is a simple, lightweight, and easy-to-use launcher/installer for Minecraft Server.

Hikari Server Launcher 是一个简单、轻量级且易于使用的Minecraft服务器启动与安装工具。它旨在简化Minecraft服务器的设置过程,让用户能够快速访问和管理自己的游戏服务器。

## What Can It Do? 可以做什么?
- Download and install Vanilla Minecraft Server
- Download and install Forge|Fabric|Neoforge(TODO)
- Manage your Servers in console.
- 下载并安装原版Minecraft服务器
- 下载并安装Forge | Fabric | Neoforge(还没做)
- 通过控制台管理你的服务器
## 功能特性

- 自动下载和安装原版Minecraft服务器
- 支持Forge、Fabric及Neoforge的下载与安装(Neoforge功能正在开发中)
- 通过控制台轻松管理多个服务器实例
- 提供详细的安装和操作指导
- 轻量级,无需安装额外的软件
- 支持Windows、Linux (AMD64)
- 快捷创建服务器备份,并可恢复至原服务器

## Advantages 优势
- Download and install Minecraft Server and Java Environment automatically.
- Server files are stored in separate directories, which do not interfere with each other.
- Easy to delete your server.
- 自动下载安装服务器,Java环境
- 各个服务器文件存放在单独的目录,不会相互干扰。
- 便于删库跑路。
## 优势

- 自动下载并配置Minecraft服务器及所需的Java环境
- 服务器文件存放在独立目录中,避免互相干扰
- 便于删除不再使用的服务器

## How to Use? 如何使用?
1. Download the latest version of Hikari Server Launcher from [Actions](https://github.com/Hikari16665/HikariServerLauncher/actions)
2. Run HikariServerLauncher.exe
3. Follow the instructions on the screen to install the server.
4. Enjoy!
1.[Actions](https://github.com/Hikari16665/HikariServerLauncher/actions) 中下载最新版本的 Hikari Server Launcher
2. 解压文件并运行 HikariServerLauncher.exe
3. 按照屏幕上的提示安装服务器。
4. 完事了!
## 使用说明

1.[Actions](https://github.com/Hikari16665/HikariServerLauncher/actions) 下载最新版本的 Hikari Server Launcher。
2. 解压文件并运行 `HikariServerLauncher.exe`
3. 按照屏幕上的提示完成服务器安装。
4. 尽情享受你的Minecraft服务器体验!

## Contributing 贡献
- 你可以从两方面对此项目贡献:
- 提交 issue, pull request 来完善这个项目。
- 编辑spconfigs.json,这是特定配置的索引文件,个人时间有限无法全部适配,spconfigs.json的格式可以参考 [spconfig.json](https://github.com/Hikari16665/HikariServerLauncher/blob/main/spconfigs.json),里面有详细的注释。
## 贡献指南

欢迎您参与到这个项目中来!您可以通过以下方式贡献:

## 致谢 Thanks
- [Hikari](https://github.com/Hikari16665) 我自己
- 提交问题(Issue)或拉取请求(Pull Request)来改进本项目。
- 编辑 `spconfigs.json` 文件,以适应特定配置(该文件格式可参考 [spconfig.json](https://github.com/Hikari16665/HikariServerLauncher/blob/main/spconfigs.json),其中包含详细注释)。

## 致谢

站点:
- [OpenBMCLAPI](https://github.com/bangbang93/openbmclapi) OpenBMCLAPI 提供Minecraft服务端下载
- [MC灵依资源站](https://mcres.cn/) 提供了 Java 镜像源
- [辰隙互联](https://www.singsi.cn) 提供了 服务器
感谢以下项目和个人的支持:

个人:
- GloryGods 提供了 Java 镜像源
- [Hikari](https://github.com/Hikari16665) 我自己
- [OpenBMCLAPI](https://github.com/bangbang93/openbmclapi) 提供Minecraft服务端下载
- [MC灵依资源站](https://mcres.cn/) 提供Java镜像源
- [辰隙互联](https://www.singsi.cn) 提供服务器支持
- GloryGods 提供Java镜像源

希望您喜欢使用 Hikari Server Launcher!如有任何问题或建议,欢迎随时与我们联系。
[![Telegram](https://img.shields.io/badge/Chat-Telegram-27A7E7)](https://t.me/hikariserverlauncher)
[![QQ](https://img.shields.io/badge/Chat-QQ-27A7E7)](https://qm.qq.com/q/bUTqWXnwje)
2 changes: 1 addition & 1 deletion hsl/core/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def make_request(url: str, error_message: str) -> dict:
try:
response = requests.get(url)
response = requests.get(url,timeout=5)
if response.status_code == 200:
return response.json()
logger.error(f'{error_message},状态码:{response.status_code}')
Expand Down
32 changes: 25 additions & 7 deletions hsl/core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,18 @@ def consoleOutput(self, process):
async def get_input(self, process, input_queue: Queue):
while True:
try:
command_input = await ainput(f'({self.name}) >>> ')
except (KeyboardInterrupt, EOFError):
command_input = await ainput(f'{self.name} >>> ')
except (KeyboardInterrupt,asyncio.exceptions.CancelledError):
console.log("已退出输入")
process.kill()
break
except EOFError:
console.log("已退出输入")
process.kill()
break
except Exception as e:
console.log(f'输入错误: {e}')
continue
input_queue.put(command_input)
if input_queue.get() is None:
break
Expand All @@ -118,8 +125,6 @@ def check_process_exists(self, process):
return psutil.pid_exists(process.pid)

async def gen_run_command(self, path, export: bool = False) -> str:
console.log(f'[Debug]: Path: {path}')
console.log(f'[Debug]: javaversion: {self.javaversion}')
javaexecPath = await Java().getJavaByJavaVersion(self.javaversion, path)

if export:
Expand Down Expand Up @@ -185,8 +190,19 @@ def _build_run_command(self, javaexecPath, export=False):
])

async def run(self, path: str):
if 'startup_cmd' in self.data:
subprocess.Popen(self.data['startup_cmd'], cwd=self.path)
startup_cmd = self.data.get('startup_cmd', '')
if not startup_cmd:
console.log('[bold red]启动命令为空')
else:
try:
subprocess.Popen(startup_cmd, cwd=self.path)
except Exception as e:
console.log(f'[bold red]启动命令执行失败: {e}')
# if 'startup_cmd' in self.data:
# if not self.data.get('startup_cmd', ''):
# console.log('[bold red]启动命令为空')
# else:
# subprocess.Popen(self.data['startup_cmd'], cwd=self.path)

run_command = await self.gen_run_command(path)

Expand All @@ -208,11 +224,13 @@ async def run(self, path: str):
t1 = Thread(target=self.consoleOutput, args=(process,))
t2 = Thread(target=self.consoleInput, args=(process, input_queue))


t1.start()
t2.start()


t1.join()
console.print('[bold green]请输入任意内容以退出控制台')
console.print('[bold green]键入Ctrl+C以退出控制台')
t2.join()
console.print('[bold green]控制台已退出')
return
2 changes: 1 addition & 1 deletion hsl/utils/prompt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from noneprompt import ListPrompt, InputPrompt, ConfirmPrompt, Choice
from noneprompt import ListPrompt, InputPrompt, Choice
import asyncio
OPTIONS_YN = ['是', '否']
async def promptSelect(options: list,prompt: str) -> int:
Expand Down
7 changes: 5 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ async def get_editable_configs(self, configs, server: Server) -> list:
console.print(f'[bold magenta]{config_info["name"]} - 配置文件不存在。')
continue

with open(config_path, 'r') as f:
with open(config_path, 'r', encoding='utf-8') as f:
config = self.load_config_file(config_info, f)
console.print(f'[bold green]{config_info["name"]} - 读取成功。')
if any(self.get_nested_value(config, key_info['key'].split('.')) is not None for key_info in config_info['keys']):
Expand Down Expand Up @@ -384,7 +384,10 @@ async def mainMenu(self):
console.set_window_title(f'{HSL_NAME} v{str(self.version/10)}')
while True:
console.print(f'[bold gold]欢迎使用 {HSL_NAME}.')
index = await promptSelect(OPTIONS_MENU, '菜单:')
try:
index = await promptSelect(OPTIONS_MENU, '菜单:')
except (KeyboardInterrupt, asyncio.CancelledError):
pass

menu_methods: dict[int, Callable] = {
0: lambda: self.create(),
Expand Down

0 comments on commit 01c9075

Please sign in to comment.