Hello i'm simply trying to cancel the ability for a player to break a block in a set region. That has been accomplished although there is a bug. I was wondering if someone could help me squash it. Bug: When player breaks the block the event is canceled so they block ins't broken but the item still goes to the players inventory. I'd like to know how i can make it so either A. That doesn't happen or B. it check the item that was placed in the inventory and replaces it with air PHP: public function onPlayerInteract(PlayerInteractEvent $event) : void { $region = $this->plugin->getRegionFromPos($event->getBlock()); if ($region !== null) { if (!$region->canEdit($event->getPlayer())) { $event->setCancelled(); } } } public function onPlayerExhaust(PlayerExhaustEvent $event) : void { $player = $event->getPlayer(); if (isset($this->playerRegions[$k = $player->getId()]) && $this->playerRegions[$k]->hasFlag(RegionFlags::NO_HUNGER)) { $event->setCancelled(); } } public function onBlockPlace(BlockPlaceEvent $event) : void { $region = $this->plugin->getRegionFromPos($event->getBlock()); if ($region !== null) { if (!$region->canEdit($event->getPlayer())) { $event->setCancelled(true); } } } public function onBlockBreak(BlockBreakEvent $event) : void { $region = $this->plugin->getRegionFromPos($event->getBlock()); if ($region !== null) { if (!$region->canEdit($event->getPlayer())) { $event->setCancelled(); } } }
Are you using a plugin that automatically sends the block to the player's inventory rather than dropping?
That was the problem, my core plugin for some strange reason i added it to set a block to player inventory on break.. i'll have to test more to see if i broke anything but thank you for the help guys
is there a new method for Explosions or Position? public function add5(Block $block){ $task = new timeBomb($this->main, $block, 6); $h = $this->main->getServer()->getScheduler()->scheduleRepeatingTask($task, 10); $task->setHandler($h); } this make it the torch tick but no explosion is caused
Does that still relate to the first issue, or has the first issue been fixed? BTW, some microoptimisation: PHP: $event->setCancelled($region->canEdit($event->getPlayer()));