From e2298d861cebd9aec6c445c3a0f937221c8806a7 Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Sat, 14 Dec 2013 15:27:38 +1030 Subject: [PATCH 1/8] Fix #996 --- src/utils/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/Config.php b/src/utils/Config.php index dc194003d..1550c497c 100644 --- a/src/utils/Config.php +++ b/src/utils/Config.php @@ -167,7 +167,7 @@ class Config{ } public function &get($k){ - if($this->correct === false or !isset($this->config[$k])){ + if(isset($this->correct) and ($this->correct === false or !isset($this->config[$k]))){ $false = false; return $false; } From 01e9ca78528e600dabdaa3cbe40adabe9fe9a2f0 Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Sat, 14 Dec 2013 16:06:28 +1030 Subject: [PATCH 2/8] Fix #971. Add lowercase checking of Config. --- src/API/BanAPI.php | 23 ++++++++++++++++++----- src/utils/Config.php | 18 +++++++++++++++--- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/API/BanAPI.php b/src/API/BanAPI.php index 82e89f68e..1ee8821ea 100644 --- a/src/API/BanAPI.php +++ b/src/API/BanAPI.php @@ -21,9 +21,16 @@ class BanAPI{ private $server; + /* + * I would use PHPDoc Template here but PHPStorm does not recognise it. - @sekjun9878 + */ + /** @var Config */ private $whitelist; + /** @var Config */ private $banned; + /** @var Config */ private $ops; + /** @var Config */ private $bannedIPs; private $cmdWL = array();//Command WhiteList function __construct(){ @@ -349,10 +356,13 @@ class BanAPI{ public function isIPBanned($ip){ if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){ return true; - }elseif($this->bannedIPs->exists($ip)){ + }elseif($this->bannedIPs->exists($ip, true)){ return true; } - return false; + else + { + return false; + } } /** @@ -364,10 +374,13 @@ class BanAPI{ $username = strtolower($username); if($this->server->api->dhandle("api.ban.check", $username) === false){ return true; - }elseif($this->banned->exists($username)){ + }elseif($this->banned->exists($username, true)){ return true; } - return false; + else + { + return false; + } } /** @@ -381,7 +394,7 @@ class BanAPI{ return true; }elseif($this->server->api->dhandle("api.ban.whitelist.check", $username) === false){ return true; - }elseif($this->whitelist->exists($username)){ + }elseif($this->whitelist->exists($username, true)){ return true; } return false; diff --git a/src/utils/Config.php b/src/utils/Config.php index 1550c497c..1099d5fc3 100644 --- a/src/utils/Config.php +++ b/src/utils/Config.php @@ -181,9 +181,21 @@ class Config{ public function setAll($v){ $this->config = $v; } - - public function exists($k){ - return isset($this->config[$k]); + + /** + * @param mixed $k + * @param bool $lowercase If set, searches Config in single-case / lowercase. + * + * @return boolean + */ + public function exists($k, $lowercase = false){ + if($lowercase === true)://Take this ridiculously retarded IF formatting! - @sekjun98888877777778888888888888 + $k = strtolower($k);//Convert requested key to lower + $array = array_change_key_case($this->config, CASE_LOWER);//Change all keys in array to lower + return isset($array[$k]);//Find $k in modified array + else: + return isset($this->config[$k]); + endif; } public function remove($k){ From 050d3424f08c1e826291712f83161fe60ec9a3fb Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Sat, 14 Dec 2013 16:14:41 +1030 Subject: [PATCH 3/8] Fix #999. --- src/constants/ItemIDs.php | 2 +- src/material/block/solid/LitPumpkin.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/constants/ItemIDs.php b/src/constants/ItemIDs.php index 431e7c8aa..1082de446 100644 --- a/src/constants/ItemIDs.php +++ b/src/constants/ItemIDs.php @@ -149,7 +149,7 @@ define("SPAWN_EGG", 383); define("CARROT", 391); define("CARROTS", 391); define("POTATO", 392); -define("POTATOES", 392); +define("POTATOES", 392);//@shoghicp Why the heck do we need plural redundant Item ID here???? define("BAKED_POTATO", 393); define("BAKED_POTATOES", 393); diff --git a/src/material/block/solid/LitPumpkin.php b/src/material/block/solid/LitPumpkin.php index cebe24968..91c0dd07c 100644 --- a/src/material/block/solid/LitPumpkin.php +++ b/src/material/block/solid/LitPumpkin.php @@ -24,5 +24,16 @@ class LitPumpkinBlock extends SolidBlock{ parent::__construct(LIT_PUMPKIN, "Jack o'Lantern"); $this->hardness = 5; } - + + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $faces = array( + 0 => 4, + 1 => 2, + 2 => 5, + 3 => 3, + ); + $this->meta = $faces[$player->entity->getDirection()]; + $this->level->setBlock($block, $this, true, false, true); + return true; + } } \ No newline at end of file From 6d4472a339af5159cdf8ffff7337852220525f06 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 13 Dec 2013 15:52:08 +0100 Subject: [PATCH 4/8] Added Source SHA1 sum --- src/PocketMinecraftServer.php | 5 +++-- src/dependencies.php | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index b04ceeb31..06df08961 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -442,8 +442,9 @@ class PocketMinecraftServer{ } $dump .= "\r\n\r\n"; $version = new VersionString(); - $dump .= "PM Version: ".$version." #".$version->getNumber()." [Protocol ".CURRENT_PROTOCOL."]\r\n"; - $dump .= "Commit: ".GIT_COMMIT."\r\n"; + $dump .= "PocketMine-MP version: ".$version." #".$version->getNumber()." [Protocol ".CURRENT_PROTOCOL."; API ".CURRENT_API_VERSION."]\r\n"; + $dump .= "Git commit: ".GIT_COMMIT."\r\n"; + $dump .= "Source SHA1 sum: ".SOURCE_SHA1SUM."\r\n"; $dump .= "uname -a: ".php_uname("a")."\r\n"; $dump .= "PHP Version: " .phpversion()."\r\n"; $dump .= "Zend version: ".zend_version()."\r\n"; diff --git a/src/dependencies.php b/src/dependencies.php index 81dcc63a1..921c9f9a9 100644 --- a/src/dependencies.php +++ b/src/dependencies.php @@ -24,7 +24,7 @@ require_once(dirname(__FILE__)."/config.php"); require_once(FILE_PATH."/src/utils/TextFormat.php"); require_once(FILE_PATH."/src/functions.php"); /***REM_END***/ -define(DATA_PATH, realpath(arg("data-path", FILE_PATH))."/"); +define("DATA_PATH", realpath(arg("data-path", FILE_PATH))."/"); if(arg("enable-ansi", strpos(strtoupper(php_uname("s")), "WIN") === 0 ? false:true) === true and arg("disable-ansi", false) !== true){ define("ENABLE_ANSI", true); @@ -76,10 +76,22 @@ if($errors > 0){ exit(1); //Exit with error } +$sha1sum = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; /***REM_START***/ require_once(FILE_PATH."/src/math/Vector3.php"); require_once(FILE_PATH."/src/world/Position.php"); require_once(FILE_PATH."/src/pmf/PMF.php"); require_all(FILE_PATH . "src/"); -/***REM_END***/ \ No newline at end of file + +$inc = get_included_files(); +$inc[] = array_shift($inc); +$srcdir = realpath(FILE_PATH."src/"); +foreach($inc as $s){ + if(strpos(realpath(dirname($s)), $srcdir) === false and strtolower(basename($s)) !== "pocketmine-mp.php"){ + continue; + } + $sha1sum ^= sha1_file($s, true); +} +/***REM_END***/ +define("SOURCE_SHA1SUM", bin2hex($sha1sum)); \ No newline at end of file From 7bc95004844b9c083b7dbe2d9af887515ce894ed Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 13 Dec 2013 15:52:17 +0100 Subject: [PATCH 5/8] Increased error level --- src/config.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.php b/src/config.php index 21b38f068..5fbe130fd 100644 --- a/src/config.php +++ b/src/config.php @@ -44,7 +44,7 @@ if($daylight === 0){ date_default_timezone_set(timezone_name_from_abbr("", $offset, $daylight)); gc_enable(); -error_reporting(E_ALL ^ E_NOTICE); +error_reporting(E_ALL | E_STRICT); ini_set("allow_url_fopen", 1); ini_set("display_errors", 1); ini_set("display_startup_errors", 1); @@ -65,7 +65,7 @@ define("CURRENT_API_VERSION", 11); define("CURRENT_PHP_VERSION", "5.5"); $gitsha1 = false; if(file_exists(FILE_PATH.".git/refs/heads/master")){ //Found Git information! - define(GIT_COMMIT, strtolower(trim(file_get_contents(FILE_PATH.".git/refs/heads/master")))); + define("GIT_COMMIT", strtolower(trim(file_get_contents(FILE_PATH.".git/refs/heads/master")))); }else{ //Unknown :( - define(GIT_COMMIT, str_repeat("00", 20)); -} + define("GIT_COMMIT", str_repeat("00", 20)); +} \ No newline at end of file From b457e63d20d64d552911b58c6ae4fa40a006f5c9 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 16 Dec 2013 17:12:25 +0100 Subject: [PATCH 6/8] Reverted Item despawn timer --- src/world/Entity.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/world/Entity.php b/src/world/Entity.php index cade713d1..218ed8e69 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -239,7 +239,7 @@ class Entity extends Position{ $time = microtime(true); if($this->class === ENTITY_PLAYER and ($this->player instanceof Player) and $this->player->spawned === true and $this->player->blocked !== true){ foreach($this->server->api->entity->getRadius($this, 1.5, ENTITY_ITEM) as $item){ - if($item->spawntime !== -1 and ($time - $item->spawntime) >= 0.6){ + if($item->spawntime > 0 and ($time - $item->spawntime) >= 0.6){ if((($this->player->gamemode & 0x01) === 1 or $this->player->hasSpace($item->type, $item->meta, $item->stack) === true) and $this->server->api->dhandle("player.pickup", array( "eid" => $this->player->eid, "player" => $this->player, @@ -248,8 +248,9 @@ class Entity extends Position{ "meta" => $item->meta, "target" => $item->eid )) !== false){ - $item->spawntime = -1; - $this->server->schedule(15, array($item, "close")); + $item->close(); + //$item->spawntime = 0; + //$this->server->schedule(15, array($item, "close")); } } } From 351ac0d7af246d2cb4cf99dd538e8c54cdecbd54 Mon Sep 17 00:00:00 2001 From: InusualZ Date: Mon, 16 Dec 2013 19:42:35 -0500 Subject: [PATCH 7/8] Fixed Event "entity.explosion" The event don't listen to the handler --- src/world/Explosion.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/Explosion.php b/src/world/Explosion.php index 5ed0bf533..d94361d0b 100644 --- a/src/world/Explosion.php +++ b/src/world/Explosion.php @@ -46,7 +46,7 @@ class Explosion{ "level" => $this->level, "source" => $this->source, "size" => $this->size - ))){ + )) === false){ return false; } From d4057a211360590e5f07306904fc30fb8b3eaca7 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 17 Dec 2013 10:32:03 +0100 Subject: [PATCH 8/8] Fixed #997 carrots converting to potatoes [gh#997] --- src/constants/BlockIDs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index d2f572d6d..06f96cebc 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -169,7 +169,7 @@ define("STONE_WALL", 139); define("COBBLESTONE_WALL", 139); define("CARROT_BLOCK", 141); -define("POTATO_BLOCK", 141); +define("POTATO_BLOCK", 142); define("QUARTZ_BLOCK", 155); define("QUARTZ_STAIRS", 156);