Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.15.x Support #54

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ General Public License ever published by the Free Software Foundation.
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Library.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# BigBrother
Allows the connection of Minecraft: PC clients to PocketMine-MP servers. Made for PocketMine-MP

##Changelog: Update 6:
* More Fixes
* More Packets (mostly from lolcraftboy14)
* Note: Player from Minecraft PC sometimes lags.

###Changelog: Update 5:
* Works Again MCPE 0.15.x and Minecraft PC 1.8.x
* First Step on Protocols

###Changelog: Update 4:
* Bring a few changes of iPocketTeam

###Changelog: Update 3:
* Change the Source to shoghicp and rewrite the previous changes.
* Back again to protocol 1.8 (but is giving the same results in 1.10.0)
* I've set a fixed user (Hello) until the plugin works properly again (Remember to change the user to test it)
* Current issue, user logged in and kicked out for being in a different world.

##Works Again (Not properly).
6 changes: 2 additions & 4 deletions plugin.yml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: BigBrother
version: 1.5.0-beta
api: 1.10.0
version: 1.15.0 beta
api: 2.0.0
description: "Allows the connection of Minecraft: PC clients to PocketMine-MP servers"
author: shoghicp
website: https://github.com/shoghicp/BigBrother
load: STARTUP
main: shoghicp\BigBrother\BigBrother
softdepend:
- SimpleAuth
Binary file added resources/alex.yml
Binary file not shown.
11 changes: 9 additions & 2 deletions resources/config.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ network-compression-threshold: 256
motd: "§bPocketMine-MP server using §6§lBigBrother§r§b plugin\n§aConnect to Minecraft: PE servers from PC clients"

#Use Mojang services to authenticate players
online-mode: true
online-mode: false

#Automatically authenticate players on SimpleAuth that were authenticated via Mojang servers
online-mode-simpleauth: false
Expand All @@ -21,4 +21,11 @@ online-mode-simpleauth: false
#kickold: kicks the player that was on the server
#kicknew: kicks the player that is connecting
#none: do nothing, leave it up to PocketMine-MP and other plugins
action-on-conflict: none
action-on-conflict: none

#This is Skin Settings
skin-yml: "steve.yml"
skin-slim: false

#This is ResourcePackURL Settings
resourcepackurl: "false"
Empty file modified resources/server-icon.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/steve.yml
Binary file not shown.
Empty file modified src/phpseclib/Crypt/AES.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/Crypt/Base.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/Crypt/DES.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/Crypt/Hash.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/Crypt/RC4.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/Crypt/RSA.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/Crypt/Random.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/Crypt/Rijndael.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/Crypt/TripleDES.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/File/ASN1.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/File/X509.php
100644 → 100755
Empty file.
Empty file modified src/phpseclib/LICENSE
100644 → 100755
Empty file.
11 changes: 7 additions & 4 deletions src/phpseclib/Math/BigInteger.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,14 @@ function __construct($x = 0, $base = 10)
}
}

