WebSocketServices

该插件是一个持续演进的项目,旨在通过 WebSocket 为 Minecraft Bukkit 服务器提供 Web 支持。此 WebSocket 实现设计为轻量级且简单,以降低对游戏服务器本身的开销。支持 WebSocket 的客户端将能够执行简单的信息查询,例如谁在线、服务器运行的是哪个版本等。所有文本结果将以简单的 JSON 格式返回,以确保一致性。
服务
服务是基于文本的方法,客户端脚本可以通过 WebSocketServices 插件调用这些方法,以获取有关 Minecraft 服务器的更多信息。此外,每个服务都可以根据用户的偏好启用或禁用。以下列出的当前可用服务,并且可以通过使用自定义插件进行扩展:
- Info - 有关服务器的信息,如地址、MOTD(每日消息)、版本、游戏模式等。
- WHO - 有关当前在线用户的信息。
- Whitelist - 有关当前白名单用户的信息。
- Plugins - 有关服务器上运行的所有插件的信息。
- OfflinePlayers - 有关所有离线玩家的信息。
- Player - 有关特定玩家的信息。
示例站点
可以在下面列出的 URL 中找到针对此插件运行的客户端脚本实现的示例。该站点使用纯 HTML5 和 JS 运行。请注意,示例站点需要支持 HTML5 和 WebGL 的浏览器。
兼容性说明
本插件仅支持支持 Websockets Protocol 13 RFC 6455 的浏览器。这些浏览器包括:
- Firefox 11+
- Chrome 16+
- Safari 6+
- IE 10+
BUG 通知(1.1.6 及更低版本)
目前 offlinePlayer 服务中存在一个错误,导致对该服务的所有调用都被拒绝。这是一个非常简单的修复,将在 1.1.7 版本中修复。要修复您服务器上的问题,请转到此插件的 config.yml 并将 offlinePlayers 重命名为 offlineplayers。它必须全部为小写,如下所示。对于由此可能造成的任何不便,我深表歉意。
services:
...
offlineplayers: true
...
配置
有关服务器配置的详细信息,请参阅此处。
面向非开发者
本插件包含一个客户端包,以示例形式提供。为了使用客户端包,您需要有一个托管网站或博客,以便在其中查看您的服务器信息。
博客实现的示例可以在 找到(如果无法访问该站点,敬请谅解。我目前的主机遇到问题)。
面向开发者
额外的名为 websocketservices.min.js 的客户端库可在 github 上找到,并包含在下载包中。该库应能提供最简单的实现。如果您更喜欢更复杂的内容或希望根据您的喜好定制内容,请阅读以下部分。
客户端开发说明
WebSocketServices API 可以在下面列出的 github wiki 位置找到。
代码实现的示例可以在 github 上的 'examples/client-side/' 中找到,也可以在上面列出的示例站点中找到。
扩展
WebSocketServices 可以通过自定义开发进行扩展。插件可以通过创建自己的 ApplicationLayer 并使用静态方法 WebSocketServices.registerApplicationLayer(Plugin plugin, IApplicationLayer applicationLayer) 进行注册来挂钩到 WebSocketServices 服务器。更多细节将在不久的将来在 github wiki 上发布。
源代码
插件的源代码和进一步开发可以在以下 github 仓库中找到:
WebSocketServices

This plug-in is an ongoing and evolving project with the intent to bring web support, through websockets, to the Minecraft bukkit servers. This implementation of websockets is designed to be light-weight and simple, reducing overhead to the game server itself. Clients that support websockets will have the ability to perform simple informational queries, such as who is online, what version the server is running on, etc. All text base results will be returned in a simple JSON format for consistency.
Services
Services are text-based methods that a client-side script can invoke through the WebSocketServices plug-in in order to retrieve more information about a Minecraft server. Additionally, each service can be enabled or disabled depending on the user's preference. The following services listed below are currently available and can be expanded through the use of custom plugins:
- Info - Information about the server such as the address, MOTD, version, game mode, etc.
- WHO - Information about the users currently online.
- Whitelist - Information about who is currently white-listed.
- Plugins - Information about all the plug-ins running on the server.
- OfflinePlayers - Information about all offline players.
- Player - Information about a specific player.
Sample site
A sample implementation of client-side scripting running against this plugin can be found at the URL listed below. The site is running in pure HTML5 & JS. Please note that the sample site requires an HTML5 & WebGL capable browser.
Compatibility Notes
This plugin is only supported by browsers that support Websockets Protocol 13 RFC 6455. These browsers include:
- Firefox 11+
- Chrome 16+
- Safari 6+
- IE 10+
BUG NOTICE (Versions 1.1.6 and lower)
There is currently a bug in the offlinePlayer service, where all calls to it are rejected. It's a very simple fix and will be fixed in version 1.1.7. To fix the issue on your server, go to config.yml for this plug-in and rename the offlinePlayers to offlineplayers. It must be all lower case, as show below. I apologize for any inconvenience this may be causing at this time.
services:
...
offlineplayers: true
...
Configuration
Detailed information about your servers configuration can be found here.
For Non-Developers
A client-side package is included with this plug-in, in the form of an example. In order to use the client-side package, you will have to have either a hosted web-site or a blog, where your server information can be viewed.
An example of a blog implementation can be found at (apologies if the site cannot be reached. I'm currently having problems with my host).
For Developers
An additional client-side library called websocketservices.min.js is available on github and is included in the downloadable package. This library should be able to provide the most simplest of implementations. If you prefer something more complex or something that you'd like to tailor to your tastes, please read the sections below.
Client-Side Development Notes
The WebSocketServices API can be found at the github wiki location listed below.
Samples of code implementation can be found on github under 'examples/client-side/', as well as on the sample site listed above.
Extensions
WebSocketServices can be expanded through the use of custom development. Plug-ins can hook into the WebSocketServices server by creating their own ApplicationLayer and registering with static method WebSocketServices.registerApplicationLayer(Plugin plugin, IApplicationLayer applicationLayer). Further details will be released on the github wiki in the near future.
Source
Source code and further development of the plugin can be found at the following github repo:
评论 0
登录后参与评分
还没有评论,来抢沙发吧