From 0c0e152f3b2deff29d089f762073ee61f7906464 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 1 Jul 2014 01:24:22 +0200 Subject: [PATCH] Updated to protocol #17 --- plugin.yml | 2 +- src/shoghicp/BigBrother/BigBrother.php | 12 ++++--- src/shoghicp/BigBrother/DesktopPlayer.php | 2 +- .../{Translator_16.php => Translator_17.php} | 32 +++++++++---------- 4 files changed, 25 insertions(+), 23 deletions(-) rename src/shoghicp/BigBrother/network/translation/{Translator_16.php => Translator_17.php} (94%) diff --git a/plugin.yml b/plugin.yml index dae6fafd..84ae9a1b 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,5 +1,5 @@ name: BigBrother -version: 1.1.2-beta +version: 1.2.0-beta api: 1.0.0 description: "Allows the connection of Minecraft: PC clients to PocketMine-MP servers" author: shoghicp diff --git a/src/shoghicp/BigBrother/BigBrother.php b/src/shoghicp/BigBrother/BigBrother.php index 5a3a3e49..5810b05f 100644 --- a/src/shoghicp/BigBrother/BigBrother.php +++ b/src/shoghicp/BigBrother/BigBrother.php @@ -26,7 +26,7 @@ use shoghicp\BigBrother\network\Info as MCInfo; use shoghicp\BigBrother\network\ProtocolInterface; use shoghicp\BigBrother\network\ServerThread; -use shoghicp\BigBrother\network\translation\Translator_16; +use shoghicp\BigBrother\network\translation\Translator_17; use shoghicp\BigBrother\tasks\GeneratePrivateKey; class BigBrother extends PluginBase implements Listener{ @@ -78,8 +78,8 @@ public function onEnable(){ $this->getLogger()->warning("No motd has been set. The server description will be empty."); } - if(Info::CURRENT_PROTOCOL === 16){ - $this->translator = new Translator_16(); + if(Info::CURRENT_PROTOCOL === 17){ + $this->translator = new Translator_17(); }else{ $this->getLogger()->critical("Couldn't find a protocol translator for #".Info::CURRENT_PROTOCOL .", disabling plugin"); $this->getPluginLoader()->disablePlugin($this); @@ -137,8 +137,10 @@ public function decryptBinary($secret){ public function onDisable(){ //TODO: make it fully /reload compatible (remove from server) - $this->interface->shutdown(); - $this->thread->join(); + if($this->interface instanceof ProtocolInterface){ + $this->interface->shutdown(); + $this->thread->join(); + } } /** diff --git a/src/shoghicp/BigBrother/DesktopPlayer.php b/src/shoghicp/BigBrother/DesktopPlayer.php index def86e1d..0e13a73a 100644 --- a/src/shoghicp/BigBrother/DesktopPlayer.php +++ b/src/shoghicp/BigBrother/DesktopPlayer.php @@ -236,7 +236,7 @@ public function sendNextChunk(){ $this->spawnToAll(); - $this->server->getPluginManager()->callEvent($ev = new PlayerJoinEvent($this, $this->getName() . " joined the game")); + $this->server->getPluginManager()->callEvent($ev = new PlayerJoinEvent($this, TextFormat::YELLOW . $this->getName() . " joined the game")); if(strlen(trim($ev->getJoinMessage())) > 0){ $this->server->broadcastMessage($ev->getJoinMessage()); } diff --git a/src/shoghicp/BigBrother/network/translation/Translator_16.php b/src/shoghicp/BigBrother/network/translation/Translator_17.php similarity index 94% rename from src/shoghicp/BigBrother/network/translation/Translator_16.php rename to src/shoghicp/BigBrother/network/translation/Translator_17.php index 81476015..01afcfa9 100644 --- a/src/shoghicp/BigBrother/network/translation/Translator_16.php +++ b/src/shoghicp/BigBrother/network/translation/Translator_17.php @@ -38,7 +38,7 @@ use shoghicp\BigBrother\network\protocol\TimeUpdatePacket; use shoghicp\BigBrother\utils\Binary; -class Translator_16 implements Translator{ +class Translator_17 implements Translator{ @@ -204,21 +204,23 @@ public function serverToInterface(DesktopPlayer $player, DataPacket $packet){ return $packets; } - case Info::MOVE_ENTITY_PACKET_POSROT: + case Info::MOVE_ENTITY_PACKET: $packets = []; - $pk = new EntityTeleportPacket(); - $pk->eid = $packet->eid; - $pk->x = $packet->x; - $pk->y = $packet->y; - $pk->z = $packet->z; - $pk->yaw = $packet->yaw; - $pk->pitch = $packet->pitch; - $packets[] = $pk; + foreach($packet->entities as $d){ + $pk = new EntityTeleportPacket(); + $pk->eid = $d[0]; + $pk->x = $d[1]; + $pk->y = $d[2]; + $pk->z = $d[3]; + $pk->yaw = $d[4]; + $pk->pitch = $d[5]; + $packets[] = $pk; - $pk = new EntityHeadLookPacket(); - $pk->eid = $packet->eid; - $pk->yaw = $packet->yaw; - $packets[] = $pk; + $pk = new EntityHeadLookPacket(); + $pk->eid = $d[0]; + $pk->yaw = $d[4]; + $packets[] = $pk; + } return $packets; case Info::ADD_PLAYER_PACKET: @@ -246,8 +248,6 @@ public function serverToInterface(DesktopPlayer $player, DataPacket $packet){ $packets[] = $pk; return $packets; - - default: return null; }