A Minecraft plugin built using the Spigot API which sends player location information to a web socket.
This plugin was created after numerous attempts to provide a vanilla Minecraft way of providing player location data to external sources.
This works in conjunction with
Overviewer-Info-Plugin which handles the front-end rendering of players on an overviewer map.
Usage
Place the PlayerLocations.jar in the `plugins` directory
Configuration
Code (YAML):
socket_server:
port
: 8888
host
: localhost
tick_interval
: 100
socket_server.port: The server port to listen for socket requests
socket_server.host: The hostname to listen for socket requests
socket_server.tick_interval: How often, in server ticks, the information should be broadcasted to connected socket clients
Output
The information sent through the web socket is JSON data.
The default output uses the following structure:
Code (json (Unknown Language)):
{
"webClients": int,
"timeOfDay": int,
"players":[
{
"name": str,
"position": {
"x": double,
"y": double,
"z": double,
"dimension": str
},
"health": double,
"level": int,
"air": int,
"food": int
},
...
]
}
Extending
If you would like to add additional information to the socket using a custom plugin, add PlayerLocations to your plugin's dependency or soft dependency list in your `plugin.yml` file:
Code (YAML):
name
: YourPluginName
main
: com.your.plugin.YourPlugin
version
: 0.17
api-version
: 1.17
depend
:
[PlayerLocations
]
or
Code (YAML):
softdepend
:
[PlayerLocations
]
In your plugin project, add PlayerLocationsAPI as a dependency. The JAR is available as an artifact in each
release
In your plugin, use the following example to add an element with a key of "newInformation" and a value of "I've extended the PlayerLocations Plugin!".
Code (Java):
package
com.your.plugin
;
import
com.archmageinc.playerlocations.api.InfoRegistrar
;
import
com.archmageinc.playerlocations.api.InfoHandler
;
import
org.bukkit.plugin.java.JavaPlugin
;
public
class YourPlugin
extends JavaPlugin
implements InfoHandler
{
@Override
public
void onEnable
(
)
{
InfoRegistrar playerLocationsPlugin
=
(InfoRegistrar
) getServer
(
).
getPluginManager
(
).
getPlugin
(
"PlayerLocations"
)
;
playerLocationsPlugin.
registerInfoHandler
(
this
)
;
}
@Override
public Map
<
String, Object
> getInfo
(
)
{
Map
<
String, Object
> info
=
new
HashMap
(
)
;
info.
put
(
"newInformation" ,
"I've extended the PlayerLocations Plugin!"
)
;
return info
;
}
}