use of github.scarsz.discordsrv.api.events.DiscordGuildMessagePostBroadcastEvent in project DiscordSRV by Scarsz.
the class DiscordSRV method broadcastMessageToMinecraftServer.
public void broadcastMessageToMinecraftServer(String channel, String message, User author) {
// apply regex to message
if (StringUtils.isNotBlank(getConfig().getString("DiscordChatChannelRegex")))
message = message.replaceAll(getConfig().getString("DiscordChatChannelRegex"), getConfig().getString("DiscordChatChannelRegexReplacement"));
// apply placeholder API values
if (PluginUtil.pluginHookIsEnabled("placeholderapi")) {
Player authorPlayer = null;
UUID authorLinkedUuid = accountLinkManager.getUuid(author.getId());
if (authorLinkedUuid != null)
authorPlayer = Bukkit.getPlayer(authorLinkedUuid);
if (authorPlayer != null) {
message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(authorPlayer, message);
} else {
message = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(null, message);
}
}
if (getHookedPlugins().size() == 0 || channel == null) {
for (Player player : PlayerUtil.getOnlinePlayers()) player.sendMessage(message);
PlayerUtil.notifyPlayersOfMentions(null, message);
api.callEvent(new DiscordGuildMessagePostBroadcastEvent(channel, message));
} else {
if (PluginUtil.pluginHookIsEnabled("herochat"))
HerochatHook.broadcastMessageToChannel(channel, message);
else if (PluginUtil.pluginHookIsEnabled("legendchat"))
LegendChatHook.broadcastMessageToChannel(channel, message);
else if (PluginUtil.pluginHookIsEnabled("lunachat"))
LunaChatHook.broadcastMessageToChannel(channel, message);
else if (PluginUtil.pluginHookIsEnabled("townychat"))
TownyChatHook.broadcastMessageToChannel(channel, message);
else if (PluginUtil.pluginHookIsEnabled("ultimatechat"))
UltimateChatHook.broadcastMessageToChannel(channel, message);
else if (PluginUtil.pluginHookIsEnabled("venturechat"))
VentureChatHook.broadcastMessageToChannel(channel, message);
else {
broadcastMessageToMinecraftServer(null, message, author);
return;
}
api.callEvent(new DiscordGuildMessagePostBroadcastEvent(channel, message));
}
DiscordSRV.getPlugin().getMetrics().increment("messages_sent_to_minecraft");
}
Aggregations