• Guest, we are doing a new map (refresh) for Herocraft. Gather your friends and get ready! Coming next Friday, 06/28/24 @ 7PM CT play.hc.to
    Read up on the guides and new systems! Here.
    View the LIVE Map here @ hc.to/map
    Stuck or have a problem? use "/pe create" to to open a ticket with staff (There are some known issues and other hotfixes we will be pushing asap)
  • Guest, Make sure to use our LAUNCHER! Read more here!

Suggestion Serve HC Data to Web via JSON

Davros_

Web Developer
Legacy Supporter 9
Joined
May 20, 2012
Location
Earth
As you may be aware, I created the neat little online badge things for people's signatures. Doing this was a bit tricky due to the fact that the only place I could find a list of online players was on the HC homepage. My program had to download the entire homepage every single time an online status badge was requested to check whether the player was online or not. (There have been over 160,000 requests since July 11. Each request downloads about 20kb, so if my math is correct that's around 3GB total).

Around August 4th, the way the list of currently online players was displayed on the homepage changed, breaking my widget. I could slightly modify my code and have it work again, but I think I have a better solution that would not only help me, but would put less stain on the herocraftonline.com server as well as allow others to easily access this information.

To get to the point, I was wondering if it would be possible to serve a JSON file containing the list of online players. It would basically look something like this:

Code:
{
    "onlinePlayers" : ["player1", "player2", "etc"]
}

To go a step further, additional data could be served via this JSON file, enabling some pretty extremely cool things. For example, you could include players' classes, levels, the current world time, etc.


Code:
{
    "onlinePlayers" : {
        "player1" : {
            "class" : {
                "main" : ["ranger", 11],
                "profession" : ["engineer", 23]
            },
            "titles" : {
                "prefix" : ["failure", "veteran", "rogue", "crafter"],
                "suffix" : ["t1star", "t2star", "t3star"]
            }
        },
        "player2" : {
            "class" : {
                "main" : ["lostsoul", 1]
            }
        },
        "player3" : {
            "class" : {
                "main" : ["dragoon", 60],
                "profession" : ["alchemist", 55]
            },
            "titles" : {
                "prefix" : ["warrior", "dragoon", "crafter", "alchemist"]
            }
        }
    },
    "worlds" : {
        "Dragon" : {
            "time" : "23:11",
            "weather" : "rain"
        },
        "Warshard" : {
            "time" : "05:11",
            "weather" : "sun"
        }
    },
    "lottery" : {
        "countdown" : "82808763",
        "pot" : "6592"
    },
    "bounty" : {
        "bounties" : [["player1", "890.00"], ["player3", "95.00"]]
    }
}


By publishing data like this, so many doors would be opened. People could display their levels, achievements, etc. anywhere. It would be one step further in the integration of Herocraft and the web. (Also, this entire JSON file would only be 0.5kb. That's 1/40th the original size and 100x as much useful information.)

I'm sure this doesn't mean much to most of you, but it's pretty exciting to me. I'm weird, I guess. I hope you consider my suggestion though nonetheless. (I also apologize for how horribly I typed this out. It's 1:30AM and I'm half asleep.)
 
Top