From 9fd79d5588d1a13bd73745363d54ac457d3bbb10 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Tue, 23 Aug 2011 17:34:40 -0500 Subject: [PATCH] more hookable functions for use by other plugins, these for getting a list of all factions and for listing players in a specified faction --- src/com/massivecraft/factions/Factions.java | 36 ++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 1014cd34..58136cc9 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -5,6 +5,7 @@ import java.lang.reflect.Modifier; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -253,7 +254,7 @@ public class Factions extends JavaPlugin { // This value will be updated whenever new hooks are added public int hookSupportVersion() { - return 1; + return 2; } // If another plugin is handling insertion of chat tags, this should be used to notify Factions @@ -331,6 +332,39 @@ public class Factions extends JavaPlugin { return me.getTitle().trim(); } + // Get a list of all faction tags (names) + public Set getFactionTags() { + Set tags = new HashSet(); + for (Faction faction : Faction.getAll()) { + tags.add(faction.getTag()); + } + return tags; + } + + // Get a list of all players in the specified faction + public Set getPlayersInFaction(String factionTag) { + Set players = new HashSet(); + Faction faction = Faction.findByTag(factionTag); + if (faction != null) { + for (FPlayer fplayer : faction.getFPlayers()) { + players.add(fplayer.getName()); + } + } + return players; + } + + // Get a list of all online players in the specified faction + public Set getOnlinePlayersInFaction(String factionTag) { + Set players = new HashSet(); + Faction faction = Faction.findByTag(factionTag); + if (faction != null) { + for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) { + players.add(fplayer.getName()); + } + } + return players; + } + // -------------------------------------------- // // Test rights // -------------------------------------------- //