Skip to content
This repository has been archived by the owner on Feb 2, 2018. It is now read-only.

Commit

Permalink
1.0.3 update'
Browse files Browse the repository at this point in the history
  • Loading branch information
inxomnyaa committed Feb 11, 2017
2 parents a93e5b7 + ffadc34 commit cba0af2
Show file tree
Hide file tree
Showing 28 changed files with 108 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ php:

before_script:
- pecl install channel://pecl.php.net/pthreads-3.1.6
- pecl install channel://pecl.php.net/weakref-0.3.2
- pecl install channel://pecl.php.net/weakref-0.3.3
- echo | pecl install channel://pecl.php.net/yaml-2.0.0

script:
Expand Down
6 changes: 3 additions & 3 deletions src/pocketmine/MemoryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){

echo "[Dump] Wrote " . count($objects) . " objects\n";
}while($continue);

fclose($obData);

file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
file_put_contents($outputFolder . "/serverEntry.js", json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
Expand All @@ -292,8 +294,6 @@ public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){
echo "[Dump] Finished!\n";

gc_enable();

$this->server->forceShutdown();
}

private function continueDump($from, &$data, &$objects, &$refCounts, $recursion, $maxNesting, $maxStringSize){
Expand Down Expand Up @@ -330,4 +330,4 @@ private function continueDump($from, &$data, &$objects, &$refCounts, $recursion,
$data = $from;
}
}
}
}
8 changes: 6 additions & 2 deletions src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public function sendCommandData(){
* @param SourceInterface $interface
* @param null $clientID
* @param string $ip
* @param integer $port
* @param int $port
*/
public function __construct(SourceInterface $interface, $clientID, $ip, $port){
$this->interface = $interface;
Expand Down Expand Up @@ -3602,19 +3602,23 @@ public function removeMetadata($metadataKey, Plugin $plugin){
}

public function onChunkChanged(Chunk $chunk){
$this->loadQueue[Level::chunkHash($chunk->getX(), $chunk->getZ())] = abs(($this->x >> 4) - $chunk->getX()) + abs(($this->z >> 4) - $chunk->getZ());
unset($this->usedChunks[Level::chunkHash($chunk->getX(), $chunk->getZ())]);
}

public function onChunkLoaded(Chunk $chunk){

}

public function onChunkPopulated(Chunk $chunk){

}

public function onChunkUnloaded(Chunk $chunk){

}

public function onBlockChanged(Vector3 $block){

}

public function getLoaderId(){
Expand Down
25 changes: 10 additions & 15 deletions src/pocketmine/PocketMine.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function safe_var_dump(){
case is_array($var):
echo str_repeat(" ", $cnt) . "array(" . count($var) . ") {" . PHP_EOL;
foreach($var as $key => $value){
echo str_repeat(" ", $cnt + 1) . "[" . (is_integer($key) ? $key : '"' . $key . '"') . "]=>" . PHP_EOL;
echo str_repeat(" ", $cnt + 1) . "[" . (is_int($key) ? $key : '"' . $key . '"') . "]=>" . PHP_EOL;
++$cnt;
safe_var_dump($value);
--$cnt;
Expand Down Expand Up @@ -111,10 +111,9 @@ function dummy(){
}
require_once(\pocketmine\PATH . "src/spl/ClassLoader.php");
require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
}

$autoloader = new CompatibleClassLoader();
$autoloader = new \BaseClassLoader();
$autoloader->addPath(\pocketmine\PATH . "src");
$autoloader->addPath(\pocketmine\PATH . "src" . DIRECTORY_SEPARATOR . "spl");
$autoloader->register(true);
Expand Down Expand Up @@ -145,16 +144,6 @@ function dummy(){
define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR);
define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR);

/**
* @deprecated This constant has moved to {@link \pocketmine\network\protocol\Info} and will be removed from here in the future.
*/
const MINECRAFT_VERSION = ProtocolInfo::MINECRAFT_VERSION;
/**
* @deprecated This constant has moved to {@link \pocketmine\network\protocol\Info} and will be removed from here in the future.
*/
const MINECRAFT_VERSION_NETWORK = ProtocolInfo::MINECRAFT_VERSION_NETWORK;


Terminal::init();

define('pocketmine\ANSI', Terminal::hasFormattingCodes());
Expand Down Expand Up @@ -489,10 +478,17 @@ function cleanPath($path){
@define("INT32_MASK", is_int(0xffffffff) ? 0xffffffff : -1);
@ini_set("opcache.mmap_base", bin2hex(random_bytes(8))); //Fix OPCache address errors


if(!file_exists(\pocketmine\DATA . "server.properties") and !isset($opts["no-wizard"])){
new Installer();
$installer = new Installer();
if(!$installer->run()){
$logger->shutdown();
$logger->join();
exit(-1);
}
}


if(\Phar::running(true) === ""){
$logger->warning("Non-packaged PocketMine-MP installation detected, do not use on production.");
}
Expand All @@ -506,7 +502,6 @@ function cleanPath($path){
$killer->start();

$erroredThreads = 0;

foreach(ThreadManager::getInstance()->getAll() as $id => $thread){
$logger->debug("Stopping " . $thread->getThreadName() . " thread");
try{
Expand Down
1 change: 0 additions & 1 deletion src/pocketmine/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public function registerClassLoader(){
if(!interface_exists("ClassLoader", false)){
require(\pocketmine\PATH . "src/spl/ClassLoader.php");
require(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
require(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
}
if($this->classLoader !== null){
$this->classLoader->register(true);
Expand Down
1 change: 0 additions & 1 deletion src/pocketmine/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public function registerClassLoader(){
if(!interface_exists("ClassLoader", false)){
require(\pocketmine\PATH . "src/spl/ClassLoader.php");
require(\pocketmine\PATH . "src/spl/BaseClassLoader.php");
require(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php");
}
if($this->classLoader !== null){
$this->classLoader->register(true);
Expand Down
4 changes: 2 additions & 2 deletions src/pocketmine/block/SeaLantern.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

use pocketmine\item\Item;

class SeaLantern extends Solid{
class SeaLantern extends Transparent{

protected $id = self::SEA_LANTERN;

Expand All @@ -49,4 +49,4 @@ public function getDrops(Item $item){
];
}

}
}
2 changes: 1 addition & 1 deletion src/pocketmine/command/CommandExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface CommandExecutor{
* @param string $label
* @param string[] $args
*
* @return boolean
* @return bool
*/
public function onCommand(CommandSender $sender, Command $command, $label, array $args);

Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/command/CommandMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function register($fallbackPrefix, Command $command, $label = null);
* @param CommandSender $sender
* @param string $cmdLine
*
* @return boolean
* @return bool
*/
public function dispatch(CommandSender $sender, $cmdLine);

Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/event/block/BlockBreakEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function setDrops(array $drops){
}

/**
* @param boolean $instaBreak
* @param bool $instaBreak
*/
public function setInstaBreak($instaBreak){
$this->instaBreak = (bool) $instaBreak;
Expand Down
6 changes: 3 additions & 3 deletions src/pocketmine/lang/BaseLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

use pocketmine\event\TextContainer;
use pocketmine\event\TranslationContainer;
use pocketmine\Server;
use pocketmine\utils\MainLogger;

class BaseLang{

Expand All @@ -43,10 +43,10 @@ public function __construct($lang, $path = null, $fallback = self::FALLBACK_LANG
}

if(!$this->loadLang($file = $path . $this->langName . ".ini", $this->lang)){
Server::getInstance()->getLogger()->error("Missing required language file $file");
MainLogger::getLogger()->error("Missing required language file $file");
}
if(!$this->loadLang($file = $path . $fallback . ".ini", $this->fallbackLang)){
Server::getInstance()->getLogger()->error("Missing required language file $file");
MainLogger::getLogger()->error("Missing required language file $file");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/pocketmine/level/Level.php
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ public function isFullBlock(Vector3 $pos) : bool{
/**
* @param Entity $entity
* @param AxisAlignedBB $bb
* @param boolean $entities
* @param bool $entities
*
* @return AxisAlignedBB[]
*/
Expand Down Expand Up @@ -1248,7 +1248,7 @@ public function getFullBlock(int $x, int $y, int $z) : int{
* Gets the Block object on the Vector3 location
*
* @param Vector3 $pos
* @param boolean $cached
* @param bool $cached
*
* @return Block
*/
Expand Down
3 changes: 2 additions & 1 deletion src/pocketmine/level/format/Chunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,8 @@ public function initChunk(){
continue; //Fixes entities allocated in wrong chunks.
}

if(($entity = Entity::createEntity($nbt["id"], $this, $nbt)) instanceof Entity){
//TODO: check bitflags
if(($entity = Entity::createEntity($nbt["id"] & 0xff, $this, $nbt)) instanceof Entity){
$entity->spawnToAll();
}else{
$changed = true;
Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/metadata/Metadatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getMetadata($metadataKey);
*
* @param string $metadataKey
*
* @return boolean
* @return bool
*/
public function hasMetadata($metadataKey);

Expand Down
2 changes: 2 additions & 0 deletions src/pocketmine/network/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
use pocketmine\network\protocol\StartGamePacket;
use pocketmine\network\protocol\TakeItemEntityPacket;
use pocketmine\network\protocol\TextPacket;
use pocketmine\network\protocol\TransferPacket;
use pocketmine\network\protocol\UpdateBlockPacket;
use pocketmine\network\protocol\UseItemPacket;
use pocketmine\Player;
Expand Down Expand Up @@ -365,6 +366,7 @@ private function registerPackets(){
$this->registerPacket(ProtocolInfo::START_GAME_PACKET, StartGamePacket::class);
$this->registerPacket(ProtocolInfo::TAKE_ITEM_ENTITY_PACKET, TakeItemEntityPacket::class);
$this->registerPacket(ProtocolInfo::TEXT_PACKET, TextPacket::class);
$this->registerPacket(ProtocolInfo::TRANSFER_PACKET, TransferPacket::class);
$this->registerPacket(ProtocolInfo::UPDATE_BLOCK_PACKET, UpdateBlockPacket::class);
$this->registerPacket(ProtocolInfo::USE_ITEM_PACKET, UseItemPacket::class);
}
Expand Down
7 changes: 4 additions & 3 deletions src/pocketmine/network/RakLibInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use pocketmine\Player;
use pocketmine\Server;
use raklib\protocol\EncapsulatedPacket;
use raklib\protocol\PacketReliability;
use raklib\RakLib;
use raklib\server\RakLibServer;
use raklib\server\ServerHandler;
Expand Down Expand Up @@ -77,7 +78,7 @@ public function process(){
}
}

if($this->rakLib->isTerminated()){
if(!$this->rakLib->isRunning() and !$this->rakLib->isShutdown()){
$this->network->unregisterInterface($this);

throw new \Exception("RakLib Thread crashed");
Expand Down Expand Up @@ -200,7 +201,7 @@ public function putPacket(Player $player, DataPacket $packet, $needACK = false,
$packet->__encapsulatedPacket = new CachedEncapsulatedPacket;
$packet->__encapsulatedPacket->identifierACK = null;
$packet->__encapsulatedPacket->buffer = chr(0xfe) . $packet->buffer; // #blameshoghi
$packet->__encapsulatedPacket->reliability = 3;
$packet->__encapsulatedPacket->reliability = PacketReliability::RELIABLE_ORDERED;
$packet->__encapsulatedPacket->orderChannel = 0;
}
$pk = $packet->__encapsulatedPacket;
Expand All @@ -216,7 +217,7 @@ public function putPacket(Player $player, DataPacket $packet, $needACK = false,
if($pk === null){
$pk = new EncapsulatedPacket();
$pk->buffer = chr(0xfe) . $packet->buffer; // #blameshoghi
$packet->reliability = 3;
$packet->reliability = PacketReliability::RELIABLE_ORDERED;
$packet->orderChannel = 0;

if($needACK === true){
Expand Down
7 changes: 4 additions & 3 deletions src/pocketmine/network/protocol/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ interface Info{
/**
* Actual Minecraft: PE protocol version
*/
const CURRENT_PROTOCOL = 100;
const MINECRAFT_VERSION = "v1.0.0.16";
const MINECRAFT_VERSION_NETWORK = "1.0.0.16";
const CURRENT_PROTOCOL = 101;
const MINECRAFT_VERSION = "v1.0.3.0";
const MINECRAFT_VERSION_NETWORK = "1.0.3.0";

const LOGIN_PACKET = 0x01;
const PLAY_STATUS_PACKET = 0x02;
Expand Down Expand Up @@ -115,5 +115,6 @@ interface Info{
const RESOURCE_PACK_DATA_INFO_PACKET = 0x4f;
const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x50;
const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x51;
const TRANSFER_PACKET = 0x52;

}
23 changes: 11 additions & 12 deletions src/pocketmine/network/protocol/LoginPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ class LoginPacket extends DataPacket{
public $skinId;
public $skin = null;

public $clientData = [];

public function decode(){
$this->protocol = $this->getInt();

if($this->protocol !== Info::CURRENT_PROTOCOL){
$this->buffer = null;
return; //Do not attempt to decode for non-accepted protocols
}

Expand All @@ -69,18 +72,14 @@ public function decode(){
}
}

$skinToken = $this->decodeToken($this->get($this->getLInt()));
if(isset($skinToken["ClientRandomId"])){
$this->clientId = $skinToken["ClientRandomId"];
}
if(isset($skinToken["ServerAddress"])){
$this->serverAddress = $skinToken["ServerAddress"];
}
if(isset($skinToken["SkinData"])){
$this->skin = base64_decode($skinToken["SkinData"]);
}
if(isset($skinToken["SkinId"])){
$this->skinId = $skinToken["SkinId"];
$this->clientData = $this->decodeToken($this->get($this->getLInt()));

$this->clientId = $this->clientData["ClientRandomId"] ?? null;
$this->serverAddress = $this->clientData["ServerAddress"] ?? null;
$this->skinId = $this->clientData["SkinId"] ?? null;

if(isset($this->clientData["SkinData"])){
$this->skin = base64_decode($this->clientData["SkinData"]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/pocketmine/network/protocol/PlayerFallPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
class PlayerFallPacket extends DataPacket{
const NETWORK_ID = Info::PLAYER_FALL_PACKET;

public $unknown; //betting this is fall distance, but let's make sure first
public $fallDistance;

public function decode(){
$this->unknown = $this->getLFloat();
$this->fallDistance = $this->getLFloat();
}

public function encode(){
Expand Down
Loading

0 comments on commit cba0af2

Please sign in to comment.