Skip to content

Commit

Permalink
refactor: Refactor project to use Pharynx for improved plugin managem…
Browse files Browse the repository at this point in the history
…ent and build process
  • Loading branch information
nicholass003 committed Sep 29, 2024
1 parent 4a9cc66 commit f4d9c26
Show file tree
Hide file tree
Showing 25 changed files with 88 additions and 10 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build phar
on:
push:
branches: [stable]
jobs:
pharynx:
name: build phar
permissions:
contents: write
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer
- run: composer install --ignore-platform-reqs
- uses: SOF3/[email protected]
id: pharynx
with:
additional-assets: |
assets/icon.png
- uses: actions/upload-artifact@v3
with:
name: TopStats.phar
path: ${{steps.pharynx.outputs.output-phar}}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Ignore vendor folder
/vendor/

# Ignore Composer dependencies
/composer.lock
.text
extract.php

# Ignore log files
*.log

# Ignore environment files
.env
.env.local

# Ignore IDE specific files
.idea/
*.iml
8 changes: 1 addition & 7 deletions .poggit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
build-by-default: true
branches:
- main
- stable
projects:
TopStats:
path: ""
icon: "assets/icon.png"
libs:
- src: DaPigGuy/libPiggyEconomy/libPiggyEconomy
version: ^3.0.3
- src: Paroxity/Commando/Commando
version: ^3.2.1
- src: ifera-mc/UpdateNotifier/UpdateNotifier
version: ^3.1.0
...
27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "nicholass003/topstats",
"description": "A TopStats plugin for PocketMine-MP.",
"type": "project",
"require": {
"pocketmine/pocketmine-mp": "^5.0.0",
"dapigguy/libpiggyeconomy": "^3.0.3",
"ifera-mc/update-notifier": "dev-master",
"paroxity/commando": "^3.2.1",
"sof3/infoapi": "dev-master"
},
"require-dev": {
"sof3/pharynx": "^0.3.6"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ifera-mc/UpdateNotifier"
}
],
"autoload": {
"classmap": ["src"]
},
"scripts": {
"build": "php -dphar.readonly=0 vendor/bin/pharynx -i=. -c -p=TopStats.phar"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 16 additions & 3 deletions src/nicholass003/topstats/utils/Utils.php → src/utils/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
use pocketmine\entity\Skin;
use pocketmine\player\Player;
use pocketmine\Server;
use SOFe\InfoAPI\InfoAPI;
use function count;
use function floor;
use function str_replace;
use function uasort;

class Utils{
Expand Down Expand Up @@ -130,7 +130,12 @@ public static function validateTextFormat(string $type, array $data, string $tex
if($type === DataType::ONLINE_TIME){
$formattedData = self::timeFormat($data[$type]);
}
return str_replace(["{player}", "{" . $type . "}", "{rank_" . $type . "}", "{line}"], [$data["name"], $formattedData, $rank, "\n"], $text);
return InfoAPI::render(TopStats::getInstance(), $text, [
"player" => $data["name"],
$type => $formattedData,
"rank_" . $type => $rank,
"line" => "\n"
]);
}

public static function timeFormat(int $time) : string{
Expand All @@ -143,7 +148,15 @@ public static function timeFormat(int $time) : string{
$seconds = $time % 60;

$format = TopStats::getInstance()->getTimeFormat();
return str_replace(["{year}", "{month}", "{week}", "{day}", "{hour}", "{minute}", "{second}"], [$years, $months, $weeks, $days, $hours, $minutes, $seconds], $format);
return InfoAPI::render(TopStats::getInstance(), $format, [
"year" => $years,
"month" => $months,
"week" => $weeks,
"day" => $days,
"hour" => $hours,
"minute" => $minutes,
"second" => $seconds
]);
}

public static function moneyTransaction(Player $player, float|int $money) : bool{
Expand Down

0 comments on commit f4d9c26

Please sign in to comment.