Skip to content

Commit

Permalink
Merge pull request #400 from MineTrax/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Xinecraft authored Nov 22, 2024
2 parents 63f97da + e9b9fd3 commit b6814dd
Show file tree
Hide file tree
Showing 349 changed files with 8,903 additions and 2,823 deletions.
17 changes: 14 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ APP_ENV=local
APP_KEY=
#Set your websuite language by default
APP_LOCALE=en
#If you dont want a locale to appear just remove it(transaltions are accepted on our github)
# If you dont want a locale switcher to appear just make it empty. (transaltions are accepted on our github)
AVAILABLE_LOCALES=en,es,ru,sk,de,pl,uk,hi,it,zh-hk,zh-cn,ja
APP_THEME=default
# Pulse dashboard for health monitoring
Expand Down Expand Up @@ -34,11 +34,11 @@ LOG_LEVEL=debug
LOG_DISCORD_WEBHOOK_URL=

# User Settings
SETTINGS_CACHE_ENABLED=false
RANDOM_USER_AVATARS=true
DISABLE_USER_REGISTRATION=false
DISABLE_EMAIL_PASSWORD_AUTH=false
VERIFY_USER_EMAIL=false
ENFORCE_2FA_FOR_STAFF=false

# User Experience
PLAYER_SKIN_CHANGER_ENABLED=true
Expand Down Expand Up @@ -134,7 +134,6 @@ GEOLOCATION_DRIVER=maxmind_database
MAXMIND_USER_ID=
MAXMIND_LICENSE_KEY=
RATELIMIT_API_PER_MINUTE=600
USE_LEGACY_FTP_DRIVER=false
MARK_USER_VERIFYED_ON_ACCOUNT_LINK=true
DISABLE_PLAYER_UNLINKING=false
USE_USERNAME_FOR_SKINS=false
Expand All @@ -144,6 +143,7 @@ FILESYSTEM_DISK=local
MEDIA_DISK=media
PROFILE_PHOTO_DISK=public
DOWNLOADS_MODULE_DISK=download
SETTINGS_CACHE_ENABLED=false

# Database Info
DB_CONNECTION=mysql
Expand All @@ -170,3 +170,14 @@ MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=no-reply@minetrax.github.io
MAIL_FROM_NAME="${APP_NAME}"

# BanWarden
BANWARDEN_ENABLED=true
BANWARDEN_AI_INSIGHTS_ENABLED=true
BANWARDEN_SHOW_PUBLIC=true
BANWARDEN_SHOW_MASKED_IP_PUBLIC=false
BANWARDEN_MODULE_DISK=private
BANWARDEN_EVIDENCE_MAX_COUNT=2
BANWARDEN_EVIDENCE_ALLOWED_MIMETYPES=jpg,png,gif,bmp,webp,mp4,avi,mov,mkv,webm,zip,rar
BANWARDEN_EVIDENCE_MAX_SIZE_KB=51200
BANWARDEN_ALLOW_CONTROL_FROM_WEB=true
21 changes: 21 additions & 0 deletions app/Enums/PlayerPunishmentType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Enums;

use BenSampo\Enum\Enum;

final class PlayerPunishmentType extends Enum
{
const BAN = 'ban';
const MUTE = 'mute';
const WARN = 'warn';
const KICK = 'kick';

public function toArray(): mixed
{
return [
'key' => $this->key,
'value' => $this->value,
];
}
}
3 changes: 3 additions & 0 deletions app/Enums/ServerVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @method static static v1_18()
* @method static static v1_19()
* @method static static v1_20()
* @method static static v1_21()
*/
final class ServerVersion extends Enum
{
Expand All @@ -34,4 +35,6 @@ final class ServerVersion extends Enum
const v1_19 = '1.19';

const v1_20 = '1.20';

const v1_21 = '1.21';
}
37 changes: 37 additions & 0 deletions app/Events/BanWardenPlayerPardoned.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Events;

use App\Models\PlayerPunishment;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class BanWardenPlayerPardoned
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* Create a new event instance.
*/
public function __construct(public PlayerPunishment $punishment)
{
//
}

/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('channel-name'),
];
}
}
37 changes: 37 additions & 0 deletions app/Events/BanWardenPlayerPunished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Events;

