[ADMN/INFO] JSONAPI v4.3.0 - JSON HTTP and Socket API for controlling a server [1.4.7]

Discussion in 'Plugin Releases' started by Alec Gorge, Apr 24, 2011.

     
  1. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    JSONAPI - Control your server and fetch information from your server.
    Version: v4.3.0

    JSONAPI is a plugin for Bukkit that allows you to access data and other information about your server and your players through a simple, yet secure, HTTP API. This allows you to make awesome websites, iPhone apps, and a way for your players to purchase goods online and automatically receive them in game.

    However, this plugin won't do all of that by itself. It is simply an API that allows you to assemble the features in a way that makes sense for your needs.

    Download
    Download JSONAPI v4.3.0 (for Minecraft 1.4.*)
    You can find the source code on GitHub at alecgorge/jsonapi. I accept pull requests!

    What features exist in JSONAPI?

    There are tons of API methods.
    There are more than 146 different API methods in 8 different categories covering a wide range of features:
    • Chat (groups, prefixes, suffixes, etc.)
    • Economy (give money, create banks, etc.)
    • Permissions (control permissions and groups)
    • Edit signs and chests
    • Integration with drdanick's Remote Toolkit to enable the ability to turn the server on and off using API methods. Note: this requires the JSONAPI_RTK Remote Toolkit module.
    • Get a live stream of chat, connections and disconnections and/or the console.
    • ...and many more standard features (ban, unban, inventory management, etc.)

    JSONAPI is well documented.
    There are many guides along with an expansive technical reference available on the wiki.
    Every API method is documented and viewable online.

    You can read a careful documentation of the the request and response format on the wiki if you are thinking about writing a new SDK or plan on rolling your own solution.

    There are easy to use SDKs.
    SDKs allow for easy usage of all of JSONAPI's capabilities currently there are 4 SDKs:
    Easily integrate JSONAPI with other plugins.
    Using the API for JSONAPI, you can easily add new methods or stream sources. Check out the section "For plugin developers" at the bottom of the wiki.

    There is an interactive test console.
    Once you setup Adminium on your server, you can use this test console to easily test all of the available API methods and view the JSON response.

    What else can you do with JSONAPI? You can...
    • Integrate your website and your Minecraft server
    • Control your server with your iPad/iPhone/iPod Touch through Adminium
    • Setup scripts that perform actions on your server, all through an easy to use API!
    What uses JSONAPI?
    Changelog:
    just check github, i am getting tired of updating this

    Version 3.6.0:
    • Economy features
    • Chat features
    • ...much more

    Version 3.3.2:
    Version 3.3.1:
    • fixed issues with lists not being trimmed
    • fixed the dreaded "java.lang.NoSuchFieldException: configuration" error and thus making JSONAPI dynmap .30+ compatible
    Version 3.3.0:
    • fixed issues with Minecraft 1.1
    • added permission methods in the "permissions" namespace
    • added teleporting methods to teleport a player to a specific position
    • added appendToFile
    • updated upstream websocket deps
    • added getBukkitVersion
    • added getPluginVersion
    • added permission node jsonapi.calladmin for the /calladmin command
    • added a message that is sent to the player that used /calladmin once the notification is sent
    • fixed other misc. bugs I encountered
    Version 3.2.1:
    • fixed issues with getPlayer
    • added getOfflinePlayer(String playerName)
    Version 3.2.0:
    • added getOfflinePlayerNames
    • added getOfflinePlayers
    • added getPlayerNames
    • added getBlock
    • added setBlockData
    • added setBlockType
    Version 3.1.1:
    • fixed an issue with the default configuration.
    • fixed cross platform issue with file i/o.
    Version 3.1.0:
    • added addEnchantmentToPlayerInventorySlot
    • added addEnchantmentsToPlayerInventorySlot
    • added removeEnchantmentsFromPlayerInventorySlot
    • added setPlayerInventorySlotWithDataDamageAndEnchantments
    • added "level" and "experience" to player results
    • added enchantment information to player inventory output
    Version 3.0.0:
    • added setPlayerFoodLevel
    • added setPlayerGameMode
    • added banWithReason
    • upgraded WebSocket server to support latest browsers
    • added setWorldTime
    • added the server-side component of push notifications for Adminium
    • added getSingleDirectory
    • modified getFileContents to read files as UTF-8
    • compatible with CraftBukkit for 1.0-1.0.1 (built against 1597)
    • added a CI site for you to grab the latest builds: http://ci.alecgorge.com/
    Version 2.5.0:
    • added banWithReason api call
    • added new configuration option: bind-address. This can be used to only listen on a certain IP/hostname
    • fixed extra console output
    • added setPlayerGameMode api call.
    • updated to latest configuration api, bumped version to 2.5.0
    • updated world objects to include information about the weather
    • updated player objects to include information about food level, sprinting, exhaustion, gameMode
    Version 2.4.0:
    • fix log-to-console
    • fix log-to-file
    Version 2.3.1:
    • compiled against 1.8.1
    • fix memory usage being reported inaccurately
    • fix json having wrong mime type
    Version 2.3:
    • compiled against 1.8
    Version 2.2.2:
    • fix getStreamWithLimit
    Version 2.2.1:
    • fix getPlayerCount
    Version 2.2:
    • added configuration directive 'startup-delay' that allows you to configure how many milliseconds JSONAPI should wait before checking to see if dependent plugins exist
    • fixed some stuff that i don't remember
    Version 2.1:

    • added getDirectory
    • fixed bug where config_rtk.yml wasn't being properly loaded
    Version 2.0:
    • Massive behind the scenes update.
    • added getStream
    • added getStreamWithLimit
    Version 1.9:
    • fixed 2 random bytes being prepended to streams
    • added worldInfo to player object
    • other bug misc. bugs I found and fixed without telling anyone :p
    Version 1.8.2:
    • compiled against CB 860
    • fixed (finally) that pesky problem with large streams
    • fixed race condition with concurrent stream logs
    • fixed console stream not showing JSONAPI log data
    Version 1.8.1:
    • fixed streams not always providing new data
    • fixed .properties file being created when it doesn't exist
    • fixed other bug I have long since forgotten
    Version 1.8:
    • fixed countless bugs, mostly the bug with broadcastWithName and HeroChat.
    Version 1.7.2:
    • fixed output in return to console commands
    Version 1.7.1:
    • fixed startup bugs that dealt with how files were checked
    Version 1.7:
    • completed Remote Toolkit support (start, stop, restart; requires that JSONAPI_RTK be installed).
    • fixed JSONAPI to be compatible with CB 818
    • fixed lots of bugs
    • changed the configuration files to be 1 configuration file in yaml format (config.yml)
    • added a second configuration file (config_rtk.yml) for Remote Toolkit support.
    Version 1.6.2:
    • added "setPlayerHealth"
    • added "setPlayerInventorySlotWithData"
    • added "setPlayerInventorySlotWithDataAndDamage"
    • added "getServer"
    • added Remote Toolkitmethods:
      • added "remotetoolkit.rescheduleServerRestart"
      • added "remotetoolkit.restartServer"
      • added "remotetoolkit.stopServer"
    Version 1.6.1:
    Version 1.6:
    • added "isThunder" and "hasStorm" to the info returned by getWorlds()/getWorld(1)
    • added "broadcastWithName" to make chat as if you are actually on the server
    • fixed "clearPlayerInventorySlot" so it works with armor slots
    • added "getPluginFiles" to list all of the files in the plugin's data directory
    • added "isEnabled" to the info returned by getPlugin(1)/getPlugins()
    • added "updateInventorySlot" which allows you to change the number of items in an inventory slot without changing anything else
    • added a new streaming source "all", which behaves as if all the sources were subscribed tp
    Version 1.5:
    • removed the JavaSysMon dependancy and removed the following API methods:
      • system.getCPUUsage
      • system.getSystemMemoryTotal
      • system.getSystemMemoryUsage
    • added getLatestConsoleLogsWithLimit
    • added getLatestChatsWithLimit
    • added getLatestConnectionsWithLimit
    Version 1.4.1:
    • update the WebSocket server support the new HyBi-07 spec
    Version 1.4:
    • added getLatestConsoleLogs
      • returns up to the last 50 lines in the console
    • added getLatestChats
      • returns up to the last 50 chat messages
    • added getLatestConnections
      • returns up to the last 50 connections/disconnections
    • added a WebSocket server that behaves just like the Socket server, except it uses the WebSocket protocol (obviously) and runs on port that you set in the settings plus 2. (default is 20061).
    • changed runConsoleCommand to actually send commands to the console
    Version 1.3.1:
    • fixed some stability issues with streams
    Version 1.3
    • added the system namespace for CPU, disk and memory information
    • added method whitelist allowing you to define certain methods that can be used without proper authentication (JSONAPIMethodNoAuthWhitelist.txt).
    • added two console-onlycommands:
      • reloadjsonapi: self explanatory, just restarts all the JSONAPI servers and reloads all the methods from the JSON files.
      • jsonapi-list: lists all the of the currently loaded namespaces and methods
    • added getServerPort and getServerIp
    • made setPlayerInventorySlot and setPlayerInventorySlotWithDamage play nice with armor. Just use the slot numbers as defined in this picture.
    • added a super handy testing environment: http://alecgorge.github.com/jsonapi/ . This testbed is 100% client side and is never stored anywhere (except in memory of course). You can view the source code at: https://github.com/alecgorge/jsonapi/tree/gh-pages
    • probably more stuff that I forgot about...
    Version 1.2
    • added setPlayerInventorySlotWithDamage
    • added clearPlayerInventorySlot
    • fixed setPlayerInventorySlot so that you can set slots to air without crashing the client
    • fixed a bug with the method that tested for API method existence.
    Version 1.1
    • added getPlayerCount
    • added givePlayerItemWithData
    • added givePlayerItemDropWithData
    • added reloadjsonapi console command
    • added the console stream.
    Version 1.0
    • Initial release.



    Donate

    I have spent well over 300 hours developing and testing JSONAPI I would really appreciate it if you would donate some money to say thanks. If you want, I can add you (with a link to a server or community) as a donor on this post when you donate.

    [IMG] [IMG]

    Donors

    Big thanks to rch for helping me bug test!

    This post has been edited 47 times. It was last edited by Alec Gorge Mar 2, 2013.
  2.  
  3. Offline

    rch

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    It's about time! Well done Alec.
    Alec Gorge likes this.
  4. Offline

    Horia0310

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    OHMYF*****GOD. Perfect!!!
  5. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I'll take that as a complement!
  6. Offline

    ark3typ3

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thank you, thank you, thank you :D
  7. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @ark3typ3 You're welcome, you're welcome, you're welcome.

    Also, I plan on releasing some demos in the near future.
  8. Offline

    ark3typ3

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hmmm, got a file not found error when trying to make the call. I even tried constructing the URL manually for the getPlayers method. Shouldn't I be putting the name outlined in the methods.json? or would I list it as getPlayers()?

    **EDIT: Nvm...wrong port, but when are those examples coming out?
  9. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @ark3typ3 I will do the example tomorrow afternoon.
  10. Offline

    BorderKeeper

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I always wanted something like this :D too bad i am a dummie person with no knowledge about java whatsoever
  11. Offline

    NynjaWitay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Well BorderKeeper, you don't need any Java knowledge to use this. You do need knowledge for building websites and of JSON, though.

    I just (half) replaced HTTPConsole with this and am really likely the extra capabilities.

    Is there a way to give item IDs with a certain data value, so I could give certain color wools.

    I'm having no luck with the dynmap calls, although I am probably just doing it wrong. I tried setting the method to "dynmap.getPort", but that returns an error with the message "The method 'dynmap.getPort' does not exist!" What is the proper way to set the method's namespace?
  12. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @NynjaWitay Do you have a link to HTTPConsole, I would love to look at it?

    No, there is not presently a way to give item IDs with a certain data value. I will add that in the next update.

    The dynmap calls would be dynmap.getPort. The proper way to set the namespace is in value for the namespace key at the beginning of the file. The method name will be getPort, but since the namespace is set to dynmap, you have to call dynmap.getPort in the API.

    Also, examples are coming soon, I swear!
  13. Offline

    Tajin

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hi, great plugin so far. I just noticed a small bug in the php-api:

    public function __construct ($host, $port, $uname, $pword, $salt) {
    $this->host = $host;
    $this->port = $host;
    $this->username = $uname;
    $this->password = $pword;
    $this->salt = $salt;
    }
    Once that is fixed, it seems to work just fine. :)



    Oh and since it has a getPlayerLimit()... it would make sense to also have an getPlayerCount(), so we don't have to fetch all the inventory information for that.
  14. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  15. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Done with v1.1! Changelog:
    • added getPlayerCount
    • added givePlayerItemWithData
    • added givePlayerItemDropWithData
    • added reloadjsonapi console command
    • added the console stream.
    Tajin likes this.
  16. Offline

    Tajin

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    :) yay

    Oh and while u're at it: setPlayerInventorySlot is also missing a damage parameter.
  17. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Ah, you're correct. I'll slip that into the next release then.
  18. Offline

    Tajin

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Here's another thing I've found:

    clearing a specific inventory slot isn't possible.
    (I tried setting it to 0 (air)... but it turns out minecraft doesnt like that)
    So either have setPlayerInventorySlot() clear the slot when you use id 0 or add an clearPlayerInventorySlot().
    First option would probably be better as it also avoids the crash when setting a slot to zero.

    In case ur wondering: I'm currently making a jquery based inventory-editor, that originally edited the player.dat files but now uses ur plugin.
  19. Offline

    Mikor

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    All I can say is fantastic. Been waiting a long time to see something like this for Bukkit.
    Alec Gorge likes this.
  20. Offline

    ElliottB

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I'm very much glad to see this plugin come about. However, in my testing, I get this following error with any method passed:

    Code:
    {"result":"error","error":"The method 'getPlayerCount' does not exist!"}
    Url used:

    Code:
    http://[redacted]:25566/api/call?method=getPlayerCount&args=[]&key=[redacted]
    Console:
    Code:
    12:01:53 [INFO] [JSONAPI] [API Call] [redacted]: method=getPlayerCount?args=[
    ]
    12:01:53 [WARNING] [JSONAPI] The method 'getPlayerCount' does not exist!
    All the files are properly placed, as my port is obviously configured correctly and the key is being used right. Just the methods aren't returning, even the dynmap.getPort ones, for example. Either I'm missing something or something is off. Either way, hit me on the forehead and show me my mistake or find a solution otherwise.
  21. Offline

    NotoriousPyro

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Unbelievably brilliant! I will most likely migrate phpMCWeb to this.
  22. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    JSONAPI v1.2 Released

    TL;DNR: JSONAPI v1.2 is out. Download it in the first post.

    @Tajin Added setPlayerInventorySlotWithDamage. I also fixed the air/clearing inventory slot bug. setPlayerInventorySlot now works as expected and a more verbose clearPlayerInventorySlot has been added.

    @ElliottB I need to hit myself on the forehead. That was my fault.

    @NynjaWitay The problem you were having is also caused by the same bug as ElliotB. Please redownload and try again.

    @Mikor Thank you!

    @NotoriousPyro Thanks! You could also make a Python API (it really isn't very difficult). I'll put a link to it and credit it you.

    The docs are all updated with the new methods.
  23. Offline

    ElliottB

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Code:
    http://[redacted]:25566/api/call-multiple?method=[%22getPlayers%22%2C%22getPlayerCount%22]&args=[]&key=[redacted]
    returns "File not found"

    Single calls and methods work now.
  24. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @ElliottB Bah. Redownload the zip file. In my excitement to remove some dead code, I remove some live ones too. It works now. Sorry about that.
  25. Offline

    ElliottB

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Still not working, mate.
  26. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I just downloaded the zip and tried. It works for me.

    Did you restart CraftBukkit?

    What is the md5 hash of your JSONAPI.jar? It should be 68a88fb6afae1ad10f3274cb741ccf68 .
  27. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  28. Offline

    ElliottB

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Complete reinstall from a new download of the zip, and still file not found. cfae30f4ef3e4464de5469f375594fe1 Different md5. Just downloaded the zip 5 minutes before this post.
  29. Offline

    NynjaWitay

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I'm still having trouble with the dynmap methods. Here is my log.

    Code:
    15:55:25 [INFO] [JSONAPI] Logging to file: false
    15:55:25 [INFO] [JSONAPI] Logging to console: true
    15:55:25 [INFO] [JSONAPI] IP Whitelist = None, all requests are allowed.
    15:55:25 [INFO] [JSONAPI] Dynmap API methods cannot be loaded because it depends on a plugin that is not enabled: 'dynmap'
    15:55:25 [INFO] [JSONAPI] JSON Server listening on 20059
    15:55:25 [INFO] [JSONAPI] JSON Stream Server listening on 20060
    15:55:25 [INFO] [JSONAPI] Active and listening for requests.
    15:55:25 [INFO] Loading map 'org.dynmap.flat.FlatMap'...
    15:55:25 [INFO] Loading map 'org.dynmap.kzedmap.KzedMap'...
    15:55:25 [INFO] Loading renderer 'org.dynmap.kzedmap.DefaultTileRenderer'...
    15:55:25 [INFO] Loading renderer 'org.dynmap.kzedmap.CaveTileRenderer'...
    15:55:25 [INFO] Activated world 'world' in Dynmap.
    15:55:25 [INFO] Loading map 'org.dynmap.flat.FlatMap'...
    15:55:25 [INFO] Loading map 'org.dynmap.kzedmap.KzedMap'...
    15:55:25 [INFO] Loading renderer 'org.dynmap.kzedmap.DefaultTileRenderer'...
    
    I am pretty sure that dynmap is just loading after JSONAPI and so JSONAPI does not see it. If JSONAPI was set to load last, I think it would work.
  30. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
  31. Offline

    ElliottB

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    That fixed it.

Share This Page