-
Notifications
You must be signed in to change notification settings - Fork 2
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
8 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
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,7 @@ | ||
# Resource pack encryption configuration file | ||
# This file is used to parse the encrypted resource pack data | ||
# Usage: | ||
# resource-packs: | ||
# uuid-of-resource-pack: content-key | ||
resource-packs: | ||
0fc0a768-9b98-49f7-b534-7b3ce8f570d8: encryptmypack.com-FPQVLT3ZMM7Z3T |
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,4 @@ | ||
# ResourcePackEncryption | ||
|
||
> Ever been in the gophertunnel discord asking how decrypt hive pack? Did you get rejected and switch up to how to encrypt my pack? Well look no further, https://encryptmypack.com/ (made in Go) has everything a pro pocketmine php developer might ever need! | ||
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,7 @@ | ||
name: ResourcePackLoader | ||
author: alvin0319 | ||
main: alvin0319\ResourcePackEncryption\Loader | ||
version: 1.0.0 | ||
api: 4.0.0 | ||
|
||
load: STARTUP |
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,6 @@ | ||
# Resource pack encryption configuration file | ||
# This file is used to parse the encrypted resource pack data | ||
# Usage: | ||
# resource-packs: | ||
# uuid-of-resource-pack: content-key | ||
resource-packs: [] |
42 changes: 42 additions & 0 deletions
42
plugins/ResourcePackEncryption-master/src/alvin0319/ResourcePackEncryption/Loader.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,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace alvin0319\ResourcePackEncryption; | ||
|
||
use pocketmine\event\EventPriority; | ||
use pocketmine\event\server\DataPacketSendEvent; | ||
use pocketmine\network\mcpe\protocol\ResourcePacksInfoPacket; | ||
use pocketmine\network\mcpe\protocol\types\resourcepacks\ResourcePackInfoEntry; | ||
use pocketmine\plugin\PluginBase; | ||
|
||
final class Loader extends PluginBase{ | ||
|
||
/** @var string[] */ | ||
private array $encryptionKeys = []; | ||
|
||
protected function onEnable() : void{ | ||
$this->saveDefaultConfig(); | ||
foreach($this->getServer()->getResourcePackManager()->getResourceStack() as $resourcePack){ | ||
$uuid = $resourcePack->getPackId(); | ||
if($this->getConfig()->getNested("resource-packs.{$uuid}", "") !== ""){ | ||
$encryptionKey = $this->getConfig()->getNested("resource-packs.{$uuid}"); | ||
$this->encryptionKeys[$uuid] = $encryptionKey; | ||
$this->getLogger()->debug("Loaded encryption key for resource pack $uuid"); | ||
} | ||
} | ||
$this->getServer()->getPluginManager()->registerEvent(DataPacketSendEvent::class, function(DataPacketSendEvent $event) : void{ | ||
$packets = $event->getPackets(); | ||
foreach($packets as $packet){ | ||
if($packet instanceof ResourcePacksInfoPacket){ | ||
foreach($packet->resourcePackEntries as $index => $entry){ | ||
if(isset($this->encryptionKeys[$entry->getPackId()])){ | ||
$contentId = $this->encryptionKeys[$entry->getPackId()]; | ||
$packet->resourcePackEntries[$index] = new ResourcePackInfoEntry($entry->getPackId(), $entry->getVersion(), $entry->getSizeBytes(), $contentId, $entry->getSubPackName(), $entry->getPackId(), $entry->hasScripts(), $entry->isRtxCapable()); | ||
} | ||
} | ||
} | ||
} | ||
}, EventPriority::HIGHEST, $this); | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.