diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bad81d29..04394238 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,12 +19,12 @@ jobs: wget -O vendor/ScoreHud.phar https://poggit.pmmp.io/r/161570/ScoreHud_dev-71.phar - name: Download Virion Dependencies run: | - wget -O vendor/libasynql.phar https://poggit.pmmp.io/r/204062/libasynql_dev-199.phar - wget -O vendor/libFormAPI.phar https://poggit.pmmp.io/r/207248/libFormAPI_dev-4.phar - wget -O vendor/libPiggyEconomy.phar https://poggit.pmmp.io/r/177191/libPiggyEconomy_dev-18.phar + wget -O vendor/libasynql.phar https://poggit.pmmp.io/r/213142/libasynql_dev-203.phar + wget -O vendor/FormsUI.phar https://poggit.pmmp.io/r/209836/FormsUI_dev-20.phar + wget -O vendor/libPiggyEconomy.phar https://poggit.pmmp.io/r/212853/libPiggyEconomy_dev-19.phar wget -O vendor/libPiggyUpdateChecker.phar https://poggit.pmmp.io/r/163495/libPiggyUpdateChecker_dev-1.phar - wget -O vendor/Commando.phar https://poggit.pmmp.io/r/162923/Commando_dev-30.phar + wget -O vendor/Commando.phar https://poggit.pmmp.io/r/216831/Commando_dev-34.phar - name: Run PHPStan - uses: paroxity/pmmp-phpstan-action@4.21.0 + uses: paroxity/pmmp-phpstan-action@5.3.0 with: phpstan-config: phpstan.neon.dist diff --git a/.poggit.yml b/.poggit.yml index c8ac8031..692afdae 100644 --- a/.poggit.yml +++ b/.poggit.yml @@ -7,13 +7,13 @@ projects: icon: "resources/PiggyFactions-icon.png" libs: - src: Paroxity/Commando/Commando - version: ^3.0.0 + version: ^3.1.0 - src: poggit/libasynql/libasynql - version: ^4.1.6 - - src: jojoe77777/FormAPI/libFormAPI - version: ^2.1.1 + version: ^4.2.0 + - src: Vecnavium/FormsUI/FormsUI + version: ^1.1.3 - src: DaPigGuy/libPiggyEconomy/libPiggyEconomy - version: ^3.0.1 + version: ^3.0.2 - src: DaPigGuy/libPiggyUpdateChecker/libPiggyUpdateChecker version: ^1.0.0 lint: diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 3b5585ad..2d4b68a6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -10,7 +10,7 @@ parameters: - phar:///source/vendor/HRKChat.phar/src/ - phar:///source/vendor/ScoreHud.phar/src/ - phar:///source/vendor/Commando.phar/src/ - - phar:///source/vendor/libFormAPI.phar/src/ + - phar:///source/vendor/FormsUI.phar/src/ - phar:///source/vendor/libasynql.phar/src/ - phar:///source/vendor/libPiggyEconomy.phar/src/ - phar:///source/vendor/libPiggyUpdateChecker.phar/src/ diff --git a/plugin.yml b/plugin.yml index 0fbc1e7a..8147e6be 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: PiggyFactions main: DaPigGuy\PiggyFactions\PiggyFactions -version: 2.0.4 -api: 4.21.0 +version: 2.1.0 +api: 5.0.0 author: DaPigGuy softdepend: [EconomyAPI, BedrockEconomy, PiggyCustomEnchants, HRKChat, ScoreHud] website: "https://github.com/DaPigGuy/PiggyFactions" diff --git a/src/DaPigGuy/PiggyFactions/EventListener.php b/src/DaPigGuy/PiggyFactions/EventListener.php index 8c4e7061..908fc394 100644 --- a/src/DaPigGuy/PiggyFactions/EventListener.php +++ b/src/DaPigGuy/PiggyFactions/EventListener.php @@ -15,6 +15,7 @@ use pocketmine\event\player\PlayerDeathEvent; use pocketmine\event\player\PlayerJoinEvent; use pocketmine\event\player\PlayerRespawnEvent; +use pocketmine\player\chat\LegacyRawChatFormatter; use pocketmine\player\Player; class EventListener implements Listener @@ -45,11 +46,11 @@ public function onChat(PlayerChatEvent $event): void $event->setRecipients(array_merge($faction->getOnlineMembers(), ...array_map(function (Faction $ally): array { return $ally->getOnlineMembers(); }, $faction->getAllies()))); - $event->setFormat($this->plugin->getLanguageManager()->getMessage($this->plugin->getLanguageManager()->getDefaultLanguage(), "chat.ally", $placeholders)); + $event->setFormatter(new LegacyRawChatFormatter($this->plugin->getLanguageManager()->getMessage($this->plugin->getLanguageManager()->getDefaultLanguage(), "chat.ally", $placeholders))); break; case ChatTypes::FACTION: $event->setRecipients($faction->getOnlineMembers()); - $event->setFormat($this->plugin->getLanguageManager()->getMessage($this->plugin->getLanguageManager()->getDefaultLanguage(), "chat.faction", $placeholders)); + $event->setFormatter(new LegacyRawChatFormatter($this->plugin->getLanguageManager()->getMessage($this->plugin->getLanguageManager()->getDefaultLanguage(), "chat.faction", $placeholders))); break; } } diff --git a/src/DaPigGuy/PiggyFactions/PiggyFactions.php b/src/DaPigGuy/PiggyFactions/PiggyFactions.php index 7fde901a..466ac0e4 100644 --- a/src/DaPigGuy/PiggyFactions/PiggyFactions.php +++ b/src/DaPigGuy/PiggyFactions/PiggyFactions.php @@ -26,13 +26,13 @@ use DaPigGuy\PiggyFactions\tasks\UpdatePowerTask; use DaPigGuy\PiggyFactions\utils\PoggitBuildInfo; use Exception; -use jojoe77777\FormAPI\Form; use pocketmine\entity\Entity; use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\Config; use poggit\libasynql\DataConnector; use poggit\libasynql\libasynql; +use Vecnavium\FormsUI\Form; class PiggyFactions extends PluginBase { @@ -64,7 +64,7 @@ public function onEnable(): void foreach ( [ "Commando" => BaseCommand::class, - "libformapi" => Form::class, + "FormsUI" => Form::class, "libasynql" => libasynql::class, "libPiggyUpdateChecker" => libPiggyUpdateChecker::class ] as $virion => $class diff --git a/src/DaPigGuy/PiggyFactions/claims/ClaimsListener.php b/src/DaPigGuy/PiggyFactions/claims/ClaimsListener.php index ba1c855a..1e74a497 100644 --- a/src/DaPigGuy/PiggyFactions/claims/ClaimsListener.php +++ b/src/DaPigGuy/PiggyFactions/claims/ClaimsListener.php @@ -14,9 +14,9 @@ use pocketmine\event\block\BlockBreakEvent; use pocketmine\event\block\BlockPlaceEvent; use pocketmine\event\Listener; -use pocketmine\event\player\PlayerCommandPreprocessEvent; use pocketmine\event\player\PlayerInteractEvent; use pocketmine\event\player\PlayerMoveEvent; +use pocketmine\event\server\CommandEvent; use pocketmine\player\Player; use pocketmine\world\format\Chunk; use pocketmine\world\Position; @@ -34,25 +34,31 @@ public function onBreak(BlockBreakEvent $event): void public function onPlace(BlockPlaceEvent $event): void { - if (!$this->canAffectArea($event->getPlayer(), $event->getBlock()->getPosition())) $event->cancel(); + foreach($event->getTransaction()->getBlocks() as [$x, $y, $z, $block]) { + if(!$this->canAffectArea($event->getPlayer(), new Position($x, $y, $z, $event->getPlayer()->getWorld()))) { + $event->cancel(); + return; + } + } } - public function onCommandPreprocess(PlayerCommandPreprocessEvent $event): void + public function onCommand(CommandEvent $event): void { - $player = $event->getPlayer(); - $message = $event->getMessage(); + $player = $event->getSender(); + if(!$player instanceof Player) { + return; + } + $message = $event->getCommand(); $member = $this->plugin->getPlayerManager()->getPlayer($player); if ($member !== null) { $faction = $member->getFaction(); $claim = $this->manager->getClaimByPosition($player->getPosition()); if (!$member->isInAdminMode() && $claim !== null && $claim->getFaction() !== $faction) { $relation = $faction === null ? Relations::NONE : $faction->getRelation($claim->getFaction()); - if (str_starts_with($message, "/")) { - $command = substr(explode(" ", $message)[0], 1); - if (in_array($command, $this->plugin->getConfig()->getNested("factions.claims.denied-commands." . $relation, []))) { - $member->sendMessage("claims.command-denied", ["{COMMAND}" => $command, "{RELATION}" => $relation === "none" ? "neutral" : $relation]); - $event->cancel(); - } + $command = substr(explode(" ", $message)[0], 1); + if (in_array($command, $this->plugin->getConfig()->getNested("factions.claims.denied-commands." . $relation, []))) { + $member->sendMessage("claims.command-denied", ["{COMMAND}" => $command, "{RELATION}" => $relation === "none" ? "neutral" : $relation]); + $event->cancel(); } } } diff --git a/src/DaPigGuy/PiggyFactions/commands/FactionCommand.php b/src/DaPigGuy/PiggyFactions/commands/FactionCommand.php index ea718917..b532f887 100644 --- a/src/DaPigGuy/PiggyFactions/commands/FactionCommand.php +++ b/src/DaPigGuy/PiggyFactions/commands/FactionCommand.php @@ -53,9 +53,9 @@ use DaPigGuy\PiggyFactions\commands\subcommands\VersionSubCommand; use DaPigGuy\PiggyFactions\PiggyFactions; use DaPigGuy\PiggyFactions\utils\ChatTypes; -use jojoe77777\FormAPI\SimpleForm; use pocketmine\command\CommandSender; use pocketmine\player\Player; +use Vecnavium\FormsUI\SimpleForm; class FactionCommand extends BaseCommand { @@ -66,7 +66,7 @@ public function onRun(CommandSender $sender, string $aliasUsed, array $args): vo { if ($this->plugin->areFormsEnabled() && $sender instanceof Player) { $subcommands = array_filter($this->getSubCommands(), function (BaseSubCommand $subCommand, string $alias) use ($sender): bool { - return $subCommand->getName() === $alias && $sender->hasPermission($subCommand->getPermission()); + return $subCommand->getName() === $alias && count(array_filter($subCommand->getPermissions(), $sender->hasPermission(...))) > 0; }, ARRAY_FILTER_USE_BOTH); $form = new SimpleForm(function (Player $player, ?int $data) use ($subcommands): void { if ($data !== null) { diff --git a/src/DaPigGuy/PiggyFactions/commands/subcommands/FactionSubCommand.php b/src/DaPigGuy/PiggyFactions/commands/subcommands/FactionSubCommand.php index b11a84b3..a452fdc2 100644 --- a/src/DaPigGuy/PiggyFactions/commands/subcommands/FactionSubCommand.php +++ b/src/DaPigGuy/PiggyFactions/commands/subcommands/FactionSubCommand.php @@ -15,10 +15,10 @@ use DaPigGuy\PiggyFactions\PiggyFactions; use DaPigGuy\PiggyFactions\players\FactionsPlayer; use DaPigGuy\PiggyFactions\utils\PiggyArgument; -use jojoe77777\FormAPI\CustomForm; use pocketmine\command\CommandSender; use pocketmine\player\Player; use pocketmine\utils\TextFormat; +use Vecnavium\FormsUI\CustomForm; abstract class FactionSubCommand extends BaseSubCommand { diff --git a/src/DaPigGuy/PiggyFactions/commands/subcommands/HelpSubCommand.php b/src/DaPigGuy/PiggyFactions/commands/subcommands/HelpSubCommand.php index 0f3a7eef..001a4fe0 100644 --- a/src/DaPigGuy/PiggyFactions/commands/subcommands/HelpSubCommand.php +++ b/src/DaPigGuy/PiggyFactions/commands/subcommands/HelpSubCommand.php @@ -28,7 +28,7 @@ public function __construct(PiggyFactions $plugin, FactionCommand $parentCommand public function onBasicRun(CommandSender $sender, array $args): void { $subcommands = array_filter($this->parentCommand->getSubCommands(), function (BaseSubCommand $subCommand, string $alias) use ($sender): bool { - return $subCommand->getName() === $alias && $sender->hasPermission($subCommand->getPermission()); + return $subCommand->getName() === $alias && count(array_filter($subCommand->getPermissions(), $sender->hasPermission(...))) > 0; }, ARRAY_FILTER_USE_BOTH); $commandsPerPage = $sender instanceof Player ? self::COMMANDS_PER_PAGE : count($subcommands); diff --git a/src/DaPigGuy/PiggyFactions/commands/subcommands/management/LogsSubCommand.php b/src/DaPigGuy/PiggyFactions/commands/subcommands/management/LogsSubCommand.php index 8c318921..cb75d21f 100644 --- a/src/DaPigGuy/PiggyFactions/commands/subcommands/management/LogsSubCommand.php +++ b/src/DaPigGuy/PiggyFactions/commands/subcommands/management/LogsSubCommand.php @@ -10,9 +10,9 @@ use DaPigGuy\PiggyFactions\factions\Faction; use DaPigGuy\PiggyFactions\logs\LogsManager; use DaPigGuy\PiggyFactions\players\FactionsPlayer; -use jojoe77777\FormAPI\SimpleForm; use pocketmine\player\Player; use pocketmine\utils\TextFormat; +use Vecnavium\FormsUI\SimpleForm; class LogsSubCommand extends FactionSubCommand { diff --git a/src/DaPigGuy/PiggyFactions/logs/LogsManager.php b/src/DaPigGuy/PiggyFactions/logs/LogsManager.php index 88a9d438..a6fac58a 100644 --- a/src/DaPigGuy/PiggyFactions/logs/LogsManager.php +++ b/src/DaPigGuy/PiggyFactions/logs/LogsManager.php @@ -8,8 +8,8 @@ use DaPigGuy\PiggyFactions\factions\Faction; use DaPigGuy\PiggyFactions\language\LanguageManager; use DaPigGuy\PiggyFactions\PiggyFactions; -use jojoe77777\FormAPI\SimpleForm; use pocketmine\player\Player; +use Vecnavium\FormsUI\SimpleForm; class LogsManager { diff --git a/src/DaPigGuy/PiggyFactions/utils/AsciiCompass.php b/src/DaPigGuy/PiggyFactions/utils/AsciiCompass.php index 38503fae..65f3f40d 100644 --- a/src/DaPigGuy/PiggyFactions/utils/AsciiCompass.php +++ b/src/DaPigGuy/PiggyFactions/utils/AsciiCompass.php @@ -42,7 +42,7 @@ public static function getAsciiCompass(float $degrees): array public static function getDirectionsByDegrees(float $degrees): string { - $degrees = ($degrees - 157) % 360; + $degrees = (int)($degrees - 157) % 360; if ($degrees < 0) $degrees += 360; return array_keys(self::DIRECTIONS)[(int)floor($degrees / 45)];