mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 17:59:41 +00:00
MainLogger can now have debug level disabled
This commit is contained in:
parent
7bd6f2ed91
commit
8d40f843cf
@ -82,7 +82,6 @@ use pocketmine\tile\Sign;
|
|||||||
use pocketmine\tile\Spawnable;
|
use pocketmine\tile\Spawnable;
|
||||||
use pocketmine\tile\Tile;
|
use pocketmine\tile\Tile;
|
||||||
use pocketmine\utils\Binary;
|
use pocketmine\utils\Binary;
|
||||||
use pocketmine\utils\MainLogger;
|
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2128,7 +2127,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->currentTransaction = null;
|
$this->currentTransaction = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2136,7 +2134,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::SEND_INVENTORY_PACKET: //TODO, Mojang, enable this ´^_^`
|
case ProtocolInfo::SEND_INVENTORY_PACKET: //TODO, Mojang, enable this ´^_^`
|
||||||
if($this->spawned === false){
|
if($this->spawned === false){
|
||||||
@ -2374,6 +2371,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
|||||||
return $cnt;
|
return $cnt;
|
||||||
}else{
|
}else{
|
||||||
$this->removeWindow($inventory);
|
$this->removeWindow($inventory);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,6 @@ namespace pocketmine {
|
|||||||
use pocketmine\utils\Binary;
|
use pocketmine\utils\Binary;
|
||||||
use pocketmine\utils\LogLevel;
|
use pocketmine\utils\LogLevel;
|
||||||
use pocketmine\utils\MainLogger;
|
use pocketmine\utils\MainLogger;
|
||||||
use pocketmine\utils\TextFormat;
|
|
||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use pocketmine\wizard\Installer;
|
use pocketmine\wizard\Installer;
|
||||||
|
|
||||||
@ -210,25 +209,6 @@ namespace pocketmine {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function log($message, $name, $EOL = true, $level = 2, $close = false){
|
|
||||||
global $fpointers;
|
|
||||||
if((!defined("pocketmine\\DEBUG") or \pocketmine\DEBUG >= $level) and (!defined("pocketmine\\LOG") or \pocketmine\LOG === true)){
|
|
||||||
$message .= $EOL === true ? PHP_EOL : "";
|
|
||||||
if(!isset($fpointers)){
|
|
||||||
$fpointers = [];
|
|
||||||
}
|
|
||||||
if(!isset($fpointers[$name]) or $fpointers[$name] === false){
|
|
||||||
$fpointers[$name] = @fopen(\pocketmine\DATA . "/" . $name . ".log", "ab");
|
|
||||||
}
|
|
||||||
@fwrite($fpointers[$name], $message);
|
|
||||||
if($close === true){
|
|
||||||
fclose($fpointers[$name]);
|
|
||||||
unset($fpointers[$name]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
set_error_handler("\\pocketmine\\error_handler", E_ALL);
|
set_error_handler("\\pocketmine\\error_handler", E_ALL);
|
||||||
|
|
||||||
$errors = 0;
|
$errors = 0;
|
||||||
|
@ -85,6 +85,7 @@ use pocketmine\tile\Tile;
|
|||||||
use pocketmine\utils\Binary;
|
use pocketmine\utils\Binary;
|
||||||
use pocketmine\utils\Config;
|
use pocketmine\utils\Config;
|
||||||
use pocketmine\utils\Logger;
|
use pocketmine\utils\Logger;
|
||||||
|
use pocketmine\utils\MainLogger;
|
||||||
use pocketmine\utils\TextFormat;
|
use pocketmine\utils\TextFormat;
|
||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
use pocketmine\utils\VersionString;
|
use pocketmine\utils\VersionString;
|
||||||
@ -1275,6 +1276,9 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
define("pocketmine\\DEBUG", $this->getConfigInt("debug.level", 1));
|
define("pocketmine\\DEBUG", $this->getConfigInt("debug.level", 1));
|
||||||
|
if($this->logger instanceof MainLogger){
|
||||||
|
$this->logger->setLogDebug(\pocketmine\DEBUG > 1);
|
||||||
|
}
|
||||||
define("ADVANCED_CACHE", $this->getConfigBoolean("enable-advanced-cache", false));
|
define("ADVANCED_CACHE", $this->getConfigBoolean("enable-advanced-cache", false));
|
||||||
define("MAX_CHUNK_RATE", 20 / $this->getConfigInt("max-chunks-per-second", 7)); //Default rate ~448 kB/s
|
define("MAX_CHUNK_RATE", 20 / $this->getConfigInt("max-chunks-per-second", 7)); //Default rate ~448 kB/s
|
||||||
if(ADVANCED_CACHE == true){
|
if(ADVANCED_CACHE == true){
|
||||||
@ -1311,7 +1315,6 @@ class Server{
|
|||||||
$this->enablePlugins(PluginLoadOrder::STARTUP);
|
$this->enablePlugins(PluginLoadOrder::STARTUP);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Generator::addGenerator("pocketmine\\level\\generator\\Flat", "flat");
|
Generator::addGenerator("pocketmine\\level\\generator\\Flat", "flat");
|
||||||
Generator::addGenerator("pocketmine\\level\\generator\\Normal", "normal");
|
Generator::addGenerator("pocketmine\\level\\generator\\Normal", "normal");
|
||||||
Generator::addGenerator("pocketmine\\level\\generator\\Normal", "default");
|
Generator::addGenerator("pocketmine\\level\\generator\\Normal", "default");
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,11 +24,9 @@
|
|||||||
*/
|
*/
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\entity\Entity;
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Position;
|
use pocketmine\level\Position;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Vector3;
|
|
||||||
use pocketmine\metadata\Metadatable;
|
use pocketmine\metadata\Metadatable;
|
||||||
use pocketmine\metadata\MetadataValue;
|
use pocketmine\metadata\MetadataValue;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
@ -21,11 +21,8 @@
|
|||||||
|
|
||||||
namespace pocketmine\block;
|
namespace pocketmine\block;
|
||||||
|
|
||||||
use pocketmine\entity\Entity;
|
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
|
||||||
use pocketmine\math\Vector3;
|
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
|
||||||
|
@ -134,6 +134,7 @@ class DroppedItem extends Entity{
|
|||||||
public function getData(){
|
public function getData(){
|
||||||
$flags = 0;
|
$flags = 0;
|
||||||
$flags |= $this->fireTicks > 0 ? 1 : 0;
|
$flags |= $this->fireTicks > 0 ? 1 : 0;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
0 => array("type" => 0, "value" => $flags),
|
0 => array("type" => 0, "value" => $flags),
|
||||||
1 => array("type" => 1, "value" => 0),
|
1 => array("type" => 1, "value" => 0),
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace pocketmine\entity;
|
namespace pocketmine\entity;
|
||||||
|
|
||||||
|
use pocketmine\block\Block;
|
||||||
use pocketmine\event\entity\EntityDespawnEvent;
|
use pocketmine\event\entity\EntityDespawnEvent;
|
||||||
use pocketmine\event\entity\EntityLevelChangeEvent;
|
use pocketmine\event\entity\EntityLevelChangeEvent;
|
||||||
use pocketmine\event\entity\EntityMotionEvent;
|
use pocketmine\event\entity\EntityMotionEvent;
|
||||||
@ -40,16 +41,15 @@ use pocketmine\nbt\tag\Byte;
|
|||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\Compound;
|
||||||
use pocketmine\nbt\tag\Float;
|
use pocketmine\nbt\tag\Float;
|
||||||
use pocketmine\nbt\tag\Short;
|
use pocketmine\nbt\tag\Short;
|
||||||
use pocketmine\Network;
|
|
||||||
use pocketmine\network\protocol\MoveEntityPacket_PosRot;
|
use pocketmine\network\protocol\MoveEntityPacket_PosRot;
|
||||||
use pocketmine\network\protocol\MovePlayerPacket;
|
use pocketmine\network\protocol\MovePlayerPacket;
|
||||||
use pocketmine\network\protocol\RemoveEntityPacket;
|
use pocketmine\network\protocol\RemoveEntityPacket;
|
||||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||||
use pocketmine\network\protocol\SetTimePacket;
|
use pocketmine\network\protocol\SetTimePacket;
|
||||||
|
use pocketmine\Network;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
use pocketmine\block\Block;
|
|
||||||
|
|
||||||
abstract class Entity extends Position implements Metadatable{
|
abstract class Entity extends Position implements Metadatable{
|
||||||
public static $entityCount = 1;
|
public static $entityCount = 1;
|
||||||
@ -330,11 +330,13 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
|
|
||||||
if($direction === 0){
|
if($direction === 0){
|
||||||
$this->motionX = -$force;
|
$this->motionX = -$force;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($direction === 1){
|
if($direction === 1){
|
||||||
$this->motionX = $force;
|
$this->motionX = $force;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,11 +344,13 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
|
|
||||||
if($direction === 3){
|
if($direction === 3){
|
||||||
$this->motionY = $force;
|
$this->motionY = $force;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($direction === 4){
|
if($direction === 4){
|
||||||
$this->motionZ = -$force;
|
$this->motionZ = -$force;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,6 +367,7 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
//TODO: check vehicles
|
//TODO: check vehicles
|
||||||
if($this->dead === true){
|
if($this->dead === true){
|
||||||
$this->close();
|
$this->close();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,6 +466,7 @@ abstract class Entity extends Position implements Metadatable{
|
|||||||
|
|
||||||
$hasUpdate = $this->entityBaseTick();
|
$hasUpdate = $this->entityBaseTick();
|
||||||
$this->updateMovement();
|
$this->updateMovement();
|
||||||
|
|
||||||
//if($this->isStatic())
|
//if($this->isStatic())
|
||||||
return true;
|
return true;
|
||||||
//return !($this instanceof Player);
|
//return !($this instanceof Player);
|
||||||
|
@ -24,16 +24,15 @@ namespace pocketmine\entity;
|
|||||||
use pocketmine\inventory\InventoryHolder;
|
use pocketmine\inventory\InventoryHolder;
|
||||||
use pocketmine\inventory\PlayerInventory;
|
use pocketmine\inventory\PlayerInventory;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\Level;
|
|
||||||
use pocketmine\nbt\NBT;
|
use pocketmine\nbt\NBT;
|
||||||
use pocketmine\nbt\tag\Byte;
|
use pocketmine\nbt\tag\Byte;
|
||||||
use pocketmine\nbt\tag\Compound;
|
use pocketmine\nbt\tag\Compound;
|
||||||
use pocketmine\nbt\tag\Enum;
|
use pocketmine\nbt\tag\Enum;
|
||||||
use pocketmine\nbt\tag\Short;
|
use pocketmine\nbt\tag\Short;
|
||||||
use pocketmine\Network;
|
|
||||||
use pocketmine\network\protocol\AddPlayerPacket;
|
use pocketmine\network\protocol\AddPlayerPacket;
|
||||||
use pocketmine\network\protocol\RemovePlayerPacket;
|
use pocketmine\network\protocol\RemovePlayerPacket;
|
||||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||||
|
use pocketmine\Network;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
class Human extends Creature implements ProjectileSource, InventoryHolder{
|
class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||||
|
@ -20,12 +20,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace pocketmine\event\inventory;
|
namespace pocketmine\event\inventory;
|
||||||
|
|
||||||
use pocketmine\event\Cancellable;
|
use pocketmine\event\Cancellable;
|
||||||
use pocketmine\event\Event;
|
use pocketmine\event\Event;
|
||||||
use pocketmine\inventory\Inventory;
|
|
||||||
use pocketmine\inventory\CraftingTransactionGroup;
|
use pocketmine\inventory\CraftingTransactionGroup;
|
||||||
use pocketmine\inventory\Recipe;
|
use pocketmine\inventory\Recipe;
|
||||||
use pocketmine\Player;
|
|
||||||
|
|
||||||
class CraftItemEvent extends Event implements Cancellable{
|
class CraftItemEvent extends Event implements Cancellable{
|
||||||
public static $handlerList = null;
|
public static $handlerList = null;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace pocketmine\event\inventory;
|
namespace pocketmine\event\inventory;
|
||||||
|
|
||||||
use pocketmine\inventory\Inventory;
|
use pocketmine\inventory\Inventory;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace pocketmine\event\inventory;
|
namespace pocketmine\event\inventory;
|
||||||
|
|
||||||
use pocketmine\event\Cancellable;
|
use pocketmine\event\Cancellable;
|
||||||
use pocketmine\inventory\Inventory;
|
use pocketmine\inventory\Inventory;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace pocketmine\event\inventory;
|
namespace pocketmine\event\inventory;
|
||||||
|
|
||||||
use pocketmine\event\Cancellable;
|
use pocketmine\event\Cancellable;
|
||||||
use pocketmine\inventory\Inventory;
|
use pocketmine\inventory\Inventory;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
@ -20,11 +20,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace pocketmine\event\inventory;
|
namespace pocketmine\event\inventory;
|
||||||
|
|
||||||
use pocketmine\event\Cancellable;
|
use pocketmine\event\Cancellable;
|
||||||
use pocketmine\event\Event;
|
use pocketmine\event\Event;
|
||||||
use pocketmine\inventory\Inventory;
|
|
||||||
use pocketmine\inventory\TransactionGroup;
|
use pocketmine\inventory\TransactionGroup;
|
||||||
use pocketmine\Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when there is a transaction between two Inventory objects.
|
* Called when there is a transaction between two Inventory objects.
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
namespace pocketmine\event\player;
|
namespace pocketmine\event\player;
|
||||||
|
|
||||||
use pocketmine\Event;
|
|
||||||
use pocketmine\event\Cancellable;
|
use pocketmine\event\Cancellable;
|
||||||
|
use pocketmine\Event;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
namespace pocketmine\event\server;
|
namespace pocketmine\event\server;
|
||||||
|
|
||||||
use pocketmine\event\Cancellable;
|
|
||||||
use pocketmine\event;
|
use pocketmine\event;
|
||||||
|
use pocketmine\event\Cancellable;
|
||||||
use pocketmine\network\protocol\DataPacket;
|
use pocketmine\network\protocol\DataPacket;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
|
|
||||||
namespace pocketmine\event\server;
|
namespace pocketmine\event\server;
|
||||||
|
|
||||||
use pocketmine\event\Cancellable;
|
|
||||||
use pocketmine\event;
|
use pocketmine\event;
|
||||||
|
use pocketmine\event\Cancellable;
|
||||||
use pocketmine\network\protocol\DataPacket;
|
use pocketmine\network\protocol\DataPacket;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
|
|
||||||
|
@ -133,6 +133,7 @@ abstract class BaseInventory implements Inventory{
|
|||||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($holder, $this->getItem($index), $item, $index));
|
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($holder, $this->getItem($index), $item, $index));
|
||||||
if($ev->isCancelled()){
|
if($ev->isCancelled()){
|
||||||
$this->sendContents($this->getViewers());
|
$this->sendContents($this->getViewers());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$item = $ev->getNewItem();
|
$item = $ev->getNewItem();
|
||||||
@ -220,6 +221,7 @@ abstract class BaseInventory implements Inventory{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,6 +260,7 @@ abstract class BaseInventory implements Inventory{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $slots;
|
return $slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,6 +356,7 @@ abstract class BaseInventory implements Inventory{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->onOpen($who);
|
$this->onOpen($who);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
namespace pocketmine\inventory;
|
namespace pocketmine\inventory;
|
||||||
|
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\network\protocol\ContainerClosePacket;
|
use pocketmine\network\protocol\ContainerClosePacket;
|
||||||
use pocketmine\network\protocol\ContainerOpenPacket;
|
use pocketmine\network\protocol\ContainerOpenPacket;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\math\Vector3;
|
|
||||||
|
|
||||||
abstract class ContainerInventory extends BaseInventory{
|
abstract class ContainerInventory extends BaseInventory{
|
||||||
public function onOpen(Player $who){
|
public function onOpen(Player $who){
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
namespace pocketmine\inventory;
|
namespace pocketmine\inventory;
|
||||||
|
|
||||||
use pocketmine\block\Planks;
|
use pocketmine\block\Planks;
|
||||||
use pocketmine\block\Slab;
|
|
||||||
use pocketmine\block\Wood;
|
use pocketmine\block\Wood;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
|
||||||
@ -303,10 +302,10 @@ class CraftingManager{
|
|||||||
* @return FurnaceRecipe
|
* @return FurnaceRecipe
|
||||||
*/
|
*/
|
||||||
public function matchFurnaceRecipe(Item $input){
|
public function matchFurnaceRecipe(Item $input){
|
||||||
if(isset($this->furnaceRecipes[$input->getID().":".$input->getDamage()])){
|
if(isset($this->furnaceRecipes[$input->getID() . ":" . $input->getDamage()])){
|
||||||
return $this->furnaceRecipes[$input->getID().":".$input->getDamage()];
|
return $this->furnaceRecipes[$input->getID() . ":" . $input->getDamage()];
|
||||||
}elseif($this->furnaceRecipes[$input->getID().":?"]){
|
}elseif($this->furnaceRecipes[$input->getID() . ":?"]){
|
||||||
return $this->furnaceRecipes[$input->getID().":?"];
|
return $this->furnaceRecipes[$input->getID() . ":?"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -329,9 +328,9 @@ class CraftingManager{
|
|||||||
$ingredients = $recipe->getIngredientList();
|
$ingredients = $recipe->getIngredientList();
|
||||||
usort($ingredients, array($this, "sort"));
|
usort($ingredients, array($this, "sort"));
|
||||||
foreach($ingredients as $item){
|
foreach($ingredients as $item){
|
||||||
$hash .= $item->getID().":".($item->getDamage() === null ? "?":$item->getDamage())."x".$item->getCount().",";
|
$hash .= $item->getID() . ":" . ($item->getDamage() === null ? "?" : $item->getDamage()) . "x" . $item->getCount() . ",";
|
||||||
}
|
}
|
||||||
$this->recipeLookup[$result->getID().":".$result->getDamage()][$hash] = $recipe;
|
$this->recipeLookup[$result->getID() . ":" . $result->getDamage()][$hash] = $recipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,7 +338,7 @@ class CraftingManager{
|
|||||||
*/
|
*/
|
||||||
public function registerFurnaceRecipe(FurnaceRecipe $recipe){
|
public function registerFurnaceRecipe(FurnaceRecipe $recipe){
|
||||||
$input = $recipe->getInput();
|
$input = $recipe->getInput();
|
||||||
$this->furnaceRecipes[$input->getID().":".($input->getDamage() === null ? "?":$input->getDamage())] = $recipe;
|
$this->furnaceRecipes[$input->getID() . ":" . ($input->getDamage() === null ? "?" : $input->getDamage())] = $recipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -353,7 +352,7 @@ class CraftingManager{
|
|||||||
if(!($result instanceof Item)){
|
if(!($result instanceof Item)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$k = $result->getID().":".$result->getDamage();
|
$k = $result->getID() . ":" . $result->getDamage();
|
||||||
|
|
||||||
if(!isset($this->recipeLookup[$k])){
|
if(!isset($this->recipeLookup[$k])){
|
||||||
return false;
|
return false;
|
||||||
@ -364,7 +363,7 @@ class CraftingManager{
|
|||||||
$inputCount = 0;
|
$inputCount = 0;
|
||||||
foreach($input as $item){
|
foreach($input as $item){
|
||||||
$inputCount += $item->getCount();
|
$inputCount += $item->getCount();
|
||||||
$hash .= $item->getID().":".($item->getDamage() === null ? "?":$item->getDamage())."x".$item->getCount().",";
|
$hash .= $item->getID() . ":" . ($item->getDamage() === null ? "?" : $item->getDamage()) . "x" . $item->getCount() . ",";
|
||||||
}
|
}
|
||||||
if(!isset($this->recipeLookup[$k][$hash])){
|
if(!isset($this->recipeLookup[$k][$hash])){
|
||||||
$hasRecipe = null;
|
$hasRecipe = null;
|
||||||
@ -414,6 +413,7 @@ class CraftingManager{
|
|||||||
if($checkResult->equals($result, true) and $checkResult->getCount() === $result->getCount()){
|
if($checkResult->equals($result, true) and $checkResult->getCount() === $result->getCount()){
|
||||||
return $recipe;
|
return $recipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ class CraftingTransactionGroup extends SimpleTransactionGroup{
|
|||||||
*/
|
*/
|
||||||
public function getResult(){
|
public function getResult(){
|
||||||
reset($this->output);
|
reset($this->output);
|
||||||
|
|
||||||
return current($this->output);
|
return current($this->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ class CraftingTransactionGroup extends SimpleTransactionGroup{
|
|||||||
if(count($this->output) !== 1 or count($this->input) === 0){
|
if(count($this->output) !== 1 or count($this->input) === 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getMatchingRecipe() instanceof Recipe;
|
return $this->getMatchingRecipe() instanceof Recipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +83,7 @@ class CraftingTransactionGroup extends SimpleTransactionGroup{
|
|||||||
if($this->recipe === null){
|
if($this->recipe === null){
|
||||||
$this->recipe = Server::getInstance()->getCraftingManager()->matchTransaction($this);
|
$this->recipe = Server::getInstance()->getCraftingManager()->matchTransaction($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->recipe;
|
return $this->recipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +97,7 @@ class CraftingTransactionGroup extends SimpleTransactionGroup{
|
|||||||
foreach($this->inventories as $inventory){
|
foreach($this->inventories as $inventory){
|
||||||
$inventory->sendContents($inventory->getViewers());
|
$inventory->sendContents($inventory->getViewers());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@ class ShapedRecipe implements Recipe{
|
|||||||
throw new \Exception("Must provide a shape");
|
throw new \Exception("Must provide a shape");
|
||||||
}
|
}
|
||||||
if(count($shape) > 3){
|
if(count($shape) > 3){
|
||||||
throw new \Exception("Crafting recipes should be 1, 2, 3 rows, not ".count($shape));
|
throw new \Exception("Crafting recipes should be 1, 2, 3 rows, not " . count($shape));
|
||||||
}
|
}
|
||||||
foreach($shape as $row){
|
foreach($shape as $row){
|
||||||
if(strlen($row) === 0 or strlen($row) > 3){
|
if(strlen($row) === 0 or strlen($row) > 3){
|
||||||
throw new \Exception("Crafting rows should be 1, 2, 3 characters, not ".count($row));
|
throw new \Exception("Crafting rows should be 1, 2, 3 characters, not " . count($row));
|
||||||
}
|
}
|
||||||
$this->rows[] = $row;
|
$this->rows[] = $row;
|
||||||
$len = strlen($row);
|
$len = strlen($row);
|
||||||
@ -70,7 +70,7 @@ class ShapedRecipe implements Recipe{
|
|||||||
*/
|
*/
|
||||||
public function setIngredient($key, Item $item){
|
public function setIngredient($key, Item $item){
|
||||||
if(!isset($this->ingredients[$key])){
|
if(!isset($this->ingredients[$key])){
|
||||||
throw new \Exception("Symbol does not appear in the shape: ". $key);
|
throw new \Exception("Symbol does not appear in the shape: " . $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ingredients[$key] = $item;
|
$this->ingredients[$key] = $item;
|
||||||
@ -90,6 +90,7 @@ class ShapedRecipe implements Recipe{
|
|||||||
$ingredients[$key] = $ingredient;
|
$ingredients[$key] = $ingredient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ingredients;
|
return $ingredients;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,7 @@ class ShapelessRecipe implements Recipe{
|
|||||||
$item->setCount($item->getCount() - 1);
|
$item->setCount($item->getCount() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +89,7 @@ class ShapelessRecipe implements Recipe{
|
|||||||
foreach($this->ingredients as $ingredient){
|
foreach($this->ingredients as $ingredient){
|
||||||
$ingredients[] = clone $ingredient;
|
$ingredients[] = clone $ingredient;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ingredients;
|
return $ingredients;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +101,7 @@ class ShapelessRecipe implements Recipe{
|
|||||||
foreach($this->ingredients as $ingredient){
|
foreach($this->ingredients as $ingredient){
|
||||||
$count += $ingredient->getCount();
|
$count += $ingredient->getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,7 @@ class SimpleTransactionGroup implements TransactionGroup{
|
|||||||
$haveItems = [];
|
$haveItems = [];
|
||||||
$needItems = [];
|
$needItems = [];
|
||||||
$this->matchItems($haveItems, $needItems);
|
$this->matchItems($haveItems, $needItems);
|
||||||
|
|
||||||
return count($haveItems) === 0 and count($needItems) === 0 and count($this->transactions) > 0;
|
return count($haveItems) === 0 and count($needItems) === 0 and count($this->transactions) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +140,7 @@ class SimpleTransactionGroup implements TransactionGroup{
|
|||||||
foreach($this->inventories as $inventory){
|
foreach($this->inventories as $inventory){
|
||||||
$inventory->sendContents($inventory->getViewers());
|
$inventory->sendContents($inventory->getViewers());
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
namespace pocketmine\inventory;
|
namespace pocketmine\inventory;
|
||||||
|
|
||||||
use pocketmine\item\Item;
|
|
||||||
|
|
||||||
interface TransactionGroup{
|
interface TransactionGroup{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,6 +440,7 @@ class Item{
|
|||||||
}else{
|
}else{
|
||||||
$item = new Item($id, $meta, $count);
|
$item = new Item($id, $meta, $count);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ use pocketmine\event\entity\EntityExplodeEvent;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\math\Vector3 as Vector3;
|
use pocketmine\math\Vector3 as Vector3;
|
||||||
use pocketmine\network\protocol\ExplodePacket;
|
use pocketmine\network\protocol\ExplodePacket;
|
||||||
use pocketmine\Player;
|
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
|
||||||
class Explosion{
|
class Explosion{
|
||||||
|
@ -33,7 +33,6 @@ use pocketmine\event\block\BlockPlaceEvent;
|
|||||||
use pocketmine\event\player\PlayerInteractEvent;
|
use pocketmine\event\player\PlayerInteractEvent;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\format\pmf\LevelFormat;
|
use pocketmine\level\format\pmf\LevelFormat;
|
||||||
use pocketmine\level\generator\Flat;
|
|
||||||
use pocketmine\level\generator\Generator;
|
use pocketmine\level\generator\Generator;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Vector2;
|
use pocketmine\math\Vector2;
|
||||||
@ -536,6 +535,7 @@ class Level{
|
|||||||
|
|
||||||
public function isFullBlock(Vector3 $pos){
|
public function isFullBlock(Vector3 $pos){
|
||||||
$bb = $this->getBlock($pos)->getBoundingBox();
|
$bb = $this->getBlock($pos)->getBoundingBox();
|
||||||
|
|
||||||
return $bb instanceof AxisAlignedBB and $bb->getAverageEdgeLength() >= 1;
|
return $bb instanceof AxisAlignedBB and $bb->getAverageEdgeLength() >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -772,6 +772,7 @@ class Level{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,6 +826,7 @@ class Level{
|
|||||||
$hand->position($block);
|
$hand->position($block);
|
||||||
}elseif($block->getID() === Item::FIRE){
|
}elseif($block->getID() === Item::FIRE){
|
||||||
$this->setBlock($block, new Air(), true, false, true);
|
$this->setBlock($block, new Air(), true, false, true);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
@ -884,6 +886,7 @@ class Level{
|
|||||||
if($item->getCount() <= 0){
|
if($item->getCount() <= 0){
|
||||||
$item = Item::get(Item::AIR, 0, 0);
|
$item = Item::get(Item::AIR, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ class BlockMetadataStore extends MetadataStore{
|
|||||||
if(!($block instanceof Block)){
|
if(!($block instanceof Block)){
|
||||||
throw new \InvalidArgumentException("Argument must be a Block instance");
|
throw new \InvalidArgumentException("Argument must be a Block instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $block->x . ":" . $block->y . ":" . $block->z . ":" . $metadataKey;
|
return $block->x . ":" . $block->y . ":" . $block->z . ":" . $metadataKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ class EntityMetadataStore extends MetadataStore{
|
|||||||
if(!($entity instanceof Entity)){
|
if(!($entity instanceof Entity)){
|
||||||
throw new \InvalidArgumentException("Argument must be an Entity instance");
|
throw new \InvalidArgumentException("Argument must be an Entity instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entity->getID() . ":" . $metadataKey;
|
return $entity->getID() . ":" . $metadataKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,6 +29,7 @@ class LevelMetadataStore extends MetadataStore{
|
|||||||
if(!($level instanceof Level)){
|
if(!($level instanceof Level)){
|
||||||
throw new \InvalidArgumentException("Argument must be a Level instance");
|
throw new \InvalidArgumentException("Argument must be a Level instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
return strtolower($level->getName()) . ":" . $metadataKey;
|
return strtolower($level->getName()) . ":" . $metadataKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,6 +29,7 @@ class PlayerMetadataStore extends MetadataStore{
|
|||||||
if(!($player instanceof OfflinePlayer)){
|
if(!($player instanceof OfflinePlayer)){
|
||||||
throw new \InvalidArgumentException("Argument must be an OfflinePlayer instance");
|
throw new \InvalidArgumentException("Argument must be an OfflinePlayer instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
return strtolower($player->getName()) . ":" . $metadataKey;
|
return strtolower($player->getName()) . ":" . $metadataKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -52,6 +52,7 @@ class PluginDescription{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $plugin
|
* @param array $plugin
|
||||||
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
private function loadMap(array $plugin){
|
private function loadMap(array $plugin){
|
||||||
|
@ -21,12 +21,9 @@
|
|||||||
|
|
||||||
namespace pocketmine\plugin;
|
namespace pocketmine\plugin;
|
||||||
|
|
||||||
use pocketmine\level\Level;
|
|
||||||
use pocketmine\Server;
|
|
||||||
use pocketmine\utils\Logger;
|
use pocketmine\utils\Logger;
|
||||||
use pocketmine\utils\LogLevel;
|
use pocketmine\utils\LogLevel;
|
||||||
use pocketmine\utils\MainLogger;
|
use pocketmine\utils\MainLogger;
|
||||||
use pocketmine\utils\TextFormat;
|
|
||||||
|
|
||||||
class PluginLogger implements Logger{
|
class PluginLogger implements Logger{
|
||||||
|
|
||||||
|
@ -437,6 +437,7 @@ class PluginManager{
|
|||||||
unset($this->permSubs[$permission][$k]);
|
unset($this->permSubs[$permission][$k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $subs;
|
return $subs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
protected $logStream;
|
protected $logStream;
|
||||||
protected $shutdown;
|
protected $shutdown;
|
||||||
protected $hasANSI;
|
protected $hasANSI;
|
||||||
|
protected $logDebug;
|
||||||
private $logResource;
|
private $logResource;
|
||||||
/** @var MainLogger */
|
/** @var MainLogger */
|
||||||
public static $logger = null;
|
public static $logger = null;
|
||||||
@ -33,10 +34,11 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
/**
|
/**
|
||||||
* @param string $logFile
|
* @param string $logFile
|
||||||
* @param bool $hasANSI
|
* @param bool $hasANSI
|
||||||
|
* @param bool $logDebug
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function __construct($logFile, $hasANSI = false){
|
public function __construct($logFile, $hasANSI = false, $logDebug = false){
|
||||||
if(static::$logger instanceof MainLogger){
|
if(static::$logger instanceof MainLogger){
|
||||||
throw new \RuntimeException("MainLogger has been already created");
|
throw new \RuntimeException("MainLogger has been already created");
|
||||||
}
|
}
|
||||||
@ -44,6 +46,7 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
@mkdir(basename($logFile), 0777, true);
|
@mkdir(basename($logFile), 0777, true);
|
||||||
$this->logFile = $logFile;
|
$this->logFile = $logFile;
|
||||||
$this->hasANSI = (bool) $hasANSI;
|
$this->hasANSI = (bool) $hasANSI;
|
||||||
|
$this->logDebug = (bool) $logDebug;
|
||||||
$this->logStream = "";
|
$this->logStream = "";
|
||||||
$this->start(PTHREADS_INHERIT_NONE);
|
$this->start(PTHREADS_INHERIT_NONE);
|
||||||
}
|
}
|
||||||
@ -56,35 +59,45 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function emergency($message){
|
public function emergency($message){
|
||||||
$this->send(TextFormat::RED . "[EMERGENCY] ". $message);
|
$this->send(TextFormat::RED . "[EMERGENCY] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function alert($message){
|
public function alert($message){
|
||||||
$this->send(TextFormat::RED . "[ALERT] ". $message);
|
$this->send(TextFormat::RED . "[ALERT] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function critical($message){
|
public function critical($message){
|
||||||
$this->send(TextFormat::RED . "[CRITICAL] ". $message);
|
$this->send(TextFormat::RED . "[CRITICAL] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function error($message){
|
public function error($message){
|
||||||
$this->send(TextFormat::DARK_RED . "[ERROR] ". $message);
|
$this->send(TextFormat::DARK_RED . "[ERROR] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function warning($message){
|
public function warning($message){
|
||||||
$this->send(TextFormat::YELLOW . "[WARNING] ". $message);
|
$this->send(TextFormat::YELLOW . "[WARNING] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notice($message){
|
public function notice($message){
|
||||||
$this->send(TextFormat::AQUA . "[NOTICE] ". $message);
|
$this->send(TextFormat::AQUA . "[NOTICE] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function info($message){
|
public function info($message){
|
||||||
$this->send(TextFormat::WHITE . "[INFO] ". $message);
|
$this->send(TextFormat::WHITE . "[INFO] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function debug($message){
|
public function debug($message){
|
||||||
$this->send(TextFormat::GRAY . "[DEBUG] ". $message);
|
if($this->logDebug === false){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->send(TextFormat::GRAY . "[DEBUG] " . $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $logDebug
|
||||||
|
*/
|
||||||
|
public function setLogDebug($logDebug){
|
||||||
|
$this->logDebug = (bool) $logDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function log($level, $message){
|
public function log($level, $message){
|
||||||
@ -143,7 +156,7 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
|
|
||||||
while($this->shutdown === false){
|
while($this->shutdown === false){
|
||||||
if(strlen($this->logStream) >= 4096){
|
if(strlen($this->logStream) >= 4096){
|
||||||
$this->synchronized(function(){
|
$this->synchronized(function (){
|
||||||
$chunks = strlen($this->logStream) >> 12;
|
$chunks = strlen($this->logStream) >> 12;
|
||||||
$chunk = substr($this->logStream, 0, $chunks << 12);
|
$chunk = substr($this->logStream, 0, $chunks << 12);
|
||||||
$this->logStream = substr($this->logStream, $chunks << 12);
|
$this->logStream = substr($this->logStream, $chunks << 12);
|
||||||
|
@ -26,6 +26,7 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
protected $logStream;
|
protected $logStream;
|
||||||
protected $shutdown;
|
protected $shutdown;
|
||||||
protected $hasANSI;
|
protected $hasANSI;
|
||||||
|
protected $logDebug;
|
||||||
private $logResource;
|
private $logResource;
|
||||||
/** @var MainLogger */
|
/** @var MainLogger */
|
||||||
public static $logger = null;
|
public static $logger = null;
|
||||||
@ -33,10 +34,11 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
/**
|
/**
|
||||||
* @param string $logFile
|
* @param string $logFile
|
||||||
* @param bool $hasANSI
|
* @param bool $hasANSI
|
||||||
|
* @param bool $logDebug
|
||||||
*
|
*
|
||||||
* @throws \RuntimeException
|
* @throws \RuntimeException
|
||||||
*/
|
*/
|
||||||
public function __construct($logFile, $hasANSI = false){
|
public function __construct($logFile, $hasANSI = false, $logDebug = false){
|
||||||
if(static::$logger instanceof MainLogger){
|
if(static::$logger instanceof MainLogger){
|
||||||
throw new \RuntimeException("MainLogger has been already created");
|
throw new \RuntimeException("MainLogger has been already created");
|
||||||
}
|
}
|
||||||
@ -44,6 +46,7 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
@mkdir(basename($logFile), 0777, true);
|
@mkdir(basename($logFile), 0777, true);
|
||||||
$this->logFile = $logFile;
|
$this->logFile = $logFile;
|
||||||
$this->hasANSI = (bool) $hasANSI;
|
$this->hasANSI = (bool) $hasANSI;
|
||||||
|
$this->logDebug = (bool) $logDebug;
|
||||||
$this->logStream = "";
|
$this->logStream = "";
|
||||||
$this->start(PTHREADS_INHERIT_NONE);
|
$this->start(PTHREADS_INHERIT_NONE);
|
||||||
}
|
}
|
||||||
@ -56,35 +59,45 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function emergency($message){
|
public function emergency($message){
|
||||||
$this->send(TextFormat::RED . "[EMERGENCY] ". $message);
|
$this->send(TextFormat::RED . "[EMERGENCY] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function alert($message){
|
public function alert($message){
|
||||||
$this->send(TextFormat::RED . "[ALERT] ". $message);
|
$this->send(TextFormat::RED . "[ALERT] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function critical($message){
|
public function critical($message){
|
||||||
$this->send(TextFormat::RED . "[CRITICAL] ". $message);
|
$this->send(TextFormat::RED . "[CRITICAL] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function error($message){
|
public function error($message){
|
||||||
$this->send(TextFormat::DARK_RED . "[ERROR] ". $message);
|
$this->send(TextFormat::DARK_RED . "[ERROR] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function warning($message){
|
public function warning($message){
|
||||||
$this->send(TextFormat::YELLOW . "[WARNING] ". $message);
|
$this->send(TextFormat::YELLOW . "[WARNING] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notice($message){
|
public function notice($message){
|
||||||
$this->send(TextFormat::AQUA . "[NOTICE] ". $message);
|
$this->send(TextFormat::AQUA . "[NOTICE] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function info($message){
|
public function info($message){
|
||||||
$this->send(TextFormat::WHITE . "[INFO] ". $message);
|
$this->send(TextFormat::WHITE . "[INFO] " . $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function debug($message){
|
public function debug($message){
|
||||||
$this->send(TextFormat::GRAY . "[DEBUG] ". $message);
|
if($this->logDebug === false){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->send(TextFormat::GRAY . "[DEBUG] " . $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $logDebug
|
||||||
|
*/
|
||||||
|
public function setLogDebug($logDebug){
|
||||||
|
$this->logDebug = (bool) $logDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function log($level, $message){
|
public function log($level, $message){
|
||||||
@ -143,7 +156,7 @@ class MainLogger extends \Thread implements Logger{
|
|||||||
|
|
||||||
while($this->shutdown === false){
|
while($this->shutdown === false){
|
||||||
if(strlen($this->logStream) >= 4096){
|
if(strlen($this->logStream) >= 4096){
|
||||||
$this->synchronized(function(){
|
$this->synchronized(function (){
|
||||||
$chunks = strlen($this->logStream) >> 12;
|
$chunks = strlen($this->logStream) >> 12;
|
||||||
$chunk = substr($this->logStream, 0, $chunks << 12);
|
$chunk = substr($this->logStream, 0, $chunks << 12);
|
||||||
$this->logStream = substr($this->logStream, $chunks << 12);
|
$this->logStream = substr($this->logStream, $chunks << 12);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user