Skip to content

Commit

Permalink
Updated to protocol #17
Browse files Browse the repository at this point in the history
  • Loading branch information
shoghicp committed Jun 30, 2014
1 parent fac6d27 commit 0c0e152
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 7 additions & 5 deletions src/shoghicp/BigBrother/BigBrother.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/shoghicp/BigBrother/DesktopPlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{



Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -246,8 +248,6 @@ public function serverToInterface(DesktopPlayer $player, DataPacket $packet){
$packets[] = $pk;
return $packets;



default:
return null;
}
Expand Down

0 comments on commit 0c0e152

Please sign in to comment.