Giter Site home page Giter Site logo

muqsit / invmenu Goto Github PK

View Code? Open in Web Editor NEW
200.0 21.0 76.0 304 KB

A PocketMine-MP virion to create and manage virtual inventories!

Home Page: https://poggit.pmmp.io/ci/Muqsit/InvMenu/~

License: GNU General Public License v3.0

PHP 100.00%
pmmp pocketmine virion inventory gui

invmenu's Introduction

InvMenu

InvMenu is a PocketMine-MP virion that eases creating and managing fake inventories!

Installation

You can get the compiled .phar file on poggit by clicking here.

Usage

InvMenu supports creating a GUI out of any kind of Inventory.

NOTE: You MUST register InvMenuHandler during plugin enable before you can begin creating InvMenu instances.

if(!InvMenuHandler::isRegistered()){
	InvMenuHandler::register($this);
}

Creating an InvMenu instance

InvMenu::create($identifier) creates a new instance of InvMenu. $identifier must be an identifier of a registered InvMenuType object. InvMenu comes with 3 pre-registered InvMenuType identifiers: InvMenu::TYPE_CHEST, InvMenu::TYPE_DOUBLE_CHEST and InvMenu::TYPE_HOPPER.

$menu = InvMenu::create(InvMenu::TYPE_CHEST);

To access this menu's inventory, you can use:

$inventory = $menu->getInventory();

The $inventory implements pocketmine's Inventory interface, so you can access all the fancy pocketmine inventory methods.

$menu->getInventory()->setContents([
	VanillaItems::DIAMOND_SWORD(),
	VanillaItems::DIAMOND_PICKAXE()
]);
$menu->getInventory()->addItem(VanillaItems::DIAMOND_AXE());
$menu->getInventory()->setItem(3, VanillaItems::GOLD_INGOT());

To send the menu to a player, use:

/** @var Player $player */
$menu->send($player);

Yup, that's it. It's that simple.

Specifying a custom name to the menu

To set a custom name to a menu, use

$menu->setName("Custom Name");

You can also specify a different menu name for each player separately during InvMenu::send().

/** @var Player $player */
$menu->send($player, "Greetings, " . $player->getName());

Verifying whether the menu was sent to the player

Not a common occurrence but it's possible for plugins to disallow players from opening inventories. This can also occur as an attempt to drop garbage InvMenu::send() requests (if you send two menus simultaneously without any delay in betweeen, the first menu request may be regarded as garbage).

/** @var string|null $name */
$menu->send($player, $name, function(bool $sent) : void{
	if($sent){
		// do something
	}
});

Handling menu item transactions

To handle item transactions happening to and from the menu's inventory, you may specify a Closure handler that gets triggered by InvMenu every time a transaction occurs. You may allow, cancel and do other things within this handler. To register a transaction handler to a menu, use:

/** @var Closure $listener */
$menu->setListener($listener);

What's $listener?

/**
 * @param InvMenuTransaction $transaction
 *
 * Must return an InvMenuTransactionResult instance.
 * Return $transaction->continue() to continue the transaction.
 * Return $transaction->discard() to cancel the transaction.
 * @return InvMenuTransactionResult
 */
Closure(InvMenuTransaction $transaction) : InvMenuTransactionResult;

InvMenuTransaction holds all the item transction data.
InvMenuTransaction::getPlayer() returns the Player that triggered the transaction.
InvMenuTransaction::getItemClicked() returns the Item the player clicked in the menu.
InvMenuTransaction::getItemClickedWith() returns the Item the player had in their hand when clicking an item.
InvMenuTransaction::getAction() returns a SlotChangeAction instance, to get the slot index of the item clicked from the menu's inventory.
InvMenuTransaction::getTransaction() returns the complete InventoryTransaction instance.

$menu->setListener(function(InvMenuTransaction $transaction) : InvMenuTransactionResult{
	$player = $transaction->getPlayer();
	$itemClicked = $transaction->getItemClicked();
	$itemClickedWith = $transaction->getItemClickedWith();
	$action = $transaction->getAction();
	$invTransaction = $transaction->getTransaction();
	return $transaction->continue();
});

