I noticed with pocketmine players can take an item from a item frame even if the area has been protected. (i used plugin iProtect to protect) does anyone know a way to stop players from taking items from item frames? an alternative protection plugin? I couldn't find a working one
I believe there are no plugins that can protect item frames from dropping items yet. When an item is taken from an item frame the client does not send a block event packet, it sends an item frame drop item packet, most protection plugins only protect when a player breaks, places, or interacts [with] a block.
There is currently no event called when an item is removed from an item frame (Reference: https://github.com/pmmp/PocketMine-MP/blob/mcpe-1.0/src/pocketmine/Player.php#L2931#L2948). You can however cancel player interact event to prevent players adding items to an item frame.
There is an event called. DataPacketRecieveEvent. I know it's nothing you should use, but if you have no option beside modifying the core, you can consider using it. There is always a last resort. Again this is very hacky, but should work. Might break even WITHOUT an api version change. Currently working on a small plugin for this. In the meantime here is a small concept: PHP: /** * @license GPLv3 * @author robske_110 * NO WARRANTY */use pocketmine\event\server\DataPacketReceiveEvent;use pocketmine\network\protocol\ItemFrameDropItemPacket;use pocketmine\math\Vector3; public function onItemFrameDropPacket(DataPacketReceiveEvent $event){ $packet = $event->getPacket(); if($packet instanceof ItemFrameDropItemPacket){ $player = $event->getPlayer(); $level = $player->getLevel(); $vec3 = new Vector3($packet->x, $packet->y, $packet->z); #do checks using all that data #and if it is invalid do $event->setCancelled(); }}
It is possible to stop the removal of the item by stopping the server from handling the packet but it isn't very reliable and is considered hacky. It may work for now but as @robske_110 (Tim) said, it can break at any time without warning.