BlackboxMC
BlackboxMC 是一个插件,允许你使用任何能够创建共享库的语言来开发 Spigot 插件,从而让你可以使用除 Java(以及人们已为其制作过插件的其他解释型语言)之外的任何语言。它本质上是一个自动化设置 JNI 流程的插件,但它还提供了一个通过原生代码扩展 Java 类的系统,并且(独立地)允许你创建全局函数以覆盖 JavaPlugin 类中的那些函数(注意:此功能在 Paper 上不受支持,且依赖于一个已被开发者移除、且他们无意恢复的特性)。它即将支持在不使用该系统的情况下创建自定义命令。
编写此插件时,我们深知此前为何无人如此做,以及你可能不愿这样做的原因。
- 以这种方式分发的插件将变得更加困难。
- 从技术上讲,你会损失性能,因为 JNI 调用速度较慢(……在一台良好的机器上大约需要 15ns,这是一个近十年前的指标,但在某些场景下这可能很重要)。
- 你将失去链接到其他插件的能力,因此无法为其他插件创建附加组件,除非你愿意 fork 仓库并为特定插件添加支持(我正在考虑在辅助库中为最流行的插件添加支持)。
这里假设你并不在乎这些。这是给那些对 Java 感到厌倦、永远不想再与 Gradle 或 IntelliJ 打交道,只想使用一种他们真正喜欢的语言的人准备的(假设他们不喜欢 Java)。
用法
目前仅支持 Windows 和 Linux 操作系统。
在 Spigot* 服务器上使用它只需将 BlackBox 插件放入你的 plugins 文件夹即可。然后它将加载你放入同一 plugins 文件夹中的任何 .dll(Windows)或 .so(Linux)文件。
为此进行编码只需要极少关于如何使用 JNI 的知识。它与一个 Rust 库(计划中还有 C++ 库)一起开发,该库主要抽象了使用 JNI 的混乱过程,让你能更专注于插件开发,但该库具有接受 JNIEnv 指针作为参数的函数,因此你仍然需要对 JNI 的工作原理有一个基本概念。如果你想使用其他语言,也需要了解 JNI。
有一个使用该库的入门指南,以及相关的文档。
*由于 Paper 开发者移除了某项特性,因此在 Paper 下某些功能不受支持。如果你使用 Paper,你的插件将不会被视作独立插件,这意味着你无法使用插件的系统来覆盖诸如 getCustomWorldGenerator 或 onCommand 之类的函数。
BlackboxMC
BlackboxMC is a plugin that allows you to develop Spigot plugins using any language that can create shared libraries, allowing to use anything other then Java (and other interpreted languages that people have made plugins for). It's really a plugin that makes automates the process of setting up JNI, but it also has a system for extending Java classes via native code, and also (seperately) allows you to create global functions that override those from the JavaPlugin class (note: this is not supported on Paper and relies on a feature that the devs have removed and have no interest in bringing back). It will soon have support for creating custom commands without using that system.
This plugin is made knowing why this hasn't been done before and why you might not want to do it.
- Distributing plugins made this way becomes much harder.
- You technically lose performance since JNI calls are slow (...they take about 15ns on a good machine and this is a metric that's nearly 10 years old but this might matter in some scenarios)
- You lose the ability to link to, and therefore create addons for, other plugins, unless you want to fork the repo and add support for the plugin in question (I am considering adding support in the helper library for the most popular plugins).
It's assumed that you don't care. This is for the people who are sick of Java, never want to work with Gradle or IntelliJ ever again, and just want to use a language that they actually like (assuming they dislike Java).
Usage
Currently, only Windows and Linux are supported operating systems.
Using it with a Spigot* server simply requires dropping the BlackBox plugin into your plugins folder. It will then load any .dll (Windows) or .so (Linux) files that you drop into the same plugins folder.
Coding for it requires minimal knowledge of how to use JNI. It is developed alongside a Rust library (and a C++ library is planned) that mostly abstracts the messy process of using JNI, allowing you to focus more on plugin development, but said library has functions that take the JNIEnv pointer as an argument, and thus its still important that you have an idea of JNI works. JNI knowledge is also required if you want to use another language.
There is a getting started guide for using the library, and there are docs for it.
*Certain features are unsupported under Paper due to a feature that the paper devs removed. If you use Paper, your plugin won't be treated as a separate plugin, which means you can't use the plugin's system of overriding functions like getCustomWorldGenerator or onCommand.
评论 0
登录后参与评分
还没有评论,来抢沙发吧