• Stars
    star
    727
  • Rank 62,005 (Top 2 %)
  • Language
    PHP
  • License
    MIT License
  • Created about 13 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🐘 PHP library to query Minecraft servers

PHP Minecraft Query Packagist

This library can be used to query Minecraft servers for some basic information.

⚠️ Please do not create issues when you are unable to retrieve information from a server, unless you can prove that there is a bug within the library.

Differences between Ping and Query

There are two methods of retrieving information about a Minecraft server.

Ping

Ping protocol was added in Minecraft 1.7 and is used to query the server for minimal amount of information (hostname, motd, icon, and a sample of players). This is easier to use and doesn't require extra setup on server side. It uses TCP protocol on the same port as you would connect to your server.

MinecraftPing class contains a method QueryOldPre17 which can be used to query servers on version 1.6 or older.

Query

This method uses GameSpy4 protocol, and requires enabling query listener in your server.properties like this:

enable-query=true
query.port=25565

Query allows to request a full list of servers' plugins and players, however this method is more prone to breaking, so if you don't need all this information, stick to the ping method as it's more reliable.

RCON

It is possible to send console commands to a Minecraft server remotely using the Source RCON protocol. Use PHP Source Query library for your RCON needs.

SRV DNS record

This library automatically tries to resolve SRV records. If you do not wish to do so, pass false as the fourth param in the constructor (after timeout param).

Example

<?php
	require __DIR__ . '/src/MinecraftPing.php';
	require __DIR__ . '/src/MinecraftPingException.php';
	
	use xPaw\MinecraftPing;
	use xPaw\MinecraftPingException;
	
	try
	{
		$Query = new MinecraftPing( 'localhost', 25565 );
		
		print_r( $Query->Query() );
	}
	catch( MinecraftPingException $e )
	{
		echo $e->getMessage();
	}
	finally
	{
		if( $Query )
		{
			$Query->Close();
		}
	}
?>

If you want to get ping info from a server that uses a version older than Minecraft 1.7, then use function QueryOldPre17 instead of Query.


If the server has query enabled (enable-query), then you can use MinecraftQuery to more retrieve information about a server.

<?php
	require __DIR__ . '/src/MinecraftQuery.php';
	require __DIR__ . '/src/MinecraftQueryException.php';
	
	use xPaw\MinecraftQuery;
	use xPaw\MinecraftQueryException;
	
	$Query = new MinecraftQuery( );
	
	try
	{
		$Query->Connect( 'localhost', 25565 );
		
		print_r( $Query->GetInfo( ) );
		print_r( $Query->GetPlayers( ) );
	}
	catch( MinecraftQueryException $e )
	{
		echo $e->getMessage( );
	}
?>

For Bedrock servers (MCPE) use ConnectBedrock function instead of Connect, then GetInfo will work.

License

MIT

More Repositories

1

PHP-Source-Query

🐘 PHP library to query servers that implement Steam query protocol (also known as Source Engine Query protocol)
PHP
577
star
2

CS2

🔫 Counter-Strike 2 stuff
148
star
3

SteamID.php

🆔 PHP library to work with SteamIDs
PHP
142
star
4

SteamWebAPIDocumentation

📃 An automatically generated list of Steam Web API interfaces, methods and parameters. Allows you to craft requests in the browser.
Vue
138
star
5

SteamWebPipes

🚀 Pushes Steam changelists to WebSocket clients
C#
120
star
6

mcstatus

💡 Minecraft services status checker
PHP
112
star
7

AMXX-Plugins

💌 Most of my AMXX plugins that I've ever written
Pawn
73
star
8

DomainNameSearch

🔥 Lookup domain names against all extensions
HTML
70
star
9

FlatMumble

💬 Flat and unified mumble theme (MUMBLE 1.3.0 SHIPS WITH MODIFIED VERSION OF THIS THEME)
40
star
10

HTTPsys

🔥 A checker site for MS15-034 / CVE-2015-1635
PHP
38
star
11

SteamOpenID.php

🐘 A correct and simple implementation of OpenID authentication for Steam
PHP
37
star
12

Steam-Card-Farmer

🃏 Idle your Steam games to get trading cards
JavaScript
37
star
13

GitHub-WebHook

🐱 Validates and processes GitHub's webhooks
PHP
30
star
14

SteamLicenseParser

📦 Parsers your Steam licenses and generates some stats
HTML
29
star
15

Crimp.php

⚡ A simple multi curl implementation, optimized for high concurrency.
PHP
25
star
16

Re-Crono-HexChat

🕶 A dark GTK theme for HexChat
25
star
17

adventofcode-solutions

🎄 My solutions to https://adventofcode.com/
C#
24
star
18

smtp-forwarder

Simple SMTP message to HTTP forwarder
JavaScript
15
star
19

SteamDepotFileVerifier

Find unknown files in Steam game folders by comparing against depotcache manifests
C#
15
star
20

FreeWarden

🔎 Monitor whois, certificate, and dns changes
PHP
13
star
21

AMXX-Gag

🔇 This plugin allows you to gag players from using say_team, say or voicecomm
SourcePawn
13
star
22

DumpStrings

macho-strings will programmatically read an Mach-O binary's string sections within a given binary. This is meant to be much like the strings UNIX utility, however is purpose built for Mach-O binaries.
Go
11
star
23

EntityLumpDumper

Dump entity lump from BSP maps (CS:GO, TF2, etc..)
C#
9
star
24

WendySharp

👮 Wendy# — A C# IRC bot
C#
8
star
25

MumblePing

🎙 A simple function to execute UDP Ping on Mumble servers
PHP
8
star
26

TwitterToWebhook

🐦 Stream tweets to a webhook url
C#
7
star
27

CompareArrays.php

🍌 Diffing multi dimensional arrays the easy way
PHP
7
star
28

xpaw.me

🐾 My personal website
HTML
6
star
29

znc-prioritysend

⏫ Allows certain messages to be placed in front of the send queue
C++
6
star
30

OpenplanetDriveAlone

👆 A Trackmania 2020 plugin to automatically click "Drive Alone" when loading a map in Solo to avoid selecting a ghost to race against.
AngelScript
6
star
31

urlshortener

🔗 A simple url shortener.
PHP
5
star
32

xPaw

4
star
33

php-vue-template

HTML-based template for PHP syntax inspired by Vue.
PHP
3
star
34

PHP-StarMade-Query

🐘 PHP library to query StarMade servers
PHP
3
star
35

BombGame

💣 A game mode for CS:GO
SourcePawn
3
star
36

steam-tags-game

🎲 This is our defunct mini game
HTML
2
star
37

AMXX-Language-Analyzer

🈂️ Analyze AMXX translation files for missing and erroneous translations
PHP
2
star
38

Bugsnuggle

🐛 A crappy local clone of Bugsnag
PHP
2
star
39

PHP-TUG-Query

🐘 PHP library to query TUG servers
PHP
1
star
40

test-secrets

1
star
41

.github

😾 Default community health files
1
star