server

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interact

type Interact struct {
	// contains filtered or unexported fields
}

Interact 是客户端和赞颂者假服务器的表单交互实现

func NewInteract

func NewInteract(server *Server) *Interact

NewInteract 根据 server 创建并返回一个新的交互装置

func (*Interact) SendFormAndWaitResponse

func (i *Interact) SendFormAndWaitResponse(minecraftForm form.MinecraftForm) (resp any, isUserCancel bool, err error)

SendFormAndWaitResponse 发送 minecraftForm 所指示的表单给客户端并等待回应。

resp 是客户端的回应,只可能为:

  • minecraftForm.ID() 为 [from.FormTypeMessage] 时:bool
  • minecraftForm.ID() 为 [from.FormTypeAction] 时:int32
  • minecraftForm.ID() 为 [from.FormTypeModal] 时:[]any

如果回应是 []any,则其中的元素只可能是:

isUserCancel 指示表单是否是由用户通过叉号 (×) 关闭的

func (*Interact) SendFormOmitResponse

func (i *Interact) SendFormOmitResponse(minecraftForm form.MinecraftForm) (ctx context.Context, formCloseFunc func())

SendFormOmitResponse 向客户端发送 minecraftForm 所指示的表单,并且其所对应的返回值。 返回的 ctx 指示表单是否已经被客户端关闭。若没有关闭,该函数调用者有责任确保使用 formCloseFunc 关闭已经打开的表单。如果表单未能正确关闭,则后续的任何表单操作将可能被阻塞

func (*Interact) SendLargeActionFormAndWaitResponse

func (i *Interact) SendLargeActionFormAndWaitResponse(
	actionForm form.ActionForm,
	pageSize int,
) (resp int32, isUserCancel bool, err error)

SendLargeActionFormAndWaitResponse 向客户端发送大型的 ActionForm, 这意味着 actionForm.Buttons 具有很多项目,需要按 pageSize 分页拆分。 isUserCancel 指示表单是否是由用户通过叉号 (×) 关闭的

func (*Interact) Server

func (i *Interact) Server() *Server

Server 返回底层的 *Server

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server 简单的实现了一个 MC 服务器, 以用于运行一个赞颂者前置交互服务

func NewServer

func NewServer() *Server

NewServer 创建并返回一个新的 Server

func (*Server) CloseServer

func (s *Server) CloseServer() error

CloseServer 关闭正在运行的服务器。 CloseServer 调用后不应再次调用 RunServer

func (*Server) MinecraftConn

func (s *Server) MinecraftConn() *minecraft.Conn

MinecraftConn 返回已创建的连接

func (*Server) RunServer

func (s *Server) RunServer(address string) error

RunServer 在 address 所指示的地址上运行服务器

func (*Server) WaitConnect

func (s *Server) WaitConnect() error

WaitConnect 等待一个 MC 客户端创建连接

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL