描述
PySpigot 是用于 Minecraft 服务器的 Python 脚本引擎。它允许你创建脚本,这些脚本充当“迷你插件”:它们可以注册事件监听器、命令、计划任务等等!
PySpigot 很像 Skript,但功能更强大。PySpigot 使用了 Jython,这是一个完全在 Java 上运行的 Python 实现。这意味着 PySpigot 脚本可以完整访问整个 Bukkit/Spigot API,以及任何其他已加载插件的 API。通常来说,PySpigot 脚本可以做任何 Python 能做的事,也可以做任何插件能做的事。
目前支持 Bukkit 服务器实现,包括 Spigot、Paper 和 Purpur,适用于 Minecraft 1.16 及更高版本。目前有一个非官方的初步版本 PySpigot for BungeeCord 可供开放测试。在此下载。
关于插件和编写脚本的完整文档,请访问官方文档。
加入 Discord 获取支持并了解更新动态!
特性
- 在服务器启动或通过命令时加载脚本
- 通过命令停止、重新加载和卸载服务器脚本
- 支持单文件脚本和多文件项目
- 注册事件监听器
- 注册命令
- 计划任务(同步和异步)
- 处理配置文件
- 注册 ProtocolLib 数据包监听器和发送数据包
- 注册 PlaceholderAPI 占位符扩展
- 针对每个脚本全面记录错误和异常到文件
- 在运行时加载你想要使用的 Java 库
- 使用 Python 语法编写脚本
- 脚本可以完整访问 Bukkit/Spigot API 以及其他插件的 API,因此一切皆有可能。
- 支持与 SQL、Mongo 和 Redis 服务器协作
- 还有更多!
命令
/pyspigot reload: 列出一些有用的链接(文档、Discord 等)
/pyspigot info [scriptname/projectname]: 显示有关脚本或项目的详细信息,包括运行时间、注册的监听器、命令等
/pyspigot listscripts: 列出已加载和未加载的脚本和项目
/pyspigot load [scriptname/projectname]: 加载指定名称的脚本或项目
/pyspigot loadlibrary [libraryname]: 加载指定名称的 Java 库
/pyspigot reloadall: 重新加载整个插件,包括脚本、项目、库和配置
/pyspigot reload [scriptname/projectname]: 重新加载已加载的脚本或项目
/pyspigot reloadconfig: 重新加载 PySpigot 的 config.yml
/pyspigot unload [scriptname/projectname]: 卸载脚本或项目
配置
# 如果设为 false,将禁用 bStats 对 PySpigot 的指标信息收集。你也可以在 /plugins/bStats/config.yml 下的 bStats 配置中全局禁用 bStats。
metrics-enabled: true
# 服务器加载完成后,加载脚本的延迟(以刻为单位)。
script-load-delay: 20
# libs 文件夹中库的重定位规则列表。格式为 <pattern>|<relocated pattern>
library-relocations: []
# 脚本日志文件中时间戳的日期/时间格式,采用 Java 的 SimpleDateFormat 模式:https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/format/DateTimeFormatter.html
log-timestamp-format: 'MMM dd yyyy HH:mm:ss'
# 如果设为 true,每次脚本加载、运行和卸载时,都会向控制台打印日志消息。
script-action-logging: true
# 如果设为 true,会将所有 redis 事件记录到控制台和脚本的日志记录器中。如果设为 false,仅记录重连事件(重连尝试和失败)。
verbose-redis-logging: true
# 如果设为 true,当脚本所依赖的插件被卸载时,脚本也将自动卸载。这对于确保需要依赖插件才能成功完成的脚本关闭任务(在插件卸载之前)特别有用。
script-unload-on-plugin-disable: true
# 与 Jython 相关的选项。更改此部分中的选项需要重启服务器。
jython-options:
# 如果设为 true,Jython 运行时将在插件加载/服务器启动期间初始化。如果设为 false,则直到第一个脚本加载前不会初始化 Jython 运行时。
init-on-startup: true
# 将传递给 Jython 的系统属性列表。完整列表请参阅 https://javadoc.io/doc/org.python/jython-standalone/latest/org/python/core/RegistryKey.html
properties:
- 'python.cachedir.skip=true'
# 初始化时传递给 Jython 的参数列表。相当于 Python 中的 sys.argv。
args:
- ''
# 脚本选项的默认值。如果 script_options.yml 中未定义脚本的一个或多个选项,PySpigot 将回退使用这些值。
script-option-defaults:
# 对于项目而言,这是项目的主脚本文件。
main: 'main.py'
# 脚本是否启用
enabled: true
# 脚本的整数加载优先级
load-priority: 1
# 脚本所依赖的插件列表
plugin-depend: []
# 是否应将脚本日志消息记录到其各自的日志文件中
file-logging-enabled: true
# 记录到控制台和脚本日志文件的最小日志级别
min-logging-level: 'INFO'
# 权限的默认权限等级
permission-default: 'op'
# 脚本的高级调试选项
debug-options:
# 如果设为 true,会将所有与脚本相关的异常的堆栈跟踪打印到服务器控制台
print-stack-traces: false
# 如果设为 true,当 spigotmc.org 上有更新的 PySpigot 版本可供下载时,插件会在控制台显示消息,并向拥有 pyspigot.admin 权限的玩家在加入时显示消息。
show-update-messages: true
# Jython 内部组件的日志级别。为了调试目的,将其设置为 FINE 或 ALL 可能很有用。注意:服务器的根日志记录器也需要配置为接受调试消息,以便显示 Jython 的调试消息。
jython-logging-level: 'INFO'
# 如果设为 true,PySpigot 将在脚本卸载时修补 threading 模块(如果脚本正在使用它),以防止服务器挂起。更多信息请参阅 https://github.com/magicmq/pyspigot/issues/18#issue-3012022678
patch-threading: true
一些有用的链接
- 完整文档:
- 源代码:
- 对于开发者,请在此处查看 PySpigot 的 Javadocs:
指标数据
PySpigot 通过 bStats 收集匿名的服务器统计数据,这是一个用于 Minecraft 服务器的开源统计收集服务。你可以在 PySpigot config.yml 或 /plugins/bStats/config.yml 中选择退出此功能。
Description
PySpigot is a Python scripting engine for your Minecraft server. It allows you to create scripts, which act as "mini-plugins": they can register event listeners, commands, schedule tasks, and more!
PySpigot is a lot like Skript, but much more powerful. PySpigot utilizes Jython, a Python implementation that runs entirely on Java. This means that PySpigot scripts have full access to the entire Bukkit/Spigot API, as well as APIs of any other loaded plugins. In general, a PySpigot script can do anything Python can do, and anything a plugin can do as well.
Currently supports Bukkit server implementations, including Spigot, Paper, and Purpur, on Minecraft versions 1.16 and newer. There is currently an unofficial, preliminary release of PySpigot for BungeeCord available for open testing. Download it here.
For complete documentation on the plugin and writing scripts, visit the official documentation.
Join the discord for support and to stay in the loop regarding updates!
Features
- Load scripts on server start and via commands
- Stop, reload, and unload server scripts via commands
- Support for both single-file scripts and multi-file projects
- Register event listeners
- Register commands
- Schedule tasks (synchronous and asynchronous)
- Work with config files
- Register ProtocolLib packet listeners and send packets
- Register PlaceholderAPI placeholder expansions
- Comprehensive logging of errors and exceptions on a per-script basis, to file
- Load Java libraries you'd like to work with at runtime
- Write scripts in Python syntax
- Scripts have complete access to the Bukkit/Spigot API, as well as APIs of other plugins, so anything is possible.
- Support for working with SQL, Mongo, and redis servers
- And more!
Commands
/pyspigot reload: List some useful links (Documentation, Discord, etc.)
/pyspigot info [scriptname/projectname]: Displays detailed information about a script or project, including uptime, registered listeners, commands, and more info
/pyspigot listscripts: List loaded and unloaded scripts and projects
/pyspigot load [scriptname/projectname]: Load a script or project with the given name
/pyspigot loadlibrary [libraryname]: Load a Java library with the given name
/pyspigot reloadall: Reload the entire plugin, including scripts, projects, libraries, and config
/pyspigot reload [scriptname/projectname]: Reload a loaded script or project
/pyspigot reloadconfig: Reload PySpigot's config.yml
/pyspigot unload [scriptname/projectname]: Unload a script or project
Configuration
# If false, will disable collection of metrics information by bStats for PySpigot. You may also disable bStats server-wide in the bStats config.yml under /plugins/bStats.
metrics-enabled: true
# The delay for loading scripts (in ticks) after the server finishes loading.
script-load-delay: 20
# List of relocation rules for libraries in the libs folder. Format as <pattern>|<relocated pattern>
library-relocations: []
# Date/time format for timestamps in script log files, written in Java's SimpleDateFormat pattern: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/format/DateTimeFormatter.html
log-timestamp-format: 'MMM dd yyyy HH:mm:ss'
# If true, will print log messages to console every time a script is loaded, run, and unloaded.
script-action-logging: true
# If true, will log all redis events to the console and to a script's logger. If false, will only log reconnect events (reconnect attempts and failures)
verbose-redis-logging: true
# If true, scripts will be automatically unloaded if a plugin the script depends on is unloaded. This is especially useful to ensure script shutdown tasks that require a depending plugin complete successfully (prior to the plugin being unloaded).
script-unload-on-plugin-disable: true
# Options that pertain to Jython. Changing options in this section requires a server restart.
jython-options:
# If true, the Jython runtime will be initialized during plugin load/server start. If false, the Jython runtime will not be initialized until the first script is loaded.
init-on-startup: true
# A list of system properties that will be passed to Jython. For a complete list, see https://javadoc.io/doc/org.python/jython-standalone/latest/org/python/core/RegistryKey.html
properties:
- 'python.cachedir.skip=true'
# A list of args to pass to Jython when initialized. Equivalent to sys.argv in Python.
args:
- ''
# Default values for script options. If one or more options are not defined in the script_options.yml for the script, then PySpigot will fall back to these values.
script-option-defaults:
# For projects, the main script file for the project.
main: 'main.py'
# Whether the script is enabled
enabled: true
# An integer load priority for the script
load-priority: 1
# A list of plugins the script depends on
plugin-depend: []
# Whether script log messages should be logged to its respective log file
file-logging-enabled: true
# The minimum level to log to the console and to the script's log file
min-logging-level: 'INFO'
# The default permission level for permissions
permission-default: 'op'
# Advanced debug options for scripts
debug-options:
# If true, will print stack traces for all script-related exceptions to the server console
print-stack-traces: false
# If true, the plugin will show messages in console and on join (to players with the permission pyspigot.admin) when a newer version of PySpigot is available to download on spigotmc.org.
show-update-messages: true
# The logging level for Jython internals. Can be useful to set this to FINE or ALL for debugging purposes. Note: the server's root logger will also need to be configured to accept debug messages for Jython's debug messages to show.
jython-logging-level: 'INFO'
# If true, PySpigot will patch the threading module on script unload (if it's being used in the script) in order to prevent the server from hanging. For more information, see https://github.com/magicmq/pyspigot/issues/18#issue-3012022678
patch-threading: true
Some Helpful Links
- Complete documentation:
- Source code:
- For developers, check out PySpigot's Javadocs here:
Metrics
PySpigot collects anonymous server statistics via bStats, an open-source statistics collection service for Minecraft servers. You may opt out of this feature in the PySpigot config.yml or in /plugins/bStats/config.yml.
评论 0
登录后参与评分
还没有评论,来抢沙发吧