-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v3.0: PHP8, Callbacks, & BedrockEconomy (#1)
* v3.0, switch to callbacks, added support for ParoxityEcon * fix readme * Formatting * Cleanup * Register ParoxityEconProvider * Update for pm4 & Add BedrockEconomyProvider * Remove ParoxityEcon and MultiEconomy deprecated * Wrong provider class * Use more php8 features * Fix BedrockEconomy callbacks * Add PHPStan * Update descriptions * fix phpstan * fix phpstan pt2 * Fix xp provider conditions * Fix phpstan pt3 * Fix phpstan pt4 * Fix missing callback * Fix callback pt2 * remove 4.0.0 branch from poggit Co-authored-by: JackMD <jackmtaylor.jmt@gmail.com> Co-authored-by: Aericio <16523741+Aericio@users.noreply.github.com> Co-authored-by: DaPigGuy <mcpepig123@gmail.com>
- Loading branch information
1 parent
d358c84
commit 06ccf15
Showing
13 changed files
with
176 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: PHPStan | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
phpstan: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.ref }} | ||
- name: Create Vendor Directory | ||
run: mkdir vendor | ||
- name: Download Plugin Dependencies | ||
run: | | ||
wget -O vendor/BedrockEconomy.phar https://poggit.pmmp.io/r/162549/BedrockEconomy.phar | ||
wget -O vendor/EconomyAPI.phar https://poggit.pmmp.io/r/153507/EconomyAPI.phar | ||
- name: Run PHPStan | ||
uses: paroxity/pmmp-phpstan-action@4.2.0 | ||
with: | ||
phpstan-config: phpstan.neon.dist |
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 |
---|---|---|
|
@@ -18,8 +18,5 @@ $RECYCLE.BIN/ | |
*.lnk | ||
|
||
# JetBrains IDE | ||
\.idea | ||
|
||
# Floobits | ||
\.floo | ||
\.flooignore | ||
.idea | ||
.dependencies |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
parameters: | ||
paths: | ||
- /source/src | ||
level: 7 | ||
bootstrapFiles: | ||
- phar:///pocketmine/PocketMine-MP.phar/vendor/autoload.php | ||
scanDirectories: | ||
- phar:///source/vendor/BedrockEconomy.phar/src/ | ||
- phar:///source/vendor/EconomyAPI.phar/src/ | ||
excludePaths: | ||
analyse: | ||
- source/vendor | ||
checkMissingIterableValueType: false |
10 changes: 0 additions & 10 deletions
10
src/DaPigGuy/libPiggyEconomy/exceptions/UnknownMultiEconomyCurrencyException.php
This file was deleted.
Oops, something went wrong.
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
54 changes: 54 additions & 0 deletions
54
src/DaPigGuy/libPiggyEconomy/providers/BedrockEconomyProvider.php
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,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DaPigGuy\libPiggyEconomy\providers; | ||
|
||
use cooldogedev\BedrockEconomy\api\BedrockEconomyAPI; | ||
use cooldogedev\BedrockEconomy\BedrockEconomy; | ||
use cooldogedev\BedrockEconomy\currency\CurrencyManager; | ||
use cooldogedev\BedrockEconomy\libs\cooldogedev\libSQL\context\ClosureContext; | ||
use pocketmine\player\Player; | ||
use pocketmine\Server; | ||
|
||
class BedrockEconomyProvider extends EconomyProvider | ||
{ | ||
private BedrockEconomyAPI $api; | ||
private CurrencyManager $currency; | ||
|
||
public static function checkDependencies(): bool | ||
{ | ||
return Server::getInstance()->getPluginManager()->getPlugin("BedrockEconomy") !== null; | ||
} | ||
|
||
public function __construct() | ||
{ | ||
$this->api = BedrockEconomy::getInstance()->getAPI(); | ||
$this->currency = BedrockEconomy::getInstance()->getCurrencyManager(); | ||
} | ||
|
||
public function getMonetaryUnit(): string | ||
{ | ||
return $this->currency->getSymbol(); | ||
} | ||
|
||
public function getMoney(Player $player, callable $callback): void | ||
{ | ||
$this->api->getPlayerBalance($player->getName(), ClosureContext::create(fn(?int $balance) => $callback($balance ?? $this->currency->getDefaultBalance()))); | ||
} | ||
|
||
public function giveMoney(Player $player, float $amount, ?callable $callback = null): void | ||
{ | ||
$this->api->addToPlayerBalance($player->getName(), (int)$amount, $callback ? ClosureContext::create($callback) : null); | ||
} | ||
|
||
public function takeMoney(Player $player, float $amount, ?callable $callback = null): void | ||
{ | ||
$this->api->subtractFromPlayerBalance($player->getName(), (int)$amount, $callback ? ClosureContext::create($callback) : null); | ||
} | ||
|
||
public function setMoney(Player $player, float $amount, ?callable $callback = null): void | ||
{ | ||
$this->api->setPlayerBalance($player->getName(), (int)$amount, $callback ? ClosureContext::create($callback) : null); | ||
} | ||
} |
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
Oops, something went wrong.