Skip to content

Commit

Permalink
Merge pull request #322 from MineTrax/feature/skin-restorer
Browse files Browse the repository at this point in the history
v4.0.0
  • Loading branch information
Xinecraft authored Feb 11, 2024
2 parents f15a314 + bfb7803 commit 5cf6fd8
Show file tree
Hide file tree
Showing 277 changed files with 3,297 additions and 1,508 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ indent_size = 2

[docker-compose.yml]
indent_size = 4

[*.blade.php]
php_diagnostic = false
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,6 @@ SFTP_DISK_HOST=
SFTP_DISK_USERNAME=
SFTP_DISK_PASSWORD=
SFTP_DISK_PORT=22

PLAYER_SKIN_CHANGER_ENABLED=true
PLAYER_SKIN_CHANGER_COOLDOWN_IN_SECONDS=60
5 changes: 0 additions & 5 deletions .github/workflows/laravel-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,11 @@ jobs:
run: |
composer install --no-scripts
- name: Install npm dependencis
run: |
npm ci
- name: Prepare Laravel Application
run: |
cp .env.example .env
php artisan key:generate
php artisan migrate -v
npm run prod
env:
DB_HOST: mysql
REDIS_HOST: redis
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AccountLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function verify($uuid, Server $server, Request $request, PluginSettings $
}

// Run command to give this player the reward according to Plugin setting if enabled
AccountLinkAfterSuccessCommandJob::dispatch($player, $server);
AccountLinkAfterSuccessCommandJob::dispatch($player, $user->id, $server);

return redirect()->route('home')
->with(['toast' => ['type' => 'success', 'title' => __('Played linked successfully!'), 'body' => __('This player is now linked to your account.'), 'milliseconds' => 10000]]);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/PlayerIntelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function playersList(Request $request)
AllowedFilter::custom('q', new FilterMultipleFields(['player_uuid', 'player_username'])),
])
->groupBy(['player_id'])
->with(['player:id,uuid,username', 'country:id,iso_code,flag,name'])
->with(['player:id,uuid,username,skin_texture_id', 'country:id,iso_code,flag,name'])
->allowedSorts([
'id',
'player_username',
Expand Down
63 changes: 33 additions & 30 deletions app/Http/Controllers/Admin/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function index()
'order',
'country_id',
'last_scanned_at',
'created_at'
'created_at',
])
->with('country')
->allowedFilters([
Expand All @@ -66,7 +66,7 @@ public function index()
'country_id',
'last_scanned_at',
'created_at',
AllowedFilter::custom('q', new FilterMultipleFields(['name', 'hostname', 'ip_address', 'join_port', 'query_port', 'webquery_port', 'minecraft_version']))
AllowedFilter::custom('q', new FilterMultipleFields(['name', 'hostname', 'ip_address', 'join_port', 'query_port', 'webquery_port', 'minecraft_version'])),
])
->allowedSorts(['id', 'name', 'hostname', 'ip_address', 'join_port', 'query_port', 'webquery_port', 'type', 'minecraft_version', 'order', 'country_id', 'last_scanned_at', 'created_at'])
->defaultSort('-created_at')
Expand All @@ -75,7 +75,7 @@ public function index()

return Inertia::render('Admin/Server/IndexServer', [
'servers' => $servers,
'canCreateBungeeServer' => !$canCreateBungeeServer,
'canCreateBungeeServer' => ! $canCreateBungeeServer,
'filters' => request()->all(['perPage', 'sort', 'filter']),
]);
}
Expand All @@ -85,7 +85,7 @@ public function create()
$this->authorize('create', Server::class);

return Inertia::render('Admin/Server/CreateServer', [
"versionsArray" => ServerVersion::getValues()
'versionsArray' => ServerVersion::getValues(),
]);
}

Expand All @@ -99,7 +99,7 @@ public function createBungee()
$this->authorize('create', Server::class);

return Inertia::render('Admin/Server/CreateEditBungeeServer', [
"versionsArray" => ServerVersion::getValues()
'versionsArray' => ServerVersion::getValues(),
]);
}

Expand All @@ -122,14 +122,14 @@ public function store(CreateServerRequest $request, GeolocationService $geolocat
'is_server_intel_enabled' => $request->is_server_intel_enabled,
'is_player_intel_enabled' => $request->is_player_intel_enabled,
'is_ingame_chat_enabled' => $request->is_ingame_chat_enabled,
'order' => $request->order,
]);


return Inertia::render('Admin/Server/AfterCreateSteps', [
'server' => $server,
'apiKey' => $pluginSettings->plugin_api_key,
'apiSecret' => $pluginSettings->plugin_api_secret,
'apiHost' => config('app.url')
'apiHost' => config('app.url'),
])->with(['toast' => ['type' => 'success', 'title' => __('Created Successfully'), 'body' => __('New server added successfully')]]);
}

Expand Down Expand Up @@ -211,8 +211,8 @@ public function showStatistics(Server $server)

return Inertia::render('Admin/Server/ShowServerStats', [
'server' => $server,
"aggrMax" => $aggregatedMax,
"aggrTotal" => $aggregatedTotals
'aggrMax' => $aggregatedMax,
'aggrTotal' => $aggregatedTotals,
]);
}

Expand All @@ -223,28 +223,30 @@ public function edit(Server $server)
if (ServerType::Bungee()->is($server->type)) {
return Inertia::render('Admin/Server/CreateEditBungeeServer', [
'server' => $server,
"versionsArray" => ServerVersion::getValues()
'versionsArray' => ServerVersion::getValues(),
]);
}

