ShellReact

插件

· 作者 _ForgeUser9364140

触发了 shell 命令和警报。

3 本站下载 0 关注 更新于 9 年前

最新 va_shellreact ver 3.0 · 1.7.2

一键开服(送7天)

响应事件

Shell React 监控服务器和玩家的常规事件,并据此运行特定的 shell 程序或脚本。音频警报高度可配置,且每个事件的警报可以不同。最初设计用于在玩家加入私有服务器时触发带宽的释放。它可以可靠地检测到“空闲”的服务器状态,从而触发相应的外部脚本将带宽重定向到其他用途。该概念拥有众多应用场景,潜力仅受限于你的想象力。

自定义命令

快速定义能够访问玩家、控制台甚至主机操作系统的安全命令。自定义命令具有多种可定义的覆盖能力。现有的命令可以被动态重新映射以执行其他操作。你可以定义能够调用其他命令的新命令,包括自定义消息、音频输出和参数控制。

Bukkit 集成

ShellReact 将 Bukkit 服务器集成到其主机操作系统中。可以使用标准的操作系统功能来控制 Bukkit 服务器,而 Bukkit 服务器也可以使用这些相同的标准功能来指导其运行的主机。

热加载处理

按照设计,你可以在在线运行的服务器上实施更改。配置文件 'config.yml' 是用户界面,也是始终如一的主参考文件。ShellReact 永远不会修改此文件,它仅在收到命令时从中更新。例如,在 'config.yml' 中添加一个新命令,然后在控制台或作为玩家输入 /sr,瞧!它就生效了。功能可以随时开启或关闭。服务器构建者或管理员可以拥有专用的 'config.yml' 库,这些库可以复制到 ShellReact 目录并立即调用。

YAML 验证

从版本 2.5 开始,ShellReact 会预扫描其 YAML 配置文件,并且仅在其有效时才会从中更新。如果无效,则会报告语法错误以及所在的行/列位置。配合这一新增强健壮性的是自动重载功能:当检测到配置文件有任何更改时,ShellReact 会自动重载。预扫描使得这使用安全。该功能是可选的,默认处于关闭状态。

双向交互

版本 2.5 还新增了与主机操作系统的双向交互功能。这是通过使用两者共用的底层文件系统来实现的。可以使用主机操作系统的计划任务或 cron 来触发正在运行的 Bukkit 服务器上的已定义过程。从任何可以访问 ShellReact 目录的地方发送信号以重启、停止服务器或保存全部数据等。我个人最喜欢的是当服务器运行时出现在桌面上的停止和重启按钮,而在服务器停止时它们会消失。

结构化方法

在 ShellReact 中定义的命令触发器和响应非常结构化且具有自文档特性。这使得在不迷失方向的情况下基于现有工作进行扩展变得容易。随用随进,在坚实的基础上构建。

更新是可选的

Shell React 目前支持 Microsoft 和 Linux 操作系统,并在可用时充分利用集成的主题音频。它是一个真正的 Bukkit 插件,仅通过 Bukkit API 获取对 Minecraft 的访问权限。这使 Shell React 免于任何版本限制要求。将只有一个版本 :-) 它完全用 Java 编写,旨在成为一个稳健的插件,简单好用且让人忘记它的存在。本描述的其余部分将是 'config.yml' 文件,因为它旨在实现自文档化。

注意:我已将此标记为适用于 146 和 147 版本,但它应该也适用于早期版本的 Bukkit。我只是还没有测试过它们。

示例

CONFIG.YML

# Shell React, a Bukkit plugin

ShellReact will use Vault for permissions if it is installed,

otherwise it defaults to Bukkit permissions.

This is a light weight plugin that endeavors to use only the

resources it needs to implement what is defined in this file.

There is also no limit on numbered definitions, discretion is

left to the user.

ShellReact is a system level configuration utility designed to

facilitate automatic responses to specified events. An event may

be originated by the Bukkit server, the host OS or a user/player.

Two way communication with the host OS makes it possible for

server builders to control the Bukkit server using the underlying

file system, common to both. Customizable audio alerts on the

server may be defined. General access to defined player commands

may be secured by op status, permission status, or even to a

specific player. Ops are given access to the configuration

environment by default, but ops don't always have file system

access. This provides a system level basis of security, by design.

Use /shellreact or /sr to reload config.yml at any time, both

player and console. Or use the auto reload feature in 'Settings'

and ShellReact will automatically reload whenever changes are

made to 'config.yml'. ShellReact never modifies config.yml, this

file is always the master. ShellReact only uses 'config.yml' on

startup or when reloading. All configuration details are retained

in memory arrays. On reload, all memory arrays are rebuilt and

'config.yml' is released. Everything setup here is designed to

be added and modified hot, without disturbing the server.

Permission node 'shellreact.admin' is required to use the

