Rename SourceInterface -> NetworkInterface

SourceInterface doesn't make sense really...
This commit is contained in:
Dylan K. Taylor 2018-07-18 11:03:21 +01:00
parent 965f0d670d
commit 4d1e2d1b3a
10 changed files with 45 additions and 45 deletions

View File

@ -144,7 +144,7 @@ use pocketmine\network\mcpe\protocol\types\PlayerPermissions;
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket; use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
use pocketmine\network\mcpe\protocol\UpdateBlockPacket; use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
use pocketmine\network\mcpe\VerifyLoginTask; use pocketmine\network\mcpe\VerifyLoginTask;
use pocketmine\network\SourceInterface; use pocketmine\network\NetworkInterface;
use pocketmine\permission\PermissibleBase; use pocketmine\permission\PermissibleBase;
use pocketmine\permission\PermissionAttachment; use pocketmine\permission\PermissionAttachment;
use pocketmine\permission\PermissionAttachmentInfo; use pocketmine\permission\PermissionAttachmentInfo;
@ -186,7 +186,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
} }
/** @var SourceInterface */ /** @var NetworkInterface */
protected $interface; protected $interface;
/** /**
@ -705,11 +705,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
} }
/** /**
* @param SourceInterface $interface * @param NetworkInterface $interface
* @param string $ip * @param string $ip
* @param int $port * @param int $port
*/ */
public function __construct(SourceInterface $interface, string $ip, int $port){ public function __construct(NetworkInterface $interface, string $ip, int $port){
$this->interface = $interface; $this->interface = $interface;
$this->perm = new PermissibleBase($this); $this->perm = new PermissibleBase($this);
$this->namedtag = new CompoundTag(); $this->namedtag = new CompoundTag();

View File

@ -68,7 +68,7 @@ use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\LongTag; use pocketmine\nbt\tag\LongTag;
use pocketmine\nbt\tag\ShortTag; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\StringTag; use pocketmine\nbt\tag\StringTag;
use pocketmine\network\AdvancedSourceInterface; use pocketmine\network\AdvancedNetworkInterface;
use pocketmine\network\mcpe\CompressBatchedTask; use pocketmine\network\mcpe\CompressBatchedTask;
use pocketmine\network\mcpe\protocol\BatchPacket; use pocketmine\network\mcpe\protocol\BatchPacket;
use pocketmine\network\mcpe\protocol\DataPacket; use pocketmine\network\mcpe\protocol\DataPacket;
@ -2459,14 +2459,14 @@ class Server{
} }
/** /**
* @param AdvancedSourceInterface $interface * @param AdvancedNetworkInterface $interface
* @param string $address * @param string $address
* @param int $port * @param int $port
* @param string $payload * @param string $payload
* *
* TODO: move this to Network * TODO: move this to Network
*/ */
public function handlePacket(AdvancedSourceInterface $interface, string $address, int $port, string $payload){ public function handlePacket(AdvancedNetworkInterface $interface, string $address, int $port, string $payload){
try{ try{
if(strlen($payload) > 2 and substr($payload, 0, 2) === "\xfe\xfd" and $this->queryHandler instanceof QueryHandler){ if(strlen($payload) > 2 and substr($payload, 0, 2) === "\xfe\xfd" and $this->queryHandler instanceof QueryHandler){
$this->queryHandler->handle($interface, $address, $port, $payload); $this->queryHandler->handle($interface, $address, $port, $payload);

View File

@ -24,14 +24,14 @@ declare(strict_types=1);
namespace pocketmine\event\player; namespace pocketmine\event\player;
use pocketmine\event\Event; use pocketmine\event\Event;
use pocketmine\network\SourceInterface; use pocketmine\network\NetworkInterface;
use pocketmine\Player; use pocketmine\Player;
/** /**
* Allows the creation of players overriding the base Player class * Allows the creation of players overriding the base Player class
*/ */
class PlayerCreationEvent extends Event{ class PlayerCreationEvent extends Event{
/** @var SourceInterface */ /** @var NetworkInterface */
private $interface; private $interface;
/** @var string */ /** @var string */
private $address; private $address;
@ -44,13 +44,13 @@ class PlayerCreationEvent extends Event{
private $playerClass; private $playerClass;
/** /**
* @param SourceInterface $interface * @param NetworkInterface $interface
* @param Player::class $baseClass * @param Player::class $baseClass
* @param Player::class $playerClass * @param Player::class $playerClass
* @param string $address * @param string $address
* @param int $port * @param int $port
*/ */
public function __construct(SourceInterface $interface, $baseClass, $playerClass, string $address, int $port){ public function __construct(NetworkInterface $interface, $baseClass, $playerClass, string $address, int $port){
$this->interface = $interface; $this->interface = $interface;
$this->address = $address; $this->address = $address;
$this->port = $port; $this->port = $port;
@ -69,9 +69,9 @@ class PlayerCreationEvent extends Event{
} }
/** /**
* @return SourceInterface * @return NetworkInterface
*/ */
public function getInterface() : SourceInterface{ public function getInterface() : NetworkInterface{
return $this->interface; return $this->interface;
} }

View File

@ -23,7 +23,7 @@ declare(strict_types=1);
namespace pocketmine\event\server; namespace pocketmine\event\server;
use pocketmine\network\SourceInterface; use pocketmine\network\NetworkInterface;
/** /**
* Called when a network interface crashes, with relevant crash information. * Called when a network interface crashes, with relevant crash information.
@ -34,7 +34,7 @@ class NetworkInterfaceCrashEvent extends NetworkInterfaceEvent{
*/ */
private $exception; private $exception;
public function __construct(SourceInterface $interface, \Throwable $throwable){ public function __construct(NetworkInterface $interface, \Throwable $throwable){
parent::__construct($interface); parent::__construct($interface);
$this->exception = $throwable; $this->exception = $throwable;
} }

View File

@ -23,23 +23,23 @@ declare(strict_types=1);
namespace pocketmine\event\server; namespace pocketmine\event\server;
use pocketmine\network\SourceInterface; use pocketmine\network\NetworkInterface;
class NetworkInterfaceEvent extends ServerEvent{ class NetworkInterfaceEvent extends ServerEvent{
/** @var SourceInterface */ /** @var NetworkInterface */
protected $interface; protected $interface;
/** /**
* @param SourceInterface $interface * @param NetworkInterface $interface
*/ */
public function __construct(SourceInterface $interface){ public function __construct(NetworkInterface $interface){
$this->interface = $interface; $this->interface = $interface;
} }
/** /**
* @return SourceInterface * @return NetworkInterface
*/ */
public function getInterface() : SourceInterface{ public function getInterface() : NetworkInterface{
return $this->interface; return $this->interface;
} }
} }

View File

@ -30,7 +30,7 @@ namespace pocketmine\network;
* Advanced network interfaces have some additional capabilities, such as being able to ban addresses and process raw * Advanced network interfaces have some additional capabilities, such as being able to ban addresses and process raw
* packets. * packets.
*/ */
interface AdvancedSourceInterface extends SourceInterface{ interface AdvancedNetworkInterface extends NetworkInterface{
/** /**
* Prevents packets received from the IP address getting processed for the given timeout. * Prevents packets received from the IP address getting processed for the given timeout.

View File

@ -39,10 +39,10 @@ class Network{
/** @var Server */ /** @var Server */
private $server; private $server;
/** @var SourceInterface[] */ /** @var NetworkInterface[] */
private $interfaces = []; private $interfaces = [];
/** @var AdvancedSourceInterface[] */ /** @var AdvancedNetworkInterface[] */
private $advancedInterfaces = []; private $advancedInterfaces = [];
private $upload = 0; private $upload = 0;
@ -77,7 +77,7 @@ class Network{
} }
/** /**
* @return SourceInterface[] * @return NetworkInterface[]
*/ */
public function getInterfaces() : array{ public function getInterfaces() : array{
return $this->interfaces; return $this->interfaces;
@ -89,7 +89,7 @@ class Network{
} }
} }
public function processInterface(SourceInterface $interface) : void{ public function processInterface(NetworkInterface $interface) : void{
try{ try{
$interface->process(); $interface->process();
}catch(\Throwable $e){ }catch(\Throwable $e){
@ -107,14 +107,14 @@ class Network{
} }
/** /**
* @param SourceInterface $interface * @param NetworkInterface $interface
*/ */
public function registerInterface(SourceInterface $interface) : void{ public function registerInterface(NetworkInterface $interface) : void{
$this->server->getPluginManager()->callEvent($ev = new NetworkInterfaceRegisterEvent($interface)); $this->server->getPluginManager()->callEvent($ev = new NetworkInterfaceRegisterEvent($interface));
if(!$ev->isCancelled()){ if(!$ev->isCancelled()){
$interface->start(); $interface->start();
$this->interfaces[$hash = spl_object_hash($interface)] = $interface; $this->interfaces[$hash = spl_object_hash($interface)] = $interface;
if($interface instanceof AdvancedSourceInterface){ if($interface instanceof AdvancedNetworkInterface){
$this->advancedInterfaces[$hash] = $interface; $this->advancedInterfaces[$hash] = $interface;
$interface->setNetwork($this); $interface->setNetwork($this);
} }
@ -123,9 +123,9 @@ class Network{
} }
/** /**
* @param SourceInterface $interface * @param NetworkInterface $interface
*/ */
public function unregisterInterface(SourceInterface $interface) : void{ public function unregisterInterface(NetworkInterface $interface) : void{
$this->server->getPluginManager()->callEvent(new NetworkInterfaceUnregisterEvent($interface)); $this->server->getPluginManager()->callEvent(new NetworkInterfaceUnregisterEvent($interface));
unset($this->interfaces[$hash = spl_object_hash($interface)], $this->advancedInterfaces[$hash]); unset($this->interfaces[$hash = spl_object_hash($interface)], $this->advancedInterfaces[$hash]);
} }

View File

@ -32,7 +32,7 @@ use pocketmine\Player;
/** /**
* Network interfaces are transport layers which can be used to transmit packets between the server and clients. * Network interfaces are transport layers which can be used to transmit packets between the server and clients.
*/ */
interface SourceInterface{ interface NetworkInterface{
/** /**
* Performs actions needed to start the interface after it is registered. * Performs actions needed to start the interface after it is registered.

View File

@ -24,7 +24,7 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe; namespace pocketmine\network\mcpe;
use pocketmine\event\player\PlayerCreationEvent; use pocketmine\event\player\PlayerCreationEvent;
use pocketmine\network\AdvancedSourceInterface; use pocketmine\network\AdvancedNetworkInterface;
use pocketmine\network\mcpe\protocol\BatchPacket; use pocketmine\network\mcpe\protocol\BatchPacket;
use pocketmine\network\mcpe\protocol\DataPacket; use pocketmine\network\mcpe\protocol\DataPacket;
use pocketmine\network\mcpe\protocol\PacketPool; use pocketmine\network\mcpe\protocol\PacketPool;
@ -41,7 +41,7 @@ use raklib\server\ServerHandler;
use raklib\server\ServerInstance; use raklib\server\ServerInstance;
use raklib\utils\InternetAddress; use raklib\utils\InternetAddress;
class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ class RakLibInterface implements ServerInstance, AdvancedNetworkInterface{
/** /**
* Sometimes this gets changed when the MCPE-layer protocol gets broken to the point where old and new can't * Sometimes this gets changed when the MCPE-layer protocol gets broken to the point where old and new can't
* communicate. It's important that we check this to avoid catastrophes. * communicate. It's important that we check this to avoid catastrophes.

View File

@ -27,7 +27,7 @@ declare(strict_types=1);
*/ */
namespace pocketmine\network\query; namespace pocketmine\network\query;
use pocketmine\network\AdvancedSourceInterface; use pocketmine\network\AdvancedNetworkInterface;
use pocketmine\Server; use pocketmine\Server;
use pocketmine\utils\Binary; use pocketmine\utils\Binary;
@ -79,7 +79,7 @@ class QueryHandler{
return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4)); return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4));
} }
public function handle(AdvancedSourceInterface $interface, string $address, int $port, string $packet) : void{ public function handle(AdvancedNetworkInterface $interface, string $address, int $port, string $packet) : void{
$offset = 2; $offset = 2;
$packetType = ord($packet{$offset++}); $packetType = ord($packet{$offset++});
$sessionID = Binary::readInt(substr($packet, $offset, 4)); $sessionID = Binary::readInt(substr($packet, $offset, 4));