-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions
45
src/shoghicp/BigBrother/network/protocol/BlockChangePacket.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* BigBrother plugin for PocketMine-MP | ||
* Copyright (C) 2014 shoghicp <https://github.com/shoghicp/BigBrother> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
namespace shoghicp\BigBrother\network\protocol; | ||
|
||
use shoghicp\BigBrother\network\Packet; | ||
|
||
class BlockChangePacket extends Packet{ | ||
|
||
public $x; | ||
public $y; | ||
public $z; | ||
public $blockId; | ||
public $blockMeta; | ||
|
||
public function pid(){ | ||
return 0x23; | ||
} | ||
|
||
public function encode(){ | ||
$this->putInt($this->x); | ||
$this->putByte($this->y); | ||
$this->putInt($this->z); | ||
$this->putVarInt($this->blockId); | ||
$this->putByte($this->blockMeta); | ||
} | ||
|
||
public function decode(){ | ||
|
||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/shoghicp/BigBrother/network/protocol/EntityHeadLookPacket.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* BigBrother plugin for PocketMine-MP | ||
* Copyright (C) 2014 shoghicp <https://github.com/shoghicp/BigBrother> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
namespace shoghicp\BigBrother\network\protocol; | ||
|
||
use shoghicp\BigBrother\network\Packet; | ||
|
||
class EntityHeadLookPacket extends Packet{ | ||
|
||
public $eid; | ||
public $yaw; | ||
|
||
public function pid(){ | ||
return 0x19; | ||
} | ||
|
||
public function encode(){ | ||
$this->putInt($this->eid); | ||
$this->putByte((int) ($this->yaw * (256 / 360))); | ||
} | ||
|
||
public function decode(){ | ||
|
||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/shoghicp/BigBrother/network/protocol/PlayerBlockPlacementPacket.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* BigBrother plugin for PocketMine-MP | ||
* Copyright (C) 2014 shoghicp <https://github.com/shoghicp/BigBrother> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
namespace shoghicp\BigBrother\network\protocol; | ||
|
||
use shoghicp\BigBrother\network\Packet; | ||
|
||
class PlayerBlockPlacementPacket extends Packet{ | ||
|
||
public $x; | ||
public $y; | ||
public $z; | ||
public $direction; | ||
/** @var \pocketmine\item\Item */ | ||
public $heldItem; | ||
public $cursorX; | ||
public $cursorY; | ||
public $cursorZ; | ||
|
||
public function pid(){ | ||
return 0x08; | ||
} | ||
|
||
public function encode(){ | ||
|
||
} | ||
|
||
public function decode(){ | ||
$this->x = $this->getInt(); | ||
$this->y = $this->getByte(); | ||
$this->z = $this->getInt(); | ||
$this->direction = $this->getByte(); | ||
$this->heldItem = $this->getSlot(); | ||
$this->cursorX = $this->getByte(); | ||
$this->cursorY = $this->getByte(); | ||
$this->cursorZ = $this->getByte(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/shoghicp/BigBrother/network/protocol/PlayerDiggingPacket.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* BigBrother plugin for PocketMine-MP | ||
* Copyright (C) 2014 shoghicp <https://github.com/shoghicp/BigBrother> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
namespace shoghicp\BigBrother\network\protocol; | ||
|
||
use shoghicp\BigBrother\network\Packet; | ||
|
||
class PlayerDiggingPacket extends Packet{ | ||
|
||
public $status; | ||
public $x; | ||
public $y; | ||
public $z; | ||
public $face; | ||
|
||
public function pid(){ | ||
return 0x07; | ||
} | ||
|
||
public function encode(){ | ||
|
||
} | ||
|
||
public function decode(){ | ||
$this->status = $this->getByte(); | ||
$this->x = $this->getInt(); | ||
$this->y = $this->getByte(); | ||
$this->z = $this->getInt(); | ||
$this->face = $this->getByte(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/* | ||
* BigBrother plugin for PocketMine-MP | ||
* Copyright (C) 2014 shoghicp <https://github.com/shoghicp/BigBrother> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
*/ | ||
|
||
namespace shoghicp\BigBrother\utils; | ||
|
||
class AES{ | ||
private $key, $keyLenght, $IV, $IVLenght, $enc, $dec, $mode, $algorithm; | ||
|
||
function __construct($bits, $mode, $blockSize){ | ||
$this->algorithm = "rijndael-".intval($bits); | ||
$this->mode = strtolower($mode); | ||
$mcrypt = mcrypt_module_open($this->algorithm, "", $this->mode, ""); | ||
$this->IVLenght = mcrypt_enc_get_iv_size($mcrypt); | ||
mcrypt_module_close($mcrypt); | ||
$this->keyLenght = $bits >> 3; | ||
$this->setKey(); | ||
$this->setIV(); | ||
$this->init(); | ||
} | ||
|
||
public function init(){ | ||
if(is_resource($this->enc)){ | ||
mcrypt_generic_deinit($this->enc); | ||
mcrypt_module_close($this->enc); | ||
} | ||
$this->enc = mcrypt_module_open($this->algorithm, "", $this->mode, ""); | ||
mcrypt_generic_init($this->enc, $this->key, $this->IV); | ||
|
||
if(is_resource($this->dec)){ | ||
mcrypt_generic_deinit($this->dec); | ||
mcrypt_module_close($this->dec); | ||
} | ||
$this->dec = mcrypt_module_open($this->algorithm, "", $this->mode, ""); | ||
mcrypt_generic_init($this->dec, $this->key, $this->IV); | ||
} | ||
|
||
public function setKey($key = ""){ | ||
$this->key = str_pad($key, $this->keyLenght, "\x00", STR_PAD_RIGHT); | ||
} | ||
|
||
public function setIV($IV = ""){ | ||
$this->IV = str_pad($IV, $this->IVLenght, "\x00", STR_PAD_RIGHT); | ||
} | ||
|
||
public function encrypt($plaintext){ | ||
return mcrypt_generic($this->enc, $plaintext); | ||
} | ||
|
||
public function decrypt($ciphertext){ | ||
return mdecrypt_generic($this->dec, $ciphertext); | ||
} | ||
|
||
} |