VotifierScripts 是一个插件,它会监听 Votifier 的投票事件,并允许你在收到投票时运行 JavaScript 代码(从而带来无限可能!)。该 JavaScript 脚本借助了 buscript 的强大功能,提供了许多全局函数,以提供易于使用的脚本编写体验。无需编程经验即可使用,但在这种情况下,你可能会发现此插件比其他大多数插件更难上手。
此插件需要 Votifier,但已预打包了 buscript。
最新的开发构建版本始终可以在 找到。
命令
目前只有一个命令:
/vstest <player> [service [address [timestamp]]]
- 此命令用于测试在收到投票时运行的脚本。
- 权限:votifierscripts.test
- <player> 用于指定脚本的目标玩家。通常情况下,如果你要使用它,目标应该是在线的玩家。
- 测试命令将始终重新加载 vote-script.txt 文件,因此即使你修改了脚本,也无需进行任何特殊操作。
- 其余三个参数是可选的,但每个参数都需要使用前一个参数,因此要使用 timestamp,你必须提供所有四个参数。这将帮助你更全面地测试投票脚本。
脚本
脚本是包含 JavaScript 代码的文本文件。对于不熟悉编码的人来说,这听起来可能有些可怕,但幸运的是 VotifierScripts 提供了几种易于使用的方法来创建基本脚本。
当 Votifier 收到投票时被调用的主脚本位于 plugins/VotifierScripts/vote-script.txt。你会注意到这个脚本最初带有一个简单的内置示例。你可以随意修改它!
主脚本调用的任何脚本都必须位于 plugin/VotifierScripts/scripts 目录中,并且可以拥有你想要的任何名称或文件扩展名。
脚本功能
- 易于使用的全局函数,包括运行命令、广播消息、权限管理等。
- 这些全局函数中使用的所有字符串都可以访问 "%target%",它代表脚本当前的目标玩家。例如:broadcast("Hello, %target%")
- 能够以 100% 的可靠性在稍后时间运行另一个脚本,即使服务器崩溃也是如此!
- 定义了全局变量 target,以便对脚本的目标玩家执行更高级的操作。
- 还提供了全局变量 server,可以直接访问 Bukkit 服务器变量,就像你在插件内部工作一样!
详细脚本功能
特定于 VotifierScripts 的附加全局函数和变量
示例脚本
- 简单广播/命令示例
- vote-script.txt
broadcast("Hey everyone, %target% is a cool guy!")
command("op %target%")
- 这是一个简单的脚本,它会告诉服务器上的每个人目标玩家(在本例中为 dumptruckman)有多酷,然后给予他管理员权限。
- 定时权限示例
- vote-script.txt
message("%target%", "You have just been given flight in the creative world for 30 minutes!")
addPerm("creative", "%target%", "flight.permission")
runLater("remove-perm.txt", "30m", "%target%")
- scripts/remove-perm.txt:
message("%target%", "Your flight power has been removed, hope you weren't up there!")
removePerm("creative", "%target%", "flight.permission")
- 请注意这两个脚本需要 Vault 和一个兼容 Vault 的权限管理器,以便在玩家不在线时也能正常工作。
- 你也可以选择使用 command() 函数来运行你自己的权限命令,而无需使用 Vault。
- 另外注意 "flight.permission" 并不是一个真实的权限。你实际启用飞行的权限可能有所不同(甚至可能不存在!)
面向开发者
源代码:
Maven 仓库:
Maven pom 信息:
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>votifierscripts</artifactId>
<version>1.0-SNAPSHOT</version>
如果您愿意,可以向脚本中添加自己的功能。以下是接入 VotifierScripts 的方法:
Plugin plugin = Bukkit.getPluginManager().getPlugin("VotifierScripts");
if (plugin != null) {
Buscript buscript = ((VotifierScripts) plugin).getScriptAPI();
// 对 buscript 对象执行操作,详见下方文档
}
有关 buscript 库的更多信息,请访问:
VotifierScripts is a plugin that listens for Votifier votes and allows you to run javascript code when a vote is received (allowing for endless possibilities!) This javascript is enhanced with the power of buscript which gives access to many global functions in order to make an easy to use scripting experience. No programming experience is required, but in that case you may find this plugin harder to use than most.
This plugin requires Votifier but already comes prepackaged with buscript.
The latest development builds can always be found at
Commands
Currently there's just one command
/vstest <player> [service [address [timestamp]]]
- This command tests the script that is run when a vote is received.
- Permission: votifierscripts.test
- <player> is used to indicate a target for your script. In general, this should probably be someone that is online if you are going to use it.
- The test command will always reload the vote-script.txt file so there is no need to do anything special should you modify the script.
- The other 3 arguments are optional but each one requires using the one before it, so to use timestamp you have to do all 4. These will help you more fully test a vote script.
Scripts
Scripts are text files that contain Javascript code. This may sound scary to people unfamiliar with coding but luckily VotifierScripts provides several easy to use methods for creating basic scripts.
The primary script that is called when Votifier receives a vote is located at plugins/VotifierScripts/vote-script.txt. You will notice this script initially comes with a simple built in sample. Feel free to modify this!
Any script that the primary script runs must be located in plugin/VotifierScripts/scripts and may have any name/file extension you like.
Script Features
- Easy to use global functions including command running, message broadcasting, permission management and more.
- Any string used in these global functions has access to "%target%" which represents the current target of the script. Example: broadcast("Hello, %target%")
- The ability to run another script at a later time with 100% reliability, even if the server crashes!
- Defines the global variable target so more advanced things can be done with the script's target.
- The global variable server is also available which gives direct access to the Bukkit server variable just as if you were working from within a plugin!
Detailed Script Features
Example Scripts
- Simple broadcast/command sample
- vote-script.txt
broadcast("Hey everyone, %target% is a cool guy!")
command("op %target%")
- This is a simple script that tells everyone on the server what a cool guy the target (dumptruckman in this case) is and then ops them.
- Timed permission sample
- vote-script.txt
message("%target%", "You have just been given flight in the creative world for 30 minutes!")
addPerm("creative", "%target%", "flight.permission")
runLater("remove-perm.txt", "30m", "%target%")
- scripts/remove-perm.txt:
message("%target%", "Your flight power has been removed, hope you weren't up there!")
removePerm("creative", "%target%", "flight.permission")
- Please note these two scripts require Vault and a Vault compatible permission manager which allows them to work even when the player is not online.
- It is possible to instead use the command() function to run your own permission commands without using Vault.
- Also note "flight.permission" is not a real permission. Your actual flight enabling permission may vary (or not even exist!)
For Developers
Source code:
Maven repository:
Maven pom information:
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>votifierscripts</artifactId>
<version>1.0-SNAPSHOT</version>
You can add your own functionality to the scripts if you so choose. Here's how to hook into VotifierScripts:
Plugin plugin = Bukkit.getPluginManager().getPlugin("VotifierScripts");
if (plugin != null) {
Buscript buscript = ((VotifierScripts) plugin).getScriptAPI();
// Do stuff with buscript object, see documentation below
}
For more information about the buscript library, visit:
评论 0
登录后参与评分
还没有评论,来抢沙发吧