diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index f58cbc95c..a82e9d9e1 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -65,6 +65,7 @@ namespace { } namespace pocketmine { + use pocketmine\network\protocol\Info as ProtocolInfo; use pocketmine\utils\Binary; use pocketmine\utils\MainLogger; use pocketmine\utils\ServerKiller; @@ -76,8 +77,6 @@ namespace pocketmine { const VERSION = "1.6.2dev"; const API_VERSION = "2.2.0"; const CODENAME = "Unleashed"; - const MINECRAFT_VERSION = "v1.0.0.2"; - const MINECRAFT_VERSION_NETWORK = "1.0.0.2"; /* * Startup code. Do not look at it, it may harm you. @@ -146,6 +145,16 @@ namespace pocketmine { 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()); diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index acdd8e538..44ad23dee 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -87,6 +87,7 @@ use pocketmine\network\Network; use pocketmine\network\protocol\BatchPacket; use pocketmine\network\protocol\CraftingDataPacket; use pocketmine\network\protocol\DataPacket; +use pocketmine\network\protocol\Info as ProtocolInfo; use pocketmine\network\protocol\PlayerListPacket; use pocketmine\network\query\QueryHandler; use pocketmine\network\RakLibInterface; @@ -301,7 +302,7 @@ class Server{ * @return string */ public function getVersion(){ - return \pocketmine\MINECRAFT_VERSION; + return ProtocolInfo::MINECRAFT_VERSION; } /** diff --git a/src/pocketmine/block/DoublePlant.php b/src/pocketmine/block/DoublePlant.php index 5e2ebc81f..a60cc2201 100644 --- a/src/pocketmine/block/DoublePlant.php +++ b/src/pocketmine/block/DoublePlant.php @@ -52,7 +52,7 @@ class DoublePlant extends Flowable{ public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent() === true){ //Replace with common break method - $this->getLevel()->setBlock($this, new Air(), false, false, true); + $this->getLevel()->setBlock($this, new Air(), true, true); return Level::BLOCK_UPDATE_NORMAL; } diff --git a/src/pocketmine/block/Fallable.php b/src/pocketmine/block/Fallable.php index bee31369e..87ecc4619 100644 --- a/src/pocketmine/block/Fallable.php +++ b/src/pocketmine/block/Fallable.php @@ -22,7 +22,6 @@ namespace pocketmine\block; use pocketmine\entity\Entity; -use pocketmine\item\Item; use pocketmine\level\Level; use pocketmine\math\Vector3; use pocketmine\nbt\tag\ByteTag; @@ -31,16 +30,9 @@ use pocketmine\nbt\tag\DoubleTag; use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\ListTag; -use pocketmine\Player; abstract class Fallable extends Solid{ - public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ - $ret = $this->getLevel()->setBlock($this, $this, true, true); - - return $ret; - } - public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ $down = $this->getSide(Vector3::SIDE_DOWN); diff --git a/src/pocketmine/block/Ladder.php b/src/pocketmine/block/Ladder.php index 508c37868..f7e508eec 100644 --- a/src/pocketmine/block/Ladder.php +++ b/src/pocketmine/block/Ladder.php @@ -124,11 +124,16 @@ class Ladder extends Transparent{ public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ - /*if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method - Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1)); - $this->getLevel()->setBlock($this, new Air(), true, true, true); + $sides = [ + 2 => 3, + 3 => 2, + 4 => 5, + 5 => 4 + ]; + if(!$this->getSide($sides[$this->meta])->isSolid()){ //Replace with common break method + $this->level->useBreakOn($this); return Level::BLOCK_UPDATE_NORMAL; - }*/ + } } return false; diff --git a/src/pocketmine/block/Leaves.php b/src/pocketmine/block/Leaves.php index 855f41641..67e9d9e62 100644 --- a/src/pocketmine/block/Leaves.php +++ b/src/pocketmine/block/Leaves.php @@ -129,7 +129,7 @@ class Leaves extends Transparent{ if($type === Level::BLOCK_UPDATE_NORMAL){ if(($this->meta & 0b00001100) === 0){ $this->meta |= 0x08; - $this->getLevel()->setBlock($this, $this, false, false, true); + $this->getLevel()->setBlock($this, $this, true, false); } }elseif($type === Level::BLOCK_UPDATE_RANDOM){ if(($this->meta & 0b00001100) === 0x08){ diff --git a/src/pocketmine/block/Leaves2.php b/src/pocketmine/block/Leaves2.php index 7869c4935..964219ac0 100644 --- a/src/pocketmine/block/Leaves2.php +++ b/src/pocketmine/block/Leaves2.php @@ -112,7 +112,7 @@ class Leaves2 extends Leaves{ if($type === Level::BLOCK_UPDATE_NORMAL){ if(($this->meta & 0b00001100) === 0){ $this->meta |= 0x08; - $this->getLevel()->setBlock($this, $this, false, false, true); + $this->getLevel()->setBlock($this, $this, true, false); } }elseif($type === Level::BLOCK_UPDATE_RANDOM){ if(($this->meta & 0b00001100) === 0x08){ diff --git a/src/pocketmine/block/TallGrass.php b/src/pocketmine/block/TallGrass.php index 9214a3442..ce485770d 100644 --- a/src/pocketmine/block/TallGrass.php +++ b/src/pocketmine/block/TallGrass.php @@ -62,7 +62,7 @@ class TallGrass extends Flowable{ public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ if($this->getSide(0)->isTransparent() === true){ //Replace with common break method - $this->getLevel()->setBlock($this, new Air(), false, false, true); + $this->getLevel()->setBlock($this, new Air(), true, true); return Level::BLOCK_UPDATE_NORMAL; } diff --git a/src/pocketmine/block/Vine.php b/src/pocketmine/block/Vine.php index 14def3f33..60a88c198 100644 --- a/src/pocketmine/block/Vine.php +++ b/src/pocketmine/block/Vine.php @@ -146,7 +146,7 @@ class Vine extends Transparent{ if($type === Level::BLOCK_UPDATE_NORMAL){ /*if($this->getSide(0)->getId() === self::AIR){ //Replace with common break method Server::getInstance()->api->entity->drop($this, Item::get(LADDER, 0, 1)); - $this->getLevel()->setBlock($this, new Air(), true, true, true); + $this->getLevel()->setBlock($this, new Air(), true, true); return Level::BLOCK_UPDATE_NORMAL; }*/ } diff --git a/src/pocketmine/command/CommandReader.php b/src/pocketmine/command/CommandReader.php index dbfde72ea..1be89627c 100644 --- a/src/pocketmine/command/CommandReader.php +++ b/src/pocketmine/command/CommandReader.php @@ -28,6 +28,7 @@ class CommandReader extends Thread{ /** @var \Threaded */ protected $buffer; private $shutdown = false; + private $streamBlocking = false; public function __construct(){ $this->buffer = new \Threaded; @@ -40,15 +41,28 @@ class CommandReader extends Thread{ $this->shutdown = true; } + private function initStdin(){ + global $stdin; + $stdin = fopen("php://stdin", "r"); + $this->streamBlocking = (stream_set_blocking($stdin, 0) === false); + } + private function readLine(){ if(!$this->readline){ global $stdin; if(!is_resource($stdin)){ - return ""; + $this->initStdin(); } - return trim(fgets($stdin)); + $line = fgets($stdin); + + if($line === false and $this->streamBlocking === true){ //windows sucks + $this->initStdin(); + $line = fgets($stdin); + } + + return trim($line); }else{ $line = trim(readline("> ")); if($line != ""){ @@ -74,9 +88,7 @@ class CommandReader extends Thread{ public function run(){ if(!$this->readline){ - global $stdin; - $stdin = fopen("php://stdin", "r"); - stream_set_blocking($stdin, 0); + $this->initStdin(); } $lastLine = microtime(true); @@ -91,6 +103,11 @@ class CommandReader extends Thread{ $lastLine = microtime(true); } + + if(!$this->readline){ + global $stdin; + fclose($stdin); + } } public function getThreadName(){ diff --git a/src/pocketmine/network/RakLibInterface.php b/src/pocketmine/network/RakLibInterface.php index 24ab4ec78..46ec7ef80 100644 --- a/src/pocketmine/network/RakLibInterface.php +++ b/src/pocketmine/network/RakLibInterface.php @@ -172,7 +172,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $this->interface->sendOption("name", "MCPE;" . addcslashes($name, ";") . ";" . Info::CURRENT_PROTOCOL . ";" . - \pocketmine\MINECRAFT_VERSION_NETWORK . ";" . + Info::MINECRAFT_VERSION_NETWORK . ";" . $info->getPlayerCount() . ";" . $info->getMaxPlayerCount() ); diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index 64cf217b7..75c6fdda9 100644 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -31,6 +31,8 @@ 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 LOGIN_PACKET = 0x01; const PLAY_STATUS_PACKET = 0x02; diff --git a/src/pocketmine/plugin/ScriptPluginLoader.php b/src/pocketmine/plugin/ScriptPluginLoader.php index 196b6c987..aa0af87dc 100644 --- a/src/pocketmine/plugin/ScriptPluginLoader.php +++ b/src/pocketmine/plugin/ScriptPluginLoader.php @@ -105,7 +105,7 @@ class ScriptPluginLoader implements PluginLoader{ $data[$key] = $content; } - if($insideHeader and strpos($line, "**/") !== false){ + if($insideHeader and strpos($line, "*/") !== false){ break; } } diff --git a/tests/run.sh b/tests/run.sh index cada237fc..89c037330 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -1,8 +1,8 @@ #!/bin/bash -echo -e "version\nmakeserver\nstop\n" | php src/pocketmine/PocketMine.php --no-wizard --disable-ansi --disable-readline +echo -e "version\nmakeserver\nstop\n" | php src/pocketmine/PocketMine.php --no-wizard --disable-ansi --disable-readline --debug.level=2 if ls plugins/DevTools/PocketMine*.phar >/dev/null 2>&1; then echo Server phar created successfully. else echo No phar created! exit 1 -fi \ No newline at end of file +fi