mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-26 12:16:24 +01:00
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:
parent
3f0d330d6e
commit
6c37f4cbe1
@ -194,6 +194,47 @@ public class Factions extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// 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
|
// Test rights
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
Loading…
Reference in New Issue
Block a user