mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-25 11:35:36 +01:00
Don't send duplicate messages to from VentureChat. #14
This commit is contained in:
parent
d290a818ef
commit
e2bd187844
0
dependency-reduced-pom.xml
Normal file → Executable file
0
dependency-reduced-pom.xml
Normal file → Executable file
@ -32,15 +32,18 @@ public class VentureChatEvent extends Event {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final AsyncPlayerChatEvent event;
|
||||
private final PurpleBot bot;
|
||||
private final String ircChannel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param event
|
||||
* @param bot
|
||||
* @param ircChannel
|
||||
*/
|
||||
public VentureChatEvent(AsyncPlayerChatEvent event, PurpleBot bot) {
|
||||
public VentureChatEvent(AsyncPlayerChatEvent event, PurpleBot bot, String ircChannel) {
|
||||
this.event = event;
|
||||
this.bot = bot;
|
||||
this.ircChannel = ircChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,6 +69,14 @@ public class VentureChatEvent extends Event {
|
||||
public PurpleBot getBot() {
|
||||
return bot;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getIrcChannel() {
|
||||
return ircChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -50,17 +50,19 @@ public class VentureChatListener implements Listener {
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
public void onVentureChatEvent(VentureChatEvent event) {
|
||||
ventureChat(event.getPlayer(), event.getMessage(), event.getBot());
|
||||
plugin.logDebug("Entering onVentureChatEvent: " + event.getMessage());
|
||||
ventureChat(event.getPlayer(), event.getMessage(), event.getBot(), event.getIrcChannel());
|
||||
}
|
||||
|
||||
/**
|
||||
* VentureChat from game to IRC
|
||||
*
|
||||
* @param player
|
||||
* @param message
|
||||
* @param player the player
|
||||
* @param message the message
|
||||
* @param bot the calling bot
|
||||
* @param channelName destination IRC channel
|
||||
*/
|
||||
public void ventureChat(Player player, String message, PurpleBot bot) {
|
||||
public void ventureChat(Player player, String message, PurpleBot bot, String channelName) {
|
||||
MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(player);
|
||||
ChatChannel eventChannel = mcp.getCurrentChannel();
|
||||
if (mcp.isQuickChat()) { //for single message chat detection
|
||||
@ -75,23 +77,21 @@ public class VentureChatListener implements Listener {
|
||||
}
|
||||
String vcChannel = eventChannel.getName();
|
||||
String vcColor = eventChannel.getColor();
|
||||
for (String channelName : bot.botChannels) {
|
||||
if (!bot.isPlayerInValidWorld(player, channelName)) {
|
||||
continue;
|
||||
}
|
||||
plugin.logDebug("VC Channel: " + vcChannel);
|
||||
String channelTemplateName = "venture-" + vcChannel + "-chat";
|
||||
if (bot.isMessageEnabled(channelName, channelTemplateName)
|
||||
|| bot.isMessageEnabled(channelName, TemplateName.VENTURE_CHAT)) {
|
||||
String template = plugin.getVentureChatTemplate(bot.botNick, vcChannel);
|
||||
plugin.logDebug("VC Template: " + template);
|
||||
bot.asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.ventureChatTokenizer(player, vcChannel, vcColor, message, template));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in VentureChat channel "
|
||||
+ vcChannel + ". Message types " + channelTemplateName + " and "
|
||||
+ TemplateName.VENTURE_CHAT + " are disabled. No message sent to IRC.");
|
||||
}
|
||||
if (!bot.isPlayerInValidWorld(player, channelName)) {
|
||||
return;
|
||||
}
|
||||
plugin.logDebug("VC Channel: " + vcChannel);
|
||||
String channelTemplateName = "venture-" + vcChannel + "-chat";
|
||||
if (bot.isMessageEnabled(channelName, channelTemplateName)
|
||||
|| bot.isMessageEnabled(channelName, TemplateName.VENTURE_CHAT)) {
|
||||
String template = plugin.getVentureChatTemplate(bot.botNick, vcChannel);
|
||||
plugin.logDebug("VC Template: " + template);
|
||||
bot.asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.ventureChatTokenizer(player, vcChannel, vcColor, message, template));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in VentureChat channel "
|
||||
+ vcChannel + ". Message types " + channelTemplateName + " and "
|
||||
+ TemplateName.VENTURE_CHAT + " are disabled. No message sent to IRC.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1243,7 +1243,8 @@ public final class PurpleBot {
|
||||
plugin.logDebug("No Factions");
|
||||
}
|
||||
if (plugin.ventureChatEnabled) {
|
||||
plugin.getServer().getPluginManager().callEvent(new VentureChatEvent(event, this));
|
||||
plugin.logDebug("Calling VentureChatEvent: " + event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(new VentureChatEvent(event, this, channelName));
|
||||
}
|
||||
if (isMessageEnabled(channelName, TemplateName.GAME_CHAT)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
|
Loading…
Reference in New Issue
Block a user