API
The official API
This API allows developers to make their plugins interact with TeamPlugin! Here is how it works:
Setting up
1. Include TeamApi.jar (download TeamPluginApi.zip from Files and unzip it) to your libraries just like including bukkit.jar! 2. Add this to your plugin.yml!
depend: [TeamPlugin]
3. Add this to your code!
//remember to import all classes! public class MyTeamsApiTest { TeamManager teamManager; //the variable teamManager is declared manage teams. @Override public void onEnable(){ manager = TeamPlugin.getApiManager(); //gets the manager from TeamPlugin } }
Now you have set-up your plugin!
Doing something
The main functions are listed here, for other functions, please read the Javadocs
Creating teams, and modifing its /team vault:
//assume this is in a command if(manager.getMemberByName(s.getName())!=null){ //checks if the CommandSender already has a team s.sendMessage("You already have a team!"); //sends a message to the sender return true; } if(!(s instanceof Player)){ //checks if the CommandSender is not a player s.sendMessage("Only players can use this command!"); //tells the sender only players can use this command return true; //returns true, this will not execute code below } Team t=null; //declares the created team try{ manager.createNewTeam("team"+s.getName().substring(4),(Player)s); //creates a team using TeamManager.createNewTeam(name,player) //The player will be the moderator/admin of the team (/team admin) and the team will be named "team" plus first 4 chars of the name of the player }catch(IllegalArgumentException e){ //there is an error in creating a team! if(e.getMessage().startsWith("The name is al")){ //checks if the error is caused by an existing name s.sendMessage("The team already exists!"); return true; //does not call the code below } s.sendMessage("Unknown error"); //unknown error! you should log the error to getLogger() return true; //does not call the code below } Inventory teamVault=t.getVault(); //gets the vault of the team (/team vault). An inventory will be returned. Check Inventory in Bukkit for //more help ItemStack diamonds=new ItemStack(Material.DIAMOND,64); //creates an itemstack that contains 64 diamonds teamVault.addItem(diamonds); //adds the diamonds to the created team! s.sendMessage("Success!");
Disbanding a team
//assume this is in a command Member m=manager.getMemberByName(s.getName()); if(m==null){ //checks if the CommandSender does not have a team s.sendMessage("You do not have a team!"); //sends a message to the sender return true; } m.getTeam().disband();
Checks if a player is in a team, and is a moderator in a team
String playerName=something; Member m=manager.getMemberByName(playerName); if(m==null){ //then the player is not in a team }else{ if(m.isMod()){ //then the player is a moderator in a team }else{ //the player is in a team, but is not a moderator } }
Checks if a team exists
String teamName=something; Team t=manager.getTeamByName(teamName); if(t!=null){ //team exists, and do something }
Lists all members in a team
Team t=something; Member[] members=manager.listMembers(t); //lists all members. throws an exception if t==null
The API may be buggy and is in its beta version!
Check the javadocs for more information!
i cant change the config? when i do showname: False and reload the server it wil automaticly back to true
please help