Skip to content

Commit 53451ad

Browse files
szpolnyBoy132
andauthored
arma-reforger-workshop - Plugin for managing Arma Reforger mods. (#20)
* feat: add arma-reforger-workshop plugin * browse workshop directly in browser * readme for arma-reforger-workshop plugin * fix: correct string interpolation in mod notifications * eliminate n+1 calls * fix pint * use localization strings instead of hardcoded texts * enhance mod enrichment with concurrent requests and caching * normalize modId to uppercase for consistent comparison * improve caching for errors * laravel pint * fix: correct URL generation for config path by trimming trailing dots * fix for caching issues * replace __('...') with trans('...') * allow nullable version parameter in addMod method * replace __('...') with trans('...') for localization consistency * update translations * refactor mod details handling: replace parseModDetailsFromResponse with parseNextDataFromHtml for improved data extraction * fix phpstan issues * pint fix * type hint fix * another fix for phpstan * remove getModDetails method * reset the installed mods cache after successful installation * update readme * simplify phpdoc --------- Co-authored-by: Boy132 <mail@boy132.de>
1 parent 65ab4a9 commit 53451ad

8 files changed

Lines changed: 1109 additions & 0 deletions

File tree

arma-reforger-workshop/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Arma Reforger Workshop Plugin (by spolny)
2+
3+
A Pelican Panel plugin for managing Arma Reforger workshop mods directly from the server panel.
4+
5+
## Features
6+
7+
- **View Installed Mods** - See all mods currently configured in your server's `config.json`
8+
- **Add Mods** - Add mods by entering their Workshop ID (GUID)
9+
- **Remove Mods** - Remove mods from your server configuration
10+
- **Browse Workshop** - Search and browse mods from the Bohemia Arma Reforger Workshop directly in the panel
11+
- **One-Click Install** - Add mods to your server directly from the workshop browser
12+
- **Mod Details** - View version, subscriber count, downloads, and ratings for each mod
13+
14+
## Requirements
15+
16+
Your server egg must have one of the following:
17+
- Feature: `arma_reforger_workshop`
18+
- Tag: `arma_reforger` or `arma-reforger`
19+
20+
## Configuration
21+
22+
The plugin automatically detects the server's config file location. By default, it looks for `config.json` in the server root.
23+
24+
You can customize the config path by adding a `CONFIG_FILE` server variable in your egg.
25+
26+
## How It Works
27+
28+
Arma Reforger servers use a `config.json` file where mods are listed in the `game.mods` array:
29+
30+
```json
31+
{
32+
"game": {
33+
"mods": [
34+
{
35+
"modId": "5965550F24A0C152",
36+
"name": "Where Am I",
37+
"version": "1.2.0"
38+
}
39+
]
40+
}
41+
}
42+
```
43+
44+
This plugin provides a user-friendly interface to manage this configuration without manually editing the JSON file.
45+
46+
## Workshop Integration
47+
48+
The plugin integrates with the [Bohemia Arma Reforger Workshop](https://reforger.armaplatform.com/workshop) to:
49+
50+
- Fetch mod details (name, version, subscribers, downloads, rating)
51+
- Search for mods by name
52+
- Browse popular mods
53+
- Display mod thumbnails and descriptions
54+
55+
Mod data is cached to improve performance:
56+
- Individual mod details: 6 hours
57+
- Workshop search results: 15 minutes
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
return [
4+
'navigation' => [
5+
'workshop_mods' => 'Workshop Mods',
6+
'browse_workshop' => 'Browse Workshop',
7+
],
8+
'titles' => [
9+
'browse_workshop' => 'Browse Arma Reforger Workshop',
10+
],
11+
'labels' => [
12+
'mod' => 'Mod',
13+
'mod_id' => 'Mod ID',
14+
'mod_name' => 'Mod Name',
15+
'author' => 'Author',
16+
'version' => 'Version',
17+
'subscribers' => 'Subscribers',
18+
'downloads' => 'Downloads',
19+
'rating' => 'Rating',
20+
'type' => 'Type',
21+
'config_path' => 'Config Path',
22+
'installed_mods' => 'Installed Mods',
23+
],
24+
'actions' => [
25+
'add_mod' => 'Add Mod',
26+
'add_to_server' => 'Add to Server',
27+
'browse_workshop' => 'Browse Workshop',
28+
'edit_config' => 'Edit Config',
29+
'remove' => 'Remove',
30+
'installed' => 'Installed',
31+
'view_installed_mods' => 'View Installed Mods',
32+
'open_in_browser' => 'Open in Browser',
33+
],
34+
'form' => [
35+
'mod_id_helper' => 'Enter the mod ID (GUID) from the Bohemia Workshop. Example: 5965550F24A0C152',
36+
'mod_id_placeholder' => '5965550F24A0C152',
37+
'mod_name_helper' => 'A friendly name for the mod',
38+
'version_placeholder' => 'Optional - leave empty for latest',
39+
'mod_id_validation_regex' => 'The mod ID must be a 16-character hexadecimal string.',
40+
],
41+
'modals' => [
42+
'remove_mod_heading' => 'Remove Mod',
43+
'remove_mod_description' => 'Are you sure you want to remove ":name" from your server\'s mod list?',
44+
'add_mod_heading' => 'Add ":name"',
45+
'add_mod_description' => 'This will add ":name" by :author to your server\'s mod list.',
46+
],
47+
'sections' => [
48+
'browse_mods' => 'Browse Mods',
49+
'browse_mods_description' => 'Search and browse mods from the Bohemia Arma Reforger Workshop. Click "Add to Server" to install a mod.',
50+
],
51+
'notifications' => [
52+
'mod_added' => 'Mod added',
53+
'mod_added_body' => "':name' has been added to your server configuration.",
54+
'mod_removed' => 'Mod removed',
55+
'mod_removed_body' => "':name' has been removed from your server configuration.",
56+
'failed_to_add' => 'Failed to add mod',
57+
'failed_to_remove' => 'Failed to remove mod',
58+
'config_update_failed' => 'Could not update the server configuration.',
59+
],
60+
];

arma-reforger-workshop/plugin.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"id": "arma-reforger-workshop",
3+
"name": "Arma Reforger Workshop",
4+
"author": "spolny",
5+
"version": "1.0.0",
6+
"description": "Manage Arma Reforger workshop mods in server config",
7+
"category": "plugin",
8+
"url": "https://github.com/pelican-dev/plugins/tree/main/arma-reforger-workshop",
9+
"update_url": null,
10+
"namespace": "spolny\\ArmaReforgerWorkshop",
11+
"class": "ArmaReforgerWorkshopPlugin",
12+
"panels": [
13+
"server"
14+
],
15+
"panel_version": null,
16+
"composer_packages": null
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace spolny\ArmaReforgerWorkshop;
4+
5+
use Filament\Contracts\Plugin;
6+
use Filament\Panel;
7+
8+
class ArmaReforgerWorkshopPlugin implements Plugin
9+
{
10+
public function getId(): string
11+
{
12+
return 'arma-reforger-workshop';
13+
}
14+
15+
public function register(Panel $panel): void
16+
{
17+
$id = str($panel->getId())->title();
18+
19+
$panel->discoverPages(plugin_path($this->getId(), "src/Filament/$id/Pages"), "spolny\\ArmaReforgerWorkshop\\Filament\\$id\\Pages");
20+
}
21+
22+
public function boot(Panel $panel): void {}
23+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace spolny\ArmaReforgerWorkshop\Facades;
4+
5+
use App\Models\Server;
6+
use App\Repositories\Daemon\DaemonFileRepository;
7+
use Illuminate\Support\Facades\Facade;
8+
use spolny\ArmaReforgerWorkshop\Services\ArmaReforgerWorkshopService;
9+
10+
/**
11+
* @method static bool isArmaReforgerServer(Server $server)
12+
* @method static array<int, array{modId: string, name: string, version: string}> getInstalledMods(Server $server, DaemonFileRepository $fileRepository)
13+
* @method static string getConfigPath(Server $server)
14+
* @method static bool addMod(Server $server, DaemonFileRepository $fileRepository, string $modId, string $name, string $version = '')
15+
* @method static bool removeMod(Server $server, DaemonFileRepository $fileRepository, string $modId)
16+
* @method static string getModWorkshopUrl(string $modId)
17+
* @method static array<string, mixed> parseNextDataFromHtml(string $html, string $modId)
18+
* @method static array{mods: array<int, mixed>, total: int, page: int, perPage: int} browseWorkshop(string $search = '', int $page = 1)
19+
* @method static bool isModInstalled(Server $server, DaemonFileRepository $fileRepository, string $modId)
20+
*
21+
* @see ArmaReforgerWorkshopService
22+
*/
23+
class ArmaReforgerWorkshop extends Facade
24+
{
25+
protected static function getFacadeAccessor(): string
26+
{
27+
return ArmaReforgerWorkshopService::class;
28+
}
29+
}

0 commit comments

Comments
 (0)