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 15ee0c37c6
commit 8ddd701d76
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\FullChunkDataPacket;
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\MoveEntityPacket;
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);
}
if(count($this->usedChunks) >= 56 and $this->spawned === false){
if(count($this->usedChunks) >= 16 and $this->spawned === false){
$spawned = 0;
foreach($this->usedChunks as $d){
if($d === true){
@ -645,12 +645,16 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
}
if($spawned < 56){
if($spawned < 16){
return;
}
$this->spawned = true;
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::PLAYER_SPAWN;
$this->dataPacket($pk);
$pk = new SetTimePacket();
$pk->time = $this->level->getTime();
$pk->started = $this->level->stopTime == false;
@ -1420,12 +1424,12 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
if($packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL){
if($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL){
$pk = new LoginStatusPacket();
$pk->status = 1;
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
$this->dataPacket($pk);
}else{
$pk = new LoginStatusPacket();
$pk->status = 2;
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
$this->dataPacket($pk);
}
$this->close("", "Incorrect protocol #" . $packet->protocol1, false);
@ -1526,8 +1530,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->inventory->setHeldItemSlot(0);
}
$pk = new LoginStatusPacket();
$pk->status = 0;
$pk = new PlayStatusPacket();
$pk->status = PlayStatusPacket::LOGIN_SUCCESS;
$this->dataPacket($pk);
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\DisconnectPacket;
use pocketmine\network\protocol\LoginPacket;
use pocketmine\network\protocol\LoginStatusPacket;
use pocketmine\network\protocol\PlayStatusPacket;
use pocketmine\network\protocol\MessagePacket;
use pocketmine\network\protocol\MoveEntityPacket;
use pocketmine\network\protocol\MovePlayerPacket;
@ -306,7 +306,7 @@ class RakLibInterface implements ServerInstance, SourceInterface{
$this->packetPool = new \SplFixedArray(256);
$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::MESSAGE_PACKET, MessagePacket::class);
$this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class);

View File

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

View File

@ -24,14 +24,20 @@ namespace pocketmine\network\protocol;
#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 $next = 0;
public $status;
public function pid(){
return Info::LOGIN_STATUS_PACKET;
return Info::PLAY_STATUS_PACKET;
}
public function decode(){

View File

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