Skip to content

API: FPlayers

Mark Hughes edited this page Aug 11, 2017 · 2 revisions

You can work with players extremely easily with the LegacyFactions API.

Getting FPlayers

Use the FPlayers Collection Class (FPlayerColl) to get a list of all FPlayers:

List<FPlayer> fplayers = FPlayerColl.all();

You can use this in a for loop like this:

for (FPlayer fplayer : FPlayerColl.all()) {
	String name = fplayer.getName();
	Faction faction = fplayer.getFaction();
	Role role = fplayer.getRole();
}

You can see all the methods for the FPlayer class right here on GitHub.

Want to take advantage of lambdas? The FPlayerColl in LegacyFactions provides this to you:

FPlayerColl.all(fplayer -> {
	fplayer.sendMessage("hey!");
});

You can also get a FPlayer by Player, OfflinePlayer, UUID, String id, or String name all from the one .get() method:

FPlayer fplayer = FPlayerColl.get(player);
FPlayer fplayer = FPlayerColl.get("name");
// ... etc

The .get() method will work it out for you. Easy, right?

Clone this wiki locally