Renamed LoginStatusPacket to PlayStatusPacket, added spawn status, new colors

This commit is contained in:
Shoghi Cervantes 2015-03-12 10:35:39 +01:00
parent 44dfb59409
commit 4b442a9d7c
5 changed files with 43 additions and 32 deletions

View File

@ -92,7 +92,7 @@ use pocketmine\network\protocol\DisconnectPacket;
use pocketmine\network\protocol\EntityEventPacket; use pocketmine\network\protocol\EntityEventPacket;
use pocketmine\network\protocol\FullChunkDataPacket; use pocketmine\network\protocol\FullChunkDataPacket;
use pocketmine\network\protocol\Info as ProtocolInfo; use pocketmine\network\protocol\Info as ProtocolInfo;
use pocketmine\network\protocol\LoginStatusPacket; use pocketmine\network\protocol\PlayStatusPacket;
use pocketmine\network\protocol\MessagePacket; use pocketmine\network\protocol\MessagePacket;
use pocketmine\network\protocol\MoveEntityPacket; use pocketmine\network\protocol\MoveEntityPacket;
use pocketmine\network\protocol\MovePlayerPacket; use pocketmine\network\protocol\MovePlayerPacket;
@ -637,7 +637,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->level->requestChunk($X, $Z, $this, LevelProvider::ORDER_ZXY); $this->level->requestChunk($X, $Z, $this, LevelProvider::ORDER_ZXY);
} }
if(count($this->usedChunks) >= 56 and $this->spawned === false){ if(count($this->usedChunks) >= 16 and $this->spawned === false){
$spawned = 0; $spawned = 0;
foreach($this->usedChunks as $d){ foreach($this->usedChunks as $d){
if($d === true){ if($d === true){
@ -645,11 +645,15 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
} }
} }
if($spawned < 56){ if($spawned < 16){
return; return;
} }
$this->spawned = true; $this->spawned = true;
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::PLAYER_SPAWN;
$this->dataPacket($pk);
$pk = new SetTimePacket(); $pk = new SetTimePacket();
$pk->time = $this->level->getTime(); $pk->time = $this->level->getTime();
@ -1420,12 +1424,12 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
} }
if($packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL){ if($packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL){
if($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL){ if($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL){
$pk = new LoginStatusPacket(); $pk = new PlayStatusPacket();
$pk->status = 1; $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
$this->dataPacket($pk); $this->dataPacket($pk);
}else{ }else{
$pk = new LoginStatusPacket(); $pk = new PlayStatusPacket();
$pk->status = 2; $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
$this->dataPacket($pk); $this->dataPacket($pk);
} }
$this->close("", "Incorrect protocol #" . $packet->protocol1, false); $this->close("", "Incorrect protocol #" . $packet->protocol1, false);
@ -1526,8 +1530,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->inventory->setHeldItemSlot(0); $this->inventory->setHeldItemSlot(0);
} }
$pk = new LoginStatusPacket(); $pk = new PlayStatusPacket();
$pk->status = 0; $pk->status = PlayStatusPacket::LOGIN_SUCCESS;
$this->dataPacket($pk); $this->dataPacket($pk);
if($this->spawnPosition === null and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level){ if($this->spawnPosition === null and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level){

View File

@ -49,7 +49,7 @@ use pocketmine\network\protocol\InteractPacket;
use pocketmine\network\protocol\LevelEventPacket; use pocketmine\network\protocol\LevelEventPacket;
use pocketmine\network\protocol\DisconnectPacket; use pocketmine\network\protocol\DisconnectPacket;
use pocketmine\network\protocol\LoginPacket; use pocketmine\network\protocol\LoginPacket;
use pocketmine\network\protocol\LoginStatusPacket; use pocketmine\network\protocol\PlayStatusPacket;
use pocketmine\network\protocol\MessagePacket; use pocketmine\network\protocol\MessagePacket;
use pocketmine\network\protocol\MoveEntityPacket; use pocketmine\network\protocol\MoveEntityPacket;
use pocketmine\network\protocol\MovePlayerPacket; use pocketmine\network\protocol\MovePlayerPacket;
@ -306,7 +306,7 @@ class RakLibInterface implements ServerInstance, SourceInterface{
$this->packetPool = new \SplFixedArray(256); $this->packetPool = new \SplFixedArray(256);
$this->registerPacket(ProtocolInfo::LOGIN_PACKET, LoginPacket::class); $this->registerPacket(ProtocolInfo::LOGIN_PACKET, LoginPacket::class);
$this->registerPacket(ProtocolInfo::LOGIN_STATUS_PACKET, LoginStatusPacket::class); $this->registerPacket(ProtocolInfo::PLAY_STATUS_PACKET, PlayStatusPacket::class);
$this->registerPacket(ProtocolInfo::DISCONNECT_PACKET, DisconnectPacket::class); $this->registerPacket(ProtocolInfo::DISCONNECT_PACKET, DisconnectPacket::class);
$this->registerPacket(ProtocolInfo::MESSAGE_PACKET, MessagePacket::class); $this->registerPacket(ProtocolInfo::MESSAGE_PACKET, MessagePacket::class);
$this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class); $this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class);

View File

@ -33,7 +33,7 @@ interface Info{
const CURRENT_PROTOCOL = 21; const CURRENT_PROTOCOL = 21;
const LOGIN_PACKET = 0x82; const LOGIN_PACKET = 0x82;
const LOGIN_STATUS_PACKET = 0x83; const PLAY_STATUS_PACKET = 0x83;
const DISCONNECT_PACKET = 0x84; const DISCONNECT_PACKET = 0x84;

View File

@ -24,14 +24,20 @@ namespace pocketmine\network\protocol;
#include <rules/DataPacket.h> #include <rules/DataPacket.h>
class LoginStatusPacket extends DataPacket{ class PlayStatusPacket extends DataPacket{
const LOGIN_SUCCESS = 0;
const LOGIN_FAILED_CLIENT = 1;
const LOGIN_FAILED_SERVER = 2;
const PLAYER_SPAWN = 3;
public static $pool = []; public static $pool = [];
public static $next = 0; public static $next = 0;
public $status; public $status;
public function pid(){ public function pid(){
return Info::LOGIN_STATUS_PACKET; return Info::PLAY_STATUS_PACKET;
} }
public function decode(){ public function decode(){
@ -43,4 +49,4 @@ class LoginStatusPacket extends DataPacket{
$this->putInt($this->status); $this->putInt($this->status);
} }
} }

View File

@ -390,6 +390,7 @@ abstract class TextFormat{
foreach($string as $token){ foreach($string as $token){
switch($token){ switch($token){
case TextFormat::BOLD: case TextFormat::BOLD:
$newString .= "\x1b[1m";
break; break;
case TextFormat::OBFUSCATED: case TextFormat::OBFUSCATED:
$newString .= "\x1b[8m"; $newString .= "\x1b[8m";
@ -409,52 +410,52 @@ abstract class TextFormat{
//Colors //Colors
case TextFormat::BLACK: case TextFormat::BLACK:
$newString .= "\x1b[0;30m"; $newString .= "\x1b[38;2;0;0;0m";
break; break;
case TextFormat::DARK_BLUE: case TextFormat::DARK_BLUE:
$newString .= "\x1b[0;34m"; $newString .= "\x1b[38;2;0;0;170m";
break; break;
case TextFormat::DARK_GREEN: case TextFormat::DARK_GREEN:
$newString .= "\x1b[0;32m"; $newString .= "\x1b[38;2;0;170;0m";
break; break;
case TextFormat::DARK_AQUA: case TextFormat::DARK_AQUA:
$newString .= "\x1b[0;36m"; $newString .= "\x1b[38;2;0;170;170m";
break; break;
case TextFormat::DARK_RED: case TextFormat::DARK_RED:
$newString .= "\x1b[0;31m"; $newString .= "\x1b[38;2;170;0;0m";
break; break;
case TextFormat::DARK_PURPLE: case TextFormat::DARK_PURPLE:
$newString .= "\x1b[0;35m"; $newString .= "\x1b[38;2;170;0;170m";
break; break;
case TextFormat::GOLD: case TextFormat::GOLD:
$newString .= "\x1b[0;33m"; $newString .= "\x1b[38;2;255;170;0m";
break; break;
case TextFormat::GRAY: case TextFormat::GRAY:
$newString .= "\x1b[0;37m"; $newString .= "\x1b[38;2;170;170;170m";
break; break;
case TextFormat::DARK_GRAY: case TextFormat::DARK_GRAY:
$newString .= "\x1b[30;1m"; $newString .= "\x1b[38;2;85;85;85m";
break; break;
case TextFormat::BLUE: case TextFormat::BLUE:
$newString .= "\x1b[34;1m"; $newString .= "\x1b[38;2;85;85;255m";
break; break;
case TextFormat::GREEN: case TextFormat::GREEN:
$newString .= "\x1b[32;1m"; $newString .= "\x1b[38;2;85;255;85m";
break; break;
case TextFormat::AQUA: case TextFormat::AQUA:
$newString .= "\x1b[36;1m"; $newString .= "\x1b[38;2;85;255;255m";
break; break;
case TextFormat::RED: case TextFormat::RED:
$newString .= "\x1b[31;1m"; $newString .= "\x1b[38;2;255;85;85m";
break; break;
case TextFormat::LIGHT_PURPLE: case TextFormat::LIGHT_PURPLE:
$newString .= "\x1b[35;1m"; $newString .= "\x1b[38;2;255;85;255m";
break; break;
case TextFormat::YELLOW: case TextFormat::YELLOW:
$newString .= "\x1b[33;1m"; $newString .= "\x1b[38;2;255;255;85m";
break; break;
case TextFormat::WHITE: case TextFormat::WHITE:
$newString .= "\x1b[37;1m"; $newString .= "\x1b[38;2;255;255;255m";
break; break;
default: default:
$newString .= $token; $newString .= $token;
@ -465,4 +466,4 @@ abstract class TextFormat{
return $newString; return $newString;
} }
} }