Fix banlist crash when | is entered in any /ban arguments

This commit is contained in:
Dylan K. Taylor 2016-10-17 18:21:07 +01:00
parent f3e35bb94a
commit d53810c6bc

View File

@ -21,6 +21,8 @@
namespace pocketmine\permission;
use pocketmine\utils\MainLogger;
class BanEntry{
public static $format = "Y-m-d H:i:s O";
@ -109,7 +111,12 @@ class BanEntry{
$str = explode("|", trim($str));
$entry = new BanEntry(trim(array_shift($str)));
if(count($str) > 0){
$entry->setCreated(\DateTime::createFromFormat(self::$format, array_shift($str)));
$datetime = \DateTime::createFromFormat(self::$format, array_shift($str));
if(!($datetime instanceof \DateTime)){
MainLogger::getLogger()->alert("Error parsing date for BanEntry for player \"" . $entry->getName() . "\", the format may be invalid!");
return $entry;
}
$entry->setCreated($datetime);
if(count($str) > 0){
$entry->setSource(trim(array_shift($str)));
if(count($str) > 0){