Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

player.Handler improvements #1009

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions server/player/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ type Handler interface {
// HandleTransfer handles a player being transferred to another server. ctx.Cancel() may be called to
// cancel the transfer.
HandleTransfer(ctx *Context, addr *net.UDPAddr)
// HandleTick handles player tick.
HandleTick(p *Player, tx *world.Tx, tick int64)
// HandleCommandExecution handles the command execution of a player, who wrote a command in the chat.
// ctx.Cancel() may be called to cancel the command execution.
HandleCommandExecution(ctx *Context, command cmd.Command, args []string)
Expand Down Expand Up @@ -171,6 +173,7 @@ func (NopHandler) HandleToggleSprint(*Context, bool)
func (NopHandler) HandleToggleSneak(*Context, bool) {}
func (NopHandler) HandleCommandExecution(*Context, cmd.Command, []string) {}
func (NopHandler) HandleTransfer(*Context, *net.UDPAddr) {}
func (NopHandler) HandleTick(p *Player, tx *world.Tx, tick int64) {}
func (NopHandler) HandleChat(*Context, *string) {}
func (NopHandler) HandleSkinChange(*Context, *skin.Skin) {}
func (NopHandler) HandleFireExtinguish(*Context, cube.Pos) {}
Expand Down
1 change: 1 addition & 0 deletions server/player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -2349,6 +2349,7 @@ func (p *Player) Latency() time.Duration {

// Tick ticks the entity, performing actions such as checking if the player is still breaking a block.
func (p *Player) Tick(tx *world.Tx, current int64) {
p.Handler().HandleTick(p, tx, current)
if p.Dead() {
return
}
Expand Down