[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

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @paulstraw I cannot reproduce that problem. If you can give more exact steps, perhaps I can help.

    @slizone Thanks!

    @xPaw And thank you for the bug reports! They are all fixed and 1.6.1 is out:

    Version 1.6.1 released:
  4. Offline

    xPaw

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Cool thanks ;)
  5. Offline

    paulstraw

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @Alec Gorge After a bit more testing, it seems to happen to all the streams except connections after a certain number of WS reconnections.

    * All dies out first, at around 30.
    * Console seems to stop working at 100 or so.
    * Chat dies after 200ish.

    Once a stream is "dead," it no longer functions properly until the server is reset. Want me to file an issue on GitHub? This is happening in both the application I'm developing as well as a blank test page that simply console.log()s responses.
  6. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @paulstraw If you could open a issue on GitHub, I would appreciate that. So when you say reconnections, you mean reloading the page? Or do you mean that many lines returned by that source?
  7. Offline

    paulstraw

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @Alec Gorge Reloading the page. Opening issue shortly.
  8. Offline

    tha d0ctor

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    can this send commands to my iconomy so I could have a button on my website that sends a /money grant command?
  9. Offline

    Alec Gorge

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

    pudd1nG

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    After installing I cannot seem to get a response from the server.

    I can connect to our server from my web server using ssh2_connect so I don't think its any issues relating to firewalls etc.

    My PHP script (the example from the wiki) just sits loading till it finally times out.

    Suggestions?

    Thanks
  11. Offline

    paulstraw

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @pudd1nG What version of PHP are you using? Also, do you have error reporting turned on? If not, try sticking this at the top of your script, then post any errors here:

    Code:
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    
  12. Offline

    RoyAwesome

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    So, I set log_to_console false and it still spams my console with log messages
  13. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @pudd1inG Exactly what @paulstraw said.

    @Kylegar Odd. I'll look into it. Thanks for opening the GitHub issue.
  14. Offline

    pudd1nG

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

    @alex gorge

    Thanks for the replies. I am running PHP5, actually hosting this off site5.com at the moment. All it does is sit loading for a LONG time. Then finally returns a tcp_error in a nicely formatted way (doesn't look like a php error).

    Worth mentioning that i can connect to my server with the test app in the first post.
  15. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Can you paste exactly what code you are using?
  16. Offline

    pudd1nG

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    PHP:
    require_once('JSONAPI.php');

    $api = new JSONAPI("173.236.47.139"20059"admin""foo""foo");

    $banned var_dump($api->call("getBannedPlayers"));

    echo 
    $banned;
    not really any code at all XD.
  17. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @pudd1G That is odd, that works for me. Are you sure that port is open?
  18. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Version 1.6.2 Released:
    • added "setPlayerHealth"
    • added "setPlayerInventorySlotWithData"
    • added "setPlayerInventorySlotWithDataAndDamage"
    • added "getServer"
    • added Remote Toolkit methods:
      • added "remotetoolkit.rescheduleServerRestart"
      • added "remotetoolkit.restartServer"
      • added "remotetoolkit.stopServer"
  19. Offline

    xPaw

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Useful as always ;)
  20. Offline

    Alec Gorge

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

    pbgben

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hi, is there a way to get the messages to have a bit of color?

    $message = "&4[SHOP]&f {$qty} of {$item} has been put in your inventory";
    $out = $api->call("sendMessage", array($player, $message));
    echo $out;
  22. Offline

    Alec Gorge

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

    xPaw

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Also if you dont want it to be broken by utf8 stuff...
    PHP:
    define'COLOR_KEY'Chr194 ) );
  24. Offline

    pbgben

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    many thanks.
  25. Offline

    pbgben

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    sorry, how would that look in the code?

    PHP:
    $message "§4[SHOP]§f {$player} has Just Brought {$qty} of {$item} From The Shop.";
    $message = (string)$message;
    $out $api->call("broadcast", array($message));
    echo 
    $message;
    as that does not work :/
  26. Offline

    xPaw

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    PHP:
    $message = (string)$message;
    is not needed.

    And does it print fine for you in browser?
  27. Offline

    pbgben

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    §4[SHOP]§f pbgben has Just Brought 2 of 1 From The Shop.


    that is printed into the browser
  28. Offline

    pbgben

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I tried both the § and the § but the § just stops the message from displaying in game.
  29. Offline

    Alec Gorge

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @pbgben The JSON encoder isn't liking the mix of UTF8 and non-UTF8, so do:

    PHP:
    $message utf8_encode($message);
  30. Offline

    pbgben

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Ok, I will try that.
  31. Offline

    pbgben

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thank you, it works now.
  32. Offline

    pbgben

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Me again,
    when getting the latest chats
    it returns the output twice, I have no idea why.

    Code:
    array(3) { ["result"]=> string(7) "success" ["source"]=> string(14) "getLatestChats" ["success"]=> array(2) { [0]=> array(3) { ["message"]=> string(1) "." ["time"]=> int(1306607724) ["player"]=> string(8) "playername" } [1]=> array(3) { ["message"]=> string(1) "." ["time"]=> int(1306607724) ["player"]=> string(8) "playername" } } } 

Share This Page