github.com/df-mc/dragonfly@v0.9.13/server/item/inventory/handler.go (about)

     1  package inventory
     2  
     3  import (
     4  	"github.com/df-mc/dragonfly/server/event"
     5  	"github.com/df-mc/dragonfly/server/item"
     6  )
     7  
     8  // Handler is a type that may be used to handle actions performed on an inventory by a player.
     9  type Handler interface {
    10  	// HandleTake handles an item.Stack being taken from a slot in the inventory. This item might be the whole stack or
    11  	// part of the stack currently present in that slot.
    12  	HandleTake(ctx *event.Context, slot int, it item.Stack)
    13  	// HandlePlace handles an item.Stack being placed in a slot of the inventory. It might either be added to an empty
    14  	// slot or a slot that contains an item of the same type.
    15  	HandlePlace(ctx *event.Context, slot int, it item.Stack)
    16  	// HandleDrop handles the dropping of an item.Stack in a slot out of the inventory.
    17  	HandleDrop(ctx *event.Context, slot int, it item.Stack)
    18  }
    19  
    20  // Check to make sure NopHandler implements Handler.
    21  var _ Handler = NopHandler{}
    22  
    23  // NopHandler is an implementation of Handler that does not run any code in any of its methods. It is the default
    24  // Handler of an Inventory.
    25  type NopHandler struct{}
    26  
    27  func (NopHandler) HandleTake(*event.Context, int, item.Stack)  {}
    28  func (NopHandler) HandlePlace(*event.Context, int, item.Stack) {}
    29  func (NopHandler) HandleDrop(*event.Context, int, item.Stack)  {}