Purpouse
Simplify creating rest api for your Spigot minecraft server.
Basically it allows to create HTTP endpoints for everything you want.
Configuration is simple, plugin is little, and usage is generic.
By default it will embed little HTTP server on port 8888, so you can access endpoints via http://minecraftserverip:8888/endpoint
It supports parameters!
Installing
Just copy latest release to your plugins folder.
Latest build are contained here:
http://dev.razniewski.eu:8080/job/TotallyMCRestApi/
Donate
https://www.buymeacoffee.com/razikus
Just buy me a cofee if you like it and you want me to spend more time on developing plugins
Usage
After deploying plugin - standard www server will be avalaible under http://minecraftipserver:8888/
Example endpoints:
http://minecraftipserver:8888/onlinePlayers?token=testToken
http://minecraftipserver:8888/onlinePlayersNickname?token=testToken
http://minecraftipserver:8888/help
Currently avalaible callbacks
Build-in Java callbacks:
- CLASSNAME: eu.razniewski.totallymcrestapi.defaultCallbacks.PlayersNicknamesCallback
returns player nicknames - CLASSNAME: eu.razniewski.totallymcrestapi.defaultCallback.PlayersOnlineCallback
returns online player count
Command callback:
- CLASSNAME: eu.razniewski.totallymcrestapi.commandCallback.OutputConfigCommandCallback
DATA:
"command": "",
"additionalParams": {
"param1": ...,}
"paramn": ...
Returns output of command to enpoint. You can pass additionalParams in command by put a {%paramName%} tag. You can pass params from endpoint by putting a {:_paramName} tag. So if you will make endpoint /test/:_paramName it will parse {:_paramName} tag from command with param putted in callback.
So if somebody will pass into /test/blabla, {:_paramName} will change to blabla
- CLASSNAME: eu.razniewski.totallymcrestapi.commandCallback.VoidConfigCommandCallback
DATA:
"command": "put here command to execute",
"additionalParams": {
"param1": ...,}
"paramn": ...
Returns true or false from command. No output from command will be here. ou can pass params from endpoint by putting a {:_paramName} tag. So if you will make endpoint /test/:_paramName it will parse {:_paramName} tag from command with param putted in callback.
So if somebody will pass into /test/blabla, {:_paramName} will change to blabla
Groovy callback:
- CLASSNAME: eu.razniewski.totallymcrestapi.groovyCallbacks.GroovyCallback
DATA:
"fileName": "path to file that have groovy script"
This callback will try to compile fileName as Groovy class, then integrate it into TotallyMCRestAPI system. So if you will make endpoint /test, and set up into your Groovy script - it will execute when somebody will pass into it. You can also put params in endpoint, cause your function will get map of user params.
Groovy is very powerful, read about here http://groovy-lang.org/syntax.html
With this callback you can do ANYTHING you want. See example Callback - it have access to whole Bukkit system, so you can easily access all plugins etc.
Configuration
See standard calls.json after deploying plugin, and adjust it to your needs.
config.yml
# Port where server will be listening to
port: 8888
# file with endpoints configuration
calls: calls.json
calls.json
[
{
"callback": {
# Points to class that will be used. Some of are build-in, some of are generic. List are included in file.
"CLASSNAME": "eu.razniewski.totallymcrestapi.defaultCallbacks.PlayersOnlineCallback",
"DATA": {}
},
# Route to endpoint, so it will be accessible via IP:PORT/route
"route": "/onlinePlayers",
# Possibilities - GET, DELETE, PUT, POST,
"requestType": "GET",
# If true - only endpoints with ?token=testToken will be avalaible so for example localhost:8888/onlinePlayers?token=testToken
"tokenEnabled": true,
# list of tokens that will be good for this endpoint
"tokens": [
"testToken"
]
},
{
"callback": {
"CLASSNAME": "eu.razniewski.totallymcrestapi.defaultCallbacks.PlayersNicknamesCallback",
"DATA": {}
},
"route": "/onlinePlayersNickname",
"requestType": "GET",
"tokenEnabled": true,
"tokens": [
"testToken"
]
},
{
"callback": {
"CLASSNAME": "eu.razniewski.totallymcrestapi.commandCallback.OutputConfigCommandCallback",
"DATA": {
# Additional data of that command. {:text} for parameter from request, {%text%} for parameter from additionalParams
"command": "? {:name}",
"additionalParams": {}
}
},
"route": "/help/:name",
"requestType": "GET",
"tokenEnabled": false,
"tokens": []
},
{
"callback": {
"CLASSNAME": "eu.razniewski.totallymcrestapi.groovyCallbacks.GroovyCallback",
"DATA": {
"fileName": "plugins/TotallyMCRestApi/test.groovy"
}
},
"route": "/test",
"requestType": "GET",
"tokenEnabled": false,
"tokens": []
}
]
Example test.groovy
import eu.razniewski.totallymcrestapi.TotallyCallback
import eu.razniewski.totallymcrestapi.TotallyMCRestApi
class MySuperClass implements TotallyCallback {
@Override
public Object callWithParams(Map<String, String> params) {
return TotallyMCRestApi.getInstance().getServer().shutdown();
}
}
Issues
Go to page:
https://github.com/Razikus/TotallyMCRestApi/issues
Report a bug or want-to-implement feature description
In progress
Actually working on version 0.4 (Reloading plugin)
Icons made by Pixel perfect from www.flaticon.com is licensed by CC 3.0 BY
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta
