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