Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.19 KB | None | 0 0
  1. package me.sitrismc.footballedition;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.OfflinePlayer;
  6. import org.bukkit.scoreboard.Team;
  7.  
  8. import java.util.ArrayList;
  9. import java.util.Collections;
  10. import java.util.List;
  11. import java.util.Random;
  12.  
  13. /**
  14.  * Created by linse_000 on 10/31/2014.
  15.  */
  16. public class FootballUtils {
  17.  
  18.     FootballEdition plugin;
  19.  
  20.     public void randomizeFormation(Team team) {
  21.         Random r = new Random();
  22.  
  23.         if (team.getSize() != 11) {
  24.             Bukkit.broadcastMessage(ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + team.getDisplayName() + " does not have 11 people");
  25.             return;
  26.         }
  27.  
  28.         List<String> randomTeam = new ArrayList<String>();
  29.  
  30.         for (OfflinePlayer p : team.getPlayers()) {
  31.             randomTeam.add(p.getName());
  32.         }
  33.  
  34.         Collections.shuffle(randomTeam);
  35.  
  36.         int formation = r.nextInt(3) + 1;
  37.         if (formation == 1) {
  38.             firstFormation(randomTeam);
  39.             return;
  40.         } else if (formation == 2) {
  41.             secondFormation(randomTeam);
  42.             return;
  43.         } else if (formation == 3) {
  44.             thirdFormation(randomTeam);
  45.             return;
  46.         } else if (formation == 4) {
  47.             fourthFormation(randomTeam);
  48.             return;
  49.         } else if (formation == 5) {
  50.             fifthFormation(randomTeam);
  51.             return;
  52.         } else {
  53.             firstFormation(randomTeam);
  54.         }
  55.     }
  56.  
  57.     public void firstFormation(List<String> team) {
  58.         for (int i = 0 ; i < 4 ; i++) {
  59.             plugin.positions.put(team.get(i), "Defender");
  60.         }
  61.         for (int i = 4 ; i < 7 ; i++) {
  62.             plugin.positions.put(team.get(i), "Midfielders");
  63.         }
  64.         for (int i = 7 ; i < 10 ; i++) {
  65.             plugin.positions.put(team.get(i), "Forwards");
  66.         }
  67.         plugin.positions.put(team.get(10), "Goalkeeper");
  68.     }
  69.  
  70.     public void secondFormation(List<String> team) {
  71.  
  72.     }
  73.  
  74.     public void thirdFormation(List<String> team) {
  75.  
  76.     }
  77.  
  78.     public void fourthFormation(List<String> team) {
  79.  
  80.     }
  81.  
  82.     public void fifthFormation(List<String> team) {
  83.  
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement