TeamAPI
TeamAPI
About
TeamAPI is a small library that allows developers to create teams, store values, store custom data for players, and easily retrieve this data!
Commands/Permissions
NONE
Adding to plugin
Add this API to your build path, and if you put the plugin on Bukkit, make sure to mark TeamAPI as a dependency.
Usage
How to store API data
List<Participant> players = new ArrayList<Participant>(); List<Team> team = new ArrayList<Team>();
Creating a Team
TeamAPI api = new TeamAPI(); Team team = api.createTeam("Warrior", Color.BLUE); // Create a team with the name Warrior and blue armor
Getting team armor
public void setArmor(Participant p){ Player player = p.getPlayer(); // get the player behind a participant ItemStack[] armor = p.getTeam().getArmor(); // get the team's armor player.setArmorContents(armor); }
Adding points to a participant
public void addFivePoints(Participant p){ p.addPoints(5); }
Getting a participant's points
// this assumes you have a Participant variable called p Integer points = p.getPoints();
Removing a participant's points
public void takeFivePoints(Participant p){ p.removePoints(5); }
Reset a participant's points
public void reset(Participant p){ p.resetPoints(); }
Get a team's colored names
public String getTeamName(Team t){ return t.getColoredName(); }
Get a team's points
public Integer getPoints(Team t){ return t.getPoints(); }
Manipulate a team's points
// this assumes you have a Team called t t.addPoints(10); // add 10 points t.removePoints(8); // remove 8 points t.resetPoints(); // reset their points
Add / Remove Players
public void swapOut(Participant in, Participant out){ Team inTeam = in.getTeam(); Team outTeam = out.getTeam(); inTeam.addPlayer(out); // add out to in's team outTeam().addPlayer(in); // add in to out's team inTeam.removePlayer(in); // remove in from their team outTeam().removePlayer(out); // remove out from their team }
Get a team's color
public Color byPlayer(Participant e){ return e.getTeam().getColor(); } public Color byTeam(Team t){ return t.getColor(); }
Get a list of players on a team
public List<Participant> byTeam(Team t){ return t.getPlayers(); } public List<Participant> byPlayer(Participant e){ return e.getTeam().getPlayers(); }
Convert a player into participant
public Participant find(Player p, List<Participant> players){ TeamAPI api = new TeamAPI(); Participant e = api.findPlayer(players, p); return e; }
More examples will be added as needed!
Have a question? Post a comment!
May I use some of these ideas for my API?