/shellreact command if the Allow_op_shellreact flag under settings

below is set to 'false'.

DON'T USE TABS, PERIOD. Follow standard YAML rules and formatting.

'config.yml' is validated when loaded or reloaded. A syntax error

will be concisely displayed along with the row/column. This

validation is done before using the yaml file allowing ShellReact

to routinely abort the process, leaving the existing config intact.

此文件中的每个可配置项都有一个“Active”标志,

旨在方便根据需要动态开启或关闭触发器。因此,

未始终保持激活状态的触发器的详细信息在非活动状态下仍可保留完整。

每个单独的设置都有合理的默认值,如果未使用或默认值合适,则可以省略。字符串设置通常默认为 'none',布尔值通常默认为 'false'。无效的设置将恢复为其默认值。

玩家和服务器的冷却时间决定了在最终确定服务器空闲状态之前等待的时间长度。这为遭受 TCP 问题的玩家提供了缓冲,并防止了不必要的玩家退出处理。

'Platform'(平台)可以是:'Auto'、'Windows'、'Linux' 或 'Custom'(自定义)。

'Custom'(自定义)除了命令本身外,还需要定义由 'Shell_cmd' 指定的 shell 和 shell 参数。即:

Shell_cmd: CMD, /C, batch.cmd parm1 parm2 等

使用逗号分隔 shell、shell 参数和命令。

Settings: Platform : Auto Allow_op_shellreact : true Auto_reload : false Quiet : false Debug : false Player_quit_cool : 10 Server_vacant_cool : 20

当 'Auto_reload' 设置为 'true' 时,ShellReact 会在检测到 'Config.yml' 发生更改时自动重新加载它。

将 'Quiet' 设置为 'true' 以关闭所有 ShellReact 消息,仅保留自定义的 'Message_out' 字符串和错误消息。

当 'Debug' 设置为 true 时,将在控制台显示你的 shell 命令的输出。

对于 Windows 平台,建议对 shell 命令使用标准反斜杠而不是正斜杠,但两者应该都可以。

FQN(完全限定名称)示例:

Shell_cmd: C:\parent_dir\child_dir\batch_file.cmd parm1 %player%

UNC(通用命名约定)示例:

Shell_cmd: \Computer\parent_dir\child_dir\program.exe %player%

可以使用平台友好的 'beep' 警报设置音频提醒。

单独的 'beep' 将发出单个控制台蜂鸣声。'beep.5' 将发出 5 次控制台蜂鸣声。'beep.3.300' 将发出 3 次控制台蜂鸣声,间隔 300 毫秒。格式为:beep.[次数].[延迟]

也可以使用标准的 Windows 主题警报。见底部。

在 Windows 中,任何音频都可以使用控制面板/声音连接到任何主题标识符。

'Console_cmd'、'Player_cmd' 和 'Sreact_cmd' 接受用逗号分隔的多个命令。'Shell_cmd' 不需要这样做。

命令处理器接受多条命令,或者,你也可以将所有变量传递给脚本或批处理文件,然后做任何你想做的事,完全独立于 Bukkit 和 Minecraft。隔离,但知情 :-) 例如:

Shell_cmd: SCRIPT.CMD %parameters% %player% %player_ip%

%player_count% %location%

%world% %X% %Y% %Z%

变量 (区分大小写)

%parameters% 运行时输入的参数

%player% 加入或退出的玩家

%player_ip% 玩家的 tcp/ip 地址 '0.0.0.0'

%player_count% 在线玩家数量

%location% 玩家位置,格式为:'world x y z'

%world% 玩家所在的世界位置

%X% 玩家 X 坐标位置

%Y% 玩家 Y 坐标位置

%Z% 玩家 Z 坐标位置

指令 (区分大小写)

'_ ' 下划线后跟一个空格,称为行锚点。用于标记每行的字符串定义开头。消除了平衡引号的需求。有助于多行字符串定义。在运行时被剥离,包括空格。保留它与该行字符串定义起始之间的空白。

_nl 在消息输出中表示换行

_runtime 用于下面 Commands 部分中的 'Default_params' 设置。用于标记该命令使用参数,但未定义默认参数。

'Message_out' 是与玩家命令关联时发送给玩家的自定义消息,否则发送给控制台。使用标准的 '&x' 格式化。变量会被展开。不包含 ShellReact 前缀。在你的字符串中使用 'nl' 来表示换行。如果你的字符串以格式化字符开头,你必须以 ' ' 开头。它将在运行时被剥离。例如:

Message_out: _ &cExample string starting with the line anchor.

行锚点也将保留空白。

使用 Active 'false' 使整个事件处于非活动状态。

使用 'none' 使某个详情未被使用。

***************************************************************

服务器触发器

***************************************************************

Player_join: Active : false Message_out : none Shell_cmd : none Console_cmd : none Sreact_cmd : none Audio_alert : none

Player_quit: Active : false Message_out : none Shell_cmd : none Console_cmd : none Sreact_cmd : none Audio_alert : none

玩家加入和退出的示例。取消注释并替换上面的内容以使用。

按玩家记录日志,存储在名为 'PlayerLogs' 的目录中,位于你的 Bukkit 目录下。你可以随意定制它,或者用于其他用途。

Linux 用户需要更改 shell 命令以适应他们的需求。

#Player_join:

Active : true

Message_out : none

Shell_cmd : _ MD .\PlayerLogs &

_ ECHO %date% %time% JOINED from %player_ip% at

_ %location% with %player_count% players online.

_ >> .\PlayerLogs%player%.log

Console_cmd : none

Audio_alert : beep

#Player_quit:

Active : true

Message_out : none

Shell_cmd : _ ECHO %date% %time% QUIT from %player_ip% at

_ %location% with %player_count% players online.

_ >> .\PlayerLogs%player%.log

Console_cmd : none

Audio_alert : beep.2.500

Server_vacant: Active : false Message_out : none Shell_cmd : none Console_cmd : none Sreact_cmd : none Audio_alert : none

#Server_vacant:

Active : true

Message_out : All changes flushed to disk.

Shell_cmd : none

Console_cmd : save-all

Audio_alert : win.sound.exit

Server_start: Active : false Message_out : none Shell_cmd : none Console_cmd : none Sreact_cmd : none Audio_alert : none

Server_stop: Active : false Message_out : none Shell_cmd : none Console_cmd : none Sreact_cmd : none Audio_alert : none

***************************************************************

以下所有部分均为编号序列列表,

从 0(零)开始,依次递增。正确的顺序是强制性的。内置数量没有限制。

序列号 0 包含每个部分的所有可用设置及其默认值。

可以使用序列 0,但最好将其保留为参考,并保持非激活状态。

无需为每个序列包含所有定义名称。只需包含未使用默认值的定义即可。

***************************************************************

文件触发器。这些是由文件名定义的布尔触发器。

使用此功能从主机操作系统向 ShellReact 发送信号。

当在 ShellReact 目录中找到由 'File_name' 定义的文件名时,即会触发。

该文件会被自动删除,以防止意外递归。

***************************************************************

主机操作系统标志(从 0 开始,依次递增)

***************************************************************

File_triggers: 0: File_name : DEFAULT Message_out : none Shell_cmd : none Console_cmd : none Sreact_cmd : none Audio_alert : none Active : false

1:

File_name : Do_Restart

Message_out : Server restarted using a file trigger.

Sreact_cmd : RESTART

Active : true

2:

File_name : Do_Stop

Message_out : Server stopped using a file trigger.

Sreact_cmd : STOP

Active : true

示例 1 和 2 将向服务器发出停止或重启的信号。

它们引用下方“Commands”部分中的命令。

Windows 示例:在桌面上创建一个新的快捷方式,

并在位置处输入 'cmd /c echo %time% > path_to_ShellReact_dir\Do_Restart',

并将其命名为“RESTART”。为其指定一个漂亮的图标,

这样你就拥有了一个桌面版 Bukkit 重启按钮。

服务器可以位于网络上的任何位置。

控制台监控触发器。这些是由不区分大小写的字符串定义的触发器。

当控制台输出的行中找到 Trigger_string 时,将调用该触发器。

Trigger_string 要在控制台输出中查找的字符串

Trigger_cool 连续调用之间的最小延迟(毫秒)

***************************************************************

控制台监控触发器(从 0 开始,依次递增)

***************************************************************

Console_mon: 0: Trigger_string : DEFAULT Message_out : none Shell_cmd : none Console_cmd : none Sreact_cmd : none Trigger_cool : 10000 Audio_alert : none Active : false

1:

Trigger_string : Did the system time change

Message_out : Automatic server lag response example.

Console_cmd : lag

Trigger_cool : 30000

Active : true

自定义命名命令。这些是由玩家输入的命令,

并且可以选择性地包含控制台输入。

这些也是可以从任何部分通过 'Sreact_cmd' 设置调用的命名子程序。

使用此功能配合 /shellreact 或 /sr 命令,

动态添加安全的控制台和玩家命令序列,

这些序列可以选择性地提醒控制台并触发 shell 命令。

此设计支持热配置,无需干扰服务器或正在进行的游玩过程。

虽然动作序列可能相当长,但采取的措施确保以不会干扰 Minecraft 游玩的方式调用它们。

例如;一条典型的命令将立即调用 'Player_cmd' 序列。

'Console_cmd' 和 'Sreact_cmd' 序列随后会有轻微延迟地执行。

'Shell_cmd' 和 'Audio_alert' 则在各自的线程上调用。

当 Override 设置为 false 时,此处定义的命令不会影响

