Data packet handling!!!

This commit is contained in:
Shoghi Cervantes Pueyo
2012-11-21 23:19:16 +01:00
parent 668994b5a4
commit aae04b8dfd
11 changed files with 184 additions and 54 deletions

View File

@ -28,7 +28,7 @@ the Free Software Foundation, either version 3 of the License, or
require_once("classes/Session.class.php");
class PocketMinecraftServer{
protected $interface, $protocol, $entities, $player, $cnt, $events, $username, $version, $clients;
protected $interface, $protocol, $entities, $player, $cnt, $events, $username, $version, $clients, $serverType;
function __construct($username, $protocol = CURRENT_PROTOCOL, $version = CURRENT_VERSION){
//$this->player = new Player($username);
$this->version = (int) $version;
@ -39,6 +39,7 @@ class PocketMinecraftServer{
$this->actions = array();
$this->clients = array();
$this->protocol = (int) $protocol;
$this->setType("normal");
$this->interface = new MinecraftInterface("255.255.255.255", $this->protocol, 19132, true, false);
console("[INFO] Creating Minecraft Server");
console("[INFO] Username: ".$this->username);
@ -46,6 +47,18 @@ class PocketMinecraftServer{
$this->stop = false;
}
public function setType($type = "demo"){
switch($type){
case "normal":
$this->serverType = "MCCPP;Demo;";
break;
case "minecon":
$this->serverType = "MCCPP;MINECON;";
break;
}
}
public function action($microseconds, $code){
$this->actions[] = array($microseconds / 1000000, microtime(true), $code);
console("[INTERNAL] Attached to action ".$microseconds, true, true, 3);
@ -86,7 +99,7 @@ class PocketMinecraftServer{
$data[0],
$this->serverID,
MAGIC,
"MCCPP;Demo;". $this->username,
$this->serverType. $this->username,
), false, $packet["ip"], $packet["port"]);
break;
case 0x05: