From f79831d3d6e7709e4ee3dc4d3f07cda3ecf3ebb5 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Mon, 27 Jun 2011 12:25:02 -0500 Subject: [PATCH] added another simplified function for chat plugins to hook, ShouldLetFactionsHandleThisChat(PlayerChatEvent event) to see if chat event is a special case which should be left alone for Factions to handle (Faction Chat enabled player, or factions f command without slash used) --- src/org/mcteam/factions/Factions.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/org/mcteam/factions/Factions.java b/src/org/mcteam/factions/Factions.java index d7441c7f..590cd57a 100644 --- a/src/org/mcteam/factions/Factions.java +++ b/src/org/mcteam/factions/Factions.java @@ -15,6 +15,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Event; +import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; @@ -182,6 +183,17 @@ public class Factions extends JavaPlugin { // Functions for other plugins to hook into // -------------------------------------------- // + // If another plugin is handling insertion of chat tags, this should be used to notify Factions + public void handleFactionTagExternally(boolean notByFactions) { + Conf.chatTagHandledByAnotherPlugin = notByFactions; + } + + // Simply put, should this chat event be left for Factions to handle? For now, that means players with Faction Chat + // enabled or use of the Factions f command without a slash; combination of isPlayerFactionChatting() and isFactionsCommand() + public boolean ShouldLetFactionsHandleThisChat(PlayerChatEvent event) { + return (isPlayerFactionChatting(event.getPlayer()) || isFactionsCommand(event.getMessage())); + } + // Does player have Faction Chat enabled? If so, chat plugins should preferably not do channels, // local chat, or anything else which targets individual recipients, so Faction Chat can be done public boolean isPlayerFactionChatting(Player player) { @@ -193,11 +205,6 @@ public class Factions extends JavaPlugin { return me.isFactionChatting(); } - // If another plugin is handling insertion of chat tags, this should be used to notify Factions - public void handleFactionTagExternally(boolean notByFactions) { - Conf.chatTagHandledByAnotherPlugin = notByFactions; - } - // Is this chat message actually a Factions command, and thus should be left alone by other plugins? public boolean isFactionsCommand(String check) { return ((check.startsWith(instance.getBaseCommand()+" ") || check.equals(instance.getBaseCommand())) && Conf.allowNoSlashCommand);