So i have not been working on stuff lately. And i recently started learning gui's. SO ye i got stuff out the way i know how to send a chest inv to a player. Then i wanted to cancel the event when the player taps on the given item so there 2 options to use and i chose EntityInventoryChangeEvent because InventoryTransactionEvent is hard. But my brother asked a friend if he could help cuz that friend was good at gui's We mest around with the code and we got our way around it. But it does not cancel when i take the Item out of the Inventory. Sorry for the useless paragraph Heres my code. PHP: public function onTap(EntityInventoryChangeEvent $ev){ $p = $ev->getEntity(); if ($p instanceof Player) { if ($ev->getNewItem()->getCustomName() == "§e(!) §7Factions Realm" ){ $ev->setCancelled(true); $p->sendMessage("§aWE UP IN THIS BITCH"); } if ($ev->getNewItem()->getCustomName() == "§e(!) §cDevelopment Realm" ){ $ev->setCancelled(true); $p->sendMessage("§aWE UP IN THIS BITCH"); } }}
These are my eevnts PHP: //playeruse pocketmine\nbt\tag\IntTag;use pocketmine\nbt\tag\StringTag;use pocketmine\Player;//inventoryuse pocketmine\inventory\Inventory;use pocketmine\event\inventory\InventoryTransactionEvent;use pocketmine\inventory\ChestInventory;use pocketmine\inventory\DoubleChestInventory;//eventsuse pocketmine\event\player\PlayerMoveEvent;use pocketmine\event\entity\EntityInventoryChangeEvent;use pocketmine\event\player\PlayerItemHeldEvent;use pocketmine\event\server\DataPacketReceiveEvent;use pocketmine\event\player\PlayerChatEvent;use pocketmine\event\entity\EntityTeleportEvent;use pocketmine\event\entity\ProjectileHitEvent;use pocketmine\event\entity\EntityShootBowEvent;use pocketmine\event\entity\EntityDamageByEntityEvent;use pocketmine\event\entity\EntityDamageByChildEntityEvent;use pocketmine\event\entity\EntityDamageEvent;use pocketmine\event\player\PlayerItemConsumeEvent;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\event\player\PlayerRespawnEvent;use pocketmine\event\player\PlayerDeathEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerKickEvent;use pocketmine\event\player\PlayerCommandPreprocessEvent;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\player\PlayerPreLoginEvent;use pocketmine\event\player\PlayerLoginEvent;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\entity\EntityLevelChangeEvent;use pocketmine\event\level\LevelLoadEvent;use pocketmine\event\Listener;use pocketmine\event\player\PlayerBedEnterEvent;use pocketmine\event\player\PlayerDropItemEvent;use pocketmine\event\player\PlayerHungerChangeEvent;//itemsuse pocketmine\item\Slimeball;use pocketmine\item\Item;//commandsuse pocketmine\command\CommandExecutor;use pocketmine\command\ConsoleCommandExecutor;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\command\ConsoleCommandSender;//utilsuse pocketmine\tile\Tile;use pocketmine\utils\TextFormat;use pocketmine\utils\config;use pocketmine\utils\TextFormat as Color;use pocketmine\utils\TextFormat as TF;use pocketmine\utils\TextFormat as MT;use pocketmine\utils\TextFormat as C;use pocketmine\utils\BinaryStream;use pocketmine\utils\Binary;//entityuse pocketmine\entity\Entity;use pocketmine\entity\Effect;use pocketmine\entity\Arrow;//leveluse pocketmine\level\sound\BlazeShootSound;use pocketmine\level\sound\GhastShootSound;use pocketmine\level\sound\EndermanTeleportSound;use pocketmine\level\sound\AnvilFallSound;use pocketmine\level\particle\FloatingTextParticle;use pocketmine\level\particle\ExplodeParticle;use pocketmine\level\particle\BubbleParticle;use pocketmine\level\particle\Particle;use pocketmine\level\particle\DustParticle;use pocketmine\level\Position;use pocketmine\level\Location;use pocketmine\level\format\Chunk;use pocketmine\level\format\FullChunk;use pocketmine\level\Level;//blockuse pocketmine\block\IronOre;use pocketmine\block\GoldOre;use pocketmine\block\Block;//pluginuse pocketmine\plugin\PluginBase;use pocketmine\plugin\PluginManager;use pocketmine\plugin\Plugin;//serveruse pocketmine\Server;//networkuse pocketmine\network\protocol\AddEntityPacket;use pocketmine\network\protocol\PlayerActionPacket;use pocketmine\network\protocol\MovePlayerPacket;use pocketmine\network\protocol\BlockEventPacket;//mathuse pocketmine\math\Vector3;use pocketmine\math\Math;use pocketmine\math\AxisAlignedBB;//scheduleruse pocketmine\scheduler\PluginTask;use pocketmine\scheduler\CallbackTask;//nbtuse pocketmine\nbt\tag\DoubleTag;use pocketmine\nbt\NBT;use pocketmine\nbt\tag\FloatTag;use pocketmine\nbt\tag\ListTag;use pocketmine\nbt\tag\CompoundTag;//permissionuse pocketmine\permission\Permission;
its a EntityINVENTORYChangeEvent , when player makes a change in their inventory or chest inventory whatever inventory this event is trigged , he cant cancell it but am sure he isnt using it the right way or something
Just tips, on every Event bracket or if, you should put this PHP: echo "Yay my code is working! thanks god" . PHP_EOL; it will HELP you from stressed issue and protect you from headache. for example PHP: public function onMove(PlayerMoveEvent $event) { echo "Yay my code is working! thanks god" . PHP_EOL;} Its look simple but yes, you must do that.