forked from xPaw/PHP-Minecraft-Query
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRconTest.php
35 lines (27 loc) · 791 Bytes
/
RconTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
define( 'MQ_SERVER_ADDR', 'localhost' );
define( 'MQ_SERVER_PORT', 25575 );
define( 'MQ_SERVER_PASS', 'lolrcontest' );
define( 'MQ_TIMEOUT', 2 );
require __DIR__ . '/MinecraftRcon.class.php';
echo "<pre>";
try
{
$Rcon = new MinecraftRcon;
$Rcon->Connect( MQ_SERVER_ADDR, MQ_SERVER_PORT, MQ_SERVER_PASS, MQ_TIMEOUT );
$Data = $Rcon->Command( "say Hello from xPaw's minecraft rcon implementation." );
if( $Data === false )
{
throw new MinecraftRconException( "Failed to get command result." );
}
else if( StrLen( $Data ) == 0 )
{
throw new MinecraftRconException( "Got command result, but it's empty." );
}
echo HTMLSpecialChars( $Data );
}
catch( MinecraftRconException $e )
{
echo $e->getMessage( );
}
$Rcon->Disconnect( );