Skip to content

Commit

Permalink
Added compatibility for protocol 18, keep backwards compatibility wit…
Browse files Browse the repository at this point in the history
…h 17, closes #11
  • Loading branch information
shoghicp committed Jul 28, 2014
1 parent be1ee56 commit 559fbef
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 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.2.1-beta
version: 1.2.2-beta
api: 1.0.0
description: "Allows the connection of Minecraft: PC clients to PocketMine-MP servers"
author: shoghicp
Expand Down
28 changes: 16 additions & 12 deletions src/shoghicp/BigBrother/BigBrother.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
namespace shoghicp\BigBrother;

use phpseclib\Crypt\RSA;
use pocketmine\event\player\PlayerRespawnEvent;
use shoghicp\BigBrother\network\protocol\RespawnPacket;
use shoghicp\BigBrother\network\translation\Translator;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerLoginEvent;
use pocketmine\network\protocol\Info;
use pocketmine\plugin\PluginBase;
use shoghicp\BigBrother\network\Info as MCInfo;
use shoghicp\BigBrother\network\ProtocolInterface;
use shoghicp\BigBrother\network\ServerThread;
use shoghicp\BigBrother\network\translation\Translator_17;
use shoghicp\BigBrother\network\translation\Translator_18;
use shoghicp\BigBrother\tasks\GeneratePrivateKey;

class BigBrother extends PluginBase implements Listener{
Expand Down Expand Up @@ -78,8 +79,8 @@ public function onEnable(){
$this->getLogger()->warning("No motd has been set. The server description will be empty.");
}

if(Info::CURRENT_PROTOCOL === 17){
$this->translator = new Translator_17();
if(Info::CURRENT_PROTOCOL === 17 or Info::CURRENT_PROTOCOL === 18){
$this->translator = new Translator_18();
}else{
$this->getLogger()->critical("Couldn't find a protocol translator for #".Info::CURRENT_PROTOCOL .", disabling plugin");
$this->getPluginLoader()->disablePlugin($this);
Expand Down Expand Up @@ -144,17 +145,20 @@ public function onDisable(){
}

/**
* @param PlayerLoginEvent $event
* @param PlayerRespawnEvent $event
*
* @priority MONITOR
* @priority NORMAL
*/
public function onLogin(PlayerLoginEvent $event){
/*$player = $event->getPlayer();
public function onRespawn(PlayerRespawnEvent $event){
$player = $event->getPlayer();
if($player instanceof DesktopPlayer){
if(!$event->isCancelled()){
$player->bigBrother_authenticate();
}
}*/
$pk = new RespawnPacket();
$pk->dimension = 0;
$pk->gamemode = $player->getGamemode();
$pk->difficulty = $player->getServer()->getDifficulty();
$pk->levelType = "default";
$player->putRawPacket($pk);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
use shoghicp\BigBrother\network\protocol\TimeUpdatePacket;
use shoghicp\BigBrother\utils\Binary;

class Translator_17 implements Translator{
class Translator_18 implements Translator{



Expand Down

0 comments on commit 559fbef

Please sign in to comment.