more hookable functions for use by other plugins, these for getting a list of all factions and for listing players in a specified faction

This commit is contained in:
Brettflan 2011-08-23 17:34:40 -05:00
parent 82db1624c9
commit 9fd79d5588

View File

@ -5,6 +5,7 @@ import java.lang.reflect.Modifier;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -253,7 +254,7 @@ public class Factions extends JavaPlugin {
// This value will be updated whenever new hooks are added // This value will be updated whenever new hooks are added
public int hookSupportVersion() { public int hookSupportVersion() {
return 1; return 2;
} }
// If another plugin is handling insertion of chat tags, this should be used to notify Factions // 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(); return me.getTitle().trim();
} }
// Get a list of all faction tags (names)
public Set<String> getFactionTags() {
Set<String> tags = new HashSet<String>();
for (Faction faction : Faction.getAll()) {
tags.add(faction.getTag());
}
return tags;
}
// Get a list of all players in the specified faction
public Set<String> getPlayersInFaction(String factionTag) {
Set<String> players = new HashSet<String>();
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<String> getOnlinePlayersInFaction(String factionTag) {
Set<String> players = new HashSet<String>();
Faction faction = Faction.findByTag(factionTag);
if (faction != null) {
for (FPlayer fplayer : faction.getFPlayersWhereOnline(true)) {
players.add(fplayer.getName());
}
}
return players;
}
// -------------------------------------------- // // -------------------------------------------- //
// Test rights // Test rights
// -------------------------------------------- // // -------------------------------------------- //