/** * @param object $object * * @return int */ public function store($object) { $this->objects[$id = $this->nextId()] = $object; if (count($this->objects) >= $this->main->getConfig()->getNested("advanced.objectPool.warningSize")) { $this->main->getLogger()->warning("OrderedObjectPool size reached " . count($this->objects) . "! Object summary:"); $summary = []; foreach ($this->objects as $obj) { $class = get_class($obj); if (isset($summary[$class])) { $summary[$class]++; } else { $summary[$class] = 1; } } foreach ($summary as $class => $cnt) { $this->main->getLogger()->warning($class . ": {$cnt} entries"); } $this->main->getLogger()->warning("The above is most likely caused by a mistake in code that results in a memory leak. Please report the above to the issue tracker on GitHub at " . TextFormat::LIGHT_PURPLE . "http://lgpe.co/weai/"); } return $id; }
public function __construct(WorldEditArt $main, $name, SelectedTool $wand = null, SelectedTool $jump = null) { $config = $main->getConfig(); if ($wand === null) { $wand = new SelectedTool(PlayerData::USE_DEFAULT, PlayerData::USE_DEFAULT, $config->get("wand-id"), $config->get("wand-damage")); } if ($jump === null) { $jump = new SelectedTool(PlayerData::USE_DEFAULT, PlayerData::USE_DEFAULT, $config->get("jump-id"), $config->get("jump-damage")); } $this->main = $main; $this->name = $name; $this->tools = [self::WAND => $wand, self::JUMP => $jump]; }