A handler that doesn't allow players to take out apples from the menu's inventory:

$menu->setListener(function(InvMenuTransaction $transaction) : InvMenuTransactionResult{
	if($transaction->getItemClicked()->getId() === ItemIds::APPLE){
		$player->sendMessage("You cannot take apples out of that inventory.");
		return $transaction->discard();
	}
	return $transaction->continue();
});

Preventing inventory from being changed by players

There are two ways you can go with to prevent players from modifying the inventory contents of a menu.

Method #1: Calling InvMenuTransaction::discard()

$menu->setListener(function(InvMenuTransaction $transaction) : InvMenuTransactionResult{
	// do something
	return $transaction->discard();
});

Method #2: Using InvMenu::readonly()

$menu->setListener(InvMenu::readonly());
$menu->setListener(InvMenu::readonly(function(DeterministicInvMenuTransaction $transaction) : void{
	// do something
}));

Based on your use-case, you may find one better than the other. While Method #1 gives you full control over a transaction (you can conditionally cancel a transaction, f.e based on whether player has permission, or player is in a specific area etc), Method #2 reduces boilerplate InvMenuTransactionResult imports and calls to InvMenutransaction::discard().

Executing a task post-transaction

A few actions are impossible to be done at the time a player is viewing an inventory, such as sending a form — a player won't be able to view a form while viewing an inventory. To do this, you will need to close the menu inventory and make sure they've closed it by waiting for a response from their side. You can do this by supplying a callback to InvMenuTransactionResult::then().

$menu->setListener(function(InvMenuTransaction $transaction) : InvMenuTransactionResult{
	$transaction->getPlayer()->removeCurrentWindow();
	return $transaction->discard()->then(function(Player $player) : void{ // $player === $transaction->getPlayer()
		// assert($player->isOnline());
		$player->sendForm(new Form());
	});
});
$menu->setListener(InvMenu::readonly(function(DeterministicInvMenuTransaction $transaction) : void{
	$transaction->getPlayer()->removeCurrentWindow();
	$transaction->then(function(Player $player) : void{
		$player->sendForm(new Form());
	});
}));

Listening players closing or no longer viewing the inventory

To listen inventory close triggers, specify the inventory close Closure using:

/** @var Closure $listener */
$menu->setInventoryCloseListener($listener);

What's $listener?

/**
 * @param Player $player the player who closed the inventory.
 *
 * @param Inventory $inventory the inventory instance closed by the player.
 */
Closure(Player $player, Inventory $inventory) : void;

To forcefully close or remove the menu from a player:

/** @var Player $player */
$player->removeCurrentWindow();

Registering a custom InvMenu type

So let's say you'd like to send players a dispenser inventory. While InvMenu doesn't ship with a InvMenu::TYPE_DISPENSER, you can still create a dispenser InvMenu by registering an InvMenuType object with the information about what a dispenser inventory looks like.

public const TYPE_DISPENSER = "myplugin:dispenser";

protected function onEnable() : void{
	InvMenuHandler::getTypeRegistry()->register(self::TYPE_DISPENSER, InvMenuTypeBuilders::BLOCK_ACTOR_FIXED()
		->setBlock(BlockFactory::getInstance()->get(BlockLegacyIds::DISPENSER, 0))
		->setBlockActorId("Dispenser")
		->setSize(9)
		->setNetworkWindowType(WindowTypes::DISPENSER)
	->build());
}

Sweet! Now you can create a dispenser menu using

$menu = InvMenu::create(self::TYPE_DISPENSER);

InvMenu Wiki

Applications, examples, tutorials and featured projects using InvMenu can be found on the InvMenu Wiki.

invmenu's People

Contributors

brandpvp avatar dadodasyra avatar dries-c avatar fernanacm avatar inxomnyaa avatar ipad54 avatar muqsit avatar poggit-bot avatar sof3 avatar xerenahmed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

invmenu's Issues

