-
Notifications
You must be signed in to change notification settings - Fork 89
InvMenu v3.0
Muqsit edited this page Jun 30, 2019
·
9 revisions
InvMenu v3.0 is a major rewrite of InvMenu v2.0!
-
InvMenu::sessionize()— Sessionized was an unnecessary feature which had the same effect as creating a clonedInvMenuinstance for each player. If you'd still like to create sessionizedInvMenuinstances, you may useInvMenu::createSessionized()instead ofInvMenu::create(). SessionizedInvMenuinstances are just a cast over unsessionized ones from now onwards and will actually create a newInvMenuinstance with copied properties (readonly, listeners etc). -
InvMenu::getListener()— There was no reason to expose the listener. -
InvMenu::getINventoryCloseListener()— Again, no reason to expose the listener.
-
BaseFakeInventory,ChestInventory,DoubleChestInventory,HopperInventory,SingleBlockInventory— These are no longer needed.BaseFakeInventorywas infact a poorly-written class with a few player-related property handlers in it. The only reason behind these inventory classes were to define their network types which is no longer necessary in 4.0. All of these classes have been replaced by aninvMenuInventoryclass. -
HolderData— This has been replaced by a much better designedPlayerSessionclass. -
DelayedFakeBlockDataNotifyTask— The whole reason behind having this was to work-around the issue of sending double chest inventories to the client. The client would take time to render the "pairing" and this task assumed the pairing took up to 5 ticks which was actually a really bad estimation. This issue has been solved by handlingNetworkStackLatencyPacket(thanks dktapps).
-
InvMenu::create()now accepts an optional second parameter which is anInventoryinstance. This lets you create a menu out of ANY inventory and keeps theInvMenusynchronized with thatInventory. NOTE that this only maintains synchronization. Modifying items in theInvMenuwon't modify items in theInventory. -
InvMenu::__construct()now accepts only one parameter —MenuMetadata. -
InvMenu::create()'s first parameter is no longer path to an inventory class. The first parameter has been changed to a registeredMenuMetadataidentifier. -
InvMenuHandler::registerMenuType(MenuMetadata $type)is the new way to create custom inventory instances. SeeInvMenuHandler::registerDefaultMenuTypes()to find out how to do that. You no longer need to create classes for registering brewing and other inventories that aren't provided by InvMenu. It only takes one line now! -
PlayerManager::get($player)->getCurrentMenu()— A utility method to get theInvMenuinstance of theInvMenuinstance linked with the inventory the player is currently viewing. ReturnsInvMenu|null.