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

This commit is contained in:
Brettflan 2011-06-11 17:29:24 -05:00
parent 3f0d330d6e
commit 6c37f4cbe1
1 changed files with 42 additions and 1 deletions

View File

@ -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
// -------------------------------------------- //