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)

This commit is contained in:
Brettflan 2011-06-27 12:25:02 -05:00
parent a7676429fe
commit f79831d3d6

View File

@ -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);