W10 Gui disappearing

Here I go again😂. Type double chest when W10 opening and teleporting gui dissappears. With gui I mean inventory gui hearths bar ecc.

Bug or error?

[13:46:39] [Server thread/DEBUG]: #0 src/pocketmine/inventory/BaseInventory(169): pocketmine\inventory\BaseInventory->getItem(integer 5)
[13:46:39] [Server thread/DEBUG]: #1 plugins/zCases_v1.0.0/src/zyware/zCases/Tasks/zItemTask(72): pocketmine\inventory\BaseInventory->setItem(integer 5, pocketmine\item\ItemBlock object)
[13:46:39] [Server thread/DEBUG]: #2 src/pocketmine/scheduler/TaskHandler(160): zyware\zCases\Tasks\zItemTask->onRun(integer 925)
[13:46:39] [Server thread/DEBUG]: #3 src/pocketmine/scheduler/ServerScheduler(327): pocketmine\scheduler\TaskHandler->run(integer 925)
[13:46:39] [Server thread/DEBUG]: #4 src/pocketmine/Server(2500): pocketmine\scheduler\ServerScheduler->mainThreadHeartbeat(integer 925)
[13:46:39] [Server thread/DEBUG]: #5 src/pocketmine/Server(2240): pocketmine\Server->tick()
[13:46:39] [Server thread/DEBUG]: #6 src/pocketmine/Server(2116): pocketmine\Server->tickProcessor()
[13:46:39] [Server thread/DEBUG]: #7 src/pocketmine/Server(1702): pocketmine\Server->start()
[13:46:39] [Server thread/DEBUG]: #8 src/pocketmine/PocketMine(305): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\mikha\Desktop\PocketMine-MP\, string C:\Users\mikha\Desktop\PocketMine-MP\plugins\)

Opening Windows

If I use more than 1 window and add items with transaction event to open other windows it doesnt work its glitching
-the hotbar disappears
-black screen...
But I can still use everything in the window which does matter because the game has glitched...

Ive changed the task delay so I can avoid such bugs...
Same Bug... why?
https://youtu.be/fD2nUk4PrlA
This is the plugin...

I have to update it to V1.0 . I have finished my work and the plugin is read but it has this bug......
Any help

(Also hopper is really buggy)

1.11 Chests are not opening

Version: PocketMine-MP 3.8.0 Realese
Last InvMenu Version

Chests failed open. InvMenu spawns a chest but the Inventory doesnt open there is no Error after PMMP 1.11 Update the Chests are borken. Sry for my bad English :D

Error while starting server

Hello,
Ich found an error
[12:53:40] [Server thread/CRITICAL]: Error: "Class 'pocketmine\network\mcpe\protocol\types\inventory\WindowTypes' not found" (EXCEPTION) in "plugins/LobbyManager/src/muqsit/invmenu/InvMenuHandler" at line 63
when I try to start the server.

Scheduler\pmmp

[Server thread/CRITICAL]: Could not pass event 'pocketmine\event\inventory\InventoryTransactionEvent' to 'Admin v1': Call to undefined method muqsit\invmenu\inventories\DoubleChestInventory::getScheduler() on muqsit\invmenu\InvMenuHandler
[16:41:27] [Server thread/CRITICAL]: Error: "Call to undefined method muqsit\invmenu\inventories\DoubleChestInventory::getScheduler()" (EXCEPTION) in "InvMenu/src/muqsit/invmenu/inventories/DoubleChestInventory" at line 53

Level->getFullBlock()

Hello, when i spawn an InvMenu double chest, then tp to another chunk while still viewing the inventory, it gives me this error:

