[INACTIVE][ADMN/WEB] ApiCraft v0.2 - Web API system for CraftBukkit server [531]

Discussion in 'Inactive/Unsupported Plugins' started by KokaKiwi, Mar 16, 2011.

  1. Offline

    KokaKiwi

    ApiCraft - Web API system for CraftBukkit:
    Version: v0.2

    ApiCraft provide a Web API system for CraftBukkit servers, and can be easily extensible for plugins developers!

    The API can be fetched by using URL: http://[server-ip]:6561/[api]

    This plugin provide some basics API, but it can be extended by plugins developers in their plugins.
    You can add an API URL by using ApiListener class like others Listener classes:
    Code:
    public class ApiCraftListener extends ApiListener {
        @Override
        public void onApiEvent(ApiEvent event) {
            if(event.path[0].equalsIgnoreCase("serverinfos"))
            {
                if(event.path.length > 1)
                {
                    if(event.path[1].equalsIgnoreCase("online"))
                    {
                        Player[] online = event.getPlugin().getServer().getOnlinePlayers();
                        event.setResponse(online.length + "");
                        event.setActionTaken(true);
                    }else {
                        event.setResponse("API not found.");
                        event.setActionTaken(true);
                    }
                }else {
                    event.setResponse("APIs available for 'serverinfos' : online, players-online");
                    event.setActionTaken(true);
                }
            }
        }
    
    }
    event.setResponse() is used to set Response to send to client. It accepts String, Map and List values.
    event.setActionTaken() is used to say to webserver that there is a response available.

    API response can be displayed in Plain Text or XML Format, by using "?format=plaintext|xml" in the end of URL.

    Features:
    Download ApiCraft v0.2
    Source Code

    Changelog:
    Version 0.1

    • First version
    Version 0.2
    • Improved Plain Text and XML Formatters
    • Added Json Output
    • Added whois and max-players to basic API
    ToDo:

    • Add some basics informations in base API
    • Add token verification for users
     
    sinkir, zok and SpeedKeks like this.
  2. Offline

    SpeedKeks

    Nice Plugin. very Thanks i have search thies Plugin

    I love you! <3
     
  3. Offline

    zok

    Love This plugin have been looking for something like this :D

    Suggests:
    picture of their heads if they have skin Ect like in Dynmap

    make the pages more list like and display little more info like playing time and time this session.

    Colors for admin's like Red and Green for regular user.

    Edit:
    Max Slots how many used.

    Uptime and downtime statistics
     
  4. Offline

    ryanshawty

    Does this output max players? If it did I might think about using it for www.mcserverstatus.com instead of MineQuery
     
  5. Offline

    FrozenCow

    Nice plugin. I was working with some of the other Dynmap devs on splitting the web-server from Dynmap to a seperate plugin, but have waiting for Fill too long (I mean way too long). It'll be mostly the same as Dynmap's webserver: you can handle the full request+response, therefore allowing you to do everything from handling JSON GET/PUT/POST requests to serving a directory with files (and in the end also support WebSockets). It would be nice if we could work together, so that people don't need to host even more webservers inside CraftBukkit.
    We're in irc.esper.net #webbukkit if you'd like to talk via chat.
     
  6. Offline

    zok

    i would prefer hosting it my self, but combineing those would be a win and a option to use remote or local.
     
  7. Offline

    Unstable_Flight

    sorry for my extreme noobness, but what exactly is an API?
     
  8. Offline

    KokaKiwi

    Help us, Wikipedia! -> http://en.wikipedia.org/wiki/Application_programming_interface

    It will, I've had to add some API functions to basic APIs

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 12, 2016
  9. Offline

    funnyl

    Code:
    07:04:50 [SEVERE] java.io.IOException: Bad packet id 71
    07:04:50 [SEVERE]     at net.minecraft.server.Packet.b(SourceFile:117)
    07:04:50 [SEVERE]     at net.minecraft.server.NetworkManager.f(SourceFile:155)
    07:04:50 [SEVERE]     at net.minecraft.server.NetworkManager.c(SourceFile:9)
    07:04:50 [SEVERE]     at net.minecraft.server.NetworkReaderThread.run(SourceFile:62)
    07:04:50 [INFO] /91.180.221.190:51076 lost connection
    
     
  10. Offline

    Misa

    Json support would be nice ;)
     
  11. Offline

    KokaKiwi

    New update : 0.2!! \o/

    Changelog:
    • Improved Plain Text and XML Formatters
    • Added Json Output
    • Added whois and max-players to basic API
    Hum, it isn't my plugin that doing this error, but Server itself. I couldn't help you :/

    You've been exauced! :D
     
  12. Offline

    BacaBej

    Hi,
    /whois doesnt work. It says "Listener not found".

    But everything else works fine, ty ! :D
     
  13. Offline

    KokaKiwi

  14. Offline

    firewalled

    Whois doesn't work here either, using http://IP:PORT/serverinfos/whois/firewalled (where firewalled is my username), I get this error:

    Code:
    01:08:39 [SEVERE] Exception in thread "Thread-71"
    01:08:39 [SEVERE] java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
    01:08:39 [SEVERE]      at org.kokakiwi.apicraft.utils.PlainFormat.format(PlainFormat.java:49)
    01:08:39 [SEVERE]      at org.kokakiwi.apicraft.utils.PlainFormat.format(PlainFormat.java:26)
    01:08:39 [SEVERE]      at org.kokakiwi.apicraft.net.WebServer.serve(WebServer.java:45)
    01:08:39 [SEVERE]      at org.kokakiwi.apicraft.net.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:415)
    01:08:39 [SEVERE]      at java.lang.Thread.run(Unknown Source)>
    Using build 556 (most recent) of craftbukkit and 0.2 ApiCraft.
     
  15. Offline

    BacaBej

    Hi,
    i have the same problem.
    i get a blank page with ../whois/BacaBej
     
  16. Offline

    KokaKiwi

    Argh ><
    It would be fixed soon, I know where is the problem (it's my fault :( )
     
  17. Offline

    tenach

    Thank you for this amazing plugin! I've been trying to develop something like this for myself but have been having a little trouble as I am not a Java programmer (very new to it, though I am a seasoned php/javascript programmer).

    You've saved my bacon cooked porkchop. Definitely forking this :D

    Sorry for double post, but...
    I'm using CB # 556 and ApiCraft 0.2 and get the following error just like firewalled:
    Code:
    00:28:32 [SEVERE] Exception in thread "Thread-276"
    00:28:32 [SEVERE] java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
    00:28:32 [SEVERE]       at org.kokakiwi.apicraft.utils.PlainFormat.format(PlainFormat.java:49)
    00:28:32 [SEVERE]       at org.kokakiwi.apicraft.utils.PlainFormat.format(PlainFormat.java:26)
    00:28:32 [SEVERE]       at org.kokakiwi.apicraft.net.WebServer.serve(WebServer.java:45)
    00:28:32 [SEVERE]       at org.kokakiwi.apicraft.net.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:415)
    00:28:32 [SEVERE]       at java.lang.Thread.run(Thread.java:662)
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 12, 2016
  18. Offline

    NotoriousPyro

    Very nice, though I edited it to separate player names with a comma and space rather than just comma.

    Also, if anyone wants a little php script to display player count and players then here is the one I wrote:
    PHP:
    <strong>Players:</strong>
    <?php
        $ip 
    "APICRAFT SERVER IP";
        
    $port "APICRAFT SERVER PORT";
        
    $server "http://".$ip.":".$port."/";
        
    $check file_get_contents($server);
        if (empty(
    $check)) {
            echo 
    "Unknown - is something wrong with the server?";
        } else {
            
    $currplayers file_get_contents($server."serverinfos/online");
            
    $maxplayers file_get_contents($server."serverinfos/max-players");
            
    $playersonline file_get_contents($server."serverinfos/players-online");
            if (empty(
    $playersonline)) $playersonline "No-one is in the server! Why don't you be the first? ;)";
            echo 
    $currplayers." / ".$maxplayers."<br />\n"
                
    .$playersonline;
        }
        echo 
    "\n";
    ?>
    You can see it working here: http://craigcrawford.dyndns.org
     
  19. Offline

    KokaKiwi

    Sorry, for now I could not work on the plugin (I'm sick) ...
    I'll release v0.3 of ApiCraft soon, after I rested a little ;)

    Yeah! Thanks for the share! :)
    Can I use this code for plugin's presentation? :)
     
  20. Offline

    NotoriousPyro

    Sure - just include my credits please :)

    Here is an updated version to add a space and comma in the player list rather than just a comma without needing to edit the jar:
    PHP:
    <strong>Players:</strong>
    <?php
        $ip 
    "APICRAFT IP";
        
    $port "APICRAFT PORT";
        
    $server "http://".$ip.":".$port."/";
        
    $check file_get_contents($server);
        if (empty(
    $check)) echo "Unknown - is something wrong with the server?";
        else {
            
    $currplayers file_get_contents($server."serverinfos/online");
            
    $maxplayers file_get_contents($server."serverinfos/max-players");
            
    $playersonline file_get_contents($server."serverinfos/players-online");
            if (empty(
    $playersonline)) $playersonline "No-one is in the server! Why don't you be the first? ;)";
            else 
    $playersonline preg_replace("/,/"", "$playersonline);
            echo 
    $currplayers." / ".$maxplayers."<br />\n"
                
    .$playersonline;
        }
        echo 
    "\n";
    ?>
    :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 12, 2016
  21. Offline

    FLOKER

    Great plugin, make sure that 0.3 is compatible with CraftBukkit 600+ and add maybe even more features like getting the ingame time, maybe memory-usage informations, server up-time, list of running plugins, animals + pvp + monsters active/inactive state. Just some random suggestions ;)
     
  22. Offline

    NotoriousPyro

    Seems like 0.2 is compatible with 621.

    Would be nice to have more default APIs to use, I'd gladfully make more php scripts to parse them :)
     
  23. Offline

    Sieabah

    Is your server status script private, or could I be able to use it?
     
  24. Offline

    NotoriousPyro

    @Sieabah
    That is quite complex and not really available for use as it isn't designed for any other server except mine. I'm working on various projects at the moment so there will probably be one eventually :)

    You can see the admin interface I'm working on here (removed for now - NotoriousPyro)

    It's a free open-source alternative to McMyAdmin.
     
  25. Offline

    uncovery

    I am looking for a way to execute admin-commands on the console through an api. Let me explain:

    The server is running under linux as the user "minecraft". I want to be able to go to a (secret) URL and execute some commands on the command line interface. I cannot do that through PHP since PHP runs as user httpd and that one cannot access the screen the server runs in. If the API can help me to get around that problem that would be great.

    I would need to execute commands such as /region load and /perissions -reload all by opening a URL.
    I think it would be safe if the url has to contain a long password.

    Do you think this is possible? I am a java noob, so sorry if this is a stupid question...
     
  26. Offline

    Pjstaab

    I'm definitely keeping my eye on this.
     
  27. Offline

    KokaKiwi

    I've plan to add an token system to ApiCraft that will allow an user to perform server command as if he's connected, so he could be restricted by permissions systems (Permissions or GroupManager).

    For updates, I'm sorry for the lack of informations, but I've a lot of problem with my own CraftBukkit server, and it's very strenuous to fix it =/
    I'll update ApiCraft (and my others plugins), when I have enough time.
     
  28. Offline

    NotoriousPyro

  29. Offline

    comz123

    Nice...works just fine. BEST WEB PLUGIN IVE SEEN (Cause it actually works and is easy to setup_
     
  30. Offline

    verboseone

    Thanks! Works great. Please update your title to say that it works with up to build 720. (That is what I'm running and it works.
     

Share This Page