From 0660e243f6c2ce5432fdc9deae72f5258c16eefa Mon Sep 17 00:00:00 2001 From: Sajjadidh45 Date: Mon, 30 Jun 2025 07:10:53 +0330 Subject: [PATCH 01/12] Update To [api 5.0.0] --- EconomyAPI/plugin.yml | 2 +- EconomyAPI/src/onebone/economyapi/EconomyAPI.php | 6 +++--- EconomyAPI/src/onebone/economyapi/EventListener.php | 6 +++--- EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php | 2 +- EconomyAirport/plugin.yml | 2 +- EconomyAuction/plugin.yml | 2 +- EconomyCasino/plugin.yml | 2 +- EconomyCasino/src/onebone/economycasino/EconomyCasino.php | 2 +- EconomyJob/plugin.yml | 2 +- EconomyLand/plugin.yml | 2 +- EconomyLand/src/onebone/economyland/EventListener.php | 6 +++--- EconomyPShop/plugin.yml | 2 +- EconomyProperty/plugin.yml | 2 +- .../src/onebone/economyproperty/EconomyProperty.php | 2 +- EconomySell/plugin.yml | 2 +- EconomyShop/plugin.yml | 2 +- EconomyShop/src/onebone/economyshop/EconomyShop.php | 2 +- EconomyTax/plugin.yml | 2 +- EconomyUsury/plugin.yml | 2 +- EconomyUsury/src/onebone/economyusury/DueTask.php | 2 +- 20 files changed, 26 insertions(+), 26 deletions(-) diff --git a/EconomyAPI/plugin.yml b/EconomyAPI/plugin.yml index b8235eea..450a7153 100644 --- a/EconomyAPI/plugin.yml +++ b/EconomyAPI/plugin.yml @@ -2,7 +2,7 @@ name: EconomyAPI main: onebone\economyapi\EconomyAPI version: "3.0.0-SNAPSHOT" author: onebone -api: 3.9.0 +api: 5.0.0 permissions: economyapi: diff --git a/EconomyAPI/src/onebone/economyapi/EconomyAPI.php b/EconomyAPI/src/onebone/economyapi/EconomyAPI.php index 16230f68..dc82bab8 100644 --- a/EconomyAPI/src/onebone/economyapi/EconomyAPI.php +++ b/EconomyAPI/src/onebone/economyapi/EconomyAPI.php @@ -60,7 +60,7 @@ use pocketmine\command\CommandSender; use pocketmine\event\Listener; use pocketmine\event\player\PlayerJoinEvent; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\Config; use pocketmine\utils\Internet; @@ -68,7 +68,7 @@ use Throwable; class EconomyAPI extends PluginBase implements Listener { - const API_VERSION = 4; + const API_VERSION = 5; const PACKAGE_VERSION = "6.0"; /** @@ -913,7 +913,7 @@ private function registerCommands() { ]); } - public function onJoin(PlayerJoinEvent $event) { + public function onPlayerJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); if(!$this->defaultCurrency->getBalanceRepository()->hasAccount($player)) { diff --git a/EconomyAPI/src/onebone/economyapi/EventListener.php b/EconomyAPI/src/onebone/economyapi/EventListener.php index 2c84ba33..8f4bb47e 100644 --- a/EconomyAPI/src/onebone/economyapi/EventListener.php +++ b/EconomyAPI/src/onebone/economyapi/EventListener.php @@ -25,9 +25,9 @@ use pocketmine\event\player\PlayerQuitEvent; use pocketmine\event\server\DataPacketSendEvent; use pocketmine\network\mcpe\protocol\AvailableCommandsPacket; -use pocketmine\network\mcpe\protocol\types\CommandEnum; -use pocketmine\network\mcpe\protocol\types\CommandParameter; -use pocketmine\Player; +use pocketmine\network\mcpe\protocol\types\command\CommandEnum; +use pocketmine\network\mcpe\protocol\types\command\CommandParameter; +use pocketmine\player\Player; class EventListener implements Listener { /** @var EconomyAPI */ diff --git a/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php b/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php index f8829df7..f2e9e836 100644 --- a/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php +++ b/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php @@ -27,7 +27,7 @@ use onebone\economyapi\util\Transaction; use onebone\economyapi\util\TransactionAction; use onebone\economyapi\util\TransactionResult; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\utils\Config; class YamlProvider implements Provider { diff --git a/EconomyAirport/plugin.yml b/EconomyAirport/plugin.yml index d9922bdc..448a1d39 100644 --- a/EconomyAirport/plugin.yml +++ b/EconomyAirport/plugin.yml @@ -1,7 +1,7 @@ name: EconomyAirport version: "2.0.4" author: onebone -api: 3.9.0 +api: 5.0.0 main: onebone\economyairport\EconomyAirport depend: [EconomyAPI] diff --git a/EconomyAuction/plugin.yml b/EconomyAuction/plugin.yml index 26c90b26..dbabe585 100644 --- a/EconomyAuction/plugin.yml +++ b/EconomyAuction/plugin.yml @@ -1,7 +1,7 @@ name: EconomyAuction main: onebone\economyauction\EconomyAuction version: "2.0.2" -api: 3.9.0 +api: 5.0.0 author: onebone depend: [EconomyAPI] diff --git a/EconomyCasino/plugin.yml b/EconomyCasino/plugin.yml index 6158fa34..e4faa26b 100644 --- a/EconomyCasino/plugin.yml +++ b/EconomyCasino/plugin.yml @@ -2,7 +2,7 @@ name: EconomyCasino main: onebone\economycasino\EconomyCasino version: "2.0.2" author: onebone -api: 3.9.0 +api: 5.0.0 depend: [EconomyAPI] diff --git a/EconomyCasino/src/onebone/economycasino/EconomyCasino.php b/EconomyCasino/src/onebone/economycasino/EconomyCasino.php index 1731d4df..f048bf39 100644 --- a/EconomyCasino/src/onebone/economycasino/EconomyCasino.php +++ b/EconomyCasino/src/onebone/economycasino/EconomyCasino.php @@ -25,7 +25,7 @@ use pocketmine\command\CommandSender; use pocketmine\event\Listener; use pocketmine\event\player\PlayerQuitEvent; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\Config; diff --git a/EconomyJob/plugin.yml b/EconomyJob/plugin.yml index e3fe1bb3..e334ef29 100644 --- a/EconomyJob/plugin.yml +++ b/EconomyJob/plugin.yml @@ -1,7 +1,7 @@ name: EconomyJob main: onebone\economyjob\EconomyJob version: "2.0.4" -api: 3.9.0 +api: 5.0.0 depend: [EconomyAPI] author: onebone diff --git a/EconomyLand/plugin.yml b/EconomyLand/plugin.yml index 9d305b84..44648b5e 100644 --- a/EconomyLand/plugin.yml +++ b/EconomyLand/plugin.yml @@ -1,6 +1,6 @@ name: EconomyLand main: onebone\economyland\EconomyLand -api: 3.9.0 +api: 5.0.0 version: "3.0.0-SNAPSHOT" author: onebone depend: [EconomyAPI] diff --git a/EconomyLand/src/onebone/economyland/EventListener.php b/EconomyLand/src/onebone/economyland/EventListener.php index 122af3b1..7f364020 100644 --- a/EconomyLand/src/onebone/economyland/EventListener.php +++ b/EconomyLand/src/onebone/economyland/EventListener.php @@ -11,9 +11,9 @@ use pocketmine\inventory\PlayerInventory; use pocketmine\level\Position; use pocketmine\network\mcpe\protocol\AvailableCommandsPacket; -use pocketmine\network\mcpe\protocol\types\CommandEnum; -use pocketmine\network\mcpe\protocol\types\CommandParameter; -use pocketmine\Player; +use pocketmine\network\mcpe\protocol\types\command\CommandEnum; +use pocketmine\network\mcpe\protocol\types\command\CommandParameter; +use pocketmine\player\Player; class EventListener implements Listener { /** @var EconomyLand */ diff --git a/EconomyPShop/plugin.yml b/EconomyPShop/plugin.yml index d70a212a..0365dd2a 100644 --- a/EconomyPShop/plugin.yml +++ b/EconomyPShop/plugin.yml @@ -3,7 +3,7 @@ version: "2.0.2" author: onebone main: onebone\economypshop\EconomyPShop -api: 3.9.0 +api: 5.0.0 permissions: economypshop: diff --git a/EconomyProperty/plugin.yml b/EconomyProperty/plugin.yml index 4caf4bb1..1566d3a7 100644 --- a/EconomyProperty/plugin.yml +++ b/EconomyProperty/plugin.yml @@ -2,7 +2,7 @@ name: EconomyProperty main: onebone\economyproperty\EconomyProperty version: "2.0.6" author: onebone -api: 3.9.0 +api: 5.0.0 depend: - EconomyLand diff --git a/EconomyProperty/src/onebone/economyproperty/EconomyProperty.php b/EconomyProperty/src/onebone/economyproperty/EconomyProperty.php index befa6f51..eb51d751 100644 --- a/EconomyProperty/src/onebone/economyproperty/EconomyProperty.php +++ b/EconomyProperty/src/onebone/economyproperty/EconomyProperty.php @@ -39,7 +39,7 @@ use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\StringTag; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\tile\Sign; use pocketmine\tile\Tile; diff --git a/EconomySell/plugin.yml b/EconomySell/plugin.yml index 8737ff01..b31aea65 100644 --- a/EconomySell/plugin.yml +++ b/EconomySell/plugin.yml @@ -1,6 +1,6 @@ name: EconomySell version: "2.0.7" -api: 3.9.0 +api: 5.0.0 main: onebone\economysell\EconomySell author: onebone diff --git a/EconomyShop/plugin.yml b/EconomyShop/plugin.yml index 44c37097..c4fbbb22 100644 --- a/EconomyShop/plugin.yml +++ b/EconomyShop/plugin.yml @@ -1,6 +1,6 @@ name: EconomyShop version: "2.0.7" -api: 3.9.0 +api: 5.0.0 main: onebone\economyshop\EconomyShop author: onebone diff --git a/EconomyShop/src/onebone/economyshop/EconomyShop.php b/EconomyShop/src/onebone/economyshop/EconomyShop.php index d166ba17..ae8a3eea 100644 --- a/EconomyShop/src/onebone/economyshop/EconomyShop.php +++ b/EconomyShop/src/onebone/economyshop/EconomyShop.php @@ -37,7 +37,7 @@ use pocketmine\item\Item; use pocketmine\level\Position; use pocketmine\math\Vector3; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\TextFormat; diff --git a/EconomyTax/plugin.yml b/EconomyTax/plugin.yml index e4ad3fa1..19abb656 100644 --- a/EconomyTax/plugin.yml +++ b/EconomyTax/plugin.yml @@ -2,7 +2,7 @@ name: EconomyTax main: onebone\economytax\EconomyTax author: onebone version: "2.0.3" -api: 3.9.0 +api: 5.0.0 depend: [EconomyAPI] permissions: diff --git a/EconomyUsury/plugin.yml b/EconomyUsury/plugin.yml index b4ab2c0f..9dec16ac 100644 --- a/EconomyUsury/plugin.yml +++ b/EconomyUsury/plugin.yml @@ -1,7 +1,7 @@ name: EconomyUsury version: "1.0.1" author: onebone -api: 3.9.0 +api: 5.0.0 main: onebone\economyusury\EconomyUsury depend: [EconomyAPI] diff --git a/EconomyUsury/src/onebone/economyusury/DueTask.php b/EconomyUsury/src/onebone/economyusury/DueTask.php index 2bcc0af4..eae35cb7 100644 --- a/EconomyUsury/src/onebone/economyusury/DueTask.php +++ b/EconomyUsury/src/onebone/economyusury/DueTask.php @@ -21,7 +21,7 @@ namespace onebone\economyusury; use pocketmine\item\Item; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\scheduler\Task; class DueTask extends Task { From 625864f2cc2c549936c5438e6a0bb885fa2c5f64 Mon Sep 17 00:00:00 2001 From: Sajjadidh45 Date: Mon, 30 Jun 2025 07:13:19 +0330 Subject: [PATCH 02/12] Update --- EconomyAPI/plugin.yml | 2 +- EconomyAPI/src/onebone/economyapi/EconomyAPI.php | 6 +++--- EconomyAPI/src/onebone/economyapi/EventListener.php | 6 +++--- EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php | 2 +- EconomyAirport/plugin.yml | 2 +- EconomyAuction/plugin.yml | 2 +- EconomyCasino/plugin.yml | 2 +- EconomyCasino/src/onebone/economycasino/EconomyCasino.php | 2 +- EconomyJob/plugin.yml | 2 +- EconomyLand/plugin.yml | 2 +- EconomyLand/src/onebone/economyland/EventListener.php | 6 +++--- EconomyPShop/plugin.yml | 2 +- EconomyProperty/plugin.yml | 2 +- .../src/onebone/economyproperty/EconomyProperty.php | 2 +- EconomySell/plugin.yml | 2 +- EconomyShop/plugin.yml | 2 +- EconomyShop/src/onebone/economyshop/EconomyShop.php | 2 +- EconomyTax/plugin.yml | 2 +- EconomyUsury/plugin.yml | 2 +- EconomyUsury/src/onebone/economyusury/DueTask.php | 2 +- 20 files changed, 26 insertions(+), 26 deletions(-) diff --git a/EconomyAPI/plugin.yml b/EconomyAPI/plugin.yml index b8235eea..450a7153 100644 --- a/EconomyAPI/plugin.yml +++ b/EconomyAPI/plugin.yml @@ -2,7 +2,7 @@ name: EconomyAPI main: onebone\economyapi\EconomyAPI version: "3.0.0-SNAPSHOT" author: onebone -api: 3.9.0 +api: 5.0.0 permissions: economyapi: diff --git a/EconomyAPI/src/onebone/economyapi/EconomyAPI.php b/EconomyAPI/src/onebone/economyapi/EconomyAPI.php index 16230f68..dc82bab8 100644 --- a/EconomyAPI/src/onebone/economyapi/EconomyAPI.php +++ b/EconomyAPI/src/onebone/economyapi/EconomyAPI.php @@ -60,7 +60,7 @@ use pocketmine\command\CommandSender; use pocketmine\event\Listener; use pocketmine\event\player\PlayerJoinEvent; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\Config; use pocketmine\utils\Internet; @@ -68,7 +68,7 @@ use Throwable; class EconomyAPI extends PluginBase implements Listener { - const API_VERSION = 4; + const API_VERSION = 5; const PACKAGE_VERSION = "6.0"; /** @@ -913,7 +913,7 @@ private function registerCommands() { ]); } - public function onJoin(PlayerJoinEvent $event) { + public function onPlayerJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); if(!$this->defaultCurrency->getBalanceRepository()->hasAccount($player)) { diff --git a/EconomyAPI/src/onebone/economyapi/EventListener.php b/EconomyAPI/src/onebone/economyapi/EventListener.php index 2c84ba33..8f4bb47e 100644 --- a/EconomyAPI/src/onebone/economyapi/EventListener.php +++ b/EconomyAPI/src/onebone/economyapi/EventListener.php @@ -25,9 +25,9 @@ use pocketmine\event\player\PlayerQuitEvent; use pocketmine\event\server\DataPacketSendEvent; use pocketmine\network\mcpe\protocol\AvailableCommandsPacket; -use pocketmine\network\mcpe\protocol\types\CommandEnum; -use pocketmine\network\mcpe\protocol\types\CommandParameter; -use pocketmine\Player; +use pocketmine\network\mcpe\protocol\types\command\CommandEnum; +use pocketmine\network\mcpe\protocol\types\command\CommandParameter; +use pocketmine\player\Player; class EventListener implements Listener { /** @var EconomyAPI */ diff --git a/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php b/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php index f8829df7..f2e9e836 100644 --- a/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php +++ b/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php @@ -27,7 +27,7 @@ use onebone\economyapi\util\Transaction; use onebone\economyapi\util\TransactionAction; use onebone\economyapi\util\TransactionResult; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\utils\Config; class YamlProvider implements Provider { diff --git a/EconomyAirport/plugin.yml b/EconomyAirport/plugin.yml index d9922bdc..448a1d39 100644 --- a/EconomyAirport/plugin.yml +++ b/EconomyAirport/plugin.yml @@ -1,7 +1,7 @@ name: EconomyAirport version: "2.0.4" author: onebone -api: 3.9.0 +api: 5.0.0 main: onebone\economyairport\EconomyAirport depend: [EconomyAPI] diff --git a/EconomyAuction/plugin.yml b/EconomyAuction/plugin.yml index 26c90b26..dbabe585 100644 --- a/EconomyAuction/plugin.yml +++ b/EconomyAuction/plugin.yml @@ -1,7 +1,7 @@ name: EconomyAuction main: onebone\economyauction\EconomyAuction version: "2.0.2" -api: 3.9.0 +api: 5.0.0 author: onebone depend: [EconomyAPI] diff --git a/EconomyCasino/plugin.yml b/EconomyCasino/plugin.yml index 6158fa34..e4faa26b 100644 --- a/EconomyCasino/plugin.yml +++ b/EconomyCasino/plugin.yml @@ -2,7 +2,7 @@ name: EconomyCasino main: onebone\economycasino\EconomyCasino version: "2.0.2" author: onebone -api: 3.9.0 +api: 5.0.0 depend: [EconomyAPI] diff --git a/EconomyCasino/src/onebone/economycasino/EconomyCasino.php b/EconomyCasino/src/onebone/economycasino/EconomyCasino.php index 1731d4df..f048bf39 100644 --- a/EconomyCasino/src/onebone/economycasino/EconomyCasino.php +++ b/EconomyCasino/src/onebone/economycasino/EconomyCasino.php @@ -25,7 +25,7 @@ use pocketmine\command\CommandSender; use pocketmine\event\Listener; use pocketmine\event\player\PlayerQuitEvent; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\Config; diff --git a/EconomyJob/plugin.yml b/EconomyJob/plugin.yml index e3fe1bb3..e334ef29 100644 --- a/EconomyJob/plugin.yml +++ b/EconomyJob/plugin.yml @@ -1,7 +1,7 @@ name: EconomyJob main: onebone\economyjob\EconomyJob version: "2.0.4" -api: 3.9.0 +api: 5.0.0 depend: [EconomyAPI] author: onebone diff --git a/EconomyLand/plugin.yml b/EconomyLand/plugin.yml index 9d305b84..44648b5e 100644 --- a/EconomyLand/plugin.yml +++ b/EconomyLand/plugin.yml @@ -1,6 +1,6 @@ name: EconomyLand main: onebone\economyland\EconomyLand -api: 3.9.0 +api: 5.0.0 version: "3.0.0-SNAPSHOT" author: onebone depend: [EconomyAPI] diff --git a/EconomyLand/src/onebone/economyland/EventListener.php b/EconomyLand/src/onebone/economyland/EventListener.php index 122af3b1..7f364020 100644 --- a/EconomyLand/src/onebone/economyland/EventListener.php +++ b/EconomyLand/src/onebone/economyland/EventListener.php @@ -11,9 +11,9 @@ use pocketmine\inventory\PlayerInventory; use pocketmine\level\Position; use pocketmine\network\mcpe\protocol\AvailableCommandsPacket; -use pocketmine\network\mcpe\protocol\types\CommandEnum; -use pocketmine\network\mcpe\protocol\types\CommandParameter; -use pocketmine\Player; +use pocketmine\network\mcpe\protocol\types\command\CommandEnum; +use pocketmine\network\mcpe\protocol\types\command\CommandParameter; +use pocketmine\player\Player; class EventListener implements Listener { /** @var EconomyLand */ diff --git a/EconomyPShop/plugin.yml b/EconomyPShop/plugin.yml index d70a212a..0365dd2a 100644 --- a/EconomyPShop/plugin.yml +++ b/EconomyPShop/plugin.yml @@ -3,7 +3,7 @@ version: "2.0.2" author: onebone main: onebone\economypshop\EconomyPShop -api: 3.9.0 +api: 5.0.0 permissions: economypshop: diff --git a/EconomyProperty/plugin.yml b/EconomyProperty/plugin.yml index 4caf4bb1..1566d3a7 100644 --- a/EconomyProperty/plugin.yml +++ b/EconomyProperty/plugin.yml @@ -2,7 +2,7 @@ name: EconomyProperty main: onebone\economyproperty\EconomyProperty version: "2.0.6" author: onebone -api: 3.9.0 +api: 5.0.0 depend: - EconomyLand diff --git a/EconomyProperty/src/onebone/economyproperty/EconomyProperty.php b/EconomyProperty/src/onebone/economyproperty/EconomyProperty.php index befa6f51..eb51d751 100644 --- a/EconomyProperty/src/onebone/economyproperty/EconomyProperty.php +++ b/EconomyProperty/src/onebone/economyproperty/EconomyProperty.php @@ -39,7 +39,7 @@ use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\StringTag; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\tile\Sign; use pocketmine\tile\Tile; diff --git a/EconomySell/plugin.yml b/EconomySell/plugin.yml index 8737ff01..b31aea65 100644 --- a/EconomySell/plugin.yml +++ b/EconomySell/plugin.yml @@ -1,6 +1,6 @@ name: EconomySell version: "2.0.7" -api: 3.9.0 +api: 5.0.0 main: onebone\economysell\EconomySell author: onebone diff --git a/EconomyShop/plugin.yml b/EconomyShop/plugin.yml index 44c37097..c4fbbb22 100644 --- a/EconomyShop/plugin.yml +++ b/EconomyShop/plugin.yml @@ -1,6 +1,6 @@ name: EconomyShop version: "2.0.7" -api: 3.9.0 +api: 5.0.0 main: onebone\economyshop\EconomyShop author: onebone diff --git a/EconomyShop/src/onebone/economyshop/EconomyShop.php b/EconomyShop/src/onebone/economyshop/EconomyShop.php index d166ba17..ae8a3eea 100644 --- a/EconomyShop/src/onebone/economyshop/EconomyShop.php +++ b/EconomyShop/src/onebone/economyshop/EconomyShop.php @@ -37,7 +37,7 @@ use pocketmine\item\Item; use pocketmine\level\Position; use pocketmine\math\Vector3; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\TextFormat; diff --git a/EconomyTax/plugin.yml b/EconomyTax/plugin.yml index e4ad3fa1..19abb656 100644 --- a/EconomyTax/plugin.yml +++ b/EconomyTax/plugin.yml @@ -2,7 +2,7 @@ name: EconomyTax main: onebone\economytax\EconomyTax author: onebone version: "2.0.3" -api: 3.9.0 +api: 5.0.0 depend: [EconomyAPI] permissions: diff --git a/EconomyUsury/plugin.yml b/EconomyUsury/plugin.yml index b4ab2c0f..9dec16ac 100644 --- a/EconomyUsury/plugin.yml +++ b/EconomyUsury/plugin.yml @@ -1,7 +1,7 @@ name: EconomyUsury version: "1.0.1" author: onebone -api: 3.9.0 +api: 5.0.0 main: onebone\economyusury\EconomyUsury depend: [EconomyAPI] diff --git a/EconomyUsury/src/onebone/economyusury/DueTask.php b/EconomyUsury/src/onebone/economyusury/DueTask.php index 2bcc0af4..eae35cb7 100644 --- a/EconomyUsury/src/onebone/economyusury/DueTask.php +++ b/EconomyUsury/src/onebone/economyusury/DueTask.php @@ -21,7 +21,7 @@ namespace onebone\economyusury; use pocketmine\item\Item; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\scheduler\Task; class DueTask extends Task { From 037788407b6ac2f5c1a7d1d8ba71117a3b399c33 Mon Sep 17 00:00:00 2001 From: Sajjad Date: Mon, 30 Jun 2025 07:30:16 +0330 Subject: [PATCH 03/12] Create php.yml --- .github/workflows/php.yml | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 00000000..e634cf4f --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,50 @@ + +name: Build PHAR Files + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + extensions: phar, yaml + ini-values: phar.readonly=Off + + - name: Create build directory + run: mkdir -p build + + - name: Build PHAR files + run: php build_phars.php + + - name: List built files + run: ls -la build/ + + - name: Upload PHAR artifacts + uses: actions/upload-artifact@v4 + with: + name: economy-plugins-phar + path: build/*.phar + retention-days: 30 + + - name: Create Release (on tag) + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v1 + with: + files: build/*.phar + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b634f7bc0060562ccd57a5d27803f97670445d14 Mon Sep 17 00:00:00 2001 From: Sajjad Date: Mon, 30 Jun 2025 07:33:50 +0330 Subject: [PATCH 04/12] Create build.php --- build.php | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 build.php diff --git a/build.php b/build.php new file mode 100644 index 00000000..a9843f36 --- /dev/null +++ b/build.php @@ -0,0 +1,90 @@ + +startBuffering(); + + // Add plugin.yml + if (file_exists("$pluginDir/plugin.yml")) { + $phar->addFile("$pluginDir/plugin.yml", "plugin.yml"); + } + + // Add source files + if (is_dir("$pluginDir/src")) { + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator("$pluginDir/src", RecursiveDirectoryIterator::SKIP_DOTS) + ); + + foreach ($iterator as $file) { + if ($file->isFile() && $file->getExtension() === 'php') { + $relativePath = str_replace("$pluginDir/", '', $file->getPathname()); + $phar->addFile($file->getPathname(), $relativePath); + } + } + } + + // Add resources + if (is_dir("$pluginDir/resources")) { + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator("$pluginDir/resources", RecursiveDirectoryIterator::SKIP_DOTS) + ); + + foreach ($iterator as $file) { + if ($file->isFile()) { + $relativePath = str_replace("$pluginDir/", '', $file->getPathname()); + $phar->addFile($file->getPathname(), $relativePath); + } + } + } + + $phar->stopBuffering(); + echo "✓ Built $plugin.phar successfully\n"; + + } catch (Exception $e) { + echo "✗ Failed to build $plugin.phar: " . $e->getMessage() . "\n"; + } +} + +echo "\nBuild complete! Check the build/ directory for PHAR files.\n"; +?> From 50e2fa52fe9a9d2fb87e8e47e0be3269ff755860 Mon Sep 17 00:00:00 2001 From: Sajjad Date: Mon, 30 Jun 2025 07:35:11 +0330 Subject: [PATCH 05/12] Update php.yml --- .github/workflows/php.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index e634cf4f..172816ab 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -1,4 +1,3 @@ - name: Build PHAR Files on: @@ -11,34 +10,34 @@ on: jobs: build: runs-on: ubuntu-latest - + steps: - name: Checkout code uses: actions/checkout@v4 - + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: '8.2' extensions: phar, yaml ini-values: phar.readonly=Off - + - name: Create build directory run: mkdir -p build - + - name: Build PHAR files run: php build_phars.php - + - name: List built files run: ls -la build/ - + - name: Upload PHAR artifacts uses: actions/upload-artifact@v4 with: name: economy-plugins-phar path: build/*.phar retention-days: 30 - + - name: Create Release (on tag) if: startsWith(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v1 From 1011d39ed1ea3ab6f6329818ddb2078ec03b1144 Mon Sep 17 00:00:00 2001 From: Sajjad Date: Mon, 30 Jun 2025 07:38:23 +0330 Subject: [PATCH 06/12] Update and rename build.php to build_phars.php --- build.php | 90 ------------------------------------------------- build_phars.php | 70 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 90 deletions(-) delete mode 100644 build.php create mode 100644 build_phars.php diff --git a/build.php b/build.php deleted file mode 100644 index a9843f36..00000000 --- a/build.php +++ /dev/null @@ -1,90 +0,0 @@ - -startBuffering(); - - // Add plugin.yml - if (file_exists("$pluginDir/plugin.yml")) { - $phar->addFile("$pluginDir/plugin.yml", "plugin.yml"); - } - - // Add source files - if (is_dir("$pluginDir/src")) { - $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator("$pluginDir/src", RecursiveDirectoryIterator::SKIP_DOTS) - ); - - foreach ($iterator as $file) { - if ($file->isFile() && $file->getExtension() === 'php') { - $relativePath = str_replace("$pluginDir/", '', $file->getPathname()); - $phar->addFile($file->getPathname(), $relativePath); - } - } - } - - // Add resources - if (is_dir("$pluginDir/resources")) { - $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator("$pluginDir/resources", RecursiveDirectoryIterator::SKIP_DOTS) - ); - - foreach ($iterator as $file) { - if ($file->isFile()) { - $relativePath = str_replace("$pluginDir/", '', $file->getPathname()); - $phar->addFile($file->getPathname(), $relativePath); - } - } - } - - $phar->stopBuffering(); - echo "✓ Built $plugin.phar successfully\n"; - - } catch (Exception $e) { - echo "✗ Failed to build $plugin.phar: " . $e->getMessage() . "\n"; - } -} - -echo "\nBuild complete! Check the build/ directory for PHAR files.\n"; -?> diff --git a/build_phars.php b/build_phars.php new file mode 100644 index 00000000..249ef35e --- /dev/null +++ b/build_phars.php @@ -0,0 +1,70 @@ +setSignatureAlgorithm(Phar::SHA1); + $phar->startBuffering(); + + // Add all files from plugin directory + $iterator = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($pluginDir), + RecursiveIteratorIterator::LEAVES_ONLY + ); + + foreach ($iterator as $file) { + if ($file->isFile() && !in_array($file->getFilename(), ['.', '..'])) { + $relativePath = str_replace($pluginDir . '/', '', $file->getPathname()); + $phar->addFile($file->getPathname(), $relativePath); + } + } + + // Set the stub (entry point) + $phar->setStub("stopBuffering(); + + echo "✓ Built $plugin.phar successfully\n"; + + } catch (Exception $e) { + echo "✗ Failed to build $plugin.phar: " . $e->getMessage() . "\n"; + } +} + +echo "\nBuild process completed! PHAR files are in the 'build' directory.\n"; From 53988e0515bcaaa486b214e0e6add23e874b41e7 Mon Sep 17 00:00:00 2001 From: Sajjadidh45 Date: Wed, 2 Jul 2025 04:30:10 +0330 Subject: [PATCH 07/12] economy land update to PM5 --- EconomyLand/plugin.yml | 172 ++-- EconomyLand/resources/config.yml | 27 +- .../src/onebone/economyland/EconomyLand.php | 840 ++++++++++++++++-- .../src/onebone/economyland/ExpireTask.php | 40 + .../src/onebone/economyland/SaveTask.php | 40 + .../onebone/economyland/database/Database.php | 42 + .../economyland/database/SQLiteDatabase.php | 206 +++++ .../economyland/database/YamlDatabase.php | 226 +++++ .../economyland/event/LandAddedEvent.php | 78 ++ .../economyland/event/LandRemoveEvent.php | 42 + 10 files changed, 1543 insertions(+), 170 deletions(-) create mode 100644 EconomyLand/src/onebone/economyland/ExpireTask.php create mode 100644 EconomyLand/src/onebone/economyland/SaveTask.php create mode 100644 EconomyLand/src/onebone/economyland/database/Database.php create mode 100644 EconomyLand/src/onebone/economyland/database/SQLiteDatabase.php create mode 100644 EconomyLand/src/onebone/economyland/database/YamlDatabase.php create mode 100644 EconomyLand/src/onebone/economyland/event/LandAddedEvent.php create mode 100644 EconomyLand/src/onebone/economyland/event/LandRemoveEvent.php diff --git a/EconomyLand/plugin.yml b/EconomyLand/plugin.yml index 44648b5e..05547911 100644 --- a/EconomyLand/plugin.yml +++ b/EconomyLand/plugin.yml @@ -1,85 +1,109 @@ name: EconomyLand main: onebone\economyland\EconomyLand api: 5.0.0 -version: "3.0.0-SNAPSHOT" -author: onebone -depend: [EconomyAPI] +version: 1.1.0 +authors: + - onebone + - Kevin + +softdepend: + - EconomyAPI permissions: - economyland: - description: Allows player to use all functions in EconomyLand - default: op - children: - economyland.land: + economyland.*: + description: Allows player to use all functions in EconomyLand + default: op + economyland.land.*: description: Allows player to access all lands default: op - children: - economyland.land.modify.others: - description: Allows player to modify others' lands - default: op - economyland.land.modify.whiteland: - description: Allows player to modify white lands - default: op - economyland.land.give.others: - description: Allows player to give others' land to others' - default: op - economyland.land.move: - description: Allows player move to land - default: op - children: - economyland.land.move.others: - description: Allows player move to others' land - default: true - economyland.landsell: - description: Gives permission player to access all land selling function - default: op - children: - economyland.landsell.others: - description: Allows player to sell others' land - default: op + economyland.land.modify.others: + description: Allows player to modify others' lands + default: op + economyland.land.modify.whiteland: + description: Allows player to modify white lands + default: op + economyland.land.give.others: + description: Allows player to give others' land to others' + default: op + economyland.land.move.*: + description: Allows player move to land + default: op + economyland.land.move.others: + description: Allows player move to others' land + default: true + economyland.landsell.*: + description: Gives permission player to access all land selling function + default: op + economyland.landsell.others: + description: Allows player to sell others' land + default: op - economyland.command: + economyland.command.*: description: Allows player to use all commands in EconomyLand default: op - children: - economyland.command.land: - description: Allows player to use land command - default: true - children: - economyland.command.land.pos: - description: Allows player to set positions for setting land - default: true - economyland.command.land.buy: - description: Allows player to buy land - default: true - economyland.command.land.option: - description: Allows player to edit option of land - default: true - economyland.command.land.sell: - description: Allows player to sell land - default: true - economyland.command.land.move: - description: Allows player to move to other land - default: true - economyland.command.land.list: - description: Allows player to see list of lands - default: true - economyland.command.land.whose: - description: Allows player to see list of lands with specified keyword - default: true - economyland.command.land.give: - description: Allows player give land to other - default: true - economyland.command.land.here: - description: Allows player to see what land player is standing on - default: true - economyland.command.land.invite: - description: Allows player to invite players - default: true - economyland.command.land.invite.remove: - description: Allows player to remove invitee from the list - default: true - children: - economyland.command.land.invite.remove.others: - default: op + economyland.command.startp: + description: Allows player to set start position + default: true + economyland.command.endp: + description: Allows player to set end position + default: true + economyland.command.land: + description: Allows player to use land command + default: true + economyland.command.land.buy: + description: Allows player to buy land + default: true + economyland.command.land.move: + description: Allows player to move to other land + default: true + economyland.command.land.list: + description: Allows player to see list of lands + default: true + economyland.command.land.whose: + description: Allows player to see list of lands with specified keyword + default: true + economyland.command.land.give: + description: Allows player give land to other + default: true + economyland.command.land.here: + description: Allows player to see what land player is standing on + default: true + economyland.command.land.invite: + description: Allows player to invite players + default: true + economyland.command.land.invite.remove: + description: Allows player to remove invitee from the list + default: true + economyland.command.land.invite.remove.others: + default: op + economyland.command.land.invitee: + description: Allows player to see invitee + default: true + + economyland.command.landsell: + description: Allows player to sell lands + default: op + economyland.command.landsell.here: + description: Allows player to sell land here + default: true + economyland.command.landsell.number: + description: Allows player to sell land with numbers + default: true +commands: + startp: + description: Sets start position + usage: /startp + permission: economyland.command.startp + endp: + description: Sets second position + usage: /endp + permission: economyland.command.endp + land: + description: Manage land + usage: /land + permission: economyland.command.land;economyland.command.land.buy;economyland.command.land.move;economyland.command.land.list;economyland.command.land.whose;economyland.command.land.give;economyland.command.land.here;economyland.command.land.invite;economyland.command.land.invite.remove;economyland.command.land.invitee + landsell: + description: Sell land + usage: /landsell + permission: economyland.command.landsell;economyland.command.landsell.here;economyland.command.landsell.number diff --git a/EconomyLand/resources/config.yml b/EconomyLand/resources/config.yml index ba9f9291..98d449fe 100644 --- a/EconomyLand/resources/config.yml +++ b/EconomyLand/resources/config.yml @@ -1,10 +1,17 @@ -# Language which plugin will use -language: en - -# Land is unloaded if not access by player for a long time. -# This is a configuration for setting the period to check this task. -# DO NOT TOUCH THIS if you don't know what you are doing. -# unit: ticks -land-unload-task-period: 200 -# unit: seconds -land-unload-after: 10 +# Whether to allow players to overlap their lands if it is owned by same player +allow-overlap: false +# Worlds to protect by default. Players will have to buy land in order to modify the terrain. +white-world-protection: [] +# Worlds not to be checked by EconomyLand. This option is for performance improvements. +# DO NOT TOUCH this option if you don't know what it is. +non-check-worlds: [] +# Worlds to disallow players to buy +buying-disallowed-worlds: [] +# Limit of lands +player-land-limit: NaN +# Price of land per one vertical area +price-per-y-axis: 100 +# Interval of auto saving +auto-save-interval: 10 +# Type of database provider (Available: yaml) +database-type: yaml diff --git a/EconomyLand/src/onebone/economyland/EconomyLand.php b/EconomyLand/src/onebone/economyland/EconomyLand.php index 515dbc8b..52bc4642 100644 --- a/EconomyLand/src/onebone/economyland/EconomyLand.php +++ b/EconomyLand/src/onebone/economyland/EconomyLand.php @@ -2,7 +2,7 @@ /* * EconomyS, the massive economy plugin with many features for PocketMine-MP - * Copyright (C) 2013-2021 onebone + * Copyright (C) 2013-2017 onebone * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,91 +20,759 @@ namespace onebone\economyland; -use onebone\economyapi\EconomyAPI; -use onebone\economyland\command\LandCommand; -use onebone\economyland\land\LandManager; -use onebone\economyland\provider\YamlProvider; +use Closure; +use pocketmine\math\Vector3; use pocketmine\plugin\PluginBase; +use pocketmine\event\Listener; +use pocketmine\event\Event; +use pocketmine\event\block\BlockPlaceEvent; +use pocketmine\event\block\BlockBreakEvent; +use pocketmine\event\player\PlayerInteractEvent; +use pocketmine\utils\Config; +use pocketmine\command\Command; +use pocketmine\command\CommandSender; +use pocketmine\player\Player; +use pocketmine\Server; +use pocketmine\utils\SingletonTrait; +use pocketmine\world\Position; +use pocketmine\world\World as Level; +use pocketmine\event\EventPriority; + +use onebone\economyapi\EconomyAPI; +use onebone\economyland\database\YamlDatabase; +use onebone\economyland\database\SQLiteDatabase; +use onebone\economyland\database\Database; + +class EconomyLand extends PluginBase implements Listener +{ + use SingletonTrait; + + /** + * @var Database; + */ + private Database $db; + /** + * @var Config + */ + private Config $lang; + private $start, $end; + private $expire; + + private $placeQueue; + + const RET_LAND_OVERLAP = 0; + const RET_LAND_LIMIT = 1; + const RET_SUCCESS = 2; + + public function onLoad(): void + { + self::setInstance($this); + } + + public function onEnable(): void + { + + $this->saveDefaultConfig(); + + if (!is_file($this->getDataFolder() . "Expire.dat")) { + file_put_contents($this->getDataFolder() . "Expire.dat", serialize(array())); + } + $this->expire = unserialize(file_get_contents($this->getDataFolder() . "Expire.dat")); + + $this->createConfig(); + + if (is_numeric($interval = $this->getConfig()->get("auto-save-interval", 10))) { + if ($interval > 0) { + $interval = $interval * 1200; + $this->getScheduler()->scheduleDelayedRepeatingTask(new SaveTask($this), $interval, $interval); + } + } + + $this->placeQueue = []; + + $now = time(); + foreach ($this->expire as $landId => &$time) { + $time[1] = $now; + $this->getScheduler()->scheduleDelayedTask(new ExpireTask($this, $landId), ($time[0] * 20)); + } + + switch (strtolower($this->getConfig()->get("database-type", "yaml"))) { + case "yaml": + case "yml": + $this->db = new YamlDatabase($this->getDataFolder() . "Land.yml", $this->getConfig(), $this->getDataFolder() . "Land.sqlite3"); + break; + case "sqlite3": + case "sqlite": + $this->db = new SQLiteDatabase($this->getDataFolder() . "Land.sqlite3", $this->getConfig(), $this->getDataFolder() . "Land.yml"); + break; + default: + $this->db = new YamlDatabase($this->getDataFolder() . "Land.yml", $this->getConfig(), $this->getDataFolder() . "Land.sqlite3"); + $this->getLogger()->alert("Specified database type is unavailable. Database type is YAML."); + } + $this->getServer()->getPluginManager()->registerEvent("pocketmine\\event\\block\\BlockPlaceEvent", Closure::fromCallable([$this, 'onPlaceEvent']), EventPriority::HIGHEST, $this); + $this->getServer()->getPluginManager()->registerEvent("pocketmine\\event\\block\\BlockBreakEvent", Closure::fromCallable([$this, 'onBreakEvent']), EventPriority::HIGHEST, $this); + $this->getServer()->getPluginManager()->registerEvent("pocketmine\\event\\player\\PlayerInteractEvent", Closure::fromCallable([$this, 'onPlayerInteract']), EventPriority::HIGHEST, $this); + + } + + public function expireLand($landId) + { + if (!isset($this->expire[$landId])) return; + $landId = (int)$landId; + + $info = $this->db->getLandById($landId); + if ($info === false) return; + $player = $info["owner"]; + if (($player = $this->getServer()->getPlayerExact($player)) instanceof Player) { + $player->sendMessage("[EconomyLand] Your land #$landId has expired."); + } + $this->db->removeLandById($landId); + unset($this->expire[$landId]); + return; + } + + public function onDisable(): void + { + if (Server::getInstance()->isRunning()) { + $this->save(); + if ($this->db instanceof Database) { + $this->db->close(); + } + } + + } + + public function save() + { + $now = time(); + foreach ($this->expire as $landId => $time) { + $this->expire[$landId][0] -= ($now - $time[1]); + } + file_put_contents($this->getDataFolder() . "Expire.dat", serialize($this->expire)); + if ($this->db instanceof Database) { + $this->db->save(); + } + } + + public function onCommand(CommandSender $sender, Command $cmd, string $label, array $param): bool + { + switch ($cmd->getName()) { + case "startp": + if (!$sender instanceof Player) { + $sender->sendMessage($this->getMessage("run-cmd-in-game")); + return true; + } + $x = (int)floor($sender->getPosition()->x); + $z = (int)floor($sender->getPosition()->z); + $level = $sender->getPosition()->getWorld()->getFolderName(); + $this->start[$sender->getName()] = array("x" => $x, "z" => $z, "level" => $level); + $sender->sendMessage($this->getMessage("first-position-saved")); + return true; + case "endp": + if (!$sender instanceof Player) { + $sender->sendMessage($this->getMessage("run-cmd-in-game")); + return true; + } + if (!isset($this->start[$sender->getName()])) { + $sender->sendMessage($this->getMessage("set-first-position")); + return true; + } + if ($sender->getPosition()->getWorld()->getFolderName() !== $this->start[$sender->getName()]["level"]) { + $sender->sendMessage($this->getMessage("cant-set-position-in-different-world")); + return true; + } + + $startX = (int)$this->start[$sender->getName()]["x"]; + $startZ = (int)$this->start[$sender->getName()]["z"]; + $endX = (int)floor($sender->getPosition()->x); + $endZ = (int)floor($sender->getPosition()->z); + $this->end[$sender->getName()] = array( + "x" => $endX, + "z" => $endZ + ); + if ($startX > $endX) { + $temp = $endX; + $endX = $startX; + $startX = $temp; + } + if ($startZ > $endZ) { + $temp = $endZ; + $endZ = $startZ; + $startZ = $temp; + } + $startX--; + $endX++; + $startZ--; + $endZ++; + $price = (($endX - $startX) - 1) * (($endZ - $startZ) - 1) * $this->getConfig()->get("price-per-y-axis", 100); + $sender->sendMessage($this->getMessage("confirm-buy-land", array($price, "%2", "%3"))); + + if (($land = $this->db->checkOverlap($startX, $endX, $startZ, $endZ, $sender->getPosition()->getWorld())) !== false) { + $sender->sendMessage($this->getMessage("confirm-warning", [$land["ID"], "%2", "%3"])); + } + return true; + case "land": + $sub = array_shift($param); + switch ($sub) { + case "buy": + if (!$sender->hasPermission("economyland.command.land.buy")) { + $sender->sendMessage($this->getMessage("no-permission-command")); + return true; + } + if (!$sender instanceof Player) { + $sender->sendMessage($this->getMessage("run-cmd-in-game")); + return true; + } + + if (in_array($sender->getPosition()->getWorld()->getFolderName(), $this->getConfig()->get("buying-disallowed-worlds", []))) { + $sender->sendMessage($this->getMessage("not-allowed-to-buy")); + return true; + } + + $cnt = count($this->db->getLandsByOwner($sender->getName())); + + if (is_numeric($this->getConfig()->get("player-land-limit", "NaN"))) { + if ($cnt >= $this->getConfig()->get("player-land-limit", "NaN")) { + $sender->sendMessage($this->getMessage("land-limit", array($cnt, $this->getConfig()->get("player-land-limit", "NaN"), "%3", "%4"))); + return true; + } + } + if (!isset($this->start[$sender->getName()])) { + $sender->sendMessage($this->getMessage("set-first-position")); + return true; + } elseif (!isset($this->end[$sender->getName()])) { + $sender->sendMessage($this->getMessage("set-second-position")); + return true; + } + $l = $this->start[$sender->getName()]; + $endp = $this->end[$sender->getName()]; + $startX = (int)floor($l["x"]); + $endX = (int)floor($endp["x"]); + $startZ = (int)floor($l["z"]); + $endZ = (int)floor($endp["z"]); + if ($startX > $endX) { + $backup = $startX; + $startX = $endX; + $endX = $backup; + } + if ($startZ > $endZ) { + $backup = $startZ; + $startZ = $endZ; + $endZ = $backup; + } + + $result = $this->db->checkOverlap($startX, $endX, $startZ, $endZ, $sender->getPosition()->getWorld()->getFolderName()); + if ($result) { + $sender->sendMessage($this->getMessage("land-around-here", array($result["owner"], $result["ID"], "%3"))); + return true; + } + $price = ((($endX + 1) - ($startX - 1)) - 1) * ((($endZ + 1) - ($startZ - 1)) - 1) * $this->getConfig()->get("price-per-y-axis", 100); + if (EconomyAPI::getInstance()->reduceMoney($sender, $price, true, "EconomyLand") === EconomyAPI::RET_INVALID) { + $sender->sendMessage($this->getMessage("no-money-to-buy-land")); + return true; + } + + $this->db->addLand($startX, $endX, $startZ, $endZ, $sender->getPosition()->getWorld()->getFolderName(), $price, $sender->getName()); + unset($this->start[$sender->getName()], $this->end[$sender->getName()]); + $sender->sendMessage($this->getMessage("bought-land", array($price, "%2", "%3"))); + break; + case "list": + if (!$sender->hasPermission("economyland.command.land.list")) { + $sender->sendMessage($this->getMessage("no-permission-command")); + return true; + } + $page = isset($param[0]) ? (int)$param[0] : 1; + + $land = $this->db->getAll(); + $output = ""; + $max = ceil(count($land) / 5); + $pro = 1; + $page = (int)$page; + $output .= $this->getMessage("land-list-top", array($page, $max, "")); + $current = 1; + foreach ($land as $l) { + $cur = (int)ceil($current / 5); + if ($cur > $page) + continue; + if ($pro == 6) + break; + if ($page === $cur) { + $output .= $this->getMessage("land-list-format", array($l["ID"], (($l["endX"] + 1) - ($l["startX"] - 1) - 1) * (($l["endZ"] + 1) - ($l["startZ"] - 1) - 1), $l["owner"])); + $pro++; + } + $current++; + } + $sender->sendMessage($output); + break; + case "whose": + if (!$sender->hasPermission("economyland.command.land.whose")) { + $sender->sendMessage($this->getMessage("no-permission-command")); + return true; + } + $player = array_shift($param); + $alike = true; + if (str_replace(" ", "", $player) === "") { + $player = $sender->getName(); + $alike = false; + } + + $lands = $this->db->getLandsByOwner($player); + + $sender->sendMessage("Results from query : $player\n"); + foreach ($lands as $info) + $sender->sendMessage($this->getMessage("land-list-format", array($info["ID"], ($info["endX"] - $info["startX"]) * ($info["endZ"] - $info["startZ"]), $info["owner"]))); + break; + case "move": + if (!$sender instanceof Player) { + $sender->sendMessage($this->getMessage("run-cmd-in-game")); + return true; + } + if (!$sender->hasPermission("economyland.command.land.move")) { + $sender->sendMessage($this->getMessage("no-permission-command")); + return true; + } + $num = array_shift($param); + if (trim($num) == "") { + $sender->sendMessage("Usage: /land move "); + return true; + } + if (!is_numeric($num)) { + $sender->sendMessage("Usage: /land move "); + return true; + } + + $info = $this->db->getLandById($num); + if ($info === false) { + $sender->sendMessage($this->getMessage("no-land-found", array($num, "", ""))); + return true; + } + + if ($info["owner"] !== $sender->getName()) { + if (!$sender->hasPermission("economyland.land.move.others")) { + $sender->sendMessage($this->getMessage("no-permission-move", [$info["ID"], $info["owner"], "%3"])); + return true; + } + } + $level = $this->getServer()->getWorldManager()->getWorldByName($info["level"]); + if (!$level instanceof Level) { + $sender->sendMessage($this->getMessage("land-corrupted", array($num, $info["level"], ""))); + return true; + } + $x = (int)($info["startX"] + (($info["endX"] - $info["startX"]) / 2)); + $z = (int)($info["startZ"] + (($info["endZ"] - $info["startZ"]) / 2)); + $cnt = 0; + for ($y = 128; ; $y--) { + $vec = new Vector3($x, $y, $z); + if ($level->getBlock($vec)->isSolid()) { + $y++; + break; + } + if ($cnt === 5) { + break; + } + if ($y <= 0) { + ++$cnt; + ++$x; + --$z; + $y = 128; + continue; + } + } + $sender->teleport(new Position($x + 0.5, $y + 0.1, $z + 0.5, $level)); + $sender->sendMessage($this->getMessage("success-moving", array($num, "", ""))); + return true; + case "give": + if (!$sender instanceof Player) { + $sender->sendMessage($this->getMessage("run-cmd-in-game")); + return true; + } + if (!$sender->hasPermission("economyland.command.land.give")) { + $sender->sendMessage($this->getMessage("no-permission-command")); + return true; + } + $player = array_shift($param); + $landnum = array_shift($param); + if (trim($player) == "" or trim($landnum) == "" or !is_numeric($landnum)) { + $sender->sendMessage("Usage: /$cmd give "); + return true; + } + $username = $player; + $player = $this->getServer()->getPlayerByPrefix($username); + if (!$player instanceof Player) { + $sender->sendMessage($this->getMessage("player-not-connected", [$username, "%2", "%3"])); + return true; + } + + $info = $this->db->getLandById($landnum); + if ($info === false) { + $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); + return true; + } + if ($sender->getName() !== $info["owner"] and !$sender->hasPermission("economyland.land.give.others")) { + $sender->sendMessage($this->getMessage("not-your-land", array($landnum, "%2", "%3"))); + } else { + if ($sender->getName() === $player->getName()) { + $sender->sendMessage($this->getMessage("cannot-give-land-myself")); + } else { + if (is_numeric($this->getConfig()->get("player-land-limit", "NaN"))) { + $cnt = count($this->db->getLandsByOwner($player->getName())); + if ($cnt >= $this->getConfig()->get("player-land-limit", "NaN")) { + $sender->sendMessage($this->getMessage("give-land-limit", array($player->getName(), $cnt, $this->getConfig()->get("player-land-limit", "NaN"), "%4"))); + return true; + } + } + + $this->db->setOwnerById($info["ID"], $player->getName()); + $sender->sendMessage($this->getMessage("gave-land", array($landnum, $player->getName(), "%3"))); + $player->sendMessage($this->getMessage("got-land", array($sender->getName(), $landnum, "%3"))); + } + } + return true; + case "invite": + if (!$sender->hasPermission("economyland.command.land.invite")) { + $sender->sendMessage($this->getMessage("no-permission-command")); + return true; + } + $landnum = array_shift($param); + $player = array_shift($param); + if (trim($player) == "" or trim($landnum) == "") { + $sender->sendMessage("Usage : /land invite <[r:]player>"); + return true; + } + if (!is_numeric($landnum)) { + $sender->sendMessage($this->getMessage("land-num-must-numeric", array($landnum, "%2", "%3"))); + return true; + } + $info = $this->db->getLandById($landnum); + if ($info === false) { + $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); + return true; + } elseif ($info["owner"] !== $sender->getName()) { + $sender->sendMessage($this->getMessage("not-your-land", array($landnum, "%2", "%3"))); + return true; + } else { + if (!Player::isValidUserName($player)) { + $sender->sendMessage($this->getMessage("invalid-invitee", [$player, "%2", "%3"])); + return true; + } + $result = $this->db->addInviteeById($landnum, $player); + if ($result === false) { + $sender->sendMessage($this->getMessage("already-invitee", array($player, "%2", "%3"))); + return true; + } + $sender->sendMessage($this->getMessage("success-invite", array($player, $landnum, "%3"))); + } + return true; + case "kick": + if (!$sender->hasPermission("economyland.command.land.invite.remove")) { + $sender->sendMessage($this->getMessage("no-permission-command")); + return true; + } + $landnum = array_shift($param); + $player = array_shift($param); + + if (trim($player) === "") { + $sender->sendMessage("Usage: /land kick "); + return true; + } + if (!is_numeric($landnum)) { + $sender->sendMessage($this->getMessage("land-num-must-numeric", array($landnum, "%2", "%3"))); + return true; + } + + $info = $this->db->getLandById($landnum); + if ($info === false) { + $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); + return true; + } + + if ($sender->hasPermission("economyland.command.land.invite.remove.others") and $info["owner"] !== $sender->getName() + or $info["owner"] === $sender->getName()) { + $result = $this->db->removeInviteeById($landnum, $player); + if ($result === false) { + $sender->sendMessage($this->getMessage("not-invitee", array($player, $landnum, "%3"))); + return true; + } + $sender->sendMessage($this->getMessage("removed-invitee", array($player, $landnum, "%3"))); + } + return true; + case "invitee": + $landnum = array_shift($param); + if (trim($landnum) == "" or !is_numeric($landnum)) { + $sender->sendMessage("Usage: /land invitee "); + return true; + } + + $info = $this->db->getInviteeById($landnum); + if ($info === false) { + $sender->sendMessage($this->getMessage("no-land-found", array($landnum, "%2", "%3"))); + return true; + } + $output = "Invitee of land #$landnum : \n"; + $output .= implode(", ", $info); + $sender->sendMessage($output); + return true; + case "here": + if (!$sender instanceof Player) { + $sender->sendMessage($this->getMessage("run-cmd-in-game")); + return true; + } + $x = $sender->getPosition()->x; + $z = $sender->getPosition()->z; + + $info = $this->db->getByCoord($x, $z, $sender->getPosition()->getWorld()->getFolderName()); + if ($info === false) { + $sender->sendMessage($this->getMessage("no-one-owned")); + return true; + } + $sender->sendMessage($this->getMessage("here-land", array($info["ID"], $info["owner"], "%3"))); + return true; + default: + $sender->sendMessage("Usage: " . $cmd->getUsage()); + } + return true; + case "landsell": + $id = array_shift($param); + switch ($id) { + case "here": + if (!$sender instanceof Player) { + $sender->sendMessage($this->getMessage("run-cmd-in-game")); + return true; + } + $x = $sender->getPosition()->getX(); + $z = $sender->getPosition()->getZ(); + + $info = $this->db->getByCoord($x, $z, $sender->getPosition()->getWorld()->getFolderName()); + if ($info === false) { + $sender->sendMessage($this->getMessage("no-one-owned")); + return true; + } + if ($info["owner"] !== $sender->getName() and !$sender->hasPermission("economyland.landsell.others")) { + $sender->sendMessage($this->getMessage("not-my-land")); + } else { + EconomyAPI::getInstance()->addMoney($sender, $info["price"] / 2); + $sender->sendMessage($this->getMessage("sold-land", array(($info["price"] / 2), "%2", "%3"))); + //$this->land->exec("DELETE FROM land WHERE ID = {$info["ID"]}"); + $this->db->removeLandById($info["ID"]); + } + return true; + default: + $p = $id; + if (is_numeric($p)) { + $info = $this->db->getLandById($p); + if ($info === false) { + $sender->sendMessage($this->getMessage("no-land-found", array($p, "%2", "%3"))); + return true; + } + if ($info["owner"] === $sender->getName() or $sender->hasPermission("economyland.landsell.others")) { + EconomyAPI::getInstance()->addMoney($sender, ($info["price"] / 2), true, "EconomyLand"); + $sender->sendMessage($this->getMessage("sold-land", array(($info["price"] / 2), "", ""))); + + $this->db->removeLandById($p); + } else { + $sender->sendMessage($this->getMessage("not-your-land", array($p, $info["owner"], "%3"))); + } + } else { + $sender->sendMessage("Usage: /landsell "); + } + } + return true; + } + return false; + } + + public function onPlayerInteract(PlayerInteractEvent $event): void + { + if ($event->getAction() === PlayerInteractEvent::RIGHT_CLICK_BLOCK) { + $this->permissionCheck($event); + } + } + + public function onPlaceEvent(BlockPlaceEvent $event): void + { + $name = $event->getPlayer()->getName(); + if (isset($this->placeQueue[$name])) { + $event->cancel(); + unset($this->placeQueue[$name]); + } + } + + public function onBreakEvent(BlockBreakEvent $event): void + { + $this->permissionCheck($event); + } + + public function permissionCheck(PlayerInteractEvent|BlockBreakEvent $event): bool + { + $player = $event->getPlayer(); + if ($event instanceof PlayerInteractEvent) { + $block = $event->getBlock()->getSide($event->getFace()); + } else { + $block = $event->getBlock(); + } + + $x = $block->getPosition()->x; + $z = $block->getPosition()->z; + $level = $block->getPosition()->getWorld()->getFolderName(); + if (in_array($level, $this->getConfig()->get("non-check-worlds", []))) { + return false; + } + $info = $this->db->canTouch($x, $z, $level, $player); + if ($info === -1) { + if ($this->getConfig()->get("white-world-protection", [])) { + if (in_array($level, $this->getConfig()->get("white-world-protection", [])) and !$player->hasPermission("economyland.land.modify.whiteland")) { + $player->sendMessage($this->getMessage("not-owned")); + $event->cancel(); + if ($event->getItem()->canBePlaced()) { + $this->placeQueue[$player->getName()] = true; + } + return false; + } + } + } elseif ($info !== true) { + $player->sendMessage($this->getMessage("no-permission", array($info["owner"], "", ""))); + $event->cancel(); + if ($event instanceof PlayerInteractEvent) { + if ($event->getItem()->canBePlaced()) { + $this->placeQueue[$player->getName()] = true; + } + } + return false; + } + return true; + } + + /** + * Adds land to the EconomyLand database + * + * @return int + * @var int $startX + * @var int $startZ + * @var int $endX + * @var int $endZ + * @var Level|string $level + * @var float $expires + * + * @var Player|string $player + */ + public function addLand($player, $startX, $startZ, $endX, $endZ, $level, $expires = null, &$id = null) + { + if ($level instanceof Level) { + $level = $level->getFolderName(); + } + if ($player instanceof Player) { + $player = $player->getName(); + } + + if (is_numeric($this->getConfig()->get("player-land-limit", "NaN"))) { + $cnt = count($this->db->getLandsByOwner($player)); + if ($cnt >= $this->getConfig()->get("player-land-limit", "NaN")) { + return self::RET_LAND_LIMIT; + } + } + + if ($startX > $endX) { + $tmp = $startX; + $startX = $endX; + $endX = $tmp; + } + if ($startZ > $endZ) { + $tmp = $startZ; + $startZ = $endZ; + $endZ = $tmp; + } + $startX--; + $endX++; + $startZ--; + $endZ++; + + $result = $this->db->checkOverlap($startX, $endX, $startZ, $endZ, $level); + + if ($result !== false and $this->getConfig()->get("allow-overlap", false) === false) { + return self::RET_LAND_OVERLAP; + } + $price = (($endX - $startX) - 1) * (($endZ - $startZ) - 1) * $this->getConfig()->get("price-per-y-axis", 100); + $id = $this->db->addLand($startX, $endX, $startZ, $endZ, $level, $price, $player, $expires); + if ($expires !== null) { + $this->getScheduler()->scheduleDelayedTask(new ExpireTask($this, $id), $expires * 1200); + $this->expire[$id] = array( + $expires * 60, + time() + ); + } + return self::RET_SUCCESS; + } + + public function addInvitee($landId, $player) + { + return $this->db->addInviteeById($landId, $player); + } + + public function removeInvitee($landId, $player) + { + return $this->db->removeInviteeById($landId, $player); + } + + public function getLandInfo($landId) + { + return $this->db->getLandById($landId); + } + + public function checkOverlap($startX, $endX, $startZ, $endZ, $level) + { + return $this->db->checkOverlap($startX, $endX, $startZ, $endZ, $level); + } + + public function getMessage($key, $value = array("%1", "%2", "%3")) + { + if ($this->lang->exists($key)) { + return str_replace(array("%MONETARY_UNIT%", "%1", "%2", "%3", "\\n"), array(EconomyAPI::getInstance()->getMonetaryUnit(), $value[0], $value[1], $value[2], "\n"), $this->lang->get($key)); + } + return "Couldn't find message \"$key\""; + } -final class EconomyLand extends PluginBase { - public const API_VERSION = 2; - - const FALLBACK_LANGUAGE = 'en'; - - private $lang, $fallbackLang; - /** @var EconomyAPI */ - private $api; - /** @var PluginConfiguration */ - private $pluginConfig; - /** @var LandManager */ - private $landManager = null; - - public function onEnable() { - $this->saveDefaultConfig(); - $this->pluginConfig = new PluginConfiguration($this); - - $api = $this->getServer()->getPluginManager()->getPlugin('EconomyAPI'); - if(!$api instanceof EconomyAPI) { - $this->getLogger()->warning('EconomyAPI is not loaded. EconomyLand will not be enabled because required plugin is not loaded.'); - return; - } - - $this->api = $api; - - if(EconomyAPI::API_VERSION < 4) { - $this->getLogger()->warning('Current installed version of EconomyAPI is outdated. Please update EconomyAPI.'); - $this->getLogger()->warning('Expected minimum API version: 4, got ' . EconomyAPI::API_VERSION); - return; - } - - $this->loadLanguages(); - - if($this->landManager === null) { - $this->landManager = new LandManager($this, new YamlProvider($this)); - } - - $this->getServer()->getCommandMap()->register("economyland", new LandCommand($this)); - $this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this); - } - - public function getMessage(string $key, array $params = []): string { - if(isset($this->lang[$key])) { - return $this->api->replaceParameters($this->lang[$key], $params); - }elseif(isset($this->fallbackLang[$key])) { - return $this->api->replaceParameters($this->fallbackLang[$key], $params); - } - - return $key; - } - - private function loadLanguages() { - $lang = strtolower($this->pluginConfig->getLanguage()); - if(!in_array($lang, ['en'])) { - $lang = self::FALLBACK_LANGUAGE; - } - - $resource = $this->getResource('lang_' . $lang . '.json'); - if($resource === null) { - $resource = $this->getResource('lang_en.json'); - } - - $this->lang = json_decode(stream_get_contents($resource), true); - fclose($resource); - - $resource = $this->getResource('lang_en.json'); - $this->fallbackLang = json_decode(stream_get_contents($resource), true); - fclose($resource); - } - - public function onDisable() { - $this->landManager->close(); - } - - public function getPluginConfiguration(): PluginConfiguration { - return $this->pluginConfig; - } - - public function getLandManager(): LandManager { - return $this->landManager; - } + private function createConfig() + { + $this->lang = new Config($this->getDataFolder() . "language.properties", Config::PROPERTIES, array( + "sold-land" => "The land was sold for %MONETARY_UNIT%%1", + "not-my-land" => "This is not your land", + "no-one-owned" => "Nobody owns this land", + "not-your-land" => "Land number %1 is not your land", + "no-land-found" => "There is no land number %1", + "land-corrupted" => "[EconomyLand] The World %2 of Land number %1 is corrupted.", + "no-permission-move" => "You have no permission to move to land %1. Owner : %2", + "fail-moving" => "Failed to move to land %1", + "success-moving" => "Moved to land %1", + "land-list-top" => "Showing land list page %1 of %2\\n", + "land-list-format" => "#%1 Area : %2 m^2 | Owner : %3\\n", + "here-land" => "#%1 This land belongs to %2", + "land-num-must-numeric" => "Land number must be numeric", + "not-invitee" => "%1 is not invited to your land", + "already-invitee" => "Player %1 is already invited to this land", + "removed-invitee" => " %1 has been uninvited from land %2", + "invalid-invitee" => "%1 is an invalid name", + "success-invite" => "%1 is now invited to this land", + "player-not-connected" => "Player %1 is not connected", + "cannot-give-land-myself" => "You can't give land to yourself", + "gave-land" => "Land %1 was given to %2", + "got-land" => "[EconomyLand] %1 gave you land %2", + "land-limit" => "You have %1 lands. The limit is %2", + "give-land-limit" => "%1 has %2 lands. The limit is %3", + "set-first-position" => "Please set the first position", + "set-second-position" => "Please set the second position", + "not-allowed-to-buy" => "Land cannot be bought in this world", + "land-around-here" => "[EconomyLand] There is ID:%2 land near here. Owner : %1", + "no-money-to-buy-land" => "You don't have enough money to buy this land", + "bought-land" => "Land purchased for %MONETARY_UNIT%%1", + "first-position-saved" => "First position saved", + "second-position-saved" => "Second position saved", + "cant-set-position-in-different-world" => "You can't set a position in different world", + "confirm-buy-land" => "Price: %MONETARY_UNIT%%1\\nBuy this land with /land buy", + "confirm-warning" => "WARNING: This land seems to overlap with #%1.", + "no-permission" => "You don't have permission to edit this land. Owner : %1", + "no-permission-command" => "[EconomyLand] You don't have permissions to use this command.", + "not-owned" => "[EconomyLand] You must buy land to build here", + "run-cmd-in-game" => "[EconomyLand] Please run this command in-game." + )); + } } diff --git a/EconomyLand/src/onebone/economyland/ExpireTask.php b/EconomyLand/src/onebone/economyland/ExpireTask.php new file mode 100644 index 00000000..08ada22d --- /dev/null +++ b/EconomyLand/src/onebone/economyland/ExpireTask.php @@ -0,0 +1,40 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace onebone\economyland; + +use pocketmine\scheduler\Task; + +use onebone\economyland\EconomyLand; + +class ExpireTask extends Task{ + private $landId; + private EconomyLand $plugin; + + public function __construct(EconomyLand $plugin, $landId){ + $this->plugin = $plugin; + $this->landId = $landId; + } + + public function onRun(): void + { + $this->plugin->expireLand($this->landId); + } +} \ No newline at end of file diff --git a/EconomyLand/src/onebone/economyland/SaveTask.php b/EconomyLand/src/onebone/economyland/SaveTask.php new file mode 100644 index 00000000..85ab45b3 --- /dev/null +++ b/EconomyLand/src/onebone/economyland/SaveTask.php @@ -0,0 +1,40 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace onebone\economyland; + +use pocketmine\scheduler\Task; + +use onebone\economyland\EconomyLand; + +class SaveTask extends Task +{ + private EconomyLand $plugin; + + public function __construct(EconomyLand $pluginn) + { + $this->plugin = $pluginn; + } + + public function onRun(): void + { + $this->plugin->save(); + } +} diff --git a/EconomyLand/src/onebone/economyland/database/Database.php b/EconomyLand/src/onebone/economyland/database/Database.php new file mode 100644 index 00000000..a4ed8166 --- /dev/null +++ b/EconomyLand/src/onebone/economyland/database/Database.php @@ -0,0 +1,42 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace onebone\economyland\database; + +use pocketmine\player\Player; + +interface Database{ + public function __construct($fileName, $config, $otherName); + public function getByCoord($x, $z, $level); + public function getAll(); + public function getLandById($id); + public function getLandsByOwner($owner); + public function getLandsByKeyword($keyword); + public function getInviteeById($id); + public function addInviteeById($id, $name); + public function removeInviteeById($id, $name); + public function addLand($startX, $endX, $startZ, $endZ, $level, $price, $owner, $expires = null, $invitee = []); + public function setOwnerById($id, $owner); + public function removeLandById($id); + public function canTouch($x, $z, $level, Player $player); + public function checkOverlap($startX, $endX, $startZ, $endZ, $level); + public function close(); + public function save(); +} diff --git a/EconomyLand/src/onebone/economyland/database/SQLiteDatabase.php b/EconomyLand/src/onebone/economyland/database/SQLiteDatabase.php new file mode 100644 index 00000000..cbb58c37 --- /dev/null +++ b/EconomyLand/src/onebone/economyland/database/SQLiteDatabase.php @@ -0,0 +1,206 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace onebone\economyland\database; + +use onebone\economyland\event\LandAddedEvent; +use onebone\economyland\event\LandRemoveEvent; +use pocketmine\world\World as Level; +use pocketmine\player\Player; +use pocketmine\Server; +use pocketmine\utils\Config; + +class SQLiteDatabase implements Database { + private $land, $config; + private $path; + + CONST INVITEE_SEPERATOR = ";"; + + public function __construct($fileName, $config, $otherName = "") { + $this->path = $fileName; + $this->land = new \SQLite3($fileName); + $this->land->exec("CREATE TABLE IF NOT EXISTS land( + ID INTEGER PRIMARY KEY AUTOINCREMENT, + startX INTEGER NOT NULL, + startZ INTEGER NOT NULL, + endX INTEGER NOT NULL, + endZ INTEGER NOT NULL, + level TEXT NOT NULL, + owner TEXT NOT NULL, + invitee TEXT NOT NULL, + price INTEGER NOT NULL, + expires INTEGER + )"); + + $this->config = $config; + } + + public function save() { + } + + public function getByCoord($x, $z, $level) { + if ($level instanceof Level) { + $level = $level->getFolderName(); + } + return $this->land->query("SELECT * FROM land WHERE (startX <= $x AND endX >= $x) AND (startZ <= $z AND endZ >= $z) AND level = '$level'")->fetchArray(SQLITE3_ASSOC); + } + + public function getAll() { + $result = $this->land->query("SELECT * FROM land"); + $ret = []; + while (($ret[] = $result->fetchArray(SQLITE3_ASSOC)) !== false) { + } + return $ret; + } + + public function getLandById($id) { + $stmt = $this->land->prepare("SELECT * FROM land WHERE ID = :id"); + $stmt->bindValue(':id', $id, SQLITE3_INTEGER); + $result = $stmt->execute(); + return $result->fetchArray(SQLITE3_ASSOC); + } + + + public function getLandsByOwner($owner) { + $stmt = $this->land->prepare("SELECT * FROM land WHERE owner = :owner"); + $stmt->bindValue(":owner", $owner, SQLITE3_TEXT); + $result = $stmt->execute(); + $ret = []; + while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + $ret[] = $row; + } + return $ret; + } + + public function getLandsByKeyword($keyword) { + $stmt = $this->land->prepare("SELECT * FROM land WHERE owner LIKE :keyword"); + $stmt->bindValue(":keyword", "%$keyword%", SQLITE3_TEXT); + $result = $stmt->execute(); + $ret = []; + while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + $ret[] = $row; + } + return $ret; + } + + public function getInviteeById($id) { + $stmt = $this->land->prepare("SELECT invitee FROM land WHERE ID = :id"); + $stmt->bindValue(":id", $id, SQLITE3_INTEGER); + $result = $stmt->execute()->fetchArray(SQLITE3_ASSOC); + return $result ? explode(self::INVITEE_SEPERATOR, $result["invitee"]) : []; + } + + public function addInviteeById($id, $name) { + $invitee = $this->getInviteeById($id); + $name = strtolower(str_replace("'", "", $name)); + if (!in_array($name, $invitee)) { + $invitee[] = $name; + $stmt = $this->land->prepare("UPDATE land SET invitee = :invitee WHERE ID = :id"); + $stmt->bindValue(":invitee", implode(self::INVITEE_SEPERATOR, $invitee), SQLITE3_TEXT); + $stmt->bindValue(":id", $id, SQLITE3_INTEGER); + $stmt->execute(); + return true; + } + return false; + } + + public function isInvitee($id, $name) { + $name = strtolower($name); + $invitee = $this->getInviteeById($id); + return in_array($name, $invitee) === true; + } + + public function removeInviteeById($id, $name) { + $name = strtolower($name); + + $invitee = $this->getInviteeById($id); + foreach ($invitee as $key => $i) { + if ($i === $name) { + unset($invitee[$key]); + $this->land->exec("UPDATE land SET invitee = '" . serialize($invitee) . "' WHERE ID = $id"); + return true; + } + } + return false; + } + + public function addLand($startX, $endX, $startZ, $endZ, $level, $price, $owner, $expires = null, $invitee = []) { + if ($level instanceof Level) { + $level = $level->getFolderName(); + } + + $stmt = $this->land->prepare("INSERT INTO land (startX, endX, startZ, endZ, owner, level, price, invitee" . ($expires === null ? "" : ", expires") . ") VALUES (:startX, :endX, :startZ, :endZ, :owner, :level, :price, :invitee" . ($expires === null ? "" : ", :expires") . ")"); + $stmt->bindValue(":startX", $startX, SQLITE3_INTEGER); + $stmt->bindValue(":endX", $endX, SQLITE3_INTEGER); + $stmt->bindValue(":startZ", $startZ, SQLITE3_INTEGER); + $stmt->bindValue(":endZ", $endZ, SQLITE3_INTEGER); + $stmt->bindValue(":owner", $owner, SQLITE3_TEXT); + $stmt->bindValue(":level", $level, SQLITE3_TEXT); + $stmt->bindValue(":price", $price, SQLITE3_INTEGER); + $stmt->bindValue(":invitee", implode(self::INVITEE_SEPERATOR, $invitee), SQLITE3_TEXT); + if ($expires !== null) { + $stmt->bindValue(":expires", $expires, SQLITE3_INTEGER); + } + $stmt->execute(); + + $id = $this->land->lastInsertRowID(); + + $ev = new LandAddedEvent($id, $startX, $endX, $startZ, $endZ, $level, $price, $owner, $expires); + $ev->call(); + + return $id; + } + + public function setOwnerById($id, $owner) { + $this->land->exec("UPDATE land SET owner = '$owner' WHERE ID = $id"); + } + + public function removeLandById($id) { + $ev = new LandRemoveEvent($id); + $ev->call(); + if(!$ev->isCancelled()) { + $this->land->exec("DELETE FROM land WHERE ID = $id"); + } + } + + public function canTouch($x, $z, $level, Player $player) { + if (!is_bool($land = $this->land->query("SELECT owner,invitee FROM land WHERE level = '$level' AND endX >= $x AND endZ >= $z AND startX <= $x AND startZ <= $z")->fetchArray(SQLITE3_ASSOC))) { + if ($player->getName() === $land["owner"] or stripos($player->getName() . self::INVITEE_SEPERATOR, $land["invitee"]) or $player->hasPermission("economyland.land.modify.others")) { + return true; + } else { + return $land; + } + } + //return !in_array($level, $this->config["white-land"]) or $player->hasPermission("economyland.land.modify.whiteland"); + return true; + } + + public function checkOverlap($startX, $endX, $startZ, $endZ, $level) { + if ($level instanceof Level) { + $level = $level->getFolderName(); + } + $result = $this->land->query("SELECT * FROM land WHERE startX <= $endX AND endX >= $startX AND startZ <= $endZ AND endZ >= $startZ AND level = '$level'")->fetchArray(SQLITE3_ASSOC); + return $result !== null ? $result : false; + } + + public function close() { + $this->land->close(); + } +} diff --git a/EconomyLand/src/onebone/economyland/database/YamlDatabase.php b/EconomyLand/src/onebone/economyland/database/YamlDatabase.php new file mode 100644 index 00000000..6b9a6af3 --- /dev/null +++ b/EconomyLand/src/onebone/economyland/database/YamlDatabase.php @@ -0,0 +1,226 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace onebone\economyland\database; + +use onebone\economyland\event\LandRemoveEvent; +use pocketmine\world\World as Level; +use pocketmine\Server; +use pocketmine\utils\Config; +use pocketmine\player\Player; + +use onebone\economyland\event\LandAddedEvent; + +class YamlDatabase implements Database{ + /** + * @var array + */ + private $land, $config; + private $path; + private mixed $landNum = 0; + + + public function __construct($fileName, $config, $otherName){ + $this->path = $fileName; + $this->land = (new Config($fileName, Config::YAML))->getAll(); + if(count($this->land) > 0){ + $land = $this->land; + $this->landNum = end($land)["ID"] + 1; + } + if(is_file($otherName)){ + $sq = new \SQLite3($otherName); + $cnt = 0; + $query = $sq->query("SELECT * FROM land"); + while(($d = $query->fetchArray(SQLITE3_ASSOC)) !== false){ + $invitee = []; + $tmp = explode(SQLiteDatabase::INVITEE_SEPERATOR, $d["invitee"]); + foreach($tmp as $t){ + $invitee[$t] = true; + } + /* $this->land[$this->landNum] = [ + "ID" => $this->landNum++, + "startX" => $d["startX"], + "startZ" => $d["startZ"], + "endX" => $d["endX"], + "endZ" => $d["endZ"], + "level" => $d["level"], + "owner" => $d["owner"], + "invitee" => $invitee, + "price" => $d["price"], + "expires" => $d["expires"] + ];*/ + $this->addLand($d["startX"], $d["endX"], $d["startZ"], $d["endZ"], $d["level"], $d["price"], $d["owner"], $d["expires"], $invitee); + ++$cnt; + } + $sq->close(); + Server::getInstance()->getLogger()->notice("[EconomyLand] Converted $cnt data into new database"); + @unlink($otherName); + } + $this->config = $config; + } + + public function getByCoord($x, $z, $level){ + if($level instanceof Level){ + $level = $level->getFolderName(); + } + $x=floor($x); + $z=floor($z); + foreach($this->land as $land){ + if($level === $land["level"] and $land["startX"] <= $x and $land["endX"] >= $x and $land["startZ"] <= $z and $land["endZ"] >= $z){ + return $land; + } + } + return false; + } + + public function getAll(){ + return $this->land; + } + + public function getLandById($id){ + return isset($this->land[$id]) ? $this->land[$id] : false; + } + + public function getLandsByOwner($owner){ + $ret = []; + foreach($this->land as $land){ + if($land["owner"] === $owner){ + $ret[] = $land; + } + } + return $ret; + } + + public function getLandsByKeyword($keyword){ + $ret = []; + foreach($this->land as $land){ + if(stripos($keyword, $land["owner"] !== false) or stripos($land["owner"], $keyword) !== false){ + $ret[] = $land; + } + } + return $ret; + } + + public function getInviteeById($id){ + if(isset($this->land[$id])){ + return array_keys($this->land[$id]["invitee"]); + } + return false; + } + + public function addInviteeById($id, $name){ + if(isset($this->land[$id])){ + $this->land[$id]["invitee"][$name] = true; + return true; + } + return false; + } + + public function removeInviteeByid($id, $name){ + if(isset($this->land[$id]["invitee"][$name])){ + unset($this->land[$id]["invitee"][$name]); + return true; + } + return false; + } + + public function addLand($startX, $endX, $startZ, $endZ, $level, $price, $owner, $expires = null, $invitee = []){ + if($level instanceof Level){ + $level = $level->getFolderName(); + } + if($this->checkOverlap($startX, $endX, $startZ, $endZ, $level)){ + return false; + } + $this->land[$this->landNum] = [ + "ID" => $this->landNum, + "startX" => $startX, + "endX" => $endX, + "startZ" => $startZ, + "endZ" => $endZ, + "price" => $price, + "owner" => $owner, + "level" => $level, + "invitee" => [], + "expires" => $expires + ]; + $ev = new LandAddedEvent($this->landNum, $startX, $endX, $startZ, $endZ, $level, $price, $owner, $expires); + $ev->call(); + return $this->landNum++; + } + + public function setOwnerById($id, $owner){ + if(isset($this->land[$id])){ + $this->land[$id]["owner"] = $owner; + return true; + } + return false; + } + + public function removeLandById($id){ + if(isset($this->land[$id])){ + $ev = new LandRemoveEvent($id); + $ev->call(); + if(!$ev->isCancelled()){ + unset($this->land[$id]); + return true; + } + } + return false; + } + + public function canTouch($x, $z, $level, Player $player){ + foreach($this->land as $land){ + if($level === $land["level"] and $land["startX"] <= $x and $land["endX"] >= $x and $land["startZ"] <= $z and $land["endZ"] >= $z){ + if($player->getName() === $land["owner"] or isset($land["invitee"][$player->getName()]) or $player->hasPermission("economyland.land.modify.others")){ // If owner is correct + return true; + }else{ // If owner is not correct + return $land; + } + } + } + // return !in_array($level, $this->config["white-land"]) or $player->hasPermission("economyland.land.modify.whiteland"); + return -1; // If no land found + } + + public function checkOverlap($startX, $endX, $startZ, $endZ, $level){ + if($level instanceof Level){ + $level = $level->getFolderName(); + } + foreach($this->land as $land){ + if($level === $land["level"]){ + if(($startX <= $land["endX"] and $endX >= $land["startX"] + and $endZ >= $land["startZ"] and $startZ <= $land["endZ"])){ + return $land; + } + } + } + return false; + } + + public function save(){ + $config = new Config($this->path, Config::YAML); + $config->setAll($this->land); + $config->save(); + } + + public function close(){ + $this->save(); + } +} diff --git a/EconomyLand/src/onebone/economyland/event/LandAddedEvent.php b/EconomyLand/src/onebone/economyland/event/LandAddedEvent.php new file mode 100644 index 00000000..13968f63 --- /dev/null +++ b/EconomyLand/src/onebone/economyland/event/LandAddedEvent.php @@ -0,0 +1,78 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace onebone\economyland\event; + +use pocketmine\event\Event; + +class LandAddedEvent extends Event +{ + public static $handlerList = null; + + private $id, $startX, $startZ, $endX, $endZ, $level, $price, $player, $expires; + + public function __construct($id, $startX, $startZ, $endX, $endZ, $level, $price, $player, $expires){ + $this->startX = $startX; + $this->startZ = $startZ; + $this->endX = $endX; + $this->endZ = $endZ; + $this->level = $level; + $this->price = $price; + $this->id = $id; + $this->player = $player; + $this->expires = $expires; + } + + public function getId(){ + return $this->id; + } + + public function getStartX(){ + return $this->startX; + } + + public function getStartZ(){ + return $this->startZ; + } + + public function getEndX(){ + return $this->endX; + } + + public function getEndZ(){ + return $this->endZ; + } + + public function getLevel(){ + return $this->level; + } + + public function getPrice(){ + return $this->price; + } + + public function getExpires(){ + return $this->expires; + } + + public function getPlayer(){ + return $this->player; + } +} \ No newline at end of file diff --git a/EconomyLand/src/onebone/economyland/event/LandRemoveEvent.php b/EconomyLand/src/onebone/economyland/event/LandRemoveEvent.php new file mode 100644 index 00000000..82cf629c --- /dev/null +++ b/EconomyLand/src/onebone/economyland/event/LandRemoveEvent.php @@ -0,0 +1,42 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +namespace onebone\economyland\event; + +use pocketmine\event\Cancellable; +use pocketmine\event\CancellableTrait; +use pocketmine\event\Event; + +class LandRemoveEvent extends Event implements Cancellable +{ + use CancellableTrait; + + public static $handlerList = null; + + private $id; + + public function __construct($id){ + $this->id = $id; + } + + public function getId(){ + return $this->id; + } +} \ No newline at end of file From d6ac7bf649b6c1ae1b8de899c8cefa0bc80593c7 Mon Sep 17 00:00:00 2001 From: Sajjadidh45 Date: Fri, 11 Jul 2025 21:04:47 +0330 Subject: [PATCH 08/12] . --- .../src/onebone/economyapi/EconomyAPI.php | 17 +- .../src/onebone/economyapi/EventListener.php | 16 +- .../economyapi/command/EconomyCommand.php | 38 +- .../economyapi/command/GiveMoneyCommand.php | 25 +- .../economyapi/command/MyMoneyCommand.php | 25 +- .../economyapi/command/MyStatusCommand.php | 23 +- .../onebone/economyapi/command/PayCommand.php | 35 +- .../economyapi/command/SeeMoneyCommand.php | 25 +- .../economyapi/command/SetMoneyCommand.php | 27 +- .../economyapi/command/TakeMoneyCommand.php | 27 +- .../economyapi/command/TopMoneyCommand.php | 20 +- .../economyapi/provider/YamlProvider.php | 2 +- .../src/onebone/economyapi/task/SaveTask.php | 4 +- .../onebone/economyairport/EconomyAirport.php | 41 +- .../onebone/economyauction/EconomyAuction.php | 32 +- .../economyauction/QuitAuctionTask.php | 8 +- .../onebone/economycasino/EconomyCasino.php | 13 +- .../src/onebone/economyjob/EconomyJob.php | 38 +- EconomyLand/plugin.yml | 172 ++-- EconomyLand/resources/config.yml | 27 +- .../src/onebone/economyland/EconomyLand.php | 840 ++---------------- .../src/onebone/economyland/EventListener.php | 26 +- .../src/onebone/economyland/ExpireTask.php | 40 - .../src/onebone/economyland/SaveTask.php | 40 - .../economyland/command/LandCommand.php | 16 +- .../onebone/economyland/database/Database.php | 42 - .../economyland/database/SQLiteDatabase.php | 206 ----- .../economyland/database/YamlDatabase.php | 226 ----- .../economyland/event/LandAddedEvent.php | 78 -- .../economyland/event/LandRemoveEvent.php | 42 - EconomyPShop/plugin.yml | 1 + .../src/onebone/economypshop/EconomyPShop.php | 25 +- .../economyproperty/EconomyProperty.php | 78 +- .../economyproperty/PropertyCommand.php | 50 +- .../src/onebone/economysell/EconomySell.php | 37 +- .../src/onebone/economyshop/EconomyShop.php | 35 +- EconomyUsury/plugin.yml | 2 +- .../src/onebone/economyusury/DueTask.php | 2 +- 38 files changed, 495 insertions(+), 1906 deletions(-) delete mode 100644 EconomyLand/src/onebone/economyland/ExpireTask.php delete mode 100644 EconomyLand/src/onebone/economyland/SaveTask.php delete mode 100644 EconomyLand/src/onebone/economyland/database/Database.php delete mode 100644 EconomyLand/src/onebone/economyland/database/SQLiteDatabase.php delete mode 100644 EconomyLand/src/onebone/economyland/database/YamlDatabase.php delete mode 100644 EconomyLand/src/onebone/economyland/event/LandAddedEvent.php delete mode 100644 EconomyLand/src/onebone/economyland/event/LandRemoveEvent.php diff --git a/EconomyAPI/src/onebone/economyapi/EconomyAPI.php b/EconomyAPI/src/onebone/economyapi/EconomyAPI.php index dc82bab8..c660eb64 100644 --- a/EconomyAPI/src/onebone/economyapi/EconomyAPI.php +++ b/EconomyAPI/src/onebone/economyapi/EconomyAPI.php @@ -63,12 +63,11 @@ use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\Config; -use pocketmine\utils\Internet; use pocketmine\utils\TextFormat; use Throwable; class EconomyAPI extends PluginBase implements Listener { - const API_VERSION = 5; + const API_VERSION = 4; const PACKAGE_VERSION = "6.0"; /** @@ -721,7 +720,7 @@ public function onEnable() { $this->initialize(); if($this->pluginConfig->getAutoSaveInterval() > 0) { - $this->getScheduler()->scheduleDelayedRepeatingTask(new SaveTask($this), $this->pluginConfig->getAutoSaveInterval() * 1200, $this->pluginConfig->getAutoSaveInterval() * 1200); + $this->getScheduler()->scheduleRepeatingTask(new SaveTask($this), $this->pluginConfig->getAutoSaveInterval() * 1200); } if($this->currencySelector === null) { @@ -738,9 +737,9 @@ public function onEnable() { private function initialize() { $this->pluginConfig = new PluginConfig($this->getConfig()); - if($this->pluginConfig->getCheckUpdate()) { - $this->checkUpdate(); - } + //if($this->pluginConfig->getCheckUpdate()) { + // $this->checkUpdate(); + //} switch ($this->pluginConfig->getProvider()) { case 'yaml': @@ -773,7 +772,7 @@ private function initialize() { $this->provider->init(); } - private function checkUpdate(): bool { + /*private function checkUpdate(): bool { try{ $info = json_decode(Internet::getURL($this->pluginConfig->getUpdateHost() . "?version=" . $this->getDescription()->getVersion() . "&package_version=" . self::PACKAGE_VERSION), true); if(!isset($info["status"]) or $info["status"] !== true) { @@ -789,7 +788,7 @@ private function checkUpdate(): bool { $this->getLogger()->logException($e); return false; } - } + }*/ /** * Register Currency to EconomyAPI. @@ -913,7 +912,7 @@ private function registerCommands() { ]); } - public function onPlayerJoin(PlayerJoinEvent $event) { + public function onJoin(PlayerJoinEvent $event) { $player = $event->getPlayer(); if(!$this->defaultCurrency->getBalanceRepository()->hasAccount($player)) { diff --git a/EconomyAPI/src/onebone/economyapi/EventListener.php b/EconomyAPI/src/onebone/economyapi/EventListener.php index 8f4bb47e..2b5145e0 100644 --- a/EconomyAPI/src/onebone/economyapi/EventListener.php +++ b/EconomyAPI/src/onebone/economyapi/EventListener.php @@ -25,8 +25,8 @@ use pocketmine\event\player\PlayerQuitEvent; use pocketmine\event\server\DataPacketSendEvent; use pocketmine\network\mcpe\protocol\AvailableCommandsPacket; -use pocketmine\network\mcpe\protocol\types\command\CommandEnum; -use pocketmine\network\mcpe\protocol\types\command\CommandParameter; +use pocketmine\network\mcpe\protocol\types\CommandEnum; +use pocketmine\network\mcpe\protocol\types\CommandParameter; use pocketmine\player\Player; class EventListener implements Listener { @@ -37,7 +37,7 @@ public function __construct(EconomyAPI $plugin) { $this->plugin = $plugin; } - public function onDataPacketSend(DataPacketSendEvent $event) { + /*public function onDataPacketSend(DataPacketSendEvent $event) { $pk = $event->getPacket(); if(!$pk instanceof AvailableCommandsPacket) return; @@ -160,21 +160,21 @@ public function onDataPacketSend(DataPacketSendEvent $event) { $pk->commandData['economy'] = $data; } - } + }*/ /** @noinspection PhpUnusedParameterInspection */ - public function onPlayerJoin(PlayerJoinEvent $_) { + /*public function onPlayerJoin(PlayerJoinEvent $_) { foreach($this->plugin->getServer()->getOnlinePlayers() as $player) { $player->sendCommandData(); } - } + }*/ /** @noinspection PhpUnusedParameterInspection */ - public function onPlayerQuit(PlayerQuitEvent $_) { + /*public function onPlayerQuit(PlayerQuitEvent $_) { foreach($this->plugin->getServer()->getOnlinePlayers() as $player) { $player->sendCommandData(); } - } + }*/ public static function also($object, $block) { $block($object); diff --git a/EconomyAPI/src/onebone/economyapi/command/EconomyCommand.php b/EconomyAPI/src/onebone/economyapi/command/EconomyCommand.php index 893e6cb0..bb764766 100644 --- a/EconomyAPI/src/onebone/economyapi/command/EconomyCommand.php +++ b/EconomyAPI/src/onebone/economyapi/command/EconomyCommand.php @@ -23,27 +23,27 @@ use onebone\economyapi\EconomyAPI; use onebone\economyapi\form\CurrencySelectionForm; use pocketmine\command\CommandSender; -use pocketmine\command\PluginCommand; -use pocketmine\Player; +use pocketmine\command\Command; +use pocketmine\player\Player; use pocketmine\utils\TextFormat; -class EconomyCommand extends PluginCommand { +class EconomyCommand extends Command { + private EconomyAPI $plugin; + public function __construct(EconomyAPI $plugin) { + $this->plugin = $plugin; $desc = $plugin->getCommandMessage("economy"); - parent::__construct("economy", $plugin); - $this->setDescription($desc["description"]); - $this->setUsage($desc["usage"]); + parent::__construct("economy", $desc["description"], $desc["usage"]); $this->setPermission("economyapi.command.economy"); } - public function execute(CommandSender $sender, string $commandLabel, array $args): bool { + public function execute(CommandSender $sender, string $commandLabel, array $args): void { if(!$this->testPermission($sender)) { - return false; + return; } - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); + $plugin = $this->plugin; $mode = strtolower(array_shift($args)); $val = array_shift($args); @@ -53,7 +53,7 @@ public function execute(CommandSender $sender, string $commandLabel, array $args case 'language': if(trim($val) === "") { $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); - return true; + return; } if($plugin->setPlayerLanguage($sender->getName(), $val)) { @@ -61,25 +61,22 @@ public function execute(CommandSender $sender, string $commandLabel, array $args }else{ $sender->sendMessage(TextFormat::RED . "There is no language such as $val"); } - return true; + return; case 'currency': - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); - if(trim($val) === '') { if(!$sender instanceof Player) { $sender->sendMessage($plugin->getMessage('economy-currency-specify', $sender)); - return true; + return; } $sender->sendForm(new CurrencySelectionForm($plugin, $plugin->getCurrencies(), $sender)); - return true; + return; } $currency = $plugin->getCurrency($val); if($currency === null) { $sender->sendMessage($plugin->getMessage('currency-unavailable', $sender, [$val])); - return true; + return; } if($plugin->setPlayerPreferredCurrency($sender, $currency)) { @@ -89,12 +86,9 @@ public function execute(CommandSender $sender, string $commandLabel, array $args }else{ $sender->sendMessage($plugin->getMessage('economy-currency-failed', $sender, [$currency->getName()])); } - return true; + return; default: $sender->sendMessage($this->getUsage()); } - - $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); - return false; } } diff --git a/EconomyAPI/src/onebone/economyapi/command/GiveMoneyCommand.php b/EconomyAPI/src/onebone/economyapi/command/GiveMoneyCommand.php index 3481b3f3..c8cf35b3 100644 --- a/EconomyAPI/src/onebone/economyapi/command/GiveMoneyCommand.php +++ b/EconomyAPI/src/onebone/economyapi/command/GiveMoneyCommand.php @@ -23,23 +23,24 @@ use onebone\economyapi\EconomyAPI; use onebone\economyapi\currency\CurrencyReplacer; use pocketmine\command\CommandSender; -use pocketmine\command\PluginCommand; -use pocketmine\Player; +use pocketmine\command\Command; +use pocketmine\player\Player; use pocketmine\utils\TextFormat; -class GiveMoneyCommand extends PluginCommand { +class GiveMoneyCommand extends Command { + private EconomyAPI $plugin; + public function __construct(EconomyAPI $plugin) { + $this->plugin = $plugin; $desc = $plugin->getCommandMessage("givemoney"); - parent::__construct("givemoney", $plugin); - $this->setDescription($desc["description"]); - $this->setUsage($desc["usage"]); + parent::__construct("givemoney", $desc["description"], $desc["usage"]); $this->setPermission("economyapi.command.givemoney"); } - public function execute(CommandSender $sender, string $label, array $params): bool { + public function execute(CommandSender $sender, string $label, array $params): void { if(!$this->testPermission($sender)) { - return false; + return; } $player = array_shift($params); @@ -48,11 +49,10 @@ public function execute(CommandSender $sender, string $label, array $params): bo if(!is_numeric($amount)) { $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); - return true; + return; } - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); + $plugin = $this->plugin; if(($p = $plugin->getServer()->getPlayer($player)) instanceof Player) { $player = $p->getName(); @@ -65,7 +65,7 @@ public function execute(CommandSender $sender, string $label, array $params): bo $currency = $plugin->getCurrency($currencyId); if($currency === null) { $sender->sendMessage($plugin->getMessage('currency-unavailable', $sender, [$currencyId])); - return true; + return; } } @@ -95,6 +95,5 @@ public function execute(CommandSender $sender, string $label, array $params): bo break; } - return true; } } diff --git a/EconomyAPI/src/onebone/economyapi/command/MyMoneyCommand.php b/EconomyAPI/src/onebone/economyapi/command/MyMoneyCommand.php index 8132164b..760cd0dc 100644 --- a/EconomyAPI/src/onebone/economyapi/command/MyMoneyCommand.php +++ b/EconomyAPI/src/onebone/economyapi/command/MyMoneyCommand.php @@ -23,28 +23,28 @@ use onebone\economyapi\EconomyAPI; use onebone\economyapi\currency\CurrencyReplacer; use pocketmine\command\CommandSender; -use pocketmine\command\PluginCommand; -use pocketmine\Player; +use pocketmine\command\Command; +use pocketmine\player\Player; use pocketmine\utils\TextFormat; -class MyMoneyCommand extends PluginCommand { +class MyMoneyCommand extends Command { + private EconomyAPI $plugin; + public function __construct(EconomyAPI $plugin) { + $this->plugin = $plugin; $desc = $plugin->getCommandMessage("mymoney"); - parent::__construct("mymoney", $plugin); - $this->setDescription($desc["description"]); - $this->setUsage($desc["usage"]); + parent::__construct("mymoney", $desc["description"], $desc["usage"]); $this->setPermission("economyapi.command.mymoney"); } - public function execute(CommandSender $sender, string $label, array $params): bool { + public function execute(CommandSender $sender, string $label, array $params): void { if(!$this->testPermission($sender)) { - return false; + return; } if($sender instanceof Player) { - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); + $plugin = $this->plugin; $currencyId = array_shift($params); if($currencyId !== null) { @@ -52,7 +52,7 @@ public function execute(CommandSender $sender, string $label, array $params): bo if($currency === null) { $sender->sendMessage($plugin->getMessage('currency-unavailable', $sender, [$currencyId])); - return true; + return; } }else{ $currency = $plugin->getPlayerPreferredCurrency($sender, false); @@ -73,10 +73,9 @@ public function execute(CommandSender $sender, string $label, array $params): bo } } } - return true; + return; } $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); - return true; } } diff --git a/EconomyAPI/src/onebone/economyapi/command/MyStatusCommand.php b/EconomyAPI/src/onebone/economyapi/command/MyStatusCommand.php index a63fccc9..6e20e720 100644 --- a/EconomyAPI/src/onebone/economyapi/command/MyStatusCommand.php +++ b/EconomyAPI/src/onebone/economyapi/command/MyStatusCommand.php @@ -21,33 +21,33 @@ namespace onebone\economyapi\command; use onebone\economyapi\EconomyAPI; +use pocketmine\command\Command; use pocketmine\command\CommandSender; -use pocketmine\command\PluginCommand; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\utils\TextFormat; -class MyStatusCommand extends PluginCommand { +class MyStatusCommand extends Command { + private EconomyAPI $plugin; + public function __construct(EconomyAPI $plugin) { + $this->plugin = $plugin; $desc = $plugin->getCommandMessage("mystatus"); - parent::__construct("mystatus", $plugin); - $this->setDescription($desc["description"]); - $this->setUsage($desc["usage"]); + parent::__construct("mystatus", $desc["description"], $desc["usage"]); $this->setPermission("economyapi.command.mystatus"); } - public function execute(CommandSender $sender, string $label, array $params): bool { + public function execute(CommandSender $sender, string $label, array $params): void { if(!$this->testPermission($sender)) { - return false; + return; } if(!$sender instanceof Player) { $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); - return true; + return; } - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); + $plugin = $this->plugin; $money = $plugin->getAllMoney(); @@ -61,7 +61,6 @@ public function execute(CommandSender $sender, string $label, array $params): bo } $sender->sendMessage($plugin->getMessage("mystatus-show", $sender, [$topMoney])); - return true; } } diff --git a/EconomyAPI/src/onebone/economyapi/command/PayCommand.php b/EconomyAPI/src/onebone/economyapi/command/PayCommand.php index 609d9243..330bc654 100644 --- a/EconomyAPI/src/onebone/economyapi/command/PayCommand.php +++ b/EconomyAPI/src/onebone/economyapi/command/PayCommand.php @@ -24,28 +24,29 @@ use onebone\economyapi\EconomyAPI; use onebone\economyapi\form\AskPayForm; use pocketmine\command\CommandSender; -use pocketmine\command\PluginCommand; -use pocketmine\Player; +use pocketmine\command\Command; +use pocketmine\player\Player; use pocketmine\utils\TextFormat; -class PayCommand extends PluginCommand { +class PayCommand extends Command { + private EconomyAPI $plugin; + public function __construct(EconomyAPI $plugin) { + $this->plugin = $plugin; $desc = $plugin->getCommandMessage("pay"); - parent::__construct("pay", $plugin); - $this->setDescription($desc["description"]); - $this->setUsage($desc["usage"]); + parent::__construct("pay", $desc["description"], $desc["usage"]); $this->setPermission("economyapi.command.pay"); } - public function execute(CommandSender $sender, string $label, array $params): bool { + public function execute(CommandSender $sender, string $label, array $params): void { if(!$this->testPermission($sender)) { - return false; + return; } if(!$sender instanceof Player) { $sender->sendMessage(TextFormat::RED . "Please run this command in-game."); - return true; + return; } $player = array_shift($params); @@ -54,11 +55,10 @@ public function execute(CommandSender $sender, string $label, array $params): bo if(!is_numeric($amount)) { $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); - return true; + return; } - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); + $plugin = $this->plugin; if($currencyId === null) { $currency = $plugin->getPlayerPreferredCurrency($player, false); @@ -67,14 +67,14 @@ public function execute(CommandSender $sender, string $label, array $params): bo $currency = $plugin->getCurrency($currencyId); if($currency === null) { $sender->sendMessage($plugin->getMessage('currency-unavailable', $sender, [$currencyId])); - return true; + return; } } $money = $plugin->myMoney($sender, $currency); if($money < $amount) { $sender->sendMessage($plugin->getMessage("pay-no-money", $sender, [new CurrencyReplacer($currency, $amount)])); - return true; + return; } if(($p = $plugin->getServer()->getPlayer($player)) instanceof Player) { @@ -83,20 +83,19 @@ public function execute(CommandSender $sender, string $label, array $params): bo if($player === $sender->getName()) { $sender->sendMessage($plugin->getMessage("pay-no-self", $sender)); - return true; + return; } if(!$p instanceof Player and $plugin->getPluginConfig()->getAllowPayOffline() === false) { $sender->sendMessage($plugin->getMessage("player-not-connected", $sender, [$player])); - return true; + return; } if(!$plugin->hasAccount($player, $currency)) { $sender->sendMessage($plugin->getMessage("player-never-connected", $sender, [$player])); - return true; + return; } $sender->sendForm(new AskPayForm($plugin, $sender, $currency, $player, $amount, $label, $params)); - return true; } } diff --git a/EconomyAPI/src/onebone/economyapi/command/SeeMoneyCommand.php b/EconomyAPI/src/onebone/economyapi/command/SeeMoneyCommand.php index 00d7762a..fa2902d7 100644 --- a/EconomyAPI/src/onebone/economyapi/command/SeeMoneyCommand.php +++ b/EconomyAPI/src/onebone/economyapi/command/SeeMoneyCommand.php @@ -23,34 +23,34 @@ use onebone\economyapi\EconomyAPI; use onebone\economyapi\currency\CurrencyReplacer; use pocketmine\command\CommandSender; -use pocketmine\command\PluginCommand; -use pocketmine\Player; +use pocketmine\command\Command; +use pocketmine\player\Player; use pocketmine\utils\TextFormat; -class SeeMoneyCommand extends PluginCommand { +class SeeMoneyCommand extends Command { + private EconomyAPI $plugin; + public function __construct(EconomyAPI $plugin) { + $this->plugin = $plugin; $desc = $plugin->getCommandMessage("seemoney"); - parent::__construct("seemoney", $plugin); - $this->setDescription($desc["description"]); - $this->setUsage($desc["usage"]); + parent::__construct("seemoney", $desc["description"], $desc["usage"]); $this->setPermission("economyapi.command.seemoney"); } - public function execute(CommandSender $sender, string $label, array $params): bool { + public function execute(CommandSender $sender, string $label, array $params): void { if(!$this->testPermission($sender)) { - return false; + return; } $player = array_shift($params); $currencyId = array_shift($params); if(trim($player) === "") { $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); - return true; + return; } - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); + $plugin = $this->plugin; if(($p = $plugin->getServer()->getPlayer($player)) instanceof Player) { $player = $p->getName(); } @@ -62,7 +62,7 @@ public function execute(CommandSender $sender, string $label, array $params): bo $currency = $plugin->getCurrency($currencyId); if($currency === null) { $sender->sendMessage($plugin->getMessage('currency-unavailable', $sender, [$currencyId])); - return true; + return; } } @@ -72,6 +72,5 @@ public function execute(CommandSender $sender, string $label, array $params): bo }else{ $sender->sendMessage($plugin->getMessage("player-never-connected", $sender, [$player])); } - return true; } } diff --git a/EconomyAPI/src/onebone/economyapi/command/SetMoneyCommand.php b/EconomyAPI/src/onebone/economyapi/command/SetMoneyCommand.php index b1f54fa6..ae054568 100644 --- a/EconomyAPI/src/onebone/economyapi/command/SetMoneyCommand.php +++ b/EconomyAPI/src/onebone/economyapi/command/SetMoneyCommand.php @@ -23,23 +23,24 @@ use onebone\economyapi\EconomyAPI; use onebone\economyapi\currency\CurrencyReplacer; use pocketmine\command\CommandSender; -use pocketmine\command\PluginCommand; -use pocketmine\Player; +use pocketmine\command\Command; +use pocketmine\player\Player; use pocketmine\utils\TextFormat; -class SetMoneyCommand extends PluginCommand { +class SetMoneyCommand extends Command { + private EconomyAPI $plugin; + public function __construct(EconomyAPI $plugin) { + $this->plugin = $plugin; $desc = $plugin->getCommandMessage("setmoney"); - parent::__construct("setmoney", $plugin); - $this->setDescription($desc["description"]); - $this->setUsage($desc["usage"]); + parent::__construct("setmoney", $desc["description"], $desc["usage"]); $this->setPermission("economyapi.command.setmoney"); } - public function execute(CommandSender $sender, string $label, array $params): bool { + public function execute(CommandSender $sender, string $label, array $params): void { if(!$this->testPermission($sender)) { - return false; + return; } $player = array_shift($params); @@ -48,11 +49,10 @@ public function execute(CommandSender $sender, string $label, array $params): bo if(!is_numeric($amount)) { $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); - return true; + return; } - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); + $plugin = $this->plugin; if(($p = $plugin->getServer()->getPlayer($player)) instanceof Player) { $player = $p->getName(); } @@ -64,7 +64,7 @@ public function execute(CommandSender $sender, string $label, array $params): bo $currency = $plugin->getCurrency($currencyId); if($currency === null) { $sender->sendMessage($plugin->getMessage('currency-unavailable', $sender, [$currencyId])); - return true; + return; } } @@ -76,7 +76,7 @@ public function execute(CommandSender $sender, string $label, array $params): bo ])); }else{ $sender->sendMessage($plugin->getMessage("player-never-connected", $sender, [$player])); - return true; + return; } } @@ -107,6 +107,5 @@ public function execute(CommandSender $sender, string $label, array $params): bo default: $sender->sendMessage("WTF"); } - return true; } } diff --git a/EconomyAPI/src/onebone/economyapi/command/TakeMoneyCommand.php b/EconomyAPI/src/onebone/economyapi/command/TakeMoneyCommand.php index 7590175e..832ad135 100644 --- a/EconomyAPI/src/onebone/economyapi/command/TakeMoneyCommand.php +++ b/EconomyAPI/src/onebone/economyapi/command/TakeMoneyCommand.php @@ -23,23 +23,24 @@ use onebone\economyapi\EconomyAPI; use onebone\economyapi\currency\CurrencyReplacer; use pocketmine\command\CommandSender; -use pocketmine\command\PluginCommand; -use pocketmine\Player; +use pocketmine\command\Command; +use pocketmine\player\Player; use pocketmine\utils\TextFormat; -class TakeMoneyCommand extends PluginCommand { +class TakeMoneyCommand extends Command { + private EconomyAPI $plugin; + public function __construct(EconomyAPI $plugin) { + $this->plugin = $plugin; $desc = $plugin->getCommandMessage("takemoney"); - parent::__construct("takemoney", $plugin); - $this->setDescription($desc["description"]); - $this->setUsage($desc["usage"]); + parent::__construct("takemoney", $desc["description"], $desc["usage"]); $this->setPermission("economyapi.command.takemoney"); } - public function execute(CommandSender $sender, string $label, array $params): bool { + public function execute(CommandSender $sender, string $label, array $params): void { if(!$this->testPermission($sender)) { - return false; + return; } $player = array_shift($params); @@ -48,18 +49,17 @@ public function execute(CommandSender $sender, string $label, array $params): bo if(!is_numeric($amount)) { $sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage()); - return true; + return; } - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); + $plugin = $this->plugin; if(($p = $plugin->getServer()->getPlayer($player)) instanceof Player) { $player = $p->getName(); } if($amount < 0) { $sender->sendMessage($plugin->getMessage("takemoney-invalid-number", $sender, [$amount])); - return true; + return; } if($currencyId === null) { @@ -69,7 +69,7 @@ public function execute(CommandSender $sender, string $label, array $params): bo $currency = $plugin->getCurrency($currencyId); if($currency === null) { $sender->sendMessage($plugin->getMessage('currency-unavailable', $sender, [$currencyId])); - return true; + return; } } @@ -103,7 +103,6 @@ public function execute(CommandSender $sender, string $label, array $params): bo break; } - return true; } } diff --git a/EconomyAPI/src/onebone/economyapi/command/TopMoneyCommand.php b/EconomyAPI/src/onebone/economyapi/command/TopMoneyCommand.php index 75581e8d..466d6b81 100644 --- a/EconomyAPI/src/onebone/economyapi/command/TopMoneyCommand.php +++ b/EconomyAPI/src/onebone/economyapi/command/TopMoneyCommand.php @@ -23,25 +23,26 @@ use onebone\economyapi\EconomyAPI; use onebone\economyapi\currency\CurrencyReplacer; use pocketmine\command\CommandSender; -use pocketmine\command\PluginCommand; +use pocketmine\command\Command; +use pocketmine\player\Player; + +class TopMoneyCommand extends Command { + private EconomyAPI $plugin; -class TopMoneyCommand extends PluginCommand { public function __construct(EconomyAPI $plugin) { + $this->plugin = $plugin; $desc = $plugin->getCommandMessage("topmoney"); - parent::__construct("topmoney", $plugin); - $this->setDescription($desc["description"]); - $this->setUsage($desc["usage"]); + parent::__construct("topmoney", $desc["description"], $desc["usage"]); $this->setPermission("economyapi.command.topmoney"); } - public function execute(CommandSender $sender, string $label, array $params): bool { - if(!$this->testPermission($sender)) return false; + public function execute(CommandSender $sender, string $label, array $params): void { + if(!$this->testPermission($sender)) return; $page = max(1, (int) array_shift($params)); - /** @var EconomyAPI $plugin */ - $plugin = $this->getPlugin(); + $plugin = $this->plugin; $currency = $plugin->getPlayerPreferredCurrency($sender, false); @@ -58,6 +59,5 @@ public function execute(CommandSender $sender, string $label, array $params): bo })->catch(function() use ($sender) { $sender->sendMessage('Failed to fetch money leaderboard :('); }); - return true; } } diff --git a/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php b/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php index f2e9e836..f8829df7 100644 --- a/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php +++ b/EconomyAPI/src/onebone/economyapi/provider/YamlProvider.php @@ -27,7 +27,7 @@ use onebone\economyapi\util\Transaction; use onebone\economyapi\util\TransactionAction; use onebone\economyapi\util\TransactionResult; -use pocketmine\player\Player; +use pocketmine\Player; use pocketmine\utils\Config; class YamlProvider implements Provider { diff --git a/EconomyAPI/src/onebone/economyapi/task/SaveTask.php b/EconomyAPI/src/onebone/economyapi/task/SaveTask.php index b5fa6d02..a79f7427 100644 --- a/EconomyAPI/src/onebone/economyapi/task/SaveTask.php +++ b/EconomyAPI/src/onebone/economyapi/task/SaveTask.php @@ -25,13 +25,13 @@ class SaveTask extends Task { /** @var EconomyAPI */ - protected $plugin; + private EconomyAPI $plugin; public function __construct(EconomyAPI $plugin) { $this->plugin = $plugin; } - public function onRun(int $currentTick) { + public function onRun(): void { $this->plugin->saveAll(); } } diff --git a/EconomyAirport/src/onebone/economyairport/EconomyAirport.php b/EconomyAirport/src/onebone/economyairport/EconomyAirport.php index 3f3923e4..61dd3658 100644 --- a/EconomyAirport/src/onebone/economyairport/EconomyAirport.php +++ b/EconomyAirport/src/onebone/economyairport/EconomyAirport.php @@ -21,15 +21,16 @@ namespace onebone\economyairport; use onebone\economyapi\EconomyAPI; +use onebone\economyapi\event\CommandIssuer; use pocketmine\event\block\BlockBreakEvent; use pocketmine\event\block\SignChangeEvent; use pocketmine\event\Listener; use pocketmine\event\player\PlayerInteractEvent; -use pocketmine\level\Level; -use pocketmine\level\Position; +use pocketmine\world\World; +use pocketmine\world\Position; use pocketmine\math\Vector3; use pocketmine\plugin\PluginBase; -use pocketmine\tile\Sign; +use pocketmine\block\tile\Sign; use pocketmine\utils\Config; class EconomyAirport extends PluginBase implements Listener { @@ -96,7 +97,7 @@ public function onSignChange(SignChangeEvent $event) { $player->sendMessage($this->getMessage("no-arrival")); break; } - $this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName()] = array( + $this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getPosition()->getWorld()->getFolderName()] = array( "type" => 0, "cost" => ($cost = round($event->getLine(2))), "target" => $event->getLine(3), @@ -122,8 +123,8 @@ public function onSignChange(SignChangeEvent $event) { $player->sendMessage($this->getMessage("invalid-airport-name")); break; } - $this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName()] = array( - $block->getX(), $block->getY(), $block->getZ(), $block->getLevel()->getFolderName(), + $this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getPosition()->getWorld()->getFolderName()] = array( + $block->getX(), $block->getY(), $block->getZ(), $block->getPosition()->getWorld()->getFolderName(), "name" => $event->getLine(2), "type" => 1 ); @@ -164,15 +165,15 @@ public function onBlockTouch(PlayerInteractEvent $event) { return; } $block = $event->getBlock(); - if(isset($this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName()])) { - $airport = $this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName()]; + if(isset($this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getPosition()->getWorld()->getFolderName()])) { + $airport = $this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getPosition()->getWorld()->getFolderName()]; if($airport["type"] === 1) return; $player = $event->getPlayer(); if(isset($this->airport[$airport["targetX"] . ":" . $airport["targetY"] . ":" . $airport["targetZ"] . ":" . $airport["targetLevel"]]) and $this->airport[$airport["targetX"] . ":" . $airport["targetY"] . ":" . $airport["targetZ"] . ":" . $airport["targetLevel"]]["type"] === 1) { $money = EconomyAPI::getInstance()->myMoney($player); - if(!$block->getLevel()->getTile(new Vector3($airport["targetX"], $airport["targetY"], $airport["targetZ"])) instanceof Sign) { + if(!$block->getPosition()->getWorld()->getTile(new Vector3($airport["targetX"], $airport["targetY"], $airport["targetZ"])) instanceof Sign) { $player->sendMessage($this->getMessage("no-airport", [$airport["target"], "%2"])); unset($this->airport[$airport["target"]]); return; @@ -180,21 +181,21 @@ public function onBlockTouch(PlayerInteractEvent $event) { if($money < $airport["cost"]) { $player->sendMessage($this->getMessage("no-money", [$airport["cost"], $money])); }else{ - EconomyAPI::getInstance()->reduceMoney($player, $airport["cost"], true, "EconomyAirport"); - $level = $this->getServer()->getLevelByName($airport["targetLevel"]); - $player->teleport(new Position($airport["targetX"], $airport["targetY"], $airport["targetZ"], $level)); - $time = $level->getTime(); - $day = (int) ($time / Level::TIME_FULL); - $time -= ($day * Level::TIME_FULL); + EconomyAPI::getInstance()->reduceMoney($player, $airport["cost"], null, null, true); + $world = $this->getServer()->getWorldManager()->getWorldByName($airport["targetLevel"]); + $player->teleport(new Position($airport["targetX"], $airport["targetY"], $airport["targetZ"], $world)); + $time = $world->getTime(); + $day = (int) ($time / World::TIME_FULL); + $time -= ($day * World::TIME_FULL); $phrase = "sunrise"; if($time < 1200) { $phrase = "day"; - } elseif($time % Level::TIME_SUNSET < 2000) { + } elseif($time % World::TIME_SUNSET < 2000) { $phrase = "sunset"; - } elseif($time % Level::TIME_NIGHT < 9000) { + } elseif($time % World::TIME_NIGHT < 9000) { $phrase = "night"; } - $player->sendMessage($this->getMessage("thank-you", [$airport["target"], $level->getTime() . " (" . $phrase . ")"])); + $player->sendMessage($this->getMessage("thank-you", [$airport["target"], $world->getTime() . " (" . $phrase . ")"])); } }else{ $player->sendMessage($this->getMessage("no-airport", [$airport["target"], "%2"])); @@ -204,13 +205,13 @@ public function onBlockTouch(PlayerInteractEvent $event) { public function onBlockBreak(BlockBreakEvent $event) { $block = $event->getBlock(); - if(isset($this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName()])) { + if(isset($this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getPosition()->getWorld()->getFolderName()])) { $player = $event->getPlayer(); if(!$player->hasPermission("economyairport.remove")) { $player->sendMessage($this->getMessage("no-permission-break")); return; } - unset($this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName()]); + unset($this->airport[$block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getPosition()->getWorld()->getFolderName()]); $player->sendMessage($this->getMessage("airport-removed")); } } diff --git a/EconomyAuction/src/onebone/economyauction/EconomyAuction.php b/EconomyAuction/src/onebone/economyauction/EconomyAuction.php index 8b0886bf..469f828e 100644 --- a/EconomyAuction/src/onebone/economyauction/EconomyAuction.php +++ b/EconomyAuction/src/onebone/economyauction/EconomyAuction.php @@ -21,10 +21,12 @@ namespace onebone\economyauction; use onebone\economyapi\EconomyAPI; +use onebone\economyapi\event\CommandIssuer; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\item\Item; -use pocketmine\Player; +use pocketmine\item\ItemFactory; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\TextFormat; @@ -60,7 +62,7 @@ public function onEnable() { foreach($this->auctions as $player => $data) { if(isset($this->auctions[$player][6])) { - $id = $this->getScheduler()->scheduleDelayedTask(new QuitAuctionTask($this, $player), $this->auctions[$player][6])->getTaskId(); + $id = $this->getScheduler()->scheduleDelayedTask(new QuitAuctionTask($this, $player), $this->auctions[$player][6])->getHandler()->getTaskId(); $this->auctions[$player][7] = time(); $this->auctions[$player][8] = $id; } @@ -107,7 +109,8 @@ public function onCommand(CommandSender $sender, Command $command, string $label } $count = (int) $count; - $item = Item::fromString($item); + $itemData = explode(":", $item); + $item = ItemFactory::getInstance()->get((int)$itemData[0], (int)($itemData[1] ?? 0), 1); $cnt = 0; foreach($sender->getInventory()->getContents() as $i) { @@ -123,10 +126,10 @@ public function onCommand(CommandSender $sender, Command $command, string $label $sender->getInventory()->removeItem($item); $this->auctions[strtolower($sender->getName())] = array( - $item->getID(), $item->getDamage(), $count, (float) $startPrice, null, (float) $startPrice, null, null + $item->getId(), $item->getMeta(), $count, (float) $startPrice, null, (float) $startPrice, null, null ); $this->getServer()->broadcastMessage(TextFormat::GREEN . $sender->getName() . TextFormat::RESET . "'s auction has just started."); - EconomyAPI::getInstance()->reduceMoney($sender, $tax); + EconomyAPI::getInstance()->reduceMoney($sender, $tax, null, new CommandIssuer($sender, "auction", "start ...")); }else{ $sender->sendMessage("You don't have enough items"); } @@ -165,7 +168,8 @@ public function onCommand(CommandSender $sender, Command $command, string $label $sender->sendMessage("Usage: /auction time