[14:53:13] [Server thread/CRITICAL]: Error: "Call to a member function getFullBlock() on null" (EXCEPTION) in "src/pocketmine/level/Level" at l
ne 1298
[14:53:13] [Server thread/DEBUG]: #0 src/pocketmine/level/Level(899): pocketmine\level\Level->getFullBlock(integer 9, integer 7, integer 11)
[14:53:13] [Server thread/DEBUG]: #1 Core/src/muqsit/invmenu/inventories/DoubleChestInventory(66): pocketmine\level\Level->sendBlo
ks(array Array(), array Array())
[14:53:13] [Server thread/DEBUG]: #2 Core/src/muqsit/invmenu/inventories/BaseFakeInventory(88): muqsit\invmenu\inventories\DoubleC
estInventory->sendRealBlockData(pocketmine\Player object, muqsit\invmenu\utils\HolderData object)
[14:53:13] [Server thread/DEBUG]: #3 src/pocketmine/inventory/BaseInventory(412): muqsit\invmenu\inventories\BaseFakeInventory->onClose(pocketm
ne\Player object)
[14:53:13] [Server thread/DEBUG]: #4 src/pocketmine/Player(3851): pocketmine\inventory\BaseInventory->close(pocketmine\Player object)
[14:53:13] [Server thread/DEBUG]: #5 src/pocketmine/Player(2880): pocketmine\Player->removeWindow(muqsit\invmenu\inventories\DoubleChestInvento
y object)
[14:53:13] [Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(172): pocketmine\Player->handleContainerClose(pock
tmine\network\mcpe\protocol\ContainerClosePacket object)
[14:53:13] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/protocol/ContainerClosePacket(46): pocketmine\network\mcpe\PlayerNetworkSessio
Adapter->handleContainerClose(pocketmine\network\mcpe\protocol\ContainerClosePacket object)
[14:53:13] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(96): pocketmine\network\mcpe\protocol\ContainerClo
ePacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
[14:53:13] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/protocol/BatchPacket(114): pocketmine\network\mcpe\PlayerNetworkSessionAdapter
>handleDataPacket(pocketmine\network\mcpe\protocol\ContainerClosePacket object)
[14:53:13] [Server thread/DEBUG]: #10 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(96): pocketmine\network\mcpe\protocol\BatchPacket
>handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
[14:53:13] [Server thread/DEBUG]: #11 src/pocketmine/Player(3060): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocket
ine\network\mcpe\protocol\BatchPacket object)
[14:53:13] [Server thread/DEBUG]: #12 src/pocketmine/network/mcpe/RakLibInterface(161): pocketmine\Player->handleDataPacket(pocketmine\network\
cpe\protocol\BatchPacket object)
[14:53:13] [Server thread/DEBUG]: #13 vendor/pocketmine/raklib/src/server/ServerHandler(98): pocketmine\network\mcpe\RakLibInterface->handleEnc
psulated(string 182.1.41.142 64645, raklib\protocol\EncapsulatedPacket object, integer 0)
[14:53:13] [Server thread/DEBUG]: #14 src/pocketmine/network/mcpe/RakLibInterface(102): raklib\server\ServerHandler->handlePacket()
[14:53:13] [Server thread/DEBUG]: #15 src/pocketmine/network/Network(94): pocketmine\network\mcpe\RakLibInterface->process()
[14:53:13] [Server thread/DEBUG]: #16 src/pocketmine/network/mcpe/RakLibInterface(92): pocketmine\network\Network->processInterface(pocketmine\
etwork\mcpe\RakLibInterface object)
[14:53:13] [Server thread/DEBUG]: #17 vendor/pocketmine/snooze/src/SleeperHandler(120): pocketmine\network\mcpe\RakLibInterface->pocketmine\net
ork\mcpe\{closure}()
[14:53:13] [Server thread/DEBUG]: #18 vendor/pocketmine/snooze/src/SleeperHandler(82): pocketmine\snooze\SleeperHandler->processNotifications()
[14:53:13] [Server thread/DEBUG]: #19 src/pocketmine/Server(2268): pocketmine\snooze\SleeperHandler->sleepUntil(double 1543067593.1148)
[14:53:13] [Server thread/DEBUG]: #20 src/pocketmine/Server(2135): pocketmine\Server->tickProcessor()
[14:53:13] [Server thread/DEBUG]: #21 src/pocketmine/Server(1701): pocketmine\Server->start()
[14:53:13] [Server thread/DEBUG]: #22 src/pocketmine/PocketMine(249): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\M
inLogger object, string /home/user03/mc/, string /home/user03/DepressedMC/plugins/)
[14:53:13] [Server thread/DEBUG]: #23 /home/user03/mc/PocketMine-MP.phar(1): require(string phar:///home/user03/mc/PocketMine
MP.phar/src/pocketmine/PocketMine.php)

