Small cleanup for new egg features (#1343)

This commit is contained in:
Boy132 2025-05-06 13:01:34 +02:00 committed by GitHub
parent 26e20453bf
commit e38a736b61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 27 deletions

View File

@ -8,6 +8,7 @@ use App\Models\Server;
use App\Models\ServerVariable;
use App\Repositories\Daemon\DaemonPowerRepository;
use Closure;
use Exception;
use Filament\Actions\Action;
use Filament\Facades\Filament;
use Filament\Forms\Components\Placeholder;
@ -27,8 +28,8 @@ class GSLToken extends FeatureProvider
public function getListeners(): array
{
return [
'gsl token expired',
'account not found',
'(gsl token expired)',
'(account not found)',
];
}
@ -52,9 +53,8 @@ class GSLToken extends FeatureProvider
->modalSubmitActionLabel('Update GSL Token')
->disabledForm(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
->form([
Placeholder::make('java')
->label('You can either <x-filament::link href="https://steamcommunity.com/dev/managegameservers" target="_blank">generate a new one</x-filament::link> and enter it below or leave the field blank to remove it
completely.'),
Placeholder::make('info')
->label('You can either <x-filament::link href="https://steamcommunity.com/dev/managegameservers" target="_blank">generate a new one</x-filament::link> and enter it below or leave the field blank to remove it completely.'),
TextInput::make('gsltoken')
->label('GSL Token')
->rules([
@ -102,13 +102,13 @@ class GSLToken extends FeatureProvider
Notification::make()
->title('GSL Token updated')
->body('Restart the server to use the new token.')
->body('Server will restart now.')
->success()
->send();
} catch (\Exception $e) {
} catch (Exception $exception) {
Notification::make()
->title('Error')
->body($e->getMessage())
->title('Could not update GSL Token')
->body($exception->getMessage())
->danger()
->send();
}

View File

@ -6,6 +6,7 @@ use App\Facades\Activity;
use App\Models\Permission;
use App\Models\Server;
use App\Repositories\Daemon\DaemonPowerRepository;
use Exception;
use Filament\Actions\Action;
use Filament\Facades\Filament;
use Filament\Forms\Components\Placeholder;
@ -25,10 +26,11 @@ class JavaVersion extends FeatureProvider
{
return [
'java.lang.UnsupportedClassVersionError',
'minecraft 1.17 requires running the server with java 16 or above',
'minecraft 1.18 requires running the server with java 17 or above',
'unsupported major.minor version',
'has been compiled by a more recent version of the java runtime',
'minecraft 1.17 requires running the server with java 16 or above',
'minecraft 1.18 requires running the server with java 17 or above',
'minecraft 1.19 requires running the server with java 17 or above',
];
}
@ -73,17 +75,18 @@ class JavaVersion extends FeatureProvider
->property(['old' => $original, 'new' => $new])
->log();
}
$powerRepository->setServer($server)->send('restart');
Notification::make()
->title('Docker image updated')
->body('Restart the server to use the new image.')
->body('Server will restart now.')
->success()
->send();
} catch (\Exception $e) {
} catch (Exception $exception) {
Notification::make()
->title('Error')
->body($e->getMessage())
->title('Could not update docker image')
->body($exception->getMessage())
->danger()
->send();
}

View File

@ -24,7 +24,7 @@ class MinecraftEula extends FeatureProvider
public function getListeners(): array
{
return [
'You need to agree to the EULA in order to run the server',
'you need to agree to the eula in order to run the server',
];
}
@ -38,31 +38,30 @@ class MinecraftEula extends FeatureProvider
return Action::make($this->getId())
->requiresConfirmation()
->modalHeading('Minecraft EULA')
->modalDescription(new HtmlString(Blade::render('By pressing "I Accept" below you are indicating your agreement to the <x-filament::link href="https://minecraft.net/eula" target="_blank">Minecraft EULA </x-filament::link>')))
->modalDescription(new HtmlString(Blade::render('By pressing "I Accept" below you are indicating your agreement to the <x-filament::link href="https://minecraft.net/eula" target="_blank">Minecraft EULA </x-filament::link>.')))
->modalSubmitActionLabel('I Accept')
->action(function (DaemonFileRepository $fileRepository, DaemonPowerRepository $powerRepository) {
try {
/** @var Server $server */
$server = Filament::getTenant();
$content = $fileRepository->setServer($server)->getContent('eula.txt');
$content = preg_replace('/(eula=)false/', '\1true', $content);
$fileRepository->setServer($server)->putContent('eula.txt', $content);
$fileRepository->setServer($server)->putContent('eula.txt', 'eula=true');
$powerRepository->setServer($server)->send('restart');
Notification::make()
->title('Docker image updated')
->body('Restart the server.')
->title('Minecraft EULA accepted')
->body('Server will restart now.')
->success()
->send();
} catch (Exception $e) {
} catch (Exception $exception) {
Notification::make()
->title('Error')
->body($e->getMessage())
->title('Could not accept Minecraft EULA')
->body($exception->getMessage())
->danger()
->send();
}
}
);
});
}
public static function register(Application $app): self