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

     1  package session
     2  
     3  import (
     4  	"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
     5  )
     6  
     7  // RequestAbilityHandler handles the RequestAbility packet.
     8  type RequestAbilityHandler struct{}
     9  
    10  // Handle ...
    11  func (a RequestAbilityHandler) Handle(p packet.Packet, s *Session) error {
    12  	pk := p.(*packet.RequestAbility)
    13  	if pk.Ability == packet.AbilityFlying {
    14  		if !s.c.GameMode().AllowsFlying() {
    15  			s.log.Debugf("failed processing packet from %v (%v): RequestAbility: flying flag enabled while not being able to fly\n", s.conn.RemoteAddr(), s.c.Name())
    16  			s.sendAbilities()
    17  			return nil
    18  		}
    19  		s.c.StartFlying()
    20  	}
    21  	return nil
    22  }