not receiving inventory

not sure why but i had version 1.10 of the lib,however after updating to the latest version it stopped working

$contents = $items;
$this->menu = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST);
$this->menu
->readonly()
->sessionize()
->setName('AuctionHouse');
$this->menu->getInventory($player)->setContents($contents);
$this->menu->send($player);
$this->menu->getInventory($player)->sendContents($contents);

UPDATE: its only happening with double chest

How to load the plugin

Hey, I was wondering how to load the InvMenu plugin. I've created a virions folder, and added DEVirion and InvMenu to the virions plugin, and it never loads into the server. Any solutions? Thanks.

Question

My server does not load the phar. Or does it not have to be loaded at all?

players can take items fron the chest

code

$menu = InvMenu::create(InvMenu::TYPE_CHEST);
Item::get(57)
]);
$menu->readonly();
$menu->setName("Drop Party");
$menu->send($player);

i deoopped myself and i still could take items away

setName()

17:47:20 CRITICAL > Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'GameTeleporter v0.0.9': Non-static method muqsit\invmenu\InvMenu::setName() should not be called statically on ChaosDev93\GameTeleporter
17:47:20 CRITICAL > ErrorException: "Non-static method muqsit\invmenu\InvMenu::setName() should not be called statically" (EXCEPTION) in "GameTeleporter - CD/src/ChaosDev93/GameTeleporter" at line 103

I am using Altay

Dubble Chest cant open

18:41:27 CRITICAL > Could not pass event 'pocketmine\event\inventory\InventoryTransactionEvent' to 'LobbySystem-RevengerMC v1': Call to undefined method pocketmine\Server::getScheduler() on muqsit\invmenu\InvMenuHandler
18:41:27 CRITICAL > Error: "Call to undefined method pocketmine\Server::getScheduler()" (EXCEPTION) in "/RevengerMC/Lobby-1/virions/InvMenu-master/src/muqsit/invmenu/inventories/DoubleChestInventory" at line 53

Crashing when reloading

Every time I reload and try to open an double chest inventory it kicks me out of the game.
InvalidStateException: "Tried to schedule Task to disable scheduler" (EXCEPTION) in "src\pocketmine\scheduler\TaskScheduler" at line 148.

Cannot load plugin

2018-03-03 [09:58:12] [Server thread/INFO]: Loading InvMenu v1.0.0 2018-03-03 [09:58:12] [Server thread/CRITICAL]: Error: "Call to private muqsit\invmenu\InvMenu::__construct() from context 'pocketmine\plugin\PharPluginLoader'" (EXCEPTION) in "src/pocketmine/plugin/PharPluginLoader" at line 64 2018-03-03 [09:58:12] [Server thread/DEBUG]: #0 src/pocketmine/plugin/PluginManager(161): pocketmine\plugin\PharPluginLoader->loadPlugin(string phar:///home/gs/gs/data/servers/7069490/plugins/InvMenu_v1.0.0.phar) 2018-03-03 [09:58:12] [Server thread/DEBUG]: #1 src/pocketmine/plugin/PluginManager(305): pocketmine\plugin\PluginManager->loadPlugin(string /home/gs/gs/data/servers/7069490/plugins/InvMenu_v1.0.0.phar, array Array()) 2018-03-03 [09:58:12] [Server thread/DEBUG]: #2 src/pocketmine/Server(1658): pocketmine\plugin\PluginManager->loadPlugins(string /home/gs/gs/data/servers/7069490/plugins/) 2018-03-03 [09:58:12] [Server thread/DEBUG]: #3 src/pocketmine/PocketMine(385): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /home/gs/gs/data/servers/7069490/, string /home/gs/gs/data/servers/7069490/plugins/) 2018-03-03 [09:58:12] [Server thread/DEBUG]: #4 /home/gs/gs/data/servers/7069490/PocketMine-MP.phar(1): require(string phar:///home/gs/gs/data/servers/7069490/PocketMine-MP.phar/src/pocketmine/PocketMine.php) 2018-03-03 [09:58:12] [Server thread/CRITICAL]: Could not load plugin 'InvMenu'

Read

The function $menu->readOnly(); won't work !

class InvMenu not found

class 'muqsit\invmenu\InvMenu' not found.

While i have the class:

use muqsit\invmenu\InvMenu;

the code on where the error occured is

        return InvMenu::create(InvMenu::TYPE_CHEST)
            ->setName("Trash Can")
            ->sessionize()
            ->setInventoryCloseListener(Trashcan::class . "::dispose");

Inventory Transaction Bug

PMMP version 1.12, Release: 3.9.0
Click on a Item in a Chestinventory (don´t close this Inv) -> open a new Chestinventory -> Click on a Item -> Bug it doesn´t work

readonly issue

I open a issue yesterday involving thi issue and it said it was fixed but i installed it today the latest version and it still did not work

code//

$menu = InvMenu::create(InvMenu::TYPE_CHEST);
$menu->readonly();
$menu->setName("Test");
$menu->getInventory()->setContents([
Item::get(Item::NETHER_WART),
Item::get(Item::GLOWSTONE)
]);
$menu->send($player);

Server crashes when player disconnects while an inventory was open

I'm using InvMenu 3.0 fae67c3 on my server and ran into this error which crashed my server:

[16:11:29.180] [Server thread/CRITICAL]: ErrorException: "Undefined index: [�ɔ7�`v%�"" (EXCEPTION) in "plugins/Trading/src/muqsit/invmenu/session/PlayerManager" at line 40

To me it seems like InvMenu destroyed the player session because PlayerQuitEvent is being called in Player->disconnect(). But a few lines after that, Player->disconnect() also calls Player->removeCurrentWindow(), which makes InvMenu try to get the already destroyed player session because InventoryCloseEvent is fired.

After taking a look at the backtrace I believe these are the relevant calls to pinpoint the crash cause:

