Move block and network namespaces away from PluginManager->callEvent()

the original step that wasn't supposed to cause conflicts, caused messy conflicts... so I might as well do this part too
This commit is contained in:
Dylan K. Taylor
2018-10-05 18:22:49 +01:00
parent 620784e4e7
commit 495fdbd19f
15 changed files with 39 additions and 34 deletions

View File

@ -98,7 +98,7 @@ class Network{
$logger->logException($e);
}
$this->server->getPluginManager()->callEvent(new NetworkInterfaceCrashEvent($interface, $e));
(new NetworkInterfaceCrashEvent($interface, $e))->call();
$interface->emergencyShutdown();
$this->unregisterInterface($interface);
@ -110,7 +110,8 @@ class Network{
* @param SourceInterface $interface
*/
public function registerInterface(SourceInterface $interface){
$this->server->getPluginManager()->callEvent($ev = new NetworkInterfaceRegisterEvent($interface));
$ev = new NetworkInterfaceRegisterEvent($interface);
$ev->call();
if(!$ev->isCancelled()){
$interface->start();
$this->interfaces[$hash = spl_object_hash($interface)] = $interface;
@ -126,7 +127,7 @@ class Network{
* @param SourceInterface $interface
*/
public function unregisterInterface(SourceInterface $interface){
$this->server->getPluginManager()->callEvent(new NetworkInterfaceUnregisterEvent($interface));
(new NetworkInterfaceUnregisterEvent($interface))->call();
unset($this->interfaces[$hash = spl_object_hash($interface)], $this->advancedInterfaces[$hash]);
}

View File

@ -88,7 +88,8 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
$this->server->getLogger()->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": 0x" . bin2hex($remains));
}
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this->player, $packet));
$ev = new DataPacketReceiveEvent($this->player, $packet);
$ev->call();
if(!$ev->isCancelled() and !$packet->handle($this)){
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": 0x" . bin2hex($packet->buffer));
}

View File

@ -137,7 +137,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
public function openSession(string $identifier, string $address, int $port, int $clientID) : void{
$ev = new PlayerCreationEvent($this, Player::class, Player::class, $address, $port);
$this->server->getPluginManager()->callEvent($ev);
$ev->call();
$class = $ev->getPlayerClass();
/**

View File

@ -97,7 +97,8 @@ class RCON{
$response = new RemoteConsoleCommandSender();
$command = $this->instance->cmd;
$this->server->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent($response, $command));
$ev = new RemoteServerCommandEvent($response, $command);
$ev->call();
if(!$ev->isCancelled()){
$this->server->dispatchCommand($ev->getSender(), $ev->getCommand());