Skip to content

Commit

Permalink
Merge pull request #11 from taylordevs/master
Browse files Browse the repository at this point in the history
Support Encrypt Key
  • Loading branch information
NhanAZ authored Jun 22, 2023
2 parents bcecb29 + fed9cd2 commit c6ef1dc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/NhanAZ/libBedrock/ResourcePackManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ResourcePackManager {

private static ?ResourcePack $pack = null;

public static function registerResourcePack(PluginBase $plugin) : void {
public static function registerResourcePack(PluginBase $plugin, string $encryptKey = "") : void {
$plugin->getLogger()->debug('Compiling resource pack');
$zip = new \ZipArchive();
$zip->open(Path::join($plugin->getDataFolder(), $plugin->getName() . '.mcpack'), \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
Expand All @@ -47,6 +47,7 @@ public static function registerResourcePack(PluginBase $plugin) : void {
$plugin->getLogger()->debug('Registering resource pack');
$plugin->getLogger()->debug('Resource pack compiled');
self::$pack = $pack = new ZippedResourcePack(Path::join($plugin->getDataFolder(), $plugin->getName() . '.mcpack'));
$packId = $pack->getPackId();
$manager = $plugin->getServer()->getResourcePackManager();

$reflection = new \ReflectionClass($manager);
Expand All @@ -70,6 +71,10 @@ public static function registerResourcePack(PluginBase $plugin) : void {
$property = $reflection->getProperty("serverForceResources");
$property->setValue($manager, true);

if ($encryptKey !== "") {
$manager->setPackEncryptionKey($packId, $encryptKey);
}

$plugin->getLogger()->debug('Resource pack registered');
}

Expand Down

0 comments on commit c6ef1dc

Please sign in to comment.