diff --git a/resources/config.yml b/resources/config.yml index 8f111e0..6adca34 100644 --- a/resources/config.yml +++ b/resources/config.yml @@ -33,6 +33,5 @@ economy: # issue at https://github.com/Muqsit/ChestShop/issues plugin: EconomyAPI # Extra configuration options if BedrockEconomy plugin is chosen - BedrockEconomy: - unsafe-warn: true + BedrockEconomy: [] ... \ No newline at end of file diff --git a/src/muqsit/chestshop/economy/BedrockEconomyIntegration.php b/src/muqsit/chestshop/economy/BedrockEconomyIntegration.php index 7791334..413f9ec 100644 --- a/src/muqsit/chestshop/economy/BedrockEconomyIntegration.php +++ b/src/muqsit/chestshop/economy/BedrockEconomyIntegration.php @@ -9,10 +9,8 @@ use cooldogedev\BedrockEconomy\BedrockEconomy; use cooldogedev\BedrockEconomy\libs\cooldogedev\libSQL\context\ClosureContext; use InvalidArgumentException; -use muqsit\chestshop\Loader; use muqsit\chestshop\util\PlayerIdentity; use pocketmine\Server; -use function assert; final class BedrockEconomyIntegration implements EconomyIntegration{ @@ -29,14 +27,6 @@ public function __construct(){ } public function init(array $config) : void{ - if(($config["unsafe-warn"] ?? true) && count($this->plugin->getConnector()->getThreads()) > 1){ - /** @var Loader|null $chest_shop */ - $chest_shop = Server::getInstance()->getPluginManager()->getPlugin("ChestShop"); - assert($chest_shop !== null); - $chest_shop->getLogger()->warning("{$this->plugin->getName()} is unsafe to use with > 1 database threads"); - $chest_shop->getLogger()->warning("To correct this issue, set 'threads' to 1 in {$this->plugin->getConfig()->getPath()}"); - $chest_shop->getLogger()->warning("To suppress this error, set 'unsafe-warn' to false in {$chest_shop->getConfig()->getPath()}"); - } } public function getMoney(PlayerIdentity $player, Closure $callback) : void{ @@ -50,26 +40,10 @@ public function addMoney(PlayerIdentity $player, float $money) : void{ } public function removeMoney(PlayerIdentity $player, float $money, Closure $callback) : void{ - /** - * SAFETY NOTICE - * This method executes two asynchronous processes simultaneously: - * getPlayerBalance(), subtractFromPlayerBalance() - * - * It is completely possible for a race condition to happen and an unexpected value - * be subtracted as a consequence. - * BedrockEconomy lets player balances go below 0, so directly invoking - * subtractFromPlayerBalance() is not possible. - */ $money_int = (int) ceil($money); - $this->getMoney($player, static function(float $balance) use($player, $money_int, $callback) : void{ - if($balance >= $money_int){ - BedrockEconomyAPI::getInstance()->subtractFromPlayerBalance($player->getGamertag(), $money_int, ClosureContext::create(static function(bool $success) use($callback) : void{ - $callback($success); - })); - }else{ - $callback(false); - } - }); + BedrockEconomyAPI::getInstance()->subtractFromPlayerBalance($player->getGamertag(), $money_int, ClosureContext::create(static function(bool $success) use($callback) : void{ + $callback($success); + })); } public function formatMoney(float $money) : string{