[WEB][PHP] Minecraft Server Query with Avatars // EASY!

Discussion in 'Bukkit Tools' started by iPhwnU, Jan 16, 2014.

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

    NoHoPeLess

    Same issue... ?!?! When Online and Offline... dont know what happens

    [​IMG]
     
  2. Offline

    iPhwnU

    It seems that the script is totally broken at the moment. I'll try to develop a newer version soon.
     
  3. Offline

    McLive

  4. Offline

    jdf2

  5. Offline

    iPhwnU

    jdf2 I tried this query function yesterday, and I can say it's not deprecated, YET. I managed to query one server perfectly with it. Although, I can't tell if it's suitable for the script, as it may or may not work in the future...

    McLive Ya sure about Minequery? It basically serves the same purpose as the built-in query and if I'm correct, then this is the reason why they discontinued the development of the plugin.
     
  6. Offline

    iPhwnU

  7. Offline

    iPhwnU

  8. Offline

    McLive

  9. Offline

    ArSkHelios

  10. Offline

    McLive

    The ping will work with bungee servers but I haven't tested the bungee query.
     
    ArSkHelios likes this.
  11. Offline

    ArSkHelios

    Ah okay. I just tested it and got this - http://puu.sh/afmPe.png
    Query is enabled throughout my whole network for testing purposes.
     
  12. Offline

    McLive

    You could query the servers itself for now but I'll look in the bungeecord query and see how it works.

    Query is working great with bungeecord for me!
    [​IMG]
    Are you sure to have it enabled in your config.yml?
    Code:
    query_enabled: true
    query_port: 61396
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  13. Offline

    theearlypc423

    That's sexy. I'm sooooo using that for my xenforo site.
     
  14. Offline

    ArSkHelios

    It works for me in the sense of getting how many players are online, but, the part that doesn't work is showing the players online.
    http://puu.sh/ag1oG.png (note, that's not my real server IP)
    My Bungee config is set correctly as well.
     
  15. Offline

    Yonas

  16. Offline

    Tech315

    Really appreciate this! But being "new" to php and web site development I am struggling with displaying this information on my index.php rather than a separate page.
    Can anyone give me a point in the right direction for doing this?
     
  17. Offline

    McLive

    Like this? http://www.mclive.eu/PlanetMine.php
    I can PM you the code.
     
  18. Offline

    Tech315

  19. Offline

    McLive

    sent.^^
     
    Tech315 likes this.
  20. Offline

    ArSkHelios

    Finally found out my issue ~ I had UDP blocked and not allowed on my query port.
    Just curious, but would it be possible to add this type of Bungee Support? McLive http://puu.sh/akf4c/b7f63660c4.jpg
    I think that would be an AWESOME addition if so.
    #ImSmart
     
  21. Offline

    blazstyn

    So after some tinkering I got this working on my debian box.

    I'd love to have this centerstage on my site, but it doesn't quite fit in. How do I go about changing the colours of fonts and the 'there are no players online' popups? I have made the background transparent with css, but there are still parts of the page that don't work well when dropped into the site.

    See here, I'd like to customize colours, but am not sure which stylesheet to peruse before making those changes. I'd need to host them locally too, I'm thinking?

    Great piece of code, and thanks in advance for your help.
     
  22. Offline

    McLive

    This would have to be implemented into bungee. We can only ouput what the query returns :/

    Mind sharing your site so I could see how we could fix it?
    Changing colours basically works with some html color codes.
     
  23. Offline

    iPhwnU


    Custom CSS definitions have to be declared in the custom styles section since the stylesheets are fetched from CDN servers.

    Find this part between the HTML <head></head> tags.
    HTML:
    <style>
            /*Custom CSS Overrides*/
            body {
                  font-family: 'Lato', sans-serif !important;
            }
    </style>
    
     
  24. Offline

    ArSkHelios

    Are you sure? One website (PM me for direct link) has it separated.
    [​IMG]
     
  25. Offline

    iPhwnU

    ArSkHelios
    Displaying players per server separately like seen on the first screenshot, will require some hacking. Probably a custom plugin that will serve the username values through an API or something, since the default Bungee query will not show how many players there are in each server.

    However, you can achieve something like seen on the last screenshot (ofc with some CSS and HTML tweaking) with code found here: http://www.spigotmc.org/resources/web-bungeestatus.472/

    Anyway, coming back to the first screenshot (http://puu.sh/akf4c/b7f63660c4.jpg), there is a workaround you can try. This will require ALL of your servers to run on an external network (not in localhost). If you're well familiar with Bungee, you will know that the servers have to be in offline mode. This will a raise a security risk when players find out that your offline servers are running on an external network. Now this plugin will become handy: http://www.spigotmc.org/resources/ipwhitelist.61/. Basically, it will allow players to join your server only when they connect through Bungee proxy server and share the required IP. So after you've done all that's necessary, you can query each server directly using the same MinecraftAvatarQuery script. Pretty obviously you need to extend the script a bit, but I hope you get the concept :)
     
  26. Offline

    McLive

    ArSkHelios

    You need to ping/query your backend servers. I wrote a simple script to do this, just add servers to the array and build some css around it.

    PHP:
    <?php
     
    #Add servers here#
    $servers = Array(
        
    'Survival' => array(
            
    'ip' => 's.freecraft.eu',
            
    'port' => '25566',
            
    'queryport' => '25566'
            
    ),
        
    'Skyblock' => array(
            
    'ip' => 'sky.freecraft.eu',
            
    'port' => '25555',
            
    'queryport' => '25555'
            
    ),
        );
    #Add servers here#
     
    var_dump($servers);
    echo 
    "<br><br>";
     
    foreach (
    $servers as $key => $value) {
        echo 
    $key "<br>";
        foreach (
    $value as $key => $value) {
            
    //echo $key . ": " . $value . "<br>";
            
    if($key == "ip") {
                
    $ip $value;
            }
            if(
    $key == "port") {
                
    $port $value;
            }
            if(
    $key == "queryport") {
                
    $queryport $value;
            }
        }
        
    $ping json_decode(file_get_contents('http://api.minetools.eu/ping/' $ip '/' $port ''), true);
        
    $query json_decode(file_get_contents('http://api.minetools.eu/query/' $ip '/' $queryport ''), true);
     
        if(empty(
    $ping['error'])) {
            
    $version $ping['version']['name'];
            
    $online $ping['players']['online'];
            
    $max $ping['players']['max'];
            
    $motd $ping['description'];
            
    $favicon $ping['favicon'];
        }
     
        if(empty(
    $query['error'])) {
            
    $playerlist $query['Playerlist'];
        }
     
        echo 
    "Players online: " $online "/" $max "<br>";
     
        if(empty(
    $query['error'])) {
            if(
    $playerlist != "null") { //is at least one player online? Then display it!
                
    foreach ($playerlist as $player) { ?>
                    <a data-placement="top" rel="tooltip" style="display: inline-block;" title="<?php echo $player;?>">
                    <img src="http://cravatar.eu/helmavatar/<?php echo $player;?>/50" size="40" width="40" height="40" style="width: 40px; height: 40px; margin-bottom: 5px; margin-right: 5px; border-radius: 3px; "/></a>
        <?php    }
            } else {
                echo 
    "<div class=\"alert\"> There are no players online at the moment!</div>";
            }
        } else {
            echo 
    "<div class=\"alert\"> Query must be enabled in your server.properties file!</div>";
        }
     
        echo 
    "<br>";
     
    }
     
    ?>
    Preview: http://www.mclive.eu/query.php
     
  27. Offline

    ArSkHelios

    McLive - I copied and pasted your script, and then placed in my server's IP's/ports/query-ports with no luck. Just shows how many players online (except its not accurate at all) and says I need to enable query, even though it is enabled.
     
  28. Offline

    blazstyn

    Site is available at simplyvanilla.net for you to check out.
    The script is embedded on the main page right now.
     
  29. Offline

    McLive

    Maybe like this? http://www.mclive.eu/simplyvanilla.net
    I just edited the html, you need to add the colors into your php code.
    HTML:
            <div class="row">
                <div class="span4">
                    <h3><font color="white">Simply Vanilla</font></h3>
                    <table class="table">
                        <tbody>
                            <tr>
                                <td><b><font color="orange">IP</font></b></td>
                                <td><font color="lightgrey">sv.cloudnineonline.net</font></td>
                            </tr>
                                                <tr>
                                <td><b><font color="orange">Version</font></b></td>
                                <td><font color="lightgrey">Spigot 1.7.10</font></td>
                            </tr>
                                                                    <tr>
                                <td><b><font color="orange">Players</font></b></td>
                                <td><font color="lightgrey">0 / 109</font></td>
                            </tr>
                                                <tr>
                                <td><b><font color="orange">Status</font></b></td>
                                <td><font color="white"><i class="icon-ok-sign"></i></font> <font color="lightgreen"> Server is online</font></td>
                            </tr>
                                                                                    </tbody>
                    </table>
                </div>
                <div class="span8">
                    <h3><font color="white">Players</font></h3>
                    <div class="alert"> There are no players online at the moment!</div>            </div>
            </div>
     
  30. Offline

    blazstyn

    Saved. Thanks a lot! I'll look to making the changes shortly.
     
Thread Status:
Not open for further replies.

Share This Page