其他插件或服务器中具有相同名称且名为 'Name' 的命令。

这里的响应将仅补充任何其他同名命令。

将 Override 设置为 true 将有效地创建一个主命令,

取代并替换来自其他插件的任何同名命令。

Cmd_name 玩家或控制台(触发器)输入的命令

可从任何部分调用。

Default_params 如果命令未输入参数时使用的参数

使用指令 '_runtime' 表示需要参数,但未设置默认值

Player_cmd 要运行的实时玩家命令

Override 取消并替换原始输入的命令

Include_console 设为 'true' 以包含控制台输入

权限

仅在由在线玩家调用时生效。要使某条命令对特定玩家可用,

必须满足以下条件之一。

如果未设置任何玩家权限且 'Include_console' 为 true,

则该命令仅对控制台可用。如果同样情况下 'Include_console' 为 false,则该命令

只能作为子程序被调用,由 'Sreact_cmd' 定义

Op_allow 'true' 表示响应 OP(管理员)

Perm_node 权限节点,设为 'none' 则忽略节点检查

Player_allow 指定玩家的权限,设为 'none' 则忽略玩家检查

***************************************************************

自定义输入命令(从 0 开始,依次递增)

***************************************************************

Commands: 0: Cmd_name : DEFAULT Default_params : none Message_out : none Shell_cmd : none Console_cmd : none Player_cmd : none Sreact_cmd : none Audio_alert : none Override : false Include_console : false Op_allow : false Perm_node : none Player_allow : none Active : false

1:

Cmd_name : RESTART

Message_out : Restarting the server...

Shell_cmd : echo %time% > .\restart

Console_cmd : save-all, stop

Audio_alert : beep.5.1000

Override : true

Include_console : true

Op_allow : true

Perm_node : group.admin

Active : true

2:

Cmd_name : STOP

Message_out : Stopping the server...

Shell_cmd : del .\restart

Console_cmd : save-all, stop

Audio_alert : beep.5.1000

Override : true

Include_console : true

Active : true

3:

Cmd_name : RULES

Default_params : be

Message_out : Example root cmd, default parameter 'be'

Sreact_cmd : rules %parameters%

Override : true

Include_console : true

Op_allow : true

Perm_node : group.players

Active : true

4:

Cmd_name : RULES no

Message_out : _ &a Server Rules (No) _nl

_ &e No Kicking _nl

_ &e No Biting _nl

_ &e No Cussing _nl

_ &e No Hair Pulling _nl

Override : true

Include_console : true

Op_allow : true

Perm_node : group.players

Active : true

5:

Name : RULES be

Message_out : _ &a Server Rules (Be) _nl

_ &e Be Nice _nl

_ &e Be Polite _nl

_ &e Be Helpful _nl

_ &e Be Constructive _nl

Override : true

Include_console : true

Op_allow : true

Perm_node : group.players

Active : true

示例服务器重启命令:要使用此功能,请取消注释上述命令 1 和 2。

在用于启动 Bukkit 服务器的批处理文件中,在 java 启动行上方添加

标签 :Restart,并在其后添加文件存在性检查。例如:

SET BINDIR=%~dp0

CD /D "%BINDIR%"

:Restart

java -server -Xmx4G -Xms4G -jar craftbukkit.jar nogui

IF EXIST restart GOTO Restart

Linux 用户;请按所示更改 shell 命令以创建/删除名为 'restart' 的文件,

并修改你的服务器启动脚本以包含该标签和文件存在性检查。

示例命令 3、4 和 5 是 'Message_out' 的格式示例。

演示了 '_ ' 行锚点和 '_nl' 换行格式化符。

它们还展示了使用相同根命令 'RULES' 的两个独立命令定义。

音频警报 ID

通用音频警报(跨平台兼容)

beep.[次数].[延迟]

次数 = 连续蜂鸣的次数,范围为 1 到 5

延迟 = 蜂鸣之间的延迟时间(毫秒),范围为 150 到 1000

Windows 主题警报

win.sound.default

win.sound.close

win.sound.maximize

win.sound.minimize

win.sound.menuCommand

win.sound.menuPopup

win.sound.open

win.sound.restoreDown

win.sound.restoreUp

win.sound.asterisk

win.sound.exclamation

win.sound.exit

win.sound.hand

win.sound.question

win.sound.start

请随意删除注释以符合您的喜好。只需重命名

您的 config.yml 并运行 /shellreact(或 /sr),即可轻松重新生成带有文档的默认

config.yml。此外,各部分的顺序或每个部分内定义的顺序没有任何规则限制。

同样,这也取决于您个人的喜好。但是,编号序列必须正确。

另外,仅当设置值不同于默认值时,才需要单独的设置名称。

通过省略未使用的设置项,可以使您的操作定义更易于阅读。

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源