跳转到正文

player_handle API ​

完整接口目录 · 玩家查询用法 · 工具包下载

模块说明 ​

text
Immutable cached player identity with explicit, prepare-only conveniences.

PlayerIdentityChanged ​

python
class PlayerIdentityChanged(LookupError)

SDK 说明:

text
The original name no longer has exactly the resolved identity.

另继承外部类型 LookupError;其通用方法不在本 SDK 目录中重复展开。

PlayerHandle ​

python
@dataclass(frozen=True)
class PlayerHandle

SDK 说明:

text
A cached identity, not an online guarantee or atomic UUID command binding.

Obtain with resolve or ctx.player. Preparing an action does not refresh the
cache or perform IO. Server commands resolve names when they execute, so a
refresh cannot eliminate the check/use race. Retain intents and receipts.

字段(包含继承字段):

PlayerHandle.name ​

python
name: str

数据类字段;声明于 player_handle.PlayerHandle。

PlayerHandle.uuid ​

python
uuid: str

数据类字段;声明于 player_handle.PlayerHandle。

PlayerHandle.xuid ​

python
xuid: str

数据类字段;声明于 player_handle.PlayerHandle。

PlayerHandle.session ​

python
session: str

数据类字段;声明于 player_handle.PlayerHandle。

该类型另有以下内部字段,参与数据类声明但不建议直接读写;创建对象时优先使用专题中的工厂方法:

python
_peer: object = field(repr=False, compare=False)
_operations: Operations = field(repr=False, compare=False)

PlayerHandle.identity ​

python
@property
def identity(self)

SDK 说明:

text
Read-only identity; empty UUID/XUID fields remain unknown.

PlayerHandle.resolve ​

python
@classmethod
async def resolve(
    cls,
    peer,
    operations: Operations,
    *,
    name: str | None = None,
    uuid: str | None = None,
    xuid: str | None = None,
)

SDK 说明:

text
Read the Host roster once; match every supplied field exactly.

PlayerHandle.refresh ​

python
async def refresh(self)

SDK 说明:

text
Check original name and all fields once; never rebind or retry.

Missing/ambiguous names keep PlayerNotFound/AmbiguousPlayer. Any changed
field (including unknown becoming known) requires explicit new resolve.

PlayerHandle.notify ​

python
def notify(
    self,
    text: str,
    *,
    idempotency_key: str,
    deadline: str,
    max_command_bytes: int = 320,
) -> NotificationPlan

SDK 说明:

text
Prepare the existing bounded, journalled notification plan.

PlayerHandle.title ​

python
def title(self, text: str, *, idempotency_key: str, deadline: str) -> OperationIntent

PlayerHandle.subtitle ​

python
def subtitle(self, text: str, *, idempotency_key: str, deadline: str) -> OperationIntent

PlayerHandle.actionbar ​

python
def actionbar(
    self,
    text: str,
    *,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

PlayerHandle.position ​

python
def position(self, *, idempotency_key: str, deadline: str) -> OperationIntent

SDK 说明:

text
Prepare a native single-name entity sample; no coordinate correction.

PlayerHandle.score ​

python
def score(
    self,
    objective: str,
    *,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

PlayerHandle.set_score ​

python
def set_score(
    self,
    objective: str,
    value: int,
    *,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

PlayerHandle.add_score ​

python
def add_score(
    self,
    objective: str,
    delta: int,
    *,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

PlayerHandle.reset_score ​

python
def reset_score(
    self,
    objective: str,
    *,
    idempotency_key: str,
    deadline: str,
) -> OperationIntent

PlayerHandle.give ​

python
def give(
    self,
    item: str,
    *,
    idempotency_key: str,
    deadline: str,
    count: int = 1,
    data: int = 0,
) -> OperationIntent

Neomega · 使用、开发与参考文档