--- sidebarDepth: 1 --- # 消息 ## NotifyOneMessage 服务端 method in mod.server.component.msgCompServer.MsgComponentServer - 描述 给指定玩家发送聊天框消息 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | playerId | str | 指定玩家id | | msg | str | 消息内容 | | color | str | 颜色样式代码字符串,可参考wiki[样式代码](https://zh.minecraft.wiki/w/%E6%A0%BC%E5%BC%8F%E5%8C%96%E4%BB%A3%E7%A0%81),默认为白色 | - 返回值 无 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateMsg(playerId) comp.NotifyOneMessage(playerId, "test", "§c") ``` ## SendMsg 服务端 method in mod.server.component.msgCompServer.MsgComponentServer - 描述 模拟玩家给所有人发送聊天栏消息 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | name | str | 发送者玩家的名字 | | msg | str | 消息内容 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置结果 | - 备注 - name参数需要设置玩家的名字(可通过name组件的GetName接口获取),如果设置的玩家名字不存在,则随机找一个玩家发出该消息 - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateMsg(levelId) comp.SendMsg("playerName","test") ``` ## SendMsgToPlayer 服务端 method in mod.server.component.msgCompServer.MsgComponentServer - 描述 模拟玩家给另一个玩家发送聊天栏消息 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | fromEntityId | str | 发送者玩家ID | | toEntityId | str | 接受者玩家ID | | msg | str | 消息内容 | - 返回值 无 - 示例 ```python comp = serverApi.GetEngineCompFactory().CreateMsg(levelId) comp.SendMsgToPlayer(fromPlayerId, toPlayerId, "test") ``` ## SetLeftCornerNotify 客户端 method in mod.client.component.textNotifyCompClient.TextNotifyComponet - 描述 客户端设置左上角通知信息 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | textMsg | str | 通知内容 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功 | - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateTextNotifyClient(levelId) comp.SetLeftCornerNotify("做好准备") ``` ## SetNotifyMsg 服务端 method in mod.server.component.gameCompServer.GameComponentServer - 描述 设置消息通知 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | msg | str | 消息内容 | | color | str | 使用GenerateColor接口获取的颜色,默认为白色 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGame(levelId) comp.SetNotifyMsg("消息通知", serverApi.GenerateColor('BLUE')) ``` ## SetOnePopupNotice 服务端 method in mod.server.component.gameCompServer.GameComponentServer - 描述 在具体某个玩家的物品栏上方弹出popup类型通知,位置位于tip类型消息下方,此功能更建议客户端使用game组件的对应接口SetPopupNotice - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | playerId | str | 具体玩家Id | | message | str | 消息内容,可以在消息前增加extraServerApi.GenerateColor("RED")字符来设置颜色,具体参考样例 | | subtitle | str | 消息子标题内容,效果同message,也可设置颜色,位置位于message上方 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGame(playerId) # playerId 变量改为具体的玩家Id comp.SetOnePopupNotice(playerId, serverApi.GenerateColor("RED") + "消息通知", "消息子标题") ``` ## SetOneTipMessage 服务端 method in mod.server.component.gameCompServer.GameComponentServer - 描述 在具体某个玩家的物品栏上方弹出tip类型通知,位置位于popup类型通知上方,此功能更建议在客户端使用game组件的对应接口SetTipMessage - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | playerId | str | 具体玩家Id | | message | str | 消息内容,可以在消息前增加extraServerApi.GenerateColor("RED")字符来设置颜色,具体参考样例 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGame(playerId) # playerId 变量改为具体的玩家Id comp.SetOneTipMessage(playerId, serverApi.GenerateColor("RED") + "tip提示") ``` ## SetPopupNotice 服务端客户端 ### 服务端接口 method in mod.server.component.gameCompServer.GameComponentServer - 描述 在所有玩家物品栏上方弹出popup类型通知,位置位于tip类型消息下方 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | message | str | 消息内容,可以在消息前增加extraServerApi.GenerateColor("RED")字符来设置颜色,具体参考样例 | | subtitle | str | 消息子标题内容,效果同message,也可设置颜色,位置位于message上方 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGame(levelId) comp.SetPopupNotice(serverApi.GenerateColor("RED") + "消息通知", "消息子标题") ``` ### 客户端接口 method in mod.client.component.gameCompClient.GameComponentClient - 描述 在本地玩家的物品栏上方弹出popup类型通知,位置位于tip类型消息下方 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | message | str | 消息内容,可以在消息前增加extraClientApi.GenerateColor("RED")字符来设置颜色,具体参考样例 | | subtitle | str | 消息子标题内容,效果同message,也可设置颜色,位置位于message上方 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功 | - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateGame(entityId) comp.SetPopupNotice(clientApi.GenerateColor("RED") + "消息通知", "消息子标题") ``` ## SetPopupState 客户端 method in mod.client.component.gameCompClient.GameComponentClient - 描述 设置Popup消息栏状态 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | state | int | 状态值,0为原版开启状态,1为关闭,2为使用接口设置的物品dict中customTips的第一行作为弹出信息 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 是否成功 | - 备注 - 注意:该设置不会存档,如果是配在json里面的custom_tips组件中的内容,使用2模式是无法显示的,只有使用物品dict相关的接口设置的customTips才能生效、 - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateGame(entityId) comp.SetPopupState(2) ``` ## SetTipMessage 服务端客户端 ### 服务端接口 method in mod.server.component.gameCompServer.GameComponentServer - 描述 在所有玩家物品栏上方弹出tip类型通知,位置位于popup类型通知上方 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | message | str | 消息内容,可以在消息前增加extraServerApi.GenerateColor("RED")字符来设置颜色,具体参考样例 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功 | - 示例 ```python import mod.server.extraServerApi as serverApi comp = serverApi.GetEngineCompFactory().CreateGame(levelId) comp.SetTipMessage(serverApi.GenerateColor("RED") + "tip提示") ``` ### 客户端接口 method in mod.client.component.gameCompClient.GameComponentClient - 描述 在本地玩家的物品栏上方弹出tip类型通知,位置位于popup类型通知上方 - 参数 | 参数名 |
数据类型
| 说明 | | :--- | :--- | :--- | | message | str | 消息内容,可以在消息前增加extraClientApi.GenerateColor("RED")字符来设置颜色,具体参考样例 | - 返回值 |
数据类型
| 说明 | | :--- | :--- | | bool | 设置是否成功 | - 示例 ```python import mod.client.extraClientApi as clientApi comp = clientApi.GetEngineCompFactory().CreateGame(entityId) comp.SetTipMessage(clientApi.GenerateColor("RED") + "tip提示") ```