SimpleRestart
版本 1.3.4,由 FuzzyWuzzie 和 THExSYSTEM 开发
源码
该插件的源码可在 GitHub 上找到:
描述
SimpleRestart 是一款适用于 Bukkit(Minecraft 服务器包装器)的插件,允许服务器管理员简单轻松地重启服务器,并安排服务器的自动重启以“保持新鲜感”。该插件包含灵活且直观的命令,易于设置和使用,并支持权限系统。
安装设置
只需将 SimpleRestart.jar 和 SimpleRestart 文件夹复制到您的 Minecraft 服务器目录下的 "plugins" 子目录中。如果您不复制 SimpleRestart 文件夹,它将会被自动创建,同时也会生成一个默认配置文件。请根据您的需要编辑配置文件(config.yml),然后修改您的服务器启动脚本,使其在接收到 "/stop" 命令时自动重启服务器。
配置文件
默认配置文件大部分直观易懂,并包含大量注释。然而,每个选项的详细说明如下:
- auto-restart:启用/禁用按时间计划的自动重启。如果设置为 "no",则服务器仅在通过 "/restart" 命令时才会重启。
- auto-restart-interval:这是服务器自动重启自身的频率(以小时为单位)(仅当 auto-restart 设置为 "yes" 时生效)
- warn-times:在服务器重启前,它会向所有在线玩家发送友好的警告。此设置是一个列表,描述了在服务器自动重启前多少分钟(单位:分钟)向玩家发出警告。例如:warn-times: [10, 5, 2, 1] 将在服务器重启前 10 分钟、5 分钟、2 分钟和 1 分钟向玩家发出警告。
- warning-message:这是作为警告显示的消息,提示服务器即将重启。您可以使用经典的 Minecraft 服务器颜色代码()和 "%t" 来表示距离服务器重启还有多长时间。例如:warning-message: "&cServer will be restarting in %t minutes!" 将以红色显示“Server will be restarting in 5 minutes!”(当 warn-time = 5 时)
- restart-message:这是玩家在因自动重启而被踢出服务器时将看到的信息。同样,这里也可以使用颜色代码。
编辑启动脚本
为了使该插件正常工作,您需要对启动脚本进行轻微修改(Windows 上的 craftbukkit.bat,Linux 上的 craftbukkit.sh)。该插件的工作原理是简单地定期调度服务器的“停止”操作。然后当服务器关闭时,启动脚本会简单地循环并再次启动服务器,尽量减少繁琐的操作。
为了区分真正的 "/stop" 和仅仅是 "/restart",您需要检查插件目录中 SimpleRestart/restart.txt 文件的修改时间。如果调用了真正的 "/stop",则该文件的修改时间保持不变。否则,如果仅调用了 "/restart",则修改时间会发生变化。有一个用于 *nix 操作系统的辅助脚本 实现了 这一点:simple_restart_helper.sh
这可以通过启动脚本中的无限循环来实现:
- 对于 Windows,在您想要重复的内容之前的一行放置 ":start",然后在之后的一行放置 "goto start" 以形成无限循环。craftbukkit.bat 示例:
@ECHO OFF
SET BINDIR=%~dp0
CD /D "%BINDIR%"
:start
"%ProgramFiles%\Java\jre6\bin\java.exe" -Xmx1024M -Xms1024M -jar craftbukkit.jar
goto start
- 对于 *nix 操作系统,在您想要重复的内容之前的一行放置 "while true" <换行> "do",然后在之后的一行放置 "done" 以形成无限循环。craftbukkit.sh 示例:
#!/bin/sh
BINDIR=$(dirname "$(readlink -fn "$0")")
cd "\$BINDIR"
while true
do
java -Xmx1024M -Xms1024M -jar craftbukkit.jar
echo "If you want to completely stop the server process now, press Ctrl+C before the time is up!"
echo "Rebooting in:"
for i in 5 4 3 2 1
do
echo "$i..."
sleep 1
done
echo "Rebooting now!"
done
在 Windows 上,要退出这个无限循环(即永久关闭服务器),只需关闭
命令行窗口。在 Linux 系统上,请停止服务器然后按 “Ctrl+C” 以取消该进程。
权限节点
可以配置以下权限:
- simplerestart.restart:要使用 /restart 或 /reboot 命令中的几乎任何功能,用户必须拥有此权限
- simplerestart.time:要使用 /restart time 命令,用户必须拥有此权限
- simplerestart.memory:要使用 /memory 命令,用户必须拥有此权限
- 注意:simplerestart.* 不应生效
命令
所有命令都可以在控制台(当然不包括开头的 “/”)中输入,也可以由游戏内的玩家输入:
- /restart help:显示一个简单的帮助菜单
- /restart now:立即重启服务器
- /restart time:告知你在服务器重启前剩余的时间
- /restart (h|m|s) <time>:开启自动重启(如果之前是关闭状态),并将下一次自动重启时间重新计划为从现在起 <time> 小时后(小时、分钟或秒)。例如,要在 15 分钟后重启服务器,请使用 “/restart m 15”。‘h’ 代表小时,‘m’ 代表分钟,‘s’ 代表秒。
- /restart on:开启自动重启(如果在配置中或通过命令被禁用)。将根据配置中的设置从当前时间开始启动调度器。
- /restart off:取消任何待定的自动重启,并防止自动重启发生,直到重新启用
- /memory:显示 Java 运行时内存使用情况,有助于发现失控的插件
更新日志
- 1.3.4 更新至 Bukkit v1.3.1-R2.0
- 1.3.3 更新至 Bukkit v1.2.4-R1.0
- 1.3.2 更新至 Bukkit v1.2.3-R0.1
- 1.3.1 更新至 Bukkit v1.1-R6。增加了对 bPermissions 和 PermissionsEx 的支持。
- 1.3.0 更新至 Bukkit v1.1-R1
- 1.2.0 将调度系统从 Bukkit 的内部调度器(在发生延迟时会被推迟)更改为 Java 计时器,这应该能防止服务器卡顿的影响。
- 1.1.0 增加了多个警告提示并稍微整理了一下代码
- 1.0.1 在重启前增加了强制自动保存功能,并为检查距离重启还有多长时间添加了独立的权限节点
- 1.0.0 初始发布
SimpleRestart
Version 1.3.4 by FuzzyWuzzie and THExSYSTEM
Source
The source of this plugin can be found on GitHub:
Description
SimpleRestart is a plugin for Bukkit (a Minecraft server wrapper) which allows server
operators to simply and easily restart their server, as well as schedule automatic restarts
of the server "for freshness". The plugin contains flexible yet straightforward commands,
is easy to set up and use, and makes use of Permissions.
Setting Up
Simply copy SimpleRestart.jar and the SimpleRestart folder into the "plugins" subdirectory
of your minecraft server. If you do not copy in the SimpleRestart folder, it will be created
for you automatically, along with a default configuration file. Edit the configuration file
(config.yml) as you see fit, then modify your server startup script so that it automatically
reboots the server when it gets "/stop"ped.
The Configuration File
The default configuration file is mostly straight forward and contains numerous comments.
However, each option is detailed below:
- auto-restart: enable / disable automatic, time-scheduled restarting. If this is set to "no" then the server will only ever restart when using the "/restart" command.
- auto-restart-interval: this is how often (in hours) the server will automatically restart itself (only if auto-restart is set to "yes")
- warn-times: Before the server restarts, it will send out a friendly warning to all connected players, this setting is a list that describes the amount of time (in minutes) before the server automatically reboots that players are warning. For example: warn-times: [10, 5, 2, 1] will warn players at 10 minutes, 5 minutes, 2 minutes, and 1 minute before the server reboots.
- warning-message: this is the message that will be displayed as a warning that the server will be restarting soon. You may use classic minecraft server colour codes () and "%t"% to indicate how long before the server reboots. For example: warning-message: "&cServer will be restarting in %t minutes!" will display "Server will be restarting in 5 minutes!" in red (with warn-time = 5)
- restart-message: this is the message that players will see when they are kicked from the server due to the automatic reboot. Again, color codes can be used here.
Editing Your Startup Script
In order for this plugin to work properly, you will have to make a slight modification to
your startup script (craftbukkit.bat on windows, craftbukkit.sh on Linux). This plugin works by
simply scheduling regular "stops" of the server. Then when the server goes down, the
startup script simply loops around and starts the server up again, with minimal mumbo-jumbo.
To differ between a real "/stop" and just a "/restart" you have to check the modification time of the file SimpleRestart/restart.txt in your plugins directory. If a real "/stop" was called then the modification time of the file remains the same. Otherwise, if just a "/restart" was called, the modification time will be changed. There is a helper script für *nix OSes which implements this: simple_restart_helper.sh
This is accomplished in the startup scripts using infinite loops:
- For Windows, put ":start" on the line before what you want repeated, then "goto start" on the line after what you want repeated to make an infinite loop. Example craftbukkit.bat:
@ECHO OFF
SET BINDIR=%~dp0
CD /D "%BINDIR%"
:start
"%ProgramFiles%\Java\jre6\bin\java.exe" -Xmx1024M -Xms1024M -jar craftbukkit.jar
goto start
- For *nix OSes, put "while true" <new line> "do" on the lines before what you want repeated, and "done" on the line after to make an infinite loop. Example craftbukkit.sh:
#!/bin/sh
BINDIR=$(dirname "$(readlink -fn "$0")")
cd "\$BINDIR"
while true
do
java -Xmx1024M -Xms1024M -jar craftbukkit.jar
echo "If you want to completely stop the server process now, press Ctrl+C before the time is up!"
echo "Rebooting in:"
for i in 5 4 3 2 1
do
echo "$i..."
sleep 1
done
echo "Rebooting now!"
done
On Windows, to exit this infinite loop (i.e., take the server down for good), simply close the
command window. On Linux, stop the server then press "Ctrl+C" to cancel the process.
Permissions Nodes
The following permissions can be configured:
- simplerestart.restart to use just about anything in the /restart or /reboot commands, users must have the permission
- simplerestart.time to use the /restart time command, users must have the permission
- simplerestart.memory to use the /memory command, users must have the permission
- Note: simplerestart.* shouldn't work
Commands
All commands may be typed in the console (without the "/" of course) or by players in-game:
- /restart help: gives a simple help menu
- /restart now: restarts the server immediately
- /restart time: informs you how much time is left before the server restarts
- /restart (h|m|s) <time>: turns automatic restarting on (if it was off) and reschedules the next
automatic restart to be <time> (hours, minutes, or seconds) away from now. For example,
to reboot the server in 15 minutes, use "/restart m 15". 'h' is for hours, 'm' is for minutes,
and 's' is for seconds.
- /restart on: turns automatic restarting on (if disabled in configuration OR via
commands. Will start the scheduler from the current time based on the settings
in the configuration.
- /restart off: cancels any pending automatic restarts and prevents automatic restarts
from happening until re-enabled
- /memory: displays the java runtime memory usage, useful for catching runaway plugins
Changelog
- 1.3.4 Updated to Bukkit v1.3.1-R2.0
- 1.3.3 Updated to Bukkit v1.2.4-R1.0
- 1.3.2 Updated to Bukkit v1.2.3-R0.1
- 1.3.1 Updated to Bukkit v1.1-R6. Added support for bPermissions and PermissionsEx.
- 1.3.0 Updated to Bukkit v1.1-R1
- 1.2.0 Changed the scheduling system from Bukkit's internal scheduler (which gets delayed in the event of lag)
to Java timers, which should be server lag-proof.
- 1.1.0 Added multiple warnings and tidied up code a bit
- 1.0.1 Added forced auto-save before reboot and separate permissions node for checking how long before restart
- 1.0.0 Initial release
评论 0
登录后参与评分
还没有评论,来抢沙发吧