Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.kNoAPP.Zones.aspects;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import org.bukkit.ChatColor;
- import org.bukkit.Color;
- import org.bukkit.entity.Player;
- import com.kNoAPP.Zones.mapdata.Area;
- public enum GameTeam {
- WHITE("White", RGB.WHITE, ChatColor.WHITE, Color.WHITE, (byte) 0, 0),
- RED("Red", RGB.RED, ChatColor.RED, Color.RED, (byte) 14, 1),
- BLUE("Blue", RGB.BLUE, ChatColor.BLUE, Color.BLUE, (byte) 11, 2),
- GREEN("Green", RGB.GREEN, ChatColor.GREEN, Color.GREEN, (byte) 5, 3),
- YELLOW("Yellow", RGB.YELLOW, ChatColor.YELLOW, Color.YELLOW, (byte) 4, 4);
- public static GameTeam winner;
- private String name;
- private RGB rgb;
- private ChatColor color;
- private Color c;
- private byte data;
- private int priority;
- private List<Player> players = new ArrayList<Player>();
- private GameTeam(String name, RGB rgb, ChatColor color, Color c, byte data, int priority) {
- this.name = name;
- this.rgb = rgb;
- this.color = color;
- this.c = c;
- this.data = data;
- this.priority = priority;
- }
- public String getName() {
- return name;
- }
- public RGB getRGB() {
- return rgb;
- }
- public ChatColor getColor() {
- return color;
- }
- public Color getC() {
- return c;
- }
- public byte getData() {
- return data;
- }
- public int getPriority() {
- return priority;
- }
- public List<Player> getPlayers() {
- return players;
- }
- public void addPlayer(Player p) {
- if(!players.contains(p)) {
- players.add(p);
- }
- }
- public void removePlayer(Player p) {
- if(players.contains(p)) {
- players.remove(p);
- }
- }
- public boolean hasWon() {
- for(Area a : GameMap.current.getAreas()) {
- if(a.getOwner() != this) {
- return false;
- }
- }
- return true;
- }
- public static void wipePlayer(Player p) {
- for(GameTeam gt : values()) {
- if(gt.getPlayers().contains(p)) {
- gt.removePlayer(p);
- }
- }
- }
- public static GameTeam getPlayer(Player p) {
- for(GameTeam gt : values()) {
- if(gt.getPlayers().contains(p)) {
- return gt;
- }
- }
- return null;
- }
- public static GameTeam getTeamByName(String n) {
- for(GameTeam t : GameTeam.values()) {
- if(t.getName().equalsIgnoreCase(n)) {
- return t;
- }
- }
- return null;
- }
- public static ArrayList<GameTeam> getTeams(int team) {
- ArrayList<GameTeam> teams = new ArrayList<GameTeam>();
- for(GameTeam t : values()) {
- if(t.getPriority() <= team) {
- teams.add(t);
- }
- }
- return teams;
- }
- public static GameTeam lowest() {
- GameTeam lowest = RED;
- for(GameTeam gt : GameMap.current.getTeams()) {
- if(lowest.getPlayers().size() > gt.getPlayers().size()) {
- lowest = gt;
- }
- }
- return lowest;
- }
- public static GameTeam zoneLeader() {
- HashMap<GameTeam, Double> score = new HashMap<GameTeam, Double>();
- for(GameTeam gt : GameMap.current.getTeams()) {
- score.put(gt, 0.0);
- }
- for(Area a : GameMap.current.getAreas()) {
- double tS = score.get(a.getLeader());
- tS += a.getCapture();
- score.put(a.getLeader(), tS);
- }
- //Find Highest
- double h = Double.MIN_VALUE;
- GameTeam minGt = GameTeam.WHITE;
- for(GameTeam gt : score.keySet()) {
- double v = score.get(gt);
- if(v > h) {
- h = v;
- minGt = gt;
- } else if(v == h){
- return GameTeam.WHITE;
- }
- }
- return minGt;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement