diff --git a/src/DaPigGuy/libPiggyEconomy/providers/EconomyProvider.php b/src/DaPigGuy/libPiggyEconomy/providers/EconomyProvider.php index 1df9527..1ea317e 100644 --- a/src/DaPigGuy/libPiggyEconomy/providers/EconomyProvider.php +++ b/src/DaPigGuy/libPiggyEconomy/providers/EconomyProvider.php @@ -24,9 +24,9 @@ public function getMonetaryUnit(): string abstract function getMoney(Player $player): float; - abstract function giveMoney(Player $player, int $amount): void; + abstract function giveMoney(Player $player, float $amount): void; - abstract function takeMoney(Player $player, int $amount): void; + abstract function takeMoney(Player $player, float $amount): void; - abstract function setMoney(Player $player, int $amount): void; + abstract function setMoney(Player $player, float $amount): void; } \ No newline at end of file diff --git a/src/DaPigGuy/libPiggyEconomy/providers/EconomySProvider.php b/src/DaPigGuy/libPiggyEconomy/providers/EconomySProvider.php index bf734a2..b840e2b 100644 --- a/src/DaPigGuy/libPiggyEconomy/providers/EconomySProvider.php +++ b/src/DaPigGuy/libPiggyEconomy/providers/EconomySProvider.php @@ -33,17 +33,17 @@ public function getMoney(Player $player): float return $this->economyAPI->myMoney($player); } - public function giveMoney(Player $player, int $amount): void + public function giveMoney(Player $player, float $amount): void { $this->economyAPI->addMoney($player, $amount); } - public function takeMoney(Player $player, int $amount): void + public function takeMoney(Player $player, float $amount): void { $this->economyAPI->reduceMoney($player, $amount); } - public function setMoney(Player $player, int $amount): void + public function setMoney(Player $player, float $amount): void { $this->economyAPI->setMoney($player, $amount); } diff --git a/src/DaPigGuy/libPiggyEconomy/providers/MultiEconomyProvider.php b/src/DaPigGuy/libPiggyEconomy/providers/MultiEconomyProvider.php index f04e2ee..7ddacb5 100644 --- a/src/DaPigGuy/libPiggyEconomy/providers/MultiEconomyProvider.php +++ b/src/DaPigGuy/libPiggyEconomy/providers/MultiEconomyProvider.php @@ -45,17 +45,17 @@ public function getMoney(Player $player): float return $this->currency->getBalance($player->getName()) ?? $this->currency->getStartingAmount(); } - public function giveMoney(Player $player, int $amount): void + public function giveMoney(Player $player, float $amount): void { $this->currency->addToBalance($player->getName(), $amount); } - public function takeMoney(Player $player, int $amount): void + public function takeMoney(Player $player, float $amount): void { $this->currency->removeFromBalance($player->getName(), $amount); } - public function setMoney(Player $player, int $amount): void + public function setMoney(Player $player, float $amount): void { $this->currency->setBalance($player->getName(), $amount); } diff --git a/src/DaPigGuy/libPiggyEconomy/providers/XPProvider.php b/src/DaPigGuy/libPiggyEconomy/providers/XPProvider.php index 4a92351..c0afd32 100644 --- a/src/DaPigGuy/libPiggyEconomy/providers/XPProvider.php +++ b/src/DaPigGuy/libPiggyEconomy/providers/XPProvider.php @@ -4,6 +4,7 @@ namespace DaPigGuy\libPiggyEconomy\providers; +use pocketmine\entity\utils\ExperienceUtils; use pocketmine\Player; class XPProvider extends EconomyProvider @@ -15,21 +16,25 @@ public function getMonetaryUnit(): string public function getMoney(Player $player): float { - return (float) $player->getXpLevel(); + return $player->getXpLevel() + $player->getXpProgress(); } - public function giveMoney(Player $player, int $amount): void + public function giveMoney(Player $player, float $amount): void { - $player->addXpLevels($amount, false); + $levels = (int)floor($amount); + $player->addXpLevels($levels); + $player->addXp((int)(ExperienceUtils::getXpToCompleteLevel($player->getXpLevel()) * ($amount - $levels))); } - public function takeMoney(Player $player, int $amount): void + public function takeMoney(Player $player, float $amount): void { - $player->subtractXpLevels($amount); + $this->giveMoney($player, -$amount); } - public function setMoney(Player $player, int $amount): void + public function setMoney(Player $player, float $amount): void { - $player->setXpLevel($amount); + $levels = (int)floor($amount); + $player->setXpLevel($levels); + $player->setXpProgress($amount - $levels); } } \ No newline at end of file diff --git a/virion.yml b/virion.yml index b792825..7a5aaaf 100644 --- a/virion.yml +++ b/virion.yml @@ -1,5 +1,5 @@ name: libPiggyEconomy -version: 1.0.1 +version: 2.0.0 antigen: DaPigGuy\libPiggyEconomy api: 3.0.0 author: DaPigGuy \ No newline at end of file