-
Notifications
You must be signed in to change notification settings - Fork 4
getOfflinePlayers
This method queries the Minecraft WebSocketServer for offline player information.
The following is the method signature:
CaffeinatedRat.Minecraft.WebSocketServices.prototype.getOfflinePlayers(parameters)
The following parameters are available for this method:
This is a callback function that is called when the client-side library has successful received the offline player information.
- Value: function(jsonDataStructure) { }
- Default: Do nothing special.
Please refer to the Json data structure documented for the [OfflinePlayers] (https://github.com/CaffeinatedRat/WebSocketServices/wiki/OfflinePlayers-Service#json-response-format) service.
The following is an example of how to use the method and its callback function.
function callback(json) { if (json.OfflinePlayers.length > 0) { for(var i = 0; i < json.OfflinePlayers.length; i++) { var offlinePlayerInfo = json.OfflinePlayers[i]; console.log('Last Played: ' + offlinePlayerInfo.lastPlayed); console.log('Name: ' + offlinePlayerInfo.name); console.log('IsOperator: ' + offlinePlayerInfo.isOperator); } } } wss.getOfflinePlayers({ callback: callback });
The template fields feature allows a user to tag almost any HTML element with a class that will automatically be populated by the server information. If no element is tagged then the client-side library will ignore this field. Template fields do not require knowledge or use of javascript, just simply decorate an element with one of the following classes.
The parent container field is a class that decorates an element that will be a parent container for a collection of items, such as a list of players. Item fields MUST be within a parent container.
- wssMinecraftOfflineList
These are template fields that only work as classes to an element.
- wssTotalOfflinePlayers
The list item template field is a class that decorates an element that describes how an item will be displayed to the user. List item fields are then attached to elements or can stand-alone as content fields, that are populated with the details for a specific item. For example, the online time of a player. This template MUST be within a parent container.
- wssListItemTemplate
The empty list item template field is a class that decorates an element that describes what will be displayed if nothing is returned by the service. For example, if no players are online, then the content of the empty list item template is shown. This template MUST be within a parent container.
- wssEmptyListTemplate
Item Fields
These are fields that can be used as a class to an element and/or can be used as stand-alone content. Item fields describe a property of an item, such as the name of player. To use a item field as stand-alone content, simply surround the field with a set of pounds signs (#), as shown #wssPlayerName#. These fields MUST be contained within a wssListItemTemplate container.
- wssPlayerFace
- wssPlayerIsOperator
- wssPlayerName
- wssPlayerEnvironment
- wssPlayerOnlineTime
Conditional List Item Fields
These are item fields that work as conditional elements, where the element will only appear if one or the other condition is met. This will only work if the element is decorated with these template fields as classes. These fields MUST be contained within a wssListItemTemplate container.
- wssPlayerIsOperator
- wssPlayerIsNotOperator
The following is an example of how to use the template fields.
<div class="playerContainer scrollContainer">
<div class="wssMinecraftOfflineList">
<div>
<strong>Offline Players: </strong>
<span id="wssTotalOfflinePlayers"></span>
</div>
<ul class="wssListItemTemplate">
<li>
<div class="playerElement">
<div class="inline">
<div class="wssPlayerIsOperator">
<div title="Moderator" class="tiles modTile"></div>
</div>
<div class="wssPlayerIsNotOperator">
<div title="Player" class="tiles playerTile"></div>
</div>
</div>
<div class="inline">
#wssPlayerFace#
</div>
<div class="inline">
<a class="playerName" href="#" data-name="#wssPlayerName#" data-environment="#wssPlayerEnvironment#" title="Click to view #wssPlayerName#'s skin">
<strong>
#wssPlayerName#
</strong>
</a>
</div>
<div class="inline">
(#wssPlayerOnlineTime#)
</div>
</div>
</li>
</ul>
<ul class="wssEmptyListTemplate">
<li>
No offline player info available.
</li>
</ul>
</div>
</div>