$serverData = [
'id' => $server->id,
"name" => $server->name,
"join_port" => $server->join_port,
"query_port" => $server->query_port,
"webquery_port" => $server->webquery_port,
"minecraft_version" => $server->minecraft_version,
"type" => $server->type->value,
"hostname" => $server->hostname,
"ip_address" => $server->ip_address,
"is_server_intel_enabled" => $server->is_server_intel_enabled,
"is_player_intel_enabled" => $server->is_player_intel_enabled,
"is_ingame_chat_enabled" => $server->is_ingame_chat_enabled,
"settings" => $server->settings,
'name' => $server->name,
'join_port' => $server->join_port,
'query_port' => $server->query_port,
'webquery_port' => $server->webquery_port,
'minecraft_version' => $server->minecraft_version,
'type' => $server->type->value,
'hostname' => $server->hostname,
'ip_address' => $server->ip_address,
'is_server_intel_enabled' => $server->is_server_intel_enabled,
'is_player_intel_enabled' => $server->is_player_intel_enabled,
'is_ingame_chat_enabled' => $server->is_ingame_chat_enabled,
'settings' => $server->settings,
'order' => $server->order,
];

return Inertia::render('Admin/Server/EditServer', [
'server' => $serverData,
"versionsArray" => ServerVersion::getValues()
'versionsArray' => ServerVersion::getValues(),
]);
}

Expand Down Expand Up @@ -276,9 +278,9 @@ public function updateBungee(Request $request, Server $server, GeolocationServic
$server->save();

// We forget the cached result so that new data will be shown instantly and not redundant data.
Cache::forget('server:ping:' . $server->id);
Cache::forget('server:query:' . $server->id);
Cache::forget('server:webquery:' . $server->id);
Cache::forget('server:ping:'.$server->id);
Cache::forget('server:query:'.$server->id);
Cache::forget('server:webquery:'.$server->id);

return redirect()->route('admin.server.index')
->with(['toast' => ['type' => 'success', 'title' => __('Updated Successfully'), 'body' => __('Bungee server updated successfully')]]);
Expand All @@ -304,12 +306,13 @@ public function update(UpdateServerRequest $request, Server $server, Geolocation
$server->is_server_intel_enabled = $request->is_server_intel_enabled;
$server->is_player_intel_enabled = $request->is_player_intel_enabled;
$server->is_ingame_chat_enabled = $request->is_ingame_chat_enabled;
$server->order = $request->order;
$server->save();

// We forget the cached result so that new data will be shown instantly and not redundant data.
Cache::forget('server:ping:' . $server->id);
Cache::forget('server:query:' . $server->id);
Cache::forget('server:webquery:' . $server->id);
Cache::forget('server:ping:'.$server->id);
Cache::forget('server:query:'.$server->id);
Cache::forget('server:webquery:'.$server->id);

return redirect()->route('admin.server.index')
->with(['toast' => ['type' => 'success', 'title' => __('Updated Successfully'), 'body' => __('Server updated successfully')]]);
Expand All @@ -332,7 +335,7 @@ public function postSendCommandToServer(Server $server, Request $request)
$request->validate([
'type' => ['required', 'in:kill,kick,mute,ban,broadcast,custom'],
'context' => ['required', 'in:player,server'],
'params' => ['required', 'string']
'params' => ['required', 'string'],
]);

$webQuery = new MinecraftWebQuery($server->ip_address, $server->webquery_port);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function postSessionInit(Request $request, GeolocationService $geolocatio
'session_started_at' => 'required|numeric',
'is_op' => 'required|boolean',
'players_world_stat_intel' => 'sometimes|nullable|array',
'skin_property' => 'sometimes|nullable|json',
'skin_texture_id' => 'sometimes|nullable|string',
]);

$server = Server::where('id', $request->server_id)->firstOrFail();
Expand Down Expand Up @@ -240,6 +242,9 @@ public function postReportEvent(Request $request, GeolocationService $geolocatio
'vault_groups' => 'sometimes|nullable|array',
'inventory' => 'sometimes|nullable|json',
'ender_chest' => 'sometimes|nullable|json',

'skin_property' => 'sometimes|nullable|json',
'skin_texture_id' => 'sometimes|nullable|string',
]);

$inventory = $request->inventory ? json_decode($request->inventory) : null;
Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ public function home(Request $request, GeneralSettings $generalSettings, ThemeSe
$chatServerList = Server::select(['id', 'name'])
->where('type', '!=', ServerType::Bungee)
->where('is_ingame_chat_enabled', true)
->orderByDesc('order')
->orderBy('id')
->get();
$chatDefaultServerId = $chatServerList->first()?->id;

// Top 10 Players
$top10Players = Player::select(['id', 'username', 'uuid', 'position', 'rating', 'total_score', 'last_seen_at', 'country_id', 'rank_id'])
$top10Players = Player::select(['id', 'username', 'uuid', 'skin_texture_id', 'position', 'rating', 'total_score', 'last_seen_at', 'country_id', 'rank_id'])
->with(['country:id,iso_code,flag,name', 'rank:id,shortname,name'])
->orderBy(\DB::raw('-`position`'), 'desc') // this sort with position but excludes the nulls
->orderByDesc('rating')
Expand Down
Loading

0 comments on commit 5cf6fd8

Please sign in to comment.