API Host a Website using Bukkit! [WebBukkit]

Discussion in 'Resources' started by MCMastery, Aug 13, 2016.

Thread Status:
Not open for further replies.
  1. Offline


    Hello! Today I am showing you an API I made, which allows you to host websites without any external libraries, simply by running the server.

    • Obviously the website will stop working once the server is shut down. So this is only useful for 24/7 servers, where the only downtime would be during restarts
    • There's probably more... that's all I can think of though :p
    • Easily create dynamic content, depending on server info (such as who is playing, how many players are online, etc.). I will be making dynamic content possible with the use of a customized server-side scripting language (right now, all you can do is return a string containing the content of the page)
    • Easily manage your website, and have it automatically update
    • Create a responsive website, linked to the server - e.g. you could make a BuyCraft-like shop
    GitHub: https://github.com/MCMastery/webbukkit


    To start the website, use
    Website requests are handled by
    The default request handler is BasicWebsiteRequestHandler.
    This handler allows any file inside the "website" folder (inside the base server folder) to be visible.

    Making your own request handler
    I'll make a tutorial on this later. Right now, this isn't very useful... once I make dynamic content easy it will be

    How to host THE INTERWEBS

    To host your own website, create a folder inside the base server folder called "website". Place your website files in here (HTML, CSS, etc.). If you want to make a 404 page (page not found), place it in here and call it "404.html". Use "index.html" for home pages, not "home.html".

    Then, to start hosting the website, in your plugin call:
    Replace port with the port you want to host the website on (remember to port-forward, if you want to).

    Start the server, then go to http://localhost:<YOUR PORT>
    The index.html you put inside your website folder should be loaded.

    This is just a proof of concept
    I literally just started making this like 30 minutes ago. There's not much you can do with it yet (other than hosting a static website, ofc). I'll make this more accessible to non-programmers, maybe
    Last edited: Aug 13, 2016
    Tails_Prower_24 and ChipDev like this.
  2. Offline


    That's an interesting idea! I'll have to test it out once I'm done with some stuff. :)
    MCMastery likes this.
  3. Offline


    I really love that idea. Unfortunately I do not already know how to code a website. I'll have to go learn that first.
    MCMastery likes this.
  4. @MCMastery Interesting idea, how much bandwidth, ram and cpu usage is being used?
  5. Offline


    0.5% cpu (i5 3xxx (idk)), about 0.5GB ram, about 1.5 Mbps bandwidth whenever I load the site (which is the home page, so it must load all the Bootstrap files, one logo, favicon, css. also it has to parse a little server-side language I made)
  6. Offline


    Interesting idea, although I feel that more explanation is required.
    I've tried hosting a simple site that just said hello world as the heading, on the port 25566 and it won't load? Am I missing something?

    When the plugin enables I start the web server. Also how would I stop the web server?

    EDIT: @MCMastery Fixed my issue, just needed to make it bind to my PC's ip address.
    Will you be adding support for images, and a possible shutdown function?
    Last edited: Aug 24, 2016
  7. Offline


    I've added images, just need to upload the code... I'll do that soon

    The web server stops when the minecraft server stops
  8. Offline


    @MCMastery can you run server-side languages(php)? And also can you make it so that the websites are editable through the code of a plugin? That would be quite cool

    Sent from my iPhone using Tapatalk
    MCMastery likes this.
  9. Offline

    timtower Administrator Administrator Moderator

    PHP would require him to build an entire apache server XD
    Not a fun task, then it is betterto have a normal apache server running.
    MCMastery likes this.
  10. Offline


    I made my own server-side language, with basic server info-getting just for fun xD:
        playerCount = Server.getPlayerCount();
        msg = "players";
        if (playerCount = 1) {
            msg = "player";
        print("<h2>" + playerCount + " " + msg + " online</h2>");
  11. Offline


    That is still really useful can you make it that plugins can add to that? Like add the ability to get stats of a player or something

    Sent from my iPhone using Tapatalk
  12. Offline


    This was what I was thinking - maybe an API that plugins can use to add server-side functionality
  13. Offline


    That would be amazing! And what is the syntax of your language? You'd have to explain how to use your language as well. If you add this API I'll most likely be using this for my server website!

    EDIT: You'll even be able to access database data using plugins so you can almost replicate a normal server-side language!
  14. Offline


    yep! I just need to work on it more, thx
  15. Offline


    How's this project coming along, I'm actually really interested in seeing this come into full functionality and also do you have Got setup for this project so others can contribute to it?

    Sent from my iPhone using Tapatalk
  16. Offline


    I have tried to put
    WebBukkit.getInstance().start(port); eclipse errors getInstance and says "The method getInstance() is undefined for the type WebBukkit" Can someone help me resolve this problem?

    I found out that there was a missing public void getInstance in the api. I just fixed it and now it works.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Nov 11, 2016
  17. A listener to this website built in to it would be nice

    Sent from my iPhone using Tapatalk
  18. Offline

    timtower Administrator Administrator Moderator

    What kind of listener are you talking about? What would it do?
  19. Button presses etc, like php
  20. Cool idea! But it would be hard to have like a forum and shop on that website if I understand right??
  21. Offline

    timtower Administrator Administrator Moderator

    Based on what I see here: impossible with this now.
Thread Status:
Not open for further replies.

Share This Page