< >

minescraft-server-api.php


Quell Code


<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<div id="out"></div>
<script>
d=document.getElementById('out');
$.ajax({
     type:"GET",
     url:"https://minecraft-statistic.net/api/server/info/5.83.162.23_25565",
     dataType:"json",
     success:function(data){
          console.log(data);
          function timeConverter(UNIX_timestamp){
                var a = new Date(UNIX_timestamp * 1000);
                var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
                var year = a.getFullYear();
                var month = months[a.getMonth()];
                var date = a.getDate();
                var hour = a.getHours();
                var min = a.getMinutes();
                var sec = a.getSeconds();
                var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
                return time;
          }
          d.innerHTML+='Server Standort '+data.geo.city+' in '+data.geo.country_name+'<br>';
          d.innerHTML+='Online '+data.info.players+' / '+data.info.max_players+'<br>';
          for(g=1;g<=data.info.players_list.length;g++){
                ga=g-1;
                user=data.info.players_list;
                d.innerHTML+=g+' = '+user[ga]+'<br>';
          }
          d.innerHTML+='Online rekord am '+timeConverter(data.max_stat.max_online.date)+' mit '+data.max_stat.max_online.players+' Usern';
     }
})
</script>