§b[16:11:29.182] §r§7[Server thread/DEBUG]: #1 plugins/Trading/src/muqsit/invmenu/InvMenuEventHandler(69): muqsit\invmenu\session\PlayerManager::get(object SalmonDE\Server\ExtendedPlayer)§r
§b[16:11:29.185] §r§7[Server thread/DEBUG]: #2 src/pocketmine/event/RegisteredListener(88): muqsit\invmenu\InvMenuEventHandler->onInventoryClose(object pocketmine\event\inventory\InventoryCloseEvent)§r
§b[16:11:29.185] §r§7[Server thread/DEBUG]: #3 src/pocketmine/event/Event(67): pocketmine\event\RegisteredListener->callEvent(object pocketmine\event\inventory\InventoryCloseEvent)§r
§b[16:11:29.186] §r§7[Server thread/DEBUG]: #4 src/pocketmine/player/Player(2618): pocketmine\event\Event->call()§r
§b[16:11:29.186] §r§7[Server thread/DEBUG]: #5 src/pocketmine/player/Player(2281): pocketmine\player\Player->removeCurrentWindow()§r
§b[16:11:29.187] §r§7[Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/NetworkSession(525): pocketmine\player\Player->disconnect(string[7] timeout, NULL , boolean )§r

(Sorry for the cryptic console output, I ran into this issue as well: pmmp/PocketMine-MP#2986)

Can take out items

I just downloaded the most recent commit of InvMenu, and InvMenu::readonly(true) still allows items to be taken out / put in.
Code I used inside a class that extends \pocketmine\Player

	public function openServerGUI(): void{
		$menu = InvMenu::create(InvMenu::TYPE_CHEST);
		$menu->setName(TextFormat::BLUE . "Server Selection");
		$menu->readonly(true);
		$items = [
			12 => Item::get(Item::BED)->setCustomName(TextFormat::RESET . TextFormat::BLUE . "Hub " . TextFormat::GRAY . "Server")->setLore(["", TextFormat::RESET . TextFormat::GRAY . "You are here"]),
			14 => Item::get(Item::GOLDEN_APPLE)->setCustomName(TextFormat::RESET . TextFormat::BLUE . "KitPvP " . TextFormat::GRAY . "Server")
		];
		foreach($items as $index => $item) $menu->getInventory()->setItem($index, $item);
		$menu->setListener(function(Player $player, Item $itemClicked, Item $itemReplaced, SlotChangeAction $action): bool{
			if(!$player instanceof VPlayer) return false;
			switch($action->getSlot()){
				case 12:
					$player->removeWindow($action->getInventory());
					$player->sendMessage(Loader::PREFIX . "You are already in this server");
					break;
				case 14:
					$player->removeWindow($action->getInventory());
					$player->sendMessage(Loader::PREFIX . "Connecting to KitPvP...");
					$player->getServer()->getPluginManager()->getPlugin("ValionHub")->getScheduler()->scheduleDelayedTask(new TransferPlayerTask($player, 19133), 30);
					break;
			}
			return false;
		});
		$menu->send($this);
	}

Need to Increase Version Number

It would be a good idea to update the version number so that other plugins can declare compatibility with the updates from #50

This will allow other plugins to trigger compatibility updates by changing the version requirement for InvMenu.

Error.

[23:07:36] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\nbt\NetworkLittleEndianNBTStream::setData()" (EXCEPTION) in "plugins/InvMenu_v1.0/src/muqsit/invmenu/inventories/BaseFakeInventory" at line 122
[23:07:36] [Server thread/DEBUG]: #0 plugins/InvMenu_v1.0/src/muqsit/invmenu/inventories/BaseFakeInventory(70): muqsit\invmenu\inventories\BaseFakeInventory->sendFakeTile(pocketmine\Player object)
[23:07:36] [Server thread/DEBUG]: #1 src/pocketmine/inventory/BaseInventory(396): muqsit\invmenu\inventories\BaseFakeInventory->onOpen(pocketmine\Player object)
[23:07:36] [Server thread/DEBUG]: #2 src/pocketmine/Player(3758): pocketmine\inventory\BaseInventory->open(pocketmine\Player object)
[23:07:36] [Server thread/DEBUG]: #3 plugins/InvMenu_v1.0/src/muqsit/invmenu/InvMenu(153): pocketmine\Player->addWindow(muqsit\invmenu\inventories\HopperInventory object)
[23:07:36] [Server thread/DEBUG]: #4 plugins/Factions_v1.0.0/src/zyware/Shop/Shop(20): muqsit\invmenu\InvMenu->send(pocketmine\Player object)
[23:07:36] [Server thread/DEBUG]: #5 src/pocketmine/command/PluginCommand(58): zyware\Shop\Shop->onCommand(pocketmine\Player object, pocketmine\command\PluginCommand object, string shop, array Array())
[23:07:36] [Server thread/DEBUG]: #6 src/pocketmine/command/SimpleCommandMap(258): pocketmine\command\PluginCommand->execute(pocketmine\Player object, string shop, array Array())
[23:07:36] [Server thread/DEBUG]: #7 src/pocketmine/Server(1995): pocketmine\command\SimpleCommandMap->dispatch(pocketmine\Player object, string shop)
[23:07:36] [Server thread/DEBUG]: #8 src/pocketmine/Player(2113): pocketmine\Server->dispatchCommand(pocketmine\Player object, string shop)
[23:07:36] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(220): pocketmine\Player->chat(string /shop)
[23:07:36] [Server thread/DEBUG]: #10 src/pocketmine/network/mcpe/protocol/CommandRequestPacket(54): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleCommandRequest(pocketmine\network\mcpe\protocol\CommandRequestPacket object)
[23:07:36] [Server thread/DEBUG]: #11 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(92): pocketmine\network\mcpe\protocol\CommandRequestPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
[23:07:36] [Server thread/DEBUG]: #12 src/pocketmine/network/mcpe/protocol/BatchPacket(118): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\CommandRequestPacket object)
[23:07:36] [Server thread/DEBUG]: #13 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(92): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
[23:07:36] [Server thread/DEBUG]: #14 src/pocketmine/Player(2919): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
[23:07:36] [Server thread/DEBUG]: #15 src/pocketmine/network/mcpe/RakLibInterface(147): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
[23:07:36] [Server thread/DEBUG]: #16 vendor/pocketmine/raklib/server/ServerHandler(103): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 192.168.0.87 11450, raklib\protocol\EncapsulatedPacket object, integer 0)
[23:07:36] [Server thread/DEBUG]: #17 src/pocketmine/network/mcpe/RakLibInterface(88): raklib\server\ServerHandler->handlePacket()
[23:07:36] [Server thread/DEBUG]: #18 src/pocketmine/network/Network(89): pocketmine\network\mcpe\RakLibInterface->process()
[23:07:36] [Server thread/DEBUG]: #19 src/pocketmine/Server(2540): pocketmine\network\Network->processInterfaces()
[23:07:36] [Server thread/DEBUG]: #20 src/pocketmine/Server(2291): pocketmine\Server->tick()
[23:07:36] [Server thread/DEBUG]: #21 src/pocketmine/Server(2164): pocketmine\Server->tickProcessor()
[23:07:36] [Server thread/DEBUG]: #22 src/pocketmine/Server(1747): pocketmine\Server->start()
[23:07:36] [Server thread/DEBUG]: #23 src/pocketmine/PocketMine(385): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\mikha\Desktop\PocketMine-MP\, string C:\Users\mikha\Desktop\PocketMine-MP\plugins\)```

Issues instantly opening a new menu

I tried to open a menu from another menu.

Following issues occurred:
From a hopper to a chest the hopper will just close, and the chest inventory will not open, since the hopper is replaced with its original block in that tick.

From a chest to another chest inventory, the tile sometimes gets stuck in the air, and the menu's title will not change.

Win10 crash

When Win10 interacts with InvMenu, the MCBE crashes.
Tested: Altay 4.0.0 and Pocketmine 3.2.2
OS: Windows 10
Server OS: Debian 8

Command on items

How I add commands like (warp command) on the items in the fake chest???

Mobile & creative bypasses cancelled transactions

Returning false in the setListener callable cancels the transaction, well most the time.

  1. Being in creative bypasses this, without having to use any glitch to get items from the inventory, you can just click the item and get it (doesn't work in survival)
  2. Pocket users can use the quick swap feature to receive items that are cancelled in the event (video here) Windows 10 users cannot reproduce this issue

Is this an issue with InvMenu, Minecraft or my plugin?

Readonly() Bug

when i try using this on a Chest inventory it still allows me to take out the items.

CODE //

$menu = InvMenu::create(InvMenu::TYPE_CHEST);
$menu->readonly();
$menu->setName("Inv Test");
$menu->getInventory()->setContents([
Item::get(Item::NETHER_WART),
Item::get(Item::GLOWSTONE)
]);
$menu->send($player);

Help!!!

Error:
ErrorException: "Undefined variable: menu" (EXCEPTION) in "plugins/ChestGui.phar/src/GUI/Main" at line 43

My Code:

readonly() ->setName("The Inventory's Name") ->setListener([$this, "handleMenuSelection"]); $inv = $menu->getInventory(); $item = Item::get(Item::STONE); $item->setCustomName("Tap Me"); $inv->setItem(0, $item); } public function handleMenuSelection(Player $player, Item $itemClicked) : bool{ if($itemClicked->getId() === Item::STONE){ $player->getServer()->dispatchCommand($player, "test 1"); } return true; } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { switch($cmd->getName()){ case "test": $menu->send($sender); break; } } }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.