From 6c37f4cbe1f26b356e6cf1fe54388b0d57eefd10 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Sat, 11 Jun 2011 17:29:24 -0500 Subject: [PATCH] added functions to main class for other plugins to potentially hook into, targeted at chat plugins at the moment: isPlayerFactionChatting to see if player has faction chat enabled, and getPlayerFactionTag and getPlayerFactionTagRelation to get the player's uncolored or relation-colored faction tag --- src/org/mcteam/factions/Factions.java | 43 ++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/org/mcteam/factions/Factions.java b/src/org/mcteam/factions/Factions.java index e9f1133c..741470b7 100644 --- a/src/org/mcteam/factions/Factions.java +++ b/src/org/mcteam/factions/Factions.java @@ -193,7 +193,48 @@ public class Factions extends JavaPlugin { pm.enablePlugin(prePlug); } } - + + // -------------------------------------------- // + // Functions for other plugins to hook into + // -------------------------------------------- // + + // 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 static boolean isPlayerFactionChatting(Player player) { + if (player == null) + return false; + FPlayer me = FPlayer.get(player); + if (me == null) + return false; + return me.isFactionChatting(); + } + + // Get a player's faction tag (faction name), mainly for usage by chat plugins for local/channel chat + public static String getPlayerFactionTag(Player player) { + return getPlayerFactionTagRelation(player, null); + } + + // Same as above, but with relation (enemy/neutral/ally) coloring potentially added to the tag + public static String getPlayerFactionTagRelation(Player speaker, Player listener) { + if (speaker == null) + return ""; + + FPlayer me = FPlayer.get(speaker); + if (me == null) + return ""; + + // if listener isn't set, or config option is disabled, give back uncolored tag + if (listener == null || !Conf.chatTagRelationColored) + return me.getChatTag().trim(); + + FPlayer you = FPlayer.get(listener); + if (you == null) + return me.getChatTag().trim(); + + // everything checks out, give the colored tag + return me.getChatTag(you).trim(); + } + // -------------------------------------------- // // Test rights // -------------------------------------------- //