WebSocketServices
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.
http://www.caffeinatedrat.com/minecraft/
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 http://blog.caffeinatedrat.com (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.
https://github.com/CaffeinatedRat/WebSocketServices/wiki
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:
@caffeinatedrat
Great :-) It works,s, when i change config.yml from offlinePlayers to offlineplayers.
Thanks
one error I have, but not from you, i Think. If it is running "bukkit Lockette", no plugins are displayed. But i think, lockette is to old.
@jeracom
No worries, I'll try my best to answer your question. The offlineplayers service shows all players who have logged into your server at least once. Minecraft only starts keeping records of players when they log into your server.
Right now there is a small bug in this service, it will not work unless you change the service name in the config.yml from offlinePlayers to offlineplayers.
@caffeinatedrat
The website is still under construction. Therefore local. What is the Sin of the "offline player" ? Not purchased Minecraft show, right? These are cached in the list? These are not displayed. everything else yes
Excuse my english, I'm from Germany
@Sadorhael
The spectator extension may take a while, since it requires a lot of work in recreating a lightweight minecraft client in webgl.
As far as the offlineplayer service goes, it's supposed to show you everyone, who is offline and has logged into your server at least once. Although it looks like this service might have a bug in it. It's a simple fix, but I'll have to patch it.
To fix it, under the config.yml, rename offlinePlayers to offlineplayers, so that it's lowercase, and reload your settings. This should fixed the issue.
@caffeinatedrat
Thank you :-) I have installed your example code and tried it on my website. It works perfectly, except for the "Offline players" list (what is that supposed to do?). The whitelist.txt, is that for servers allowed to collect information?
How about the "Spectator" feature? How is that coming along?
@Sadorhael
You are correct in both accounts. You cannot run this on the same port as Minecraft, and yes the plug-in allows you to collect info from the minecraft server from an external domain. For example, the demo site listed above http://www.caffeinatedrat.com/minecraft/ is a completely isolated site & domain from my minecraft development server, although it may not appear that way since I using subdomain redirection for minecraft.caffeinatedrat.com. You can also restrict which domain can access the WebSocketServices plug-in by enabling the white-list feature and adding those domains to the White-list.txt file; however, this is not absolute, as those that know how and what to spoof in a custom client, can still ping the server for info. As always, if you have anymore questions, please feel free to ask. Thanks.
@MicroWhite6
Normally, you do not setup the address as it will be the same address that your minecraft server is running on; however, you can change the port, since Minecraft uses port 25565, this plug-in uses port 25564 by default. The port number can be changed from within the config.yml file. If you have any more questions, or if I have misunderstood your question, please let me know.
@caffeinatedrat
Thank you very much for your in-depth reply. I'm a software developer by trade, so don't worry about using technical jargon :-)
My question was really if it is possible to collect the data from a minecraft server remotely, let's say I run my MC server on IP minecraft.mydomain.com and want to run the web client displaying the web socket data on mcwindow.anotherdomain.com. Is this possible? From the example you gave me, it seems to be possible.
Another question: As I take it, this service may not run on the same port as Minecraft, right?
so with the plugin set up, how do i set the websocketAddress inside the java file?
@jeracom
No worries. Are you still having trouble with offline players showing up? If so, do you have a site that I can look at? The caveat with the offline players is that they will only show up if they have logged in at some point in time. I don't think this is your issue, but it is something to note.
"3d player characters" works, my mistake with drupal :-)
when will the "offline player" appears. For me, they are not displayed. When the whitelist Tab is active, the profile doesn't show "3d player characters". They are not displayed. Do I have to do anything?
@Sadorhael
Sorry to get back to you so late. I'm not sure if you're asking how the plugin works or how you can configure it to work, so I'll try to answer both.
How the plug-in works
The plug-in works by using the relatively new HTML5 protocols WebSockets, which allows your browser to connect to any port using TCP. This allows you to create a website, where the client-side scripting (javascript) will open a connection with your minecraft server, send a service request that the server will process, and return that information back to the browser, which will then be parsed by javascript to create the results you see. The intention of developing this plug-in was to make it server language independent, and to allow the server information to be accessed from any external source.
Plug-in Setup
To use this plug-in, just drop it on your server like you would any other plug-in. Configure the port (25564 by default), and make sure your host is not blocking this port. Now I am not sure of the extent of your technical expertise as far as web development goes, so you have two options.
If you have a strong understanding of javascript, HTML, etc, you can write your own client-side script to handle the service calls. I've written a wiki on how to use the WebSocketServices plug-in API, located here https://github.com/CaffeinatedRat/WebSocketServices/wiki.
If you do not have a strong understanding of web development, or do not have the time to write your own client-side scripting, there is a library (websocketservices.min.js) included with the plug-in. There is also an example included with the plug-in, that you may use as is. When using the websocketservices.min.js, just make sure that you set the websocketAddress or else you'll get an exception. For example, this is how I have it set on my site to hit my demo minecraft server:
Unfortunately I have not had time to document this object and its method calls at this time, so hopefully the example can provide enough details. I hope this answered your questions. If not, please let me know, and if you have any issues with configuration, setup, or even managing the client-side scripting, please let me know, and I'll help you work through it. Thanks.
How can this be used from a different server? I have the server's webpage running on another IP and server than Minecraft itself (which I rent as a service). How can I have this connecting to the remote Minecraft server?
@mxwllmcly
Heya mxwllmcly,
I left you a private message on this issue. It seems like this might be a simple issue, please respond to me and let me know. THanks.
this looks so awesome!! hope i can get this to work
the test site: test.blackberryweb.info
- ive installed the plugin - port forwarded the default port - downloaded the current client-side/fancy - moved to my IIS/setup properly (i run other sites so i get that part)
but all i get is the offline/The server cannot be found. You must be lost and it looks like this is the end.
ive looked for some config options to point to, like IP or anything like that and couldnt find anything
@caffeinatedrat any help would be appreciated :)
EDIT - i did update my internal IP in the minecraft.js but still didnt help
@diegobh
Sure, I'll send you a private message and we can work though this.
I`ve got the fancy example and it works. But i cant understand how.
I just want to list the players who is online at the moment and if u put the mouse over it, shows world that he is and how much time he is playing.
The same for offline players, but if u put mouse over the nameof player,it shows the date and hour that he played the last time.
I created a html at the same folder than fancy example index, but it dont works. HTML File / SS Error
@caffeinatedrat: Could u help me, please?
Thank you!
@caffeinatedrat
I'm going to check it and post here if i need some help.
Thank you very much for your attention.
@diegobh
Hi diegobh,
You can use the sample site at the URL listed below. Just grab everything in those folders and drop them onto your server. If you have any problems setting it up, please let me know. I'm working on a client-side package to go with this jar so that'll make it easier to use.
https://github.com/CaffeinatedRat/WebSocketServices/tree/master/examples/client-side/fancy
If you're a developer and wish to create your own custom site, the API below should provide all the information you need.
https://github.com/CaffeinatedRat/WebSocketServices/wiki/Websockets-API