diff --git a/WorldProtect/README.md b/WorldProtect/README.md index 6aa66ac..0a0b730 100644 --- a/WorldProtect/README.md +++ b/WorldProtect/README.md @@ -378,6 +378,7 @@ Returns an integer or null. * 2.3.0: Updated to API 2.0.0 - Added banitem exempted permissions (@BobbyTowers) + - Closes #47 (@SleepSpace9) * 2.2.0: minor Update - Implemented banned commands (@Tolo) - Documentation update diff --git a/WorldProtect/src/aliuly/worldprotect/BanItem.php b/WorldProtect/src/aliuly/worldprotect/BanItem.php index 049900f..377f5ce 100644 --- a/WorldProtect/src/aliuly/worldprotect/BanItem.php +++ b/WorldProtect/src/aliuly/worldprotect/BanItem.php @@ -27,6 +27,7 @@ use pocketmine\event\player\PlayerInteractEvent; use pocketmine\event\player\PlayerItemConsumeEvent; +use pocketmine\event\block\BlockPlaceEvent; use pocketmine\item\Item; use pocketmine\Player; use aliuly\worldprotect\common\mc; @@ -116,4 +117,15 @@ public function onConsume(PlayerItemConsumeEvent $ev) { $pl->sendMessage(mc::_("You can not use that item here!")); $ev->setCancelled(); } + public function onBlockPlace(BlockPlaceEvent $ev) { + if ($ev->isCancelled()) return; + $pl = $ev->getPlayer(); + if ($pl->hasPermission("wp.banitem.exempt")) return; + $world = $pl->getLevel()->getName(); + if (!isset($this->wcfg[$world])) return; + $item = $ev->getItem(); + if (!isset($this->wcfg[$world][$item->getId()])) return; + $pl->sendMessage(mc::_("You can not use that item here!")); + $ev->setCancelled(); + } }