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

Commit

Permalink
Update from master
Browse files Browse the repository at this point in the history
  • Loading branch information
inxomnyaa committed Feb 11, 2017
2 parents 2df8a3c + cba0af2 commit 93fe40c
Show file tree
Hide file tree
Showing 23 changed files with 85 additions and 65 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 @@ -545,7 +545,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 @@ -3774,19 +3774,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
5 changes: 2 additions & 3 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
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
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
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
5 changes: 3 additions & 2 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 @@ -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
22 changes: 10 additions & 12 deletions src/pocketmine/network/protocol/LoginPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class LoginPacket extends DataPacket{
public $skinId;
public $skin = null;

public $clientData = [];

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

Expand Down Expand Up @@ -70,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
14 changes: 9 additions & 5 deletions src/pocketmine/network/protocol/TransferPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@

namespace pocketmine\network\protocol;

class TransferPacket extends DataPacket {
#include <rules/DataPacket.h>

class TransferPacket extends DataPacket{
const NETWORK_ID = Info::TRANSFER_PACKET;

public $address;
public $port;
public $port = 19132;

public function decode(){

public function decode() { }
}

public function encode() {
public function encode(){
$this->reset();
$this->putString($this->address);
$this->putLShort($this->port);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,20 @@
*
*/

namespace pocketmine;
namespace pocketmine\network\protocol;

class CompatibleClassLoader extends \BaseClassLoader{
class TransferPacket extends DataPacket {
const NETWORK_ID = Info::TRANSFER_PACKET;

}
public $address;
public $port;

public function decode() { }

public function encode() {
$this->reset();
$this->putString($this->address);
$this->putLShort($this->port);
}

}
2 changes: 1 addition & 1 deletion src/pocketmine/permission/Permissible.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface Permissible extends ServerOperator{
*
* @param string|Permission $name
*
* @return boolean
* @return bool
*/
public function isPermissionSet($name);

Expand Down
12 changes: 6 additions & 6 deletions src/pocketmine/plugin/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function getPlugin($name){
/**
* @param string $loaderName A PluginLoader class name
*
* @return boolean
* @return bool
*/
public function registerInterface($loaderName){
if(is_subclass_of($loaderName, PluginLoader::class)){
Expand Down Expand Up @@ -381,7 +381,7 @@ public function removePermission($permission){
}

/**
* @param boolean $op
* @param bool $op
*
* @return Permission[]
*/
Expand Down Expand Up @@ -422,7 +422,7 @@ private function calculatePermissionDefault(Permission $permission){
}

/**
* @param boolean $op
* @param bool $op
*/
private function dirtyPermissibles($op){
foreach($this->getDefaultPermSubscriptions($op) as $p){
Expand Down Expand Up @@ -480,7 +480,7 @@ public function getPermissionSubscriptions($permission){
}

/**
* @param boolean $op
* @param bool $op
* @param Permissible $permissible
*/
public function subscribeToDefaultPerms($op, Permissible $permissible){
Expand All @@ -492,7 +492,7 @@ public function subscribeToDefaultPerms($op, Permissible $permissible){
}

/**
* @param boolean $op
* @param bool $op
* @param Permissible $permissible
*/
public function unsubscribeFromDefaultPerms($op, Permissible $permissible){
Expand All @@ -504,7 +504,7 @@ public function unsubscribeFromDefaultPerms($op, Permissible $permissible){
}

/**
* @param boolean $op
* @param bool $op
*
* @return Permissible[]
*/
Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/plugin/RegisteredListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class RegisteredListener{
* @param EventExecutor $executor
* @param int $priority
* @param Plugin $plugin
* @param boolean $ignoreCancelled
* @param bool $ignoreCancelled
* @param TimingsHandler $timings
*/
public function __construct(Listener $listener, EventExecutor $executor, $priority, Plugin $plugin, $ignoreCancelled, TimingsHandler $timings){
Expand Down
Loading

0 comments on commit 93fe40c

Please sign in to comment.