switch ( MATH_BIGINTEGER_MODE ) {
switch (MATH_BIGINTEGER_MODE) {
case MATH_BIGINTEGER_MODE_GMP:
if (is_resource($x) && get_resource_type($x) == 'GMP integer') {
$this->value = $x;
return;
switch (true) {
case is_resource($x) && get_resource_type($x) == 'GMP integer':
// PHP 5.6 switched GMP from using resources to objects
case is_object($x) && get_class($x) == 'GMP':
$this->value = $x;
return;
}
$this->value = gmp_init(0);
break;
Expand Down
18 changes: 6 additions & 12 deletions src/shoghicp/BigBrother/BigBrother.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use shoghicp\BigBrother\network\Info as MCInfo;
use shoghicp\BigBrother\network\ProtocolInterface;
use shoghicp\BigBrother\network\ServerThread;
use shoghicp\BigBrother\network\translation\Translator_20;
use shoghicp\BigBrother\network\translation\TranslatorProtocol;
use shoghicp\BigBrother\tasks\GeneratePrivateKey;

class BigBrother extends PluginBase implements Listener{
Expand Down Expand Up @@ -66,6 +66,8 @@ public function onEnable(){

$this->saveDefaultConfig();
$this->saveResource("server-icon.png", false);
$this->saveResource("alex.yml", false);
$this->saveResource("steve.yml", false);
$this->reloadConfig();

$this->onlineMode = (bool) $this->getConfig()->get("online-mode");
Expand All @@ -78,14 +80,7 @@ public function onEnable(){
$this->getLogger()->warning("No motd has been set. The server description will be empty.");
}

if(Info::CURRENT_PROTOCOL === 20){
$this->translator = new Translator_20();
}else{
$this->getLogger()->critical("Couldn't find a protocol translator for #".Info::CURRENT_PROTOCOL .", disabling plugin");
$this->getPluginLoader()->disablePlugin($this);
return;
}

$this->translator = new TranslatorProtocol();
$this->rsa = new RSA();

$this->getServer()->getPluginManager()->registerEvents($this, $this);
Expand Down Expand Up @@ -114,9 +109,8 @@ protected function enableServer(){
$interface = $this->getConfig()->get("interface");
$this->getLogger()->info("Starting Minecraft: PC server on ".($interface === "0.0.0.0" ? "*" : $interface).":$port version ".MCInfo::VERSION);
$this->thread = new ServerThread($this->externalQueue, $this->internalQueue, $this->getServer()->getLogger(), $this->getServer()->getLoader(), $port, $interface, (string) $this->getConfig()->get("motd"), $this->getDataFolder() . "server-icon.png");

$this->interface = new ProtocolInterface($this, $this->thread, $this->translator);
$this->getServer()->addInterface($this->interface);
$this->getServer()->getNetwork()->registerInterface($this->interface);
}

/**
Expand All @@ -140,7 +134,7 @@ public function decryptBinary($secret){
public function onDisable(){
//TODO: make it fully /reload compatible (remove from server)
if($this->interface instanceof ProtocolInterface){
$this->getServer()->removeInterface($this->interface);
$this->getServer()->getNetwork()->unregisterInterface($this->interface);
$this->thread->join();
}
}
Expand Down
94 changes: 94 additions & 0 deletions src/shoghicp/BigBrother/DesktopChunk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace shoghicp\BigBrother;

use pocketmine\Player;
use pocketmine\level\Level;

class DesktopChunk{
private $player, $chunkX, $chunkZ, $provider;

public function __construct(Player $player, $chunkX, $chunkZ){
$this->player = $player;
$this->chunkX = $chunkX;
$this->chunkZ = $chunkZ;
$this->provider = $provider = $player->getLevel()->getProvider();
$this->data = $this->generateChunk();
}

public function generateChunk(){
$chunk = $this->provider->getChunk($this->chunkX, $this->chunkZ, false);
$chunkblockIds = $chunk->getBlockIdArray();
$chunkblockData = $chunk->getBlockDataArray();
$chunkblockSkyLight = $chunk->getBlockSkyLightArray();
$chunkblockLight = $chunk->getBlockLightArray();

$chunkbiomeIds = $chunk->getBiomeIdArray();

$compressionLevel = Level::$COMPRESSION_LEVEL;

$ids = ["", "", "", "", "", "", "", ""];
$blockLight = $skyLight = [[], [], [], [], [], [], [], []];

//Complexity: O(MG)
for($Y = 0; $Y < 8; ++$Y){
for($y = 0; $y < 16; ++$y){
$offset = ($Y << 4) + $y;
for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){
$index = ($x << 11) + ($z << 7) + $offset;
$halfIndex = ($x << 10) + ($z << 6) + ($offset >> 1);
if(($y & 1) === 0){
$data = ord($chunkblockData[$halfIndex]) & 0x0F;
$bLight = ord($chunkblockLight[$halfIndex]) & 0x0F;

//$sLight = ord($blockSkyLight[$halfIndex]) & 0x0F;
}else{
$data = ord($chunkblockData[$halfIndex]) >> 4;
$bLight = ord($chunkblockLight[$halfIndex]) >> 4;
//$sLight = ord($blockSkyLight[$halfIndex]) >> 4;
}
$ids[$Y] .= pack("v", (ord($chunkblockIds[$index]) << 4) | $data);

$blockLight[$Y][] = $bLight;
//$skyLight[$Y][] = $sLight;
}
}
}
}

foreach($blockLight as $Y => $data){
$final = "";
$len = count($data);
for($i = 0; $i < $len; $i += 2){
$final .= chr(($data[$i + 1] << 4) | $data[$i]);
}
$blockLight[$Y] = $final;
}

/*
foreach($skyLight as $Y => $data){
$final = "";
$len = count($data);
for($i = 0; $i < $len; $i += 2){
$final .= chr(($data[$i + 1] << 4) | $data[$i]);
}
$skyLight[$Y] = $final;
}
*/

$skyLight = [$half = str_repeat("\xff", 4096), $half, $half, $half, $half, $half, $half, $half];

$payload = implode($ids) . implode($blockLight) . implode($skyLight) . $chunkbiomeIds;

return $payload;
}

public function getData(){
if(isset($this->data)){
return $this->data;
}
return null;
}

}
Loading