use App\Models\PlayerPunishment;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class BanWardenPlayerPunished
{
use Dispatchable, InteractsWithSockets, SerializesModels;

/**
* Create a new event instance.
*/
public function __construct(public PlayerPunishment $punishment)
{
//
}

/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('channel-name'),
];
}
}
8 changes: 8 additions & 0 deletions app/Http/Controllers/Admin/CommandQueueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ public function index()
->allowedSorts($fields)
->defaultSort('-updated_at')
->simplePaginate($perPage)
->through(function ($commandQueue) {
if ($commandQueue->tag === 'player_password_reset') {
$commandQueue->parsed_command = array_key_exists('viewable_parsed_command', $commandQueue->config)
? $commandQueue->config['viewable_parsed_command']
: $commandQueue->parsed_command;
}
return $commandQueue;
})
->withQueryString();

return Inertia::render('Admin/CommandQueue/IndexCommandQueue', [
Expand Down
11 changes: 7 additions & 4 deletions app/Http/Controllers/Admin/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use DB;
use Illuminate\Http\Request;
use Inertia\Inertia;
use Cache;

class DashboardController extends Controller
{
Expand All @@ -24,14 +25,14 @@ public function index(Request $request)
$kpiUserCreatedForInterval = User::where('created_at', '>=', Carbon::now()->subDays(7))->count();
$totalUsersMinusInterval = $kpiTotalUsers - $kpiUserCreatedForInterval ?: 1;
$kpiTotalUserPercent = $kpiTotalUsers !== 0 ? ($kpiUserCreatedForInterval / $totalUsersMinusInterval) * 100 : 0;
$kpiUserLastSeenForInterval = User::where('last_login_at', '>=', Carbon::now()->subDays(7))->count();
$kpiTotalVerifiedUsers = User::isVerified(true)->count();

// KPI for total players
$kpiTotalPlayers = Player::fastCount();
$kpiPlayerCreatedForInterval = Player::where('created_at', '>=', Carbon::now()->subDays(7))->count();
$totalPlayersMinusInterval = $kpiTotalPlayers - $kpiPlayerCreatedForInterval ?: 1;
$kpiTotalPlayersPercent = $kpiTotalPlayers !== 0 ? ($kpiPlayerCreatedForInterval / $totalPlayersMinusInterval) * 100 : 0;
$kpiPlayerLastSeenForInterval = Player::where('last_seen_at', '>=', Carbon::now()->subDays(7))->count();
$kpiTotalLinkedPlayers = Player::whereHas('users')->count();

// KPI for total posts
$kpiTotalPosts = Post::fastCount();
Expand All @@ -48,13 +49,13 @@ public function index(Request $request)

$responseData = [
'kpiTotalUsers' => $kpiTotalUsers,
'kpiTotalVerifiedUsers' => $kpiTotalVerifiedUsers,
'kpiUserCreatedForInterval' => $kpiUserCreatedForInterval,
'kpiUserLastSeenForInterval' => $kpiUserLastSeenForInterval,
'kpiTotalUserPercent' => $kpiTotalUserPercent,

'kpiTotalPlayers' => $kpiTotalPlayers,
'kpiTotalLinkedPlayers' => $kpiTotalLinkedPlayers,
'kpiPlayerCreatedForInterval' => $kpiPlayerCreatedForInterval,
'kpiPlayerLastSeenForInterval' => $kpiPlayerLastSeenForInterval,
'kpiTotalPlayersPercent' => $kpiTotalPlayersPercent,

'kpiTotalFailedJobs' => $kpiTotalFailedJobs,
Expand All @@ -65,6 +66,8 @@ public function index(Request $request)
'kpiPostCreatedForInterval' => $kpiPostCreatedForInterval,
'kpiTotalPostsPercent' => $kpiTotalPostsPercent,
'kpiTotalComments' => $kpiTotalComments,

'queueLastProcessed' => Cache::get('queue_last_processed'),
];
}

Expand Down
16 changes: 11 additions & 5 deletions app/Http/Controllers/Admin/PlayerIntelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Http\Controllers\Controller;
use App\Models\Country;
use App\Models\MinecraftPlayer;
use App\Models\Player;
use App\Models\Server;
use App\Queries\Filters\FilterMultipleFields;
use Illuminate\Http\Request;
Expand All @@ -15,13 +16,10 @@

class PlayerIntelController extends Controller
{
public function __construct()
{
$this->middleware('can:view player_intel_critical');
}

public function playersList(Request $request)
{
$this->authorize('viewAnyIntel', Player::class);

$request->validate([
'servers' => 'sometimes|nullable|array',
'servers.*' => 'sometimes|nullable|integer|exists:servers,id',
Expand Down Expand Up @@ -90,6 +88,14 @@ public function playersList(Request $request)
->paginate($perPage)
->withQueryString();

if ($request->user()->cannot('view player_intel_critical')) {
$data->makeHidden([
'last_join_address',
'vault_balance',
'last_minecraft_version'
]);
}

$countries = Country::select(['id', 'name'])->get()->pluck('name');

return Inertia::render('Admin/PlayerIntel/PlayersList', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function indexOpen(Request $request)
'user.name',
'lastActor.name',
'lastCommentor.name',
AllowedFilter::custom('q', new FilterMultipleFields(['data', 'status'])),
AllowedFilter::custom('q', new FilterMultipleFields(['id', 'data', 'status'])),
])
->allowedSorts($fields)
->defaultSort('-updated_at')
Expand Down Expand Up @@ -142,7 +142,7 @@ public function indexClosed(Request $request)
'user.name',
'lastActor.name',
'lastCommentor.name',
AllowedFilter::custom('q', new FilterMultipleFields(['data', 'status'])),
AllowedFilter::custom('q', new FilterMultipleFields(['id', 'data', 'status'])),
])
->allowedSorts($fields)
->defaultSort('-updated_at')
Expand Down
14 changes: 12 additions & 2 deletions app/Http/Controllers/Admin/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,12 @@ public function storeBungee(Request $request, GeolocationService $geolocationSer
'webquery_port' => 'nullable|numeric|min:0|max:65535|required_if_accepted:is_server_intel_enabled|different:join_port',
'name' => 'required',
'minecraft_version' => ['required', new EnumValue(ServerVersion::class)],
'settings' => 'sometimes',
'is_server_intel_enabled' => 'required|boolean',
'settings' => 'sometimes',
'settings.server_identifier' => 'nullable|alpha_dash',
'settings.is_skin_change_via_web_allowed' => 'required|boolean',
'settings.is_banwarden_enabled' => 'required|boolean',
'order' => 'nullable|numeric',
]);

$countryId = $geolocationService->getCountryIdFromIP($request->ip_address);
Expand All @@ -170,6 +174,7 @@ public function storeBungee(Request $request, GeolocationService $geolocationSer
'is_server_intel_enabled' => $request->is_server_intel_enabled,
'settings' => $request->settings,
'created_by' => $request->user()->id,
'order' => $request->order,
]);

if (! $request->webquery_port) {
Expand Down Expand Up @@ -276,8 +281,12 @@ public function updateBungee(Request $request, Server $server, GeolocationServic
'webquery_port' => 'nullable|numeric|min:0|max:65535|required_if_accepted:is_server_intel_enabled|different:join_port',
'name' => 'required',
'minecraft_version' => ['required', new EnumValue(ServerVersion::class)],
'settings' => 'sometimes',
'is_server_intel_enabled' => 'required|boolean',
'settings' => 'sometimes',
'settings.server_identifier' => 'nullable|alpha_dash',
'settings.is_skin_change_via_web_allowed' => 'required|boolean',
'settings.is_banwarden_enabled' => 'required|boolean',
'order' => 'nullable|numeric',
]);

$countryId = $geolocationService->getCountryIdFromIP($request->ip_address);
Expand All @@ -292,6 +301,7 @@ public function updateBungee(Request $request, Server $server, GeolocationServic
$server->settings = $request->settings;
$server->is_server_intel_enabled = $request->is_server_intel_enabled;
$server->country_id = $countryId;
$server->order = $request->order;
$server->updated_by = $request->user()->id;
$server->save();

Expand Down
Loading

0 comments on commit b6814dd

Please sign in to comment.