First, we can install the addon for you for free. Just create a ticket in our Discord and we will install it for you.

Uploading the addon

  1. Upload the "panel_upload" folder to your pterodactyl installation directory.

Edit Server Controller

  1. Open the file app/Http/Controllers/Api/Client/Servers/ServerController.php
  2. Find this code:
                'user_permissions' => $this->permissionsService->handle($server, $request->user()),
        
  1. Add this code below:
                'egg_id' => $server->egg_id,
        

Edit Assets Composer

  1. Open the file app/Http/ViewComposers/AssetComposer.php
  2. Uder all use statements add this code:
use Pterodactyl\Models\PocketAddonsConfig;
        
  1. Find this code:
        $view->with('asset', $this->assetHashService);
        
  1. Add this code before
        $pe_egg_id = (int) PocketAddonsConfig::first()->pe_eggs;
        
  1. Find this code:
            'recaptcha' => [
                        'enabled' => config('recaptcha.enabled', false),
                        'siteKey' => config('recaptcha.website_key') ?? '',
                    ],
        
  1. Add this code below:
            'pocketmine_egg' => $pe_egg_id,
        

Edit Server getter file

  1. Open the file resources/scripts/api/server/getServer.ts
  2. Find this code:
export default (uuid: string): Promise<[Server, string[]]> => {
        
  1. Replace it with this code:
export default (uuid: string): Promise<[Server, string[], number]> => {
        
  1. Find this code:
                    data.meta?.is_server_owner ? ['*'] : data.meta?.user_permissions || [],
        
  1. Add this code below:
                    data.meta?.egg_id || 0,
        

Edit Server Router file

  1. Open the file resources/scripts/routers/ServerRouter.tsx
  2. Under all import statements add this code:
import { ApplicationStore } from '@/state';
        
  1. Find this code:
    const getServer = ServerContext.useStoreActions((actions) => actions.server.getServer);
            const clearServerState = ServerContext.useStoreActions((actions) => actions.clearServerState)
        
  1. Add this code below:
    const eggId = ServerContext.useStoreState((state) => state.server.eggId);
            const pocketmineEggid = useStoreState((state: ApplicationStore) => state.settings.data!.pocketmine_egg);
        
  1. Find this code:
                                        route.permission ? (
                                                    <Can key={route.path} action={route.permission} matchAny>
                                                        <NavLink to={to(route.path, true)} exact={route.exact}>
                                                            {route.name}
                                                        </NavLink>
                                                    </Can>
                                                ) : (
                                                    <NavLink key={route.path} to={to(route.path, true)} exact={route.exact}>
                                                        {route.name}
                                                    </NavLink>
                                                )
        
  1. Replace it with this code:
                                        route.peEggId && pocketmineEggid !== eggId ? null : (
                                                    route.permission ? (
                                                        <Can key={route.path} action={route.permission} matchAny>
                                                            <NavLink to={to(route.path, true)} exact={route.exact}>
                                                                {route.name}
                                                            </NavLink>
                                                        </Can>
                                                    ) : (
                                                        <NavLink key={route.path} to={to(route.path, true)} exact={route.exact}>
                                                            {route.name}
                                                        </NavLink>
                                                    )
                                                )
        
  1. Find this code:
                                    {routes.server.map(({ path, permission, component: Component }) => (
                                                <PermissionRoute key={path} permission={permission} path={to(path)} exact>
                                                    <Spinner.Suspense>
                                                        <Component />
                                                    </Spinner.Suspense>
                                                </PermissionRoute>
                                            ))}
        
  1. Replace it with this code:
                                    {routes.server.map(({ path, permission, component: Component, peEggId }) => (
                                                peEggId && pocketmineEggid !== eggId ? null : (
                                                    <PermissionRoute key={path} permission={permission} path={to(path)} exact>
                                                        <Spinner.Suspense>
                                                            <Component />
                                                        </Spinner.Suspense>
                                                    </PermissionRoute>
                                                )
                                            ))}
        

Edit routes file

  1. Open the file resources/scripts/routers/routes.ts
  2. Under all import statements add this code:
import PocketAddonsContainer from '@/components/server/pocketaddons/PocketAddonsContainer';
        
  1. Find the code:
    permission: string | string[] | null;
        
  1. Add this code below:
    peEggId?: boolean;
        
  1. Find this code:
        {
                    path: '/statistics',
                    permission: null,
                    name: 'Statistics',
                    component: StatisticsContainer,
                },
        
  1. Add this code below:
        {
                    path: '/pocketaddons',
                    permission: null,
                    name: 'PocketAddons',
                    peEggId: true,
                    component: PocketAddonsContainer,
                },
        

Edit server state file

  1. Open the file resources/scripts/state/server/index.ts
  2. Under all import statements add this code:
import pocketaddons, { PocketAddonsStore } from '@/state/server/pocketaddons';
        
  1. Find this code:
    permissions: string[];
        
  1. Add this code below:
    eggId?: number;
        
  1. Find this code:
    setPermissions: Action<ServerDataStore, string[]>;
        
  1. Add this code below:
    setEggId: Action<ServerDataStore, number>;
        
  1. Find this code:
        const [server, permissions] = await getServer(payload);
        
  1. Replace it with this code:
        const [server, permissions, eggId] = await getServer(payload);
        
  1. Find the code:
        actions.setPermissions(permissions);
        
  1. Add this code below:
        actions.setEggId(eggId);
        
  1. Find this code:
    setPermissions: action((state, payload) => {
                if (!isEqual(payload, state.permissions)) {
                    state.permissions = payload;
                }
            }),
        
  1. Add this code below:
    setEggId: action((state, payload) => {
                if (!isEqual(payload, state.eggId)) {
                    state.eggId = payload;
                }
            }),
        
  1. Find this code:
    status: ServerStatusStore;
        
  1. Add this code below:
    pocketaddons: PocketAddonsStore;
        
  1. Find this code:
        schedules,
        
  1. Add this code below:
        pocketaddons,
        
  1. Find this code:
            state.schedules.data = [];
        
  1. Add this code below:
            state.server.eggId = undefined;
                    state.pocketaddons.data = [];
        

Edit Settings State

  1. Open the file resources/scripts/state/settings.ts
  2. Find this code:
        enabled: boolean;
                siteKey: string;
            };
        
  1. Add this code below:
    pocketmine_egg: number;
        

Edit admin layout file

  1. Open the file resources/views/layouts/admin.blade.php
  2. Find this code:
                        <li class="{{ ! starts_with(Route::currentRouteName(), 'admin.nests') ?: 'active' }}">
                                    <a href="{{ route('admin.nests') }}">
                                        <i class="fa fa-th-large"></i> <span>Nests</span>
                                    </a>
                                </li>
        
  1. Add this code below:
                        <li class="header">POCKET ADDONS</li>
                                <li class="{{ ! starts_with(Route::currentRouteName(), 'admin.pocketaddons') ?: 'active' }}">
                                    <a href="{{ route('admin.pocketaddons') }}">
                                        <i class="fa fa-cubes"></i> <span>PocketAddons</span>
                                    </a>
                                </li>
        

Edit admin routes file

  1. Open the file routes/admin.php

  2. Under all use statements add this code:

use Pterodactyl\Http\Controllers\Admin\PocketAddons\PocketAddonsController;
        
  1. Add this code at the end of the file:
/**
         * --------------------------------------------------------------------------
         * Pocket addons Controller Routes
         * --------------------------------------------------------------------------
         *
         * Endpoint: /admin/pocketaddons
         */
        Route::group(['prefix' => 'pocketaddons'], function () {
            Route::get('/', [PocketAddonsController::class, 'index'])->name('admin.pocketaddons');
            Route::patch('/', [PocketAddonsController::class, 'update']);
        });
        

Edit Client API routes file

  1. Open the file routes/api-client.php
  2. Under all use statements add this code:
use Pterodactyl\Http\Controllers\Api\Client\Servers\PocketAddons\getPocketAddons;
        use Pterodactyl\Http\Controllers\Api\Client\Servers\PocketAddons\InstallAddon;
        
  1. Find this code:
    Route::post('/command', [Client\Servers\CommandController::class, 'index']);
            Route::post('/power', [Client\Servers\PowerController::class, 'index']);
        
  1. Add this code below:
    Route::get('/pocketaddons', [getPocketAddons::class, 'get']);
            Route::post('/pocketaddons/install', [InstallAddon::class, 'install']);
        

Commands

  1. run theses commands:
php artisan migrate --seed --force
        php artisan db:seed pocketAddonsConfig
        php artisan view:clear
        php artisan cache:clear
        
  1. build the panel: refer to the pterodactyl docs

  2. run theses commands:

chown -R www-data:www-data /var/www/pterodactyl/*
        chmod -R 755 storage/* bootstrap/cache
        php artisan queue:restart
        

You are done!

Credits

Made by MyPlugins for Pocket Addons