mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 03:06:54 +01:00 
			
		
		
		
	Work In Progress
This commit is contained in:
		
							parent
							
								
									760649a67d
								
							
						
					
					
						commit
						93fd41d983
					
				
							
								
								
									
										16
									
								
								app/Features/Feature.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								app/Features/Feature.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Features;
 | 
			
		||||
 | 
			
		||||
use Filament\Actions\Action;
 | 
			
		||||
 | 
			
		||||
abstract class Feature
 | 
			
		||||
{
 | 
			
		||||
    /** you need to agree to the eula in order to run the server */
 | 
			
		||||
    abstract public function listeners(): array;
 | 
			
		||||
 | 
			
		||||
    /** eula */
 | 
			
		||||
    abstract public function featureName(): string;
 | 
			
		||||
 | 
			
		||||
    abstract public function action(): Action;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										44
									
								
								app/Features/MinecraftEula.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								app/Features/MinecraftEula.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Features;
 | 
			
		||||
 | 
			
		||||
use App\Repositories\Daemon\DaemonFileRepository;
 | 
			
		||||
use Filament\Actions\Action;
 | 
			
		||||
use Filament\Forms\Components\Placeholder;
 | 
			
		||||
use Filament\Notifications\Notification;
 | 
			
		||||
 | 
			
		||||
class MinecraftEula extends Feature
 | 
			
		||||
{
 | 
			
		||||
    public function listeners(): array
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'you need to agree to the eula in order to run the server',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function featureName(): string
 | 
			
		||||
    {
 | 
			
		||||
        return 'eula';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function action(): Action
 | 
			
		||||
    {
 | 
			
		||||
        return Action::make('eula')
 | 
			
		||||
            ->form([
 | 
			
		||||
                Placeholder::make('eula')
 | 
			
		||||
                    ->label('By pressing I Accept below you are indicating your agreement to the Minecraft® EULA.'),
 | 
			
		||||
            ])
 | 
			
		||||
            ->action(function (DaemonFileRepository $fileRepository) {
 | 
			
		||||
                try {
 | 
			
		||||
                    $fileRepository->putContent('eula.txt', 'eula=true');
 | 
			
		||||
                } catch (\Exception $e) {
 | 
			
		||||
                    Notification::make()
 | 
			
		||||
                        ->title('Error')
 | 
			
		||||
                        ->body($e->getMessage())
 | 
			
		||||
                        ->danger()
 | 
			
		||||
                        ->send();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -99,8 +99,14 @@
 | 
			
		||||
 | 
			
		||||
        const TERMINAL_PRELUDE = '\u001b[1m\u001b[33mpelican@' + '{{ \Filament\Facades\Filament::getTenant()->name }}' + ' ~ \u001b[0m';
 | 
			
		||||
 | 
			
		||||
        const handleConsoleOutput = (line, prelude = false) =>
 | 
			
		||||
        const handleConsoleOutput = (line, prelude = false) => {
 | 
			
		||||
            terminal.writeln((prelude ? TERMINAL_PRELUDE : '') + line.replace(/(?:\r\n|\r|\n)$/im, '') + '\u001b[0m');
 | 
			
		||||
            checkListeners(line);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const checkListeners = (line) => {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const handleTransferStatus = (status) =>
 | 
			
		||||
            status === 'failure' && terminal.writeln(TERMINAL_PRELUDE + 'Transfer has failed.\u001b[0m');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user