Giter VIP home page Giter VIP logo

minecraft-server-status's Introduction

minecraft-server-status

Get informations from a Minecraft server in real time.

Installation

Via composer

composer require adrien-nf/minecraft-server-status

Usage

Server List Ping

No configuration needed from the server, this is the easiest method.

use Ping\Ping;

$infos = (new Ping("localhost", 25565))->getInfos();

echo $infos->getVersion(); // 1.20.1
echo $infos->getServerType(); // Vanilla
echo $infos->getMotd(); // A Minecraft Server
echo $infos->getMaxPlayers(); // 20
echo $infos->getPlayersCount(); // 3
echo $infos->getIp(); // localhost
echo $infos->getPort(); // 25565

// With Ping, you only get a partial player list
var_dump($infos->getPlayers()); // ["Notch", "Deadmau5"]

// Some helper functions
echo $infos->isPlayerConnected("Notch"); // true
echo $infos->isVanilla(); // true
echo $infos->isBukkit(); // false
echo $infos->isSpigot(); // false
echo $infos->isPaper(); // false

Query

Requires configuration in server.properties:

  • enable-query=true
  • query.port=25565

Once this is done, usage is pretty straightforward.

use Queries\JavaServerQuery;

$infos = (new JavaServerQuery("localhost", 25565))->getInfos();

echo $infos->getGameType(); // SMP
echo $infos->getWorldName(); // world

// With Query, you get a full players list
var_dump($infos->getPlayers()); // ["Notch", "Deadmau5", "Jeb"]
var_dump($infos->getPlugins()); // [["name" => "Shopkeepers", "version" => "2.17.1"], ["name" => "HolographicDisplays", "version" => "3.0.2"]]

// Some helper functions
echo $infos->getPluginsAsString(); // "Shopkeepers, HolographicDisplays"
echo $infos->getPluginsAsString(true); // "Shopkeepers 2.17.1, HolographicDisplays 3.0.2"
echo $infos->hasPlugin("Shopkeepers"); // true
var_dump($infos->getPluginsAsArray()) // ["Shopkeepers", "HolographicDisplays"]
var_dump($infos->getPluginsAsArray(true)) // ["Shopkeepers 2.17.1", "HolographicDisplays 3.0.2"]

Credits

This package has been inspired by xPaw's package, extended and corrected for simpler usage.

minecraft-server-status's People

Contributors

adrien-nf avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.