Skip to content

Commit 3a2b86a

Browse files
committed
1.2.7 增加发送喇叭的api
1 parent e8920ae commit 3a2b86a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/main/java/cn/handyplus/chat/api/PlayerChatApi.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import cn.handyplus.chat.PlayerChat;
44
import cn.handyplus.chat.constants.ChatConstants;
55
import cn.handyplus.chat.core.ChatUtil;
6+
import cn.handyplus.chat.core.HornUtil;
67
import cn.handyplus.chat.enter.ChatPlayerChannelEnter;
78
import cn.handyplus.chat.event.PlayerChannelChatEvent;
89
import cn.handyplus.chat.param.ChatParam;
@@ -15,6 +16,7 @@
1516
import org.bukkit.Bukkit;
1617
import org.bukkit.entity.Player;
1718
import org.bukkit.plugin.Plugin;
19+
import org.jetbrains.annotations.NotNull;
1820

1921
import java.util.ArrayList;
2022
import java.util.List;
@@ -196,7 +198,7 @@ private String getPluginChannelName(Plugin plugin, String channel) {
196198
* @return true成功
197199
* @since 1.2.4
198200
*/
199-
public boolean sendMessage(Player player, String channel, String message, String source) {
201+
public boolean sendMessage(@NotNull Player player, @NotNull String channel, @NotNull String message, @NotNull String source) {
200202
// @处理
201203
List<String> mentionedPlayers = new ArrayList<>();
202204
message = ChatUtil.at(mentionedPlayers, message);
@@ -221,4 +223,23 @@ public boolean sendMessage(Player player, String channel, String message, String
221223
return true;
222224
}
223225

226+
/**
227+
* 发送喇叭消息
228+
* @param player 玩家
229+
* @param type 类型
230+
* @param message 消息
231+
* @since 1.2.7
232+
*/
233+
public void sendLb(@NotNull Player player, @NotNull String type, @NotNull String message) {
234+
BcUtil.BcMessageParam param = new BcUtil.BcMessageParam();
235+
param.setPluginName(PlayerChat.INSTANCE.getName());
236+
param.setType(type);
237+
param.setMessage(message);
238+
param.setTimestamp(System.currentTimeMillis());
239+
param.setPlayerName(player.getName());
240+
BcUtil.sendParamForward(player, param);
241+
// 发送消息
242+
HornUtil.sendMsg(player, param);
243+
}
244+
224245
}

0 commit comments

Comments
 (0)