From a141ea5018cfc1babe92ad1e8469e8d2f02af44f Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Thu, 19 Dec 2013 18:42:45 +1030 Subject: [PATCH 1/7] Config Object PHPDoc --- src/utils/Config.php | 168 +++++++++++++++++++++++++++++++++---------- 1 file changed, 129 insertions(+), 39 deletions(-) diff --git a/src/utils/Config.php b/src/utils/Config.php index 1099d5fc..4dce8792 100644 --- a/src/utils/Config.php +++ b/src/utils/Config.php @@ -28,11 +28,29 @@ define("CONFIG_YAML", 2); // .yml, .yaml define("CONFIG_SERIALIZED", 4); // .sl define("CONFIG_LIST", 5); // .txt, .list +/** + * Class Config + * + * Config Class for simple config manipulation of multiple formats. + */ class Config{ - private $config; - private $file; - private $correct; - private $type = CONFIG_DETECT; + /** + * @var array + */ + private $config; + /** + * @var string + */ + private $file; + /** + * @var boolean + */ + private $correct; + /** + * @var integer + */ + private $type = CONFIG_DETECT; + public static $formats = array( "properties" => CONFIG_PROPERTIES, "cnf" => CONFIG_CNF, @@ -49,7 +67,14 @@ class Config{ "txt" => CONFIG_LIST, "list" => CONFIG_LIST, ); - public function __construct($file, $type = CONFIG_DETECT, $default = array(), &$correct = null){ + + /** + * @param string $file + * @param int $type + * @param array $default + * @param null|boolean $correct + */ + public function __construct($file, $type = CONFIG_DETECT, $default = array(), &$correct = null){ $this->load($file, $type, $default); $correct = $this->check(); } @@ -61,8 +86,15 @@ class Config{ $this->load($this->file); $correct = $this->check(); } - - public function load($file, $type = CONFIG_DETECT, $default = array()){ + + /** + * @param string $file + * @param int $type + * @param array $default + * + * @return boolean + */ + public function load($file, $type = CONFIG_DETECT, $default = array()){ $this->correct = true; $this->type = (int) $type; $this->file = $file; @@ -118,12 +150,18 @@ class Config{ } return true; } - - public function check(){ + + /** + * @return boolean + */ + public function check(){ return $this->correct === true; } - - public function save(){ + + /** + * @return boolean + */ + public function save(){ if($this->correct === true){ switch($this->type){ case CONFIG_PROPERTIES: @@ -149,41 +187,70 @@ class Config{ return false; } } - - public function &__get($k){ + + /** + * @param $k + * + * @return boolean|mixed + */ + public function &__get($k){ return $this->get($k); } - - public function __set($k, $v){ - return $this->set($k, $v); + + /** + * @param $k + * @param $v + */ + public function __set($k, $v){ + $this->set($k, $v); } - - public function __isset($k){ + + /** + * @param $k + * + * @return boolean + */ + public function __isset($k){ return $this->exists($k); } - - public function __unset($k){ - return $this->remove($k); + + /** + * @param $k + */ + public function __unset($k){ + $this->remove($k); } - - public function &get($k){ + + /** + * @param $k + * + * @return boolean|mixed + */ + public function &get($k){ if(isset($this->correct) and ($this->correct === false or !isset($this->config[$k]))){ $false = false; return $false; } return $this->config[$k]; } - - public function set($k, $v = true){ + + /** + * @param $k + * @param bool $v + */ + public function set($k, $v = true){ $this->config[$k] = $v; } - - public function setAll($v){ + + /** + * @param array $v + */ + public function setAll($v){ $this->config = $v; } /** - * @param mixed $k + * @param $k * @param bool $lowercase If set, searches Config in single-case / lowercase. * * @return boolean @@ -197,16 +264,30 @@ class Config{ return isset($this->config[$k]); endif; } - - public function remove($k){ + + /** + * @param $k + */ + public function remove($k){ unset($this->config[$k]); } - - public function getAll($keys = false){ + + /** + * @param bool $keys + * + * @return array + */ + public function getAll($keys = false){ return ($keys === true ? array_keys($this->config):$this->config); } - - private function fillDefaults($default, &$data){ + + /** + * @param $default + * @param $data + * + * @return integer + */ + private function fillDefaults($default, &$data){ $changed = 0; foreach($default as $k => $v){ if(is_array($v)){ @@ -222,7 +303,10 @@ class Config{ return $changed; } - private function parseList($content){ + /** + * @param $content + */ + private function parseList($content){ foreach(explode("\n", trim(str_replace("\r\n", "\n", $content))) as $v){ $v = trim($v); if($v == ""){ @@ -231,8 +315,11 @@ class Config{ $this->config[$v] = true; } } - - private function writeProperties(){ + + /** + * @return string + */ + private function writeProperties(){ $content = "#Properties Config file\r\n#".date("D M j H:i:s T Y")."\r\n"; foreach($this->config as $k => $v){ if(is_bool($v) === true){ @@ -244,8 +331,11 @@ class Config{ } return $content; } - - private function parseProperties($content){ + + /** + * @param $content + */ + private function parseProperties($content){ if(preg_match_all('/([a-zA-Z0-9\-_\.]*)=([^\r\n]*)/u', $content, $matches) > 0){ //false or 0 matches foreach($matches[1] as $i => $k){ $v = trim($matches[2][$i]); From e3d3f91c54fc9c612bfa4b93c6b04a3e9fdd95ee Mon Sep 17 00:00:00 2001 From: InusualZ Date: Mon, 23 Dec 2013 20:15:53 -0500 Subject: [PATCH 2/7] Level::getAll() --- src/API/LevelAPI.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/API/LevelAPI.php b/src/API/LevelAPI.php index a597c989..e2d14338 100644 --- a/src/API/LevelAPI.php +++ b/src/API/LevelAPI.php @@ -237,4 +237,9 @@ class LevelAPI{ } } -} \ No newline at end of file + public function getAll() + { + return $this->levels; + } + +} From 1cc12616e86174f23fb5a288260869ac43e6b975 Mon Sep 17 00:00:00 2001 From: Jonathan Wallace Date: Wed, 25 Dec 2013 21:46:04 -0500 Subject: [PATCH 3/7] Update compile.sh Properly escape nested double quotes. --- src/build/compile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build/compile.sh b/src/build/compile.sh index d301d25a..63646457 100755 --- a/src/build/compile.sh +++ b/src/build/compile.sh @@ -280,5 +280,5 @@ mv php5/bin/php bin/php rm -r -f php5/ >> "$DIR/install.log" 2>&1 date >> "$DIR/install.log" 2>&1 echo " done!" -echo "[PocketMine] You should start the server now using \"./start.sh\."" +echo "[PocketMine] You should start the server now using \"./start.sh.\"" echo "[PocketMine] If it doesn't work, please send the \"install.log\" file to the Bug Tracker." From 969f0f05b02a11453c2ae7dbfc1aadcd8d65f26c Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Sat, 4 Jan 2014 11:59:07 +0900 Subject: [PATCH 4/7] Fix #1037 --- src/API/PlayerAPI.php | 2 +- src/Player.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index 525798e9..ed2e45d6 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -402,7 +402,7 @@ class PlayerAPI{ public function spawnToAllPlayers(Player $player){ foreach($this->getAll() as $p){ - if($p !== $player and ($p->entity instanceof Entity)){ + if($p !== $player and ($p->entity instanceof Entity) and ($player->entity instanceof Entity)){ $player->entity->spawn($p); if($p->level !== $player->level){ $p->dataPacket(MC_MOVE_ENTITY_POSROT, array( diff --git a/src/Player.php b/src/Player.php index 70efef7b..53976b7e 100644 --- a/src/Player.php +++ b/src/Player.php @@ -44,6 +44,7 @@ class Player{ private $startAction = false; private $isSleeping = false; public $data; + /** @var \Entity */ public $entity = false; public $auth = false; public $CID; @@ -78,6 +79,8 @@ class Player{ private $chunkCount = array(); private $received = array(); public $realmsData = array(); + /** @var \Level */ + public $level; public function __get($name){ if(isset($this->{$name})){ From 860f72351831eca9accf5b83a840ccbfa9be4657 Mon Sep 17 00:00:00 2001 From: wrewolf Date: Fri, 10 Jan 2014 09:43:31 +0300 Subject: [PATCH 5/7] Update Water.php Fix Remove for Left Waters --- src/material/block/liquid/Water.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/material/block/liquid/Water.php b/src/material/block/liquid/Water.php index 1959fe78..0efdc40d 100644 --- a/src/material/block/liquid/Water.php +++ b/src/material/block/liquid/Water.php @@ -119,6 +119,10 @@ class WaterBlock extends LiquidBlock{ if($sb instanceof WaterBlock){ $tlevel = $sb->meta & 0x07; if($tlevel != 0x00){ + for ($s = 0; $s <= 5; $s++) { + $ssb = $sb->getSide($s); + ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL); + } $this->level->setBlock($sb, new AirBlock(), false, false, true); } } @@ -126,6 +130,10 @@ class WaterBlock extends LiquidBlock{ if($b instanceof WaterBlock){ $tlevel = $b->meta & 0x07; if($tlevel != 0x00){ + for ($s = 0; $s <= 5; $s++) { + $ssb = $sb->getSide($s); + ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL); + } $this->level->setBlock($b, new AirBlock(), false, false, true); } } From 65a7560185763faf6dac1201300b35d222237aaa Mon Sep 17 00:00:00 2001 From: wrewolf Date: Fri, 10 Jan 2014 09:45:21 +0300 Subject: [PATCH 6/7] Update Lava.php Fix Remove for Left Lavas --- src/material/block/liquid/Lava.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/material/block/liquid/Lava.php b/src/material/block/liquid/Lava.php index 5eb39efa..a048ab4f 100644 --- a/src/material/block/liquid/Lava.php +++ b/src/material/block/liquid/Lava.php @@ -113,6 +113,10 @@ class LavaBlock extends LiquidBlock{ if($sb instanceof LavaBlock){ $tlevel = $sb->meta & 0x07; if($tlevel != 0x00){ + for ($s = 0; $s <= 5; $s++) { + $ssb = $sb->getSide($s); + rAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); + } $this->level->setBlock($sb, new AirBlock(), false, false, true); } } @@ -120,6 +124,10 @@ class LavaBlock extends LiquidBlock{ if($b instanceof LavaBlock){ $tlevel = $b->meta & 0x07; if($tlevel != 0x00){ + for ($s = 0; $s <= 5; $s++) { + $ssb = $sb->getSide($s); + ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); + } $this->level->setBlock($b, new AirBlock(), false, false, true); } } From 1f360c8bfbe81f74197d88fe104594160f9d6c43 Mon Sep 17 00:00:00 2001 From: wrewolf Date: Sun, 12 Jan 2014 12:05:17 +0300 Subject: [PATCH 7/7] Update Lava.php --- src/material/block/liquid/Lava.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/material/block/liquid/Lava.php b/src/material/block/liquid/Lava.php index a048ab4f..1f7fd557 100644 --- a/src/material/block/liquid/Lava.php +++ b/src/material/block/liquid/Lava.php @@ -115,7 +115,7 @@ class LavaBlock extends LiquidBlock{ if($tlevel != 0x00){ for ($s = 0; $s <= 5; $s++) { $ssb = $sb->getSide($s); - rAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); + ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($ssb, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); } $this->level->setBlock($sb, new AirBlock(), false, false, true); }