Skip to content

Commit

Permalink
About resourcepack encryption...
Browse files Browse the repository at this point in the history
  • Loading branch information
NgLam2911 committed Apr 24, 2022
1 parent 2c0ce56 commit 6edd94c
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugin_data/ResourcePackLoader/config.yml
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
4 changes: 4 additions & 0 deletions plugins/ResourcePackEncryption-master/README.md
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!
7 changes: 7 additions & 0 deletions plugins/ResourcePackEncryption-master/plugin.yml
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
6 changes: 6 additions & 0 deletions plugins/ResourcePackEncryption-master/resources/config.yml
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: []
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 added resource_packs/FI-Symbols-original.mcpack
Binary file not shown.
Binary file modified resource_packs/FI-Symbols.mcpack
Binary file not shown.
Binary file added resource_packs/contents.json
Binary file not shown.

0 comments on commit 6edd94c

Please sign in to comment.