什么是 SwiftApi?
SwiftApi 是一个基于 Apache Thrift 的 CraftBukkit Minecraft 服务器 API。该 API 允许您使用喜爱的编程语言通过互联网调用 Bukkit 方法。此插件充当服务器端组件,让您能够编写客户端程序、网站或应用程序,从而以几乎任何编程语言与您的 CraftBukkit 服务器进行通信!
SwiftApi 2.0
SwiftApi-2.0-alpha 现已提供下载,同时还有 SwiftApiVault-1.0-alpha。请查阅 wiki 以获取更多信息。
你可以用它做什么?
基本上,SwiftApi 允许你编写出色的代码和应用程序,这些代码和应用程序可以与你的 Minecraft 服务器通信并对其进行控制。
此类应用程序的一个示例是 MineCenter。请访问 查看。
配置选项
根据需要编辑 plugins/SwiftApi/config.yml 文件。
最重要的选项如下:
# 认证信息(请更改这些内容) username: admin password: password salt: saltines
如果保留默认设置,攻击者将很容易利用此 API 入侵你的服务器。
创建客户端应用程序
一旦你下载了 Apache Thrift 编译器,你就可以用几行代码创建一个客户端应用程序。
在此处查看示例 PHP 项目:
在此尝试 C#.NET/VB.NET 教程:
生成客户端库
你可以通过输入以下命令来生成客户端库(示例为 C#):
thrift -r --gen csharp SwiftApi.thrift
-r 选项告诉编译器为所有文件生成代码(包括在 SwiftApi.thrift 中通过 include 指令引用的文件)。gen csharp 选项告诉编译器生成 C# 代码。此命令将为你生成一个包含所有连接运行 SwiftApi 插件的服务器所需代码的 gen-csharp 目录。
将代码包含到你的应用中
如果你使用的是 C#,你可以直接将所有源文件拖入你的客户端应用程序中使用,或者你也可以使用生成的文件创建一个新项目,以保持你的代码与生成的代码分离。
示例
访问 示例页面 查看如何使用代码的示例。
这里有一个 C# 示例:
// 连接到运行 SwiftApi 的服务器 TSocket socket = new TSocket("your.bukkitserver.org", 21111); socket.Open();// 创建一个新的 SwiftApi 客户端对象 TBinaryProtocol protocol = new TBinaryProtocol(new TFramedTransport(socket)); SwiftApi.Client client = new SwiftApi.Client(protocol);
// 获取服务器版本并输出 Console.WriteLine("Server Version: " + client.getServerVersion(authString));
// 关闭连接 socket.Close();
由于代码基于 Apache Thrift,你可以访问 CraftBukkit API 中的许多复杂类型,例如 Player 对象。
这个示例是用 C# 编写的,但 thrift 编译器能够为几乎所有编程语言创建库。
访问 示例页面 查看其他语言的示例
可用的编程语言
截至 Apache Thrift 0.9.0 版本,支持以下语言:
- Actionscript 3 (AS3)
- C (使用 GLib)
- C
- C#
- Cocoa (Mac OS 和 iOS 上的 Objective-C)
- Delphi
- Erlang
- Go
- Haskell
- Java
- Javascript
- OCaml
- Perl
- PHP
- Python (包括 Twisted 异步支持)
- Ruby
- Smalltalk
代码
认为你能改进 SwiftApi?请在 Bitbucket 上 fork 仓库并提交拉取请求!
仓库地址:
注意事项
此插件会向 发送匿名使用统计数据。
要退出,请在 plugins/PluginMetrics/config.yml 中将 opt-out 设置为 true
What is SwiftApi?
SwiftApi is an Apache Thrift based API for CraftBukkit Minecraft servers. This API allows simple calls to Bukkit methods over the internet using your favorite programming language. This plugin acts as the server component, allowing you to write client programs/websites/apps that can talk to your CraftBukkit server in almost any programming language!
SwiftApi 2.0
SwiftApi-2.0-alpha is now available for download together with SwiftApiVault-1.0-alpha. Check out the wiki for more information.
What can you do with it?
Basically, SwiftApi allows you write awesome code and apps that can talk to and control your Minecraft server.
An example of such an app is MineCenter. Check it out at
Configuration Options
Edit the plugins/SwiftApi/config.yml file to your liking.
The most important options are:
# Authentication Information (CHANGE THESE) username: admin password: password salt: saltines
Leaving these at default would make it easy for an attacker to use this API on your server.
Creating a Client App
Once you have downloaded the Apache Thrift compiler, you can create a client app in a few lines of code.
Check out the example PHP project here:
Try the C#.NET/VB.NET tutorial here:
Generate the Client Library
You can generate the client library (example is in C#) by typing
thrift -r --gen csharp SwiftApi.thrift
The -r option tells the compiler to generate code for all files (including ones that are referenced in SwiftApi.thrift with the include directive. The gen csharp option tells the compiler to generate C# code. This command will leave you with a gen-csharp directory with all the code you need to connect to a server running the SwiftApi plugin.
Include the Code in your App
If you're using C#, you can just drag all the source files right into your client app to use them, or alternatively you could create a new project with the generated files to keep your code and the generated code seperate.
Examples
Visit the Examples page for examples of how to use the code.
Here's an example in C#:
//open a connection to a server running SwiftApi TSocket socket = new TSocket("your.bukkitserver.org", 21111); socket.Open();//create a new SwiftApi client object TBinaryProtocol protocol = new TBinaryProtocol(new TFramedTransport(socket)); SwiftApi.Client client = new SwiftApi.Client(protocol);
//get the server version and output it Console.WriteLine("Server Version: " + client.getServerVersion(authString));
//close the connection socket.Close();
Because the code is based on Apache thrift, you have access to many of the complex types in the CraftBukkit API, such as the Player object.
This example is in C#, but the thrift compiler is able to create libraries for almost ANY programming language.
Visit the Examples page for examples in some other languages
Available Programming Languages
As of version 0.9.0 of Apache Thrift, the following languages are available:
- Actionscript 3 (AS3)
- C (using GLib)
- C
- C#
- Cocoa (Objective-C on Mac OS and iOS)
- Delphi
- Erlang
- Go
- Haskell
- Java
- Javascript
- OCaml
- Perl
- PHP
- Python (including Twisted async support)
- Ruby
- Smalltalk
Code
Think you can improve SwiftApi? Fork the repo on Bitbucket and submit a pull request!
Repo URL:
Notes
This plugin sends anonymous usage statistics to
To opt out, set opt-out to true in plugins/PluginMetrics/config.yml
下载 SwiftApi
下载 SwiftApi
下载 SwiftApi
下载 SwiftApi
下载 SwiftApi
下载 SwiftApi
下载 SwiftApi
下载 SwiftApi
下载 SwiftApi
下载 SwiftApi
SwiftApi 插件 2.0 版本
更新内容:
- 将 Thrift 版本更新至 0.9.2
- 新增通过创建依赖 SwiftApi 的插件扩展或使用 API 来扩展自定义服务的功能。
- 新增命令(启动/停止服务器、配置编辑器、扩展列表)
注意:此为 ALPHA 测试版本,请自行承担使用风险。请参阅 Wiki 和 Bitbucket。
此版本对应的 Git 分支
在 CB 1.7.x 之前的版本中,控制台消息将无法正常工作
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
插件
PacketEvents 是一款专为 Minecraft Java 版打造的协议库,旨在简化数据包的处理与传输。
插件
ExyliaPlugins 的库。
插件
通过对话框或铁砧界面帮助你的 Anthme
插件
重新定义服务器上的生物运输方式。使用高度可定制的口袋道具,安全地捕获、存储和释放任何实体。
插件
为基于 Spigot/Paper/Folia 的服务器添加对 Vivecraft 的支持
插件
用于绘制游戏内地图或在浏览器中随探索实时进行地图绘制的实时地图。
评论 0
登录后参与评分
还没有评论,来抢沙发吧