github.com/df-mc/dragonfly@v0.9.13/server/event/context.go (about)

     1  package event
     2  
     3  // Context represents the context of an event. Handlers of an event may call methods on the context to change
     4  // the result of the event.
     5  type Context struct {
     6  	cancel bool
     7  }
     8  
     9  // C returns a new event context.
    10  func C() *Context {
    11  	return &Context{}
    12  }
    13  
    14  // Cancelled returns whether the context has been cancelled.
    15  func (ctx *Context) Cancelled() bool {
    16  	return ctx.cancel
    17  }
    18  
    19  // Cancel cancels the context.
    20  func (ctx *Context) Cancel() {
    21  	ctx.cancel = true
    22  }