With JSONAPI-Commands you can easily register real
ingame commands like /spawn
or /tp silvinci Notch
.
This is it. No downsides. No quirky hacks. It just works.
You don't even get these pesky Unknown command
messages.
View the BukkitDev page.
Download the latest version
of JSONAPI-Commands and put it in your server's plugins
directory.
If you haven't already grab the latest version
of JSONAPI and put in the very same directory.
JSONAPI-Commands listens on the PlayerCommandPreprocessEvent
, that is fired whenever a player (it has to be a player, console doesn't count) enters a command. As the name suggests it is called before any other plugin or Bukkit itself can interfere. This way we can cancel the whole command and noone will ever notice, that in reality the issued command never was officially registered.
JSONAPI-Commands creates a commands.yml
in the JSONAPI
folder. This file is pretty self-explanatory.
It contains all registered commands and may be edited by hand. This file survives server reloads and restarts.
This way you're programs don't have to re-register (refer to 'Methods') their commands all the time,
nevertheless I do encourage you to implement checks into your software. You'll never now what can possibly happen.
JSONAPI-Commands introduces new methods and a stream to @alecgorge's great JSONAPI.
commands.addListener(String command)
registers the given commandcommands.addListeners(String[] command)
registers the given commandscommands.removeListener(String command)
removes the given commandcommands.removeListeners(String[] command)
removes the given commandscommands.removeAllListeners()
removes all listeners (use with caution!)commands.allListeners()
returns an array of all registered commands
The new stream is named commands
. This means you can subscribe to it with this URL:
/api/2/subscribe?json={"name":"commands","username":"yourName","key":sha256("yourName"+"commands"+"yourPassword"+"yourSalt")}
A sample (prettifyed) response for /tp silvinci Notch
run by the player alecgorge may look like this:
{
"result": "success",
"source": "commands",
"success": {
"time": 1353715957,
"command": "tp",
"args": ["silvinci", "Notch"],
"player": "alecgorge"
}
}
time
is the exact timestamp when the command was issuedcommand
is the command issuedargs
is an array of the arguments concatenated to the command (no args = empty array)player
is the player who issued the command (not the affected player)
... will follow shortly.
- If you encounter a bug or have a feature request, feel free to open an issue.
- If you can't get everything up and running and need a helping hand, you can post to the forum thread.
(The MIT License)
Copyright (c) 2012 Jan Buschtöns <buschtoens@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.