Files
firefrost-services/services/modpack-version-checker/blueprint-extension/admin/controller.php
Claude (Chronicler #62) 35aded99fe feat(modpackchecker): add Blueprint extension Phase 2 - core architecture
Task #26 Phase 2 Complete — Core Architecture

Files created:
- conf.yml: Blueprint manifest with all paths configured
- admin/controller.php: Admin settings controller (BYOK key, webhook, interval)
- admin/view.blade.php: Admin UI with Trinity-inspired styling
- controllers/ModpackAPIController.php: Client API with all 4 platform integrations
- routes/client.php: Client route for manual version checks
- views/server/wrapper.tsx: React component for server overview page
- database/migrations: Per-server tracking table

Platform Support (all implemented):
- CurseForge (BYOK API key)
- Modrinth (open, no key)
- Technic (open, no key)
- FTB/modpacks.ch (open, no key)

Detection Strategy:
1. Egg Variables (MODPACK_PLATFORM, MODPACK_ID, platform-specific vars)
2. File fingerprinting via DaemonFileRepository (manifest.json, modrinth.index.json)
3. Manual override via admin UI

Next: Phase 3 - Testing on Dev Panel (64.50.188.128)

Signed-off-by: Claude (Chronicler #62) <claude@firefrostgaming.com>
2026-04-06 00:35:01 +00:00

83 lines
3.1 KiB
PHP

<?php
namespace Pterodactyl\Http\Controllers\Admin\Extensions\modpackchecker;
use Illuminate\View\View;
use Illuminate\View\Factory as ViewFactory;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdminLibrary as BlueprintExtensionLibrary;
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
use Illuminate\Http\RedirectResponse;
class modpackcheckerExtensionController extends Controller
{
public function __construct(
private ViewFactory $view,
private BlueprintExtensionLibrary $blueprint,
) {}
public function index(): View
{
// Get current settings
$curseforge_api_key = $this->blueprint->dbGet('modpackchecker', 'curseforge_api_key');
$discord_webhook_url = $this->blueprint->dbGet('modpackchecker', 'discord_webhook_url');
$check_interval = $this->blueprint->dbGet('modpackchecker', 'check_interval');
$tier = $this->blueprint->dbGet('modpackchecker', 'tier');
// Set defaults if empty
if ($check_interval == '') {
$this->blueprint->dbSet('modpackchecker', 'check_interval', 'daily');
$check_interval = 'daily';
}
if ($tier == '') {
$this->blueprint->dbSet('modpackchecker', 'tier', 'standard');
$tier = 'standard';
}
return $this->view->make(
'admin.extensions.modpackchecker.index', [
'curseforge_api_key' => $curseforge_api_key,
'discord_webhook_url' => $discord_webhook_url,
'check_interval' => $check_interval,
'tier' => $tier,
'root' => '/admin/extensions/modpackchecker',
'blueprint' => $this->blueprint,
]
);
}
/**
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function update(modpackcheckerSettingsFormRequest $request): RedirectResponse
{
$this->blueprint->dbSet('modpackchecker', 'curseforge_api_key', $request->input('curseforge_api_key') ?? '');
$this->blueprint->dbSet('modpackchecker', 'discord_webhook_url', $request->input('discord_webhook_url') ?? '');
$this->blueprint->dbSet('modpackchecker', 'check_interval', $request->input('check_interval') ?? 'daily');
return redirect()->route('admin.extensions.modpackchecker.index')->with('success', 'Settings saved successfully.');
}
}
class modpackcheckerSettingsFormRequest extends AdminFormRequest
{
public function rules(): array
{
return [
'curseforge_api_key' => 'nullable|string|max:500',
'discord_webhook_url' => 'nullable|url|max:500',
'check_interval' => 'required|in:daily,12h,6h',
];
}
public function attributes(): array
{
return [
'curseforge_api_key' => 'CurseForge API Key',
'discord_webhook_url' => 'Discord Webhook URL',
'check_interval' => 'Check Interval',
];
}
}