-
Notifications
You must be signed in to change notification settings - Fork 74
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 clonedInvMenu
instance for each player. If you'd still like to create sessionizedInvMenu
instances, you may useInvMenu::createSessionized()
instead ofInvMenu::create()
. SessionizedInvMenu
instances are just a cast over unsessionized ones from now onwards and will actually create a newInvMenu
instance 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.BaseFakeInventory
was 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 aninvMenuInventory
class. -
HolderData
— This has been replaced by a much better designedPlayerSession
class. -
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 anInventory
instance. This lets you create a menu out of ANY inventory and keeps theInvMenu
synchronized with thatInventory
. NOTE that this only maintains synchronization. Modifying items in theInvMenu
won'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 registeredMenuMetadata
identifier. -
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 theInvMenu
instance of theInvMenu
instance linked with the inventory the player is currently viewing. ReturnsInvMenu|null
.