first commit

This commit is contained in:
boybook
2025-03-17 13:24:39 +08:00
commit 9a0334ee84
6410 changed files with 221907 additions and 0 deletions

View File

@@ -0,0 +1,372 @@
---
sidebarDepth: 1
---
# 消息
## NotifyOneMessage
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.msgCompServer.MsgComponentServer
- 描述
给指定玩家发送聊天框消息
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| playerId | str | 指定玩家id |
| msg | str | 消息内容 |
| color | str | 颜色样式代码字符串可参考wiki[样式代码](https://minecraft-zh.gamepedia.com/%E6%A0%B7%E5%BC%8F%E4%BB%A3%E7%A0%81),默认为白色 |
- 返回值
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateMsg(entityId)
comp.NotifyOneMessage(playerId, "test", "§c")
```
## SendMsg
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.msgCompServer.MsgComponentServer
- 描述
模拟玩家给所有人发送聊天栏消息
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| name | str | 发送者玩家的名字 |
| msg | str | 消息内容 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置结果 |
- 备注
- name参数需要设置玩家的名字(可通过name组件获取),如果设置的玩家名字不存在,则随机找一个玩家发出该消息
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateMsg(entityId)
comp.SendMsg("playerName","test")
```
## SendMsgToPlayer
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.msgCompServer.MsgComponentServer
- 描述
模拟玩家给另一个玩家发送聊天栏消息
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| fromEntityId | str | 发送者玩家ID |
| toEntityId | str | 接受者玩家ID |
| msg | str | 消息内容 |
- 返回值
- 示例
```python
comp = serverApi.GetEngineCompFactory().CreateMsg(entityId)
comp.SendMsgToPlayer(fromEntityId, toEntityId, "test")
```
## SetLeftCornerNotify
<span style="display:inline;color:#7575f9">客户端</span>
method in mod.client.component.textNotifyCompClient.TextNotifyComponet
- 描述
客户端设置左上角通知信息
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| textMsg | str | 通知内容 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateTextNotifyClient(levelId)
comp.SetLeftCornerNotify("做好准备")
```
## SetNotifyMsg
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.gameCompServer.GameComponentServer
- 描述
设置消息通知
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| msg | str | 消息内容 |
| color | str | 使用GenerateColor接口获取的颜色默认为白色 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateGame(levelId)
comp.SetNotifyMsg("消息通知", serverApi.GenerateColor('BLUE'))
```
## SetOnePopupNotice
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.gameCompServer.GameComponentServer
- 描述
在具体某个玩家的物品栏上方弹出popup类型通知位置位于tip类型消息下方此功能更建议客户端使用game组件的对应接口SetPopupNotice
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| playerId | str | 具体玩家Id |
| message | str | 消息内容,可以在消息前增加extraServerApi.GenerateColor("RED")字符来设置颜色,具体参考样例 |
| subtitle | str | 消息子标题内容,效果同message也可设置颜色位置位于message上方 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateGame(playerId)
# playerId 变量改为具体的玩家Id
comp.SetOnePopupNotice(playerId, serverApi.GenerateColor("RED") + "消息通知", "消息子标题")
```
## SetOneTipMessage
<span style="display:inline;color:#ff5555">服务端</span>
method in mod.server.component.gameCompServer.GameComponentServer
- 描述
在具体某个玩家的物品栏上方弹出tip类型通知位置位于popup类型通知上方此功能更建议在客户端使用game组件的对应接口SetTipMessage
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| playerId | str | 具体玩家Id |
| message | str | 消息内容,可以在消息前增加extraServerApi.GenerateColor("RED")字符来设置颜色,具体参考样例 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateGame(playerId)
# playerId 变量改为具体的玩家Id
comp.SetOneTipMessage(playerId, serverApi.GenerateColor("RED") + "tip提示")
```
## SetPopupNotice
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
### 服务端接口
<span id="s0"></span>
method in mod.server.component.gameCompServer.GameComponentServer
- 描述
在所有玩家物品栏上方弹出popup类型通知位置位于tip类型消息下方
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| message | str | 消息内容,可以在消息前增加extraServerApi.GenerateColor("RED")字符来设置颜色,具体参考样例 |
| subtitle | str | 消息子标题内容,效果同message也可设置颜色位置位于message上方 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateGame(levelId)
comp.SetPopupNotice(serverApi.GenerateColor("RED") + "消息通知", "消息子标题")
```
### 客户端接口
<span id="c0"></span>
method in mod.client.component.gameCompClient.GameComponentClient
- 描述
在本地玩家的物品栏上方弹出popup类型通知位置位于tip类型消息下方
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| message | str | 消息内容,可以在消息前增加extraClientApi.GenerateColor("RED")字符来设置颜色,具体参考样例 |
| subtitle | str | 消息子标题内容,效果同message也可设置颜色位置位于message上方 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateGame(entityId)
comp.SetPopupNotice(clientApi.GenerateColor("RED") + "消息通知", "消息子标题")
```
## SetTipMessage
<span style="display:inline;color:#ff5555">服务端</span><span style="display:inline;color:#7575f9">客户端</span>
### 服务端接口
<span id="s0"></span>
method in mod.server.component.gameCompServer.GameComponentServer
- 描述
在所有玩家物品栏上方弹出tip类型通知位置位于popup类型通知上方
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| message | str | 消息内容,可以在消息前增加extraServerApi.GenerateColor("RED")字符来设置颜色,具体参考样例 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
import mod.server.extraServerApi as serverApi
comp = serverApi.GetEngineCompFactory().CreateGame(levelId)
comp.SetTipMessage(serverApi.GenerateColor("RED") + "tip提示")
```
### 客户端接口
<span id="c0"></span>
method in mod.client.component.gameCompClient.GameComponentClient
- 描述
在本地玩家的物品栏上方弹出tip类型通知位置位于popup类型通知上方
- 参数
| 参数名 | <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- | :--- |
| message | str | 消息内容,可以在消息前增加extraClientApi.GenerateColor("RED")字符来设置颜色,具体参考样例 |
- 返回值
| <div style="width: 4em">数据类型</div> | 说明 |
| :--- | :--- |
| bool | 设置是否成功 |
- 示例
```python
import mod.client.extraClientApi as clientApi
comp = clientApi.GetEngineCompFactory().CreateGame(entityId)
comp.SetTipMessage(clientApi.GenerateColor("RED") + "tip提示")
```