-
Notifications
You must be signed in to change notification settings - Fork 4
Plugins Service
CaffeinatedRat edited this page Oct 28, 2012
·
2 revisions
This service exposes the plug-ins that the server is currently using.
These are the properties that are available from this service:
- Plug-in name
- Description
- Author
- Version
You can query the plug-ins service by invoking the service name plugins.
The following is an example of how to invoke the service.
var ws = new WebSocket('ws://192.168.1.1:25564' ); ws.onopen = function() { ws.send('plugins'); };
The following is the format of the response generated by the service.
{ Plugins: [ { name(0): string description(0): string author(0): string version(0): string }, ... { name(n): string description(n): string author(n): string version(n): string } ], Status: string }
The following is an example of the JSON data that is returned by this service.
{ "Plugins": [ { "name": "WebSocketServices", "description": "Provides a simple websocket services for a Minecraft server.", "author": "[CaffeinatedRat]", "version": "1.0.2" }, { "name": "Spectator", "description": "A plugin that will communicate through WebSocketServices to provide a server description to a webgl client.", "author": "[CaffeinatedRat]", "version": "1.0.0.0" } ], "Status": "SUCCESSFUL" }
The following is an example of how to use JQuery to parse the JSON data.
var json = jQuery.parseJSON(msg.data); if(json.Status == "SUCCESSFUL") { if(json.Plugins.length > 0) { for(i = 0; i < json.Plugins.length; i++) { var plugin = '<tr><td>'; plugin += json.Plugins[i].name; plugin += '</td><td>'; plugin += json.Plugins[i].version; plugin += '</td><td>'; plugin += json.Plugins[i].author; plugin += '</td><td>'; plugin += json.Plugins[i].description; plugin += '</td></tr>'; $('#pluginList').append(plugin); } } else { $('#pluginList').append('<tr><td colspan="4">No plugins.</td></tr>'); } }