关于
Minecraft Paper 插件,用于在玩家闲置后节省电量,并在电池电量低/高时发出通知。此插件适用于运行在旧笔记本电脑或其他带电池设备上的小型本地服务器。该插件(目前)未对命令设置权限限制,因此任何人都可以查看电池状态。
建议
如果您有任何建议、发现了问题或有功能需求,请随时联系我!
该插件目前仅在 Paper 1.20.1 上可用,但您可以私信我,我可以为您需要的版本提供支持。
我的 Discord 用户名是 eneas._。
命令
请求并返回当前的电池百分比、状态,或在未指定参数时同时返回两者。
用法
该插件可配置为每隔指定分钟数检查一次电池状态,并在电池电量低于设定阈值且正在放电,或高于另一设定阈值且正在充电时,在聊天栏广播警告(默认低电量为 10%,高电量为 90%)。
它还具备在指定时长无活动后停止服务器的功能。其工作原理是检测是否没有玩家在线,且在达到该时长之前最后一名玩家已离开且最后一条控制台命令已执行。
如果启用,它还会在指定路径创建一个标记文件,以便服务器启动脚本可以检测该文件是否存在并触发进一步的操作,例如完全关闭设备。
配置
默认插件配置:
battery:
enabled: true # 设置为 false 时禁用电池检查
warning_thresholds:
high: 90 # 电池百分比高于此值时发出警告
low: 10 # 电池百分比低于此值时发出警告
check_interval: "5m" # 检查电池电量的频率
inactivity:
enabled: true # 设置为 false 时禁用自动关机
max_duration: "15m" # 关机前的最大无活动时间
check_interval: "5m" # 检查无活动的频率
shutdown_info:
file: "/tmp/battery_management/shutdown.info" # 指示关机请求的文件
用于启动服务器并在插件停止服务器后关闭的示例脚本:
Linux
#!/bin/bash
java -Xms2G -Xmx2G -XX:+UseG1GC -jar /Path/to/paper-server.jar --nogui
FILE="/tmp/battery_management/shutdown.info"
if [ -f "$FILE" ]; then
rm -f "$FILE"
shutdown now
fi
Windows
@echo off
setlocal
java -Xms2G -Xmx2G -XX:+UseG1GC -jar C:\Path\to\paper-server.jar --nogui
set "file=C:\Windows\Temp\battery_management\shutdown.info"
IF EXIST "%file%" (
del "%file%"
shutdown -s -t 0
)
endlocal
About
Minecraft Paper Plugin to save energy after inactivity and inform about low / high battery charge. This is thought for
small local servers that are running on old laptops or other devices with a battery. It (currently) has no permission set on it's command(s), which means everyone
is able to see the battery status.
Suggestions
If you have any suggestions, found a bug or have a feature request, please feel free to contact me!
The plugin is currently also only available for 1.20.1 on paper, but write me a DM and I can make it available for your desired version.
My discord username is eneas._.
Commands
- /battery [<percentage> | <status>]
Requests and returns the current battery percentage, status, or both if no argument is specified.
Usage
The plugin can be configured to check the battery every given amount of minutes, and broadcast a warning in the chat if
the battery is below a specified threshold and discharging or above another specified threshold and charging (default
low is 10% and high is 90%).
It also has a feature to stop the server after a given duration of inactivity. This works by testing if no players are online and that the last player left and the last console command was executed, before this duration.
If enabled, it also creates a marker file at a given path, so that the server start-script can test if the file exist and trigger further actions, like completely shutting down the device.
Configuration
Default plugin config:
battery:
enabled: true # Disable battery checks if set to false
warning_thresholds:
high: 90 # Warn if battery is above this percentage
low: 10 # Warn if battery is below this percentage
check_interval: "5m" # How often to check battery level
inactivity:
enabled: true # Disable auto-shutdown if set to false
max_duration: "15m" # Max inactivity time before shutdown
check_interval: "5m" # How often to check for inactivity
shutdown_info:
file: "/tmp/battery_management/shutdown.info" # File indicating a shutdown request
Example scripts to start server and shutdown if plugin stopped server:
Linux
#!/bin/bash
java -Xms2G -Xmx2G -XX:+UseG1GC -jar /Path/to/paper-server.jar --nogui
FILE="/tmp/battery_management/shutdown.info"
if [ -f "$FILE" ]; then
rm -f "$FILE"
shutdown now
fi
Windows
@echo off
setlocal
java -Xms2G -Xmx2G -XX:+UseG1GC -jar C:\Path\to\paper-server.jar --nogui
set "file=C:\Windows\Temp\battery_management\shutdown.info"
IF EXIST "%file%" (
del "%file%"
shutdown -s -t 0
)
endlocal
评论 0
登录后参与评分
还没有评论,来抢沙发吧