pocketmine\event\HandlerList::unregisterAll PHP Method

unregisterAll() public static method

Unregisters all the listeners If a Plugin or Listener is passed, all the listeners with that object will be removed
public static unregisterAll ( pocketmine\plugin\Plugin | Listener | null $object = null )
$object pocketmine\plugin\Plugin | Listener | null
    public static function unregisterAll($object = null)
    {
        if ($object instanceof Listener or $object instanceof Plugin) {
            foreach (self::$allLists as $h) {
                $h->unregister($object);
            }
        } else {
            foreach (self::$allLists as $h) {
                foreach ($h->handlerSlots as $key => $list) {
                    $h->handlerSlots[$key] = [];
                }
                $h->handlers = null;
            }
        }
    }

Usage Example

示例#1
0
 public function forceShutdown()
 {
     if ($this->hasStopped) {
         return;
     }
     try {
         $this->hasStopped = true;
         $this->shutdown();
         if ($this->rcon instanceof RCON) {
             $this->rcon->stop();
         }
         if ($this->getProperty("settings.upnp-forwarding", false) === true) {
             $this->logger->info("[UPnP] Removing port forward...");
             UPnP::RemovePortForward($this->getPort());
         }
         $this->pluginManager->disablePlugins();
         foreach ($this->players as $player) {
             $player->close(TextFormat::YELLOW . $player->getName() . " has left the game", $this->getProperty("settings.shutdown-message", "Server closed"));
         }
         foreach ($this->getLevels() as $level) {
             $this->unloadLevel($level, true);
         }
         if ($this->generationManager instanceof GenerationRequestManager) {
             $this->generationManager->shutdown();
         }
         HandlerList::unregisterAll();
         $this->scheduler->cancelAllTasks();
         $this->scheduler->mainThreadHeartbeat(PHP_INT_MAX);
         $this->properties->save();
         $this->console->kill();
         foreach ($this->network->getInterfaces() as $interface) {
             $interface->shutdown();
             $this->network->unregisterInterface($interface);
         }
     } catch (\Exception $e) {
         $this->logger->emergency("Crashed while crashing, killing process");
         @kill(getmypid());
     }
 }
All Usage Examples Of pocketmine\event\HandlerList::unregisterAll