Advertisement
Eliaseeg

Team class

Jun 27th, 2015
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.57 KB | None | 0 0
  1. // Destacar que hace falta un Java Enum llamado TeamType donde tenga Red,Blue.
  2. package es.hol.eliaseeg;
  3.  
  4. import java.util.ArrayList;
  5. import java.util.List;
  6. import org.bukkit.entity.Player;
  7.  
  8. public class Team {
  9.     private static List<String> redTeam = new ArrayList<String>();
  10.     private static List<String> blueTeam = new ArrayList<String>();
  11.    
  12.     public static void addToTeam(TeamType type, Player player) {
  13.         switch (type) {
  14.         case Red:
  15.             redTeam.add(player.getName());
  16.             break;
  17.         case Blue:
  18.             blueTeam.add(player.getName());
  19.             break;
  20.         }
  21.         player.sendMessage("Added to " + type.name() + " team!");
  22.     }
  23.     public static boolean isInTeam(Player player) {
  24.         return redTeam.contains(player.getName())
  25.                 || blueTeam.contains(player.getName());
  26.     }
  27.     public static void clearTeams(){
  28.         redTeam.clear();
  29.         blueTeam.clear();
  30.     }
  31.     public static List<String> getRedTeam() {
  32.         return redTeam;
  33.     }
  34.     public static List<String> getBlueTeam() {
  35.         return blueTeam;
  36.     }
  37.     public static List<String> getAllPlayersInTeams() {
  38.         List<String> combinedTeams = new ArrayList<String>();
  39.         combinedTeams.addAll(redTeam);
  40.         combinedTeams.addAll(blueTeam);
  41.         return combinedTeams;
  42.     }
  43.     public static TeamType getTeamType(Player player) {
  44.         if (!isInTeam(player))
  45.             return null;
  46.         return (redTeam.contains(player.getName()) ? TeamType.Red
  47.                 : TeamType.Blue);
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement