Skip to content

Commit 71e8b57

Browse files
authored
McLogCleaner: Added the update-system to automatically check for new updates. (#108)
Added a setting to enable/ disable the text in the delete-logs button.
1 parent 60cb9e3 commit 71e8b57

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'mclogcleaner_text_enabled' => filter_var(env('MCLOGCLEANER_TEXT_ENABLED', true), FILTER_VALIDATE_BOOL),
5+
];

mclogcleaner/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"id": "mclogcleaner",
33
"name": "McLogCleaner",
44
"author": "JuggleGaming",
5-
"version": "1.1.1",
5+
"version": "1.1.2",
66
"description": "Clean your Minecraft-logs with ease",
77
"category": "plugin",
88
"url": "https://github.com/pelican-dev/plugins/tree/main/mclogcleaner",
9-
"update_url": null,
9+
"update_url": "https://raw.githubusercontent.com/JuggleGaming/mclogcleaner/refs/heads/main/updater.json",
1010
"namespace": "JuggleGaming\\McLogCleaner",
1111
"class": "McLogCleanerPlugin",
1212
"panels": null,

mclogcleaner/src/Filament/Components/Actions/McLogCleanAction.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ protected function setUp(): void
3535
return !in_array('mclogcleaner', $features, true);
3636
});
3737

38-
$this->label('Delete logs');
38+
$this->label(function () {
39+
return config('mclogcleaner.mclogcleaner_text_enabled') ? 'Delete logs' : '';
40+
});
3941
$this->icon('tabler-trash');
4042
$this->color('danger');
4143
$this->size(Size::ExtraLarge);
@@ -104,7 +106,7 @@ protected function setUp(): void
104106
return $logDate->lessThan($threshold);
105107
})
106108
->pluck('name')
107-
->map(fn ($name) => 'logs/' . $name)
109+
->map(fn ($name) => 'logs/'.$name)
108110
->values()
109111
->all();
110112
if (empty($logsToDelete)) {
@@ -124,7 +126,7 @@ protected function setUp(): void
124126
->throw();
125127
Notification::make()
126128
->title('Logfolder cleaned')
127-
->body(count($logsToDelete) . ' files were deleted.')
129+
->body(count($logsToDelete).' files were deleted.')
128130
->success()
129131
->send();
130132
} catch (\Throwable $e) {

mclogcleaner/src/McLogCleanerPlugin.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22

33
namespace JuggleGaming\McLogCleaner;
44

5+
use App\Contracts\Plugins\HasPluginSettings;
6+
use App\Traits\EnvironmentWriterTrait;
57
use Filament\Contracts\Plugin;
8+
use Filament\Forms\Components\Toggle;
9+
use Filament\Notifications\Notification;
610
use Filament\Panel;
711

8-
class McLogCleanerPlugin implements Plugin
12+
class McLogCleanerPlugin implements HasPluginSettings, Plugin
913
{
14+
use EnvironmentWriterTrait;
15+
1016
public function getId(): string
1117
{
1218
return 'mclogcleaner';
@@ -21,4 +27,26 @@ public function boot(Panel $panel): void
2127
{
2228
//
2329
}
30+
31+
public function getSettingsForm(): array
32+
{
33+
return [
34+
Toggle::make('mclogcleaner_text_enabled')
35+
->label('Enable button text')
36+
->default(fn () => (bool) config('mclogcleaner.mclogcleaner_text_enabled', true)),
37+
];
38+
}
39+
40+
public function saveSettings(array $data): void
41+
{
42+
$this->writeToEnvironment([
43+
'MCLOGCLEANER_TEXT_ENABLED' => $data['mclogcleaner_text_enabled'] ? 'true' : 'false',
44+
]);
45+
46+
Notification::make()
47+
->title('McLogCleaner')
48+
->body('Settings successfully saved!')
49+
->success()
50+
->send();
51+
}
2452
}

mclogcleaner/updater.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"*": {
3+
"version": "1.1.2",
4+
"download_url": "https://github.com/JuggleGaming/mclogcleaner/releases/latest/download/mclogcleaner.zip"
5+
}
6+
}

0 commit comments

Comments
 (0)