-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WiP: Pardon control from web feature
- Loading branch information
Showing
5 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Models\PlayerPunishment; | ||
use App\Models\Server; | ||
use App\Utils\MinecraftQuery\MinecraftWebQuery; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldBeUnique; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class PardonPlayerPunishmentJob implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
public function __construct(public PlayerPunishment $playerPunishment, public $reason) | ||
{ | ||
// | ||
} | ||
|
||
public function handle(): void | ||
{ | ||
// Decide which server to connect. | ||
// 1. If we have origin_server_id & that server has webquery, use that server. | ||
// 2. else, send to all servers that have webquery. | ||
if ($this->playerPunishment->origin_server_id && $this->playerPunishment->originServer?->webquery_port) { | ||
$server = [$this->playerPunishment->originServer]; | ||
} else { | ||
$servers = Server::select(['id', 'name', 'hostname'])->whereNotNull('webquery_port')->get(); | ||
} | ||
|
||
|
||
foreach ($servers as $server) { | ||
$this->pardonPlayerPunishment($server); | ||
} | ||
} | ||
|
||
private function pardonPlayerPunishment(Server $server): void | ||
{ | ||
$webQuery = new MinecraftWebQuery($server->ip_address, $server->webquery_port); | ||
|
||
$victim = $this->playerPunishment->uuid ?? $this->playerPunishment->ip_address; | ||
$webQuery->banwardenPardon( | ||
$this->playerPunishment->type->value, | ||
$victim, | ||
$this->reason, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters