@EventHandler
  public void onPlayerQuit(PlayerQuitEvent e) {
    Player p = e.getPlayer();
    if (PBMethods.allowedZone.containsKey(p.getName())) {
      if (PBMethods.matchStarted
          && PBMethods.getWorldGuard() != null
          && PBMethods.AutomateMatches) {
        String teamSide = null;
        if (PBMethods.getPlayerTeam(p.getUniqueId()) != null) {
          if (PBMethods.getPlayerTeam(p.getUniqueId()).equalsIgnoreCase(PBMethods.TeamOne))
            teamSide = PBMethods.TeamOne;
          if (PBMethods.getPlayerTeam(p.getUniqueId()).equalsIgnoreCase(PBMethods.TeamTwo))
            teamSide = PBMethods.TeamTwo;
        }

        if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) {
          PBMethods.sendPBChat(Strings.PlayerEliminated.replace("%player", p.getName()));
          PBMethods.allowedZone.remove(p.getName());
          p.getInventory().setArmorContents(null);
          p.getInventory().setArmorContents(Commands.tmpArmor.get(p));
          Commands.tmpArmor.remove(p);
          if (PBMethods.teamOnePlayers.isEmpty()) {
            PBMethods.sendPBChat(Strings.RoundStopped);
            PBMethods.sendPBChat(Strings.TeamWon.replace("%team", PBMethods.TeamTwo));
            Bukkit.getServer().getScheduler().cancelTask(Commands.clockTask);
            PBMethods.matchStarted = false;
            PBMethods.playingTeams.clear();
            PBMethods.TeamOne = null;
            PBMethods.TeamTwo = null;
            PBMethods.allowedZone.clear();
            PBMethods.restoreArmor();
          }
        }
        if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
          PBMethods.sendPBChat(Strings.PlayerEliminated.replace("%player", p.getName()));
          PBMethods.allowedZone.remove(p.getName());
          p.getInventory().setArmorContents(null);
          p.getInventory().setArmorContents(Commands.tmpArmor.get(p));
          Commands.tmpArmor.remove(p);
          if (PBMethods.teamTwoPlayers.isEmpty()) {
            PBMethods.sendPBChat(Strings.RoundStopped);
            PBMethods.sendPBChat(Strings.TeamWon.replace("%team", PBMethods.TeamOne));
            Bukkit.getServer().getScheduler().cancelTask(Commands.clockTask);
            PBMethods.matchStarted = false;
            PBMethods.playingTeams.clear();
            PBMethods.TeamOne = null;
            PBMethods.TeamTwo = null;
            PBMethods.allowedZone.clear();
            PBMethods.restoreArmor();
          }
        }
      }
    }
  }
  @EventHandler
  public void onPlayerMoveEvent(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Location from = e.getFrom();
    Location to = e.getTo();
    Set<String> fromRegions = PBMethods.RegionsAtLocation(from);
    Set<String> toRegions = PBMethods.RegionsAtLocation(to);
    String teamSide = null;
    if (PBMethods.allowedZone.containsKey(p.getName())) {

      if (PBMethods.matchStarted
          && PBMethods.getWorldGuard() != null
          && PBMethods.AutomateMatches) {
        if (PBMethods.getPlayerTeam(p.getUniqueId()) != null) {
          if (PBMethods.getPlayerTeam(p.getUniqueId()).equalsIgnoreCase(PBMethods.TeamOne))
            teamSide = PBMethods.TeamOne;
          if (PBMethods.getPlayerTeam(p.getUniqueId()).equalsIgnoreCase(PBMethods.TeamTwo))
            teamSide = PBMethods.TeamTwo;
        }

        if (PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t2z3)) {
          if (!toRegions.contains(PBMethods.t2z3) || toRegions.isEmpty()) {
            if (fromRegions.contains(PBMethods.t2z3)) {
              PBMethods.allowedZone.remove(p.getName());
              PBMethods.sendPBChat(Strings.PlayerEliminated.replace("%player", p.getName()));
              p.getInventory().setArmorContents(null);
              p.getInventory().setArmorContents(Commands.tmpArmor.get(p));
              Commands.tmpArmor.remove(p);
              PBMethods.teamTwoPlayers.remove(p.getName());
              if (PBMethods.teamTwoPlayers.isEmpty()) {
                PBMethods.sendPBChat(Strings.RoundStopped);
                PBMethods.sendPBChat(Strings.TeamWon.replace("%team", PBMethods.TeamOne));
                Bukkit.getServer().getScheduler().cancelTask(Commands.clockTask);
                PBMethods.matchStarted = false;
                PBMethods.playingTeams.clear();
                PBMethods.TeamOne = null;
                PBMethods.TeamTwo = null;
                PBMethods.allowedZone.clear();
                PBMethods.restoreArmor();
              }
            }
          }
          return;
        }
        if (PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t1z3)) {
          if (!toRegions.contains(PBMethods.t1z3) || toRegions.isEmpty()) {
            if (fromRegions.contains(PBMethods.t1z3)) {
              PBMethods.allowedZone.remove(p.getName());
              PBMethods.sendPBChat(Strings.PlayerEliminated.replace("%player", p.getName()));
              p.getInventory().setArmorContents(null);
              p.getInventory().setArmorContents(Commands.tmpArmor.get(p));
              Commands.tmpArmor.remove(p);
              PBMethods.teamOnePlayers.remove(p.getName());
              if (PBMethods.teamOnePlayers.isEmpty()) {
                PBMethods.sendPBChat(Strings.RoundStopped);
                PBMethods.sendPBChat(Strings.TeamWon.replace("%team", PBMethods.TeamTwo));
                Bukkit.getServer().getScheduler().cancelTask(Commands.clockTask);
                PBMethods.matchStarted = false;
                PBMethods.playingTeams.clear();
                PBMethods.TeamOne = null;
                PBMethods.TeamTwo = null;
                PBMethods.allowedZone.clear();
                PBMethods.restoreArmor();
              }
            }
          }
          return;
        }
        if (toRegions.contains(PBMethods.t2z3)) {
          if (!PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t2z3)) {
            // Check Team Two Zone 2
            if (fromRegions.contains(PBMethods.t2z2)
                && PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t2z2)) {
              if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t2z1);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamOne, PBMethods.t2z2)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamTwo, "Two");
                }
              }

              if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t2z3);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamTwo, PBMethods.t2z2)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamOne, "One");
                }
              }
            }
          }
        }
        if (toRegions.contains(PBMethods.t1z3)) {
          if (!PBMethods.allowedZone.containsKey(p.getName())) return;
          if (!PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t1z3)) {
            // Check Team One Zone 2
            if (fromRegions.contains(PBMethods.t1z2)
                && PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t1z2)) {
              if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t1z3);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamOne, PBMethods.t1z2)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamTwo, "Two");
                }
              }

              if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t1z1);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamTwo, PBMethods.t1z2)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamOne, "One");
                }
              }
            }
          }
        }

        if (toRegions.contains(PBMethods.t1z2)) {
          if (!PBMethods.allowedZone.containsKey(p.getName())) return;
          if (!PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t1z2)) {
            // Check Team One Zone One
            if (fromRegions.contains(PBMethods.t1z1)
                && PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t1z1)) {
              if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t1z2);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamOne, PBMethods.t1z1)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamTwo, "Two");
                }
              }
              if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t2z1);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamTwo, PBMethods.t1z1)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamOne, "One");
                }
              }
            }
            // Check Team One Zone Three
            if (fromRegions.contains(PBMethods.t1z3)
                && PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t1z3)) {
              if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) {
                PBMethods.allowedZone.remove(p.getName());
                PBMethods.sendPBChat(Strings.PlayerEliminated.replace("%player", p.getName()));
                p.getInventory().setArmorContents(null);
                p.getInventory().setArmorContents(Commands.tmpArmor.get(p));
                Commands.tmpArmor.remove(p);
                PBMethods.teamOnePlayers.remove(p.getName());
                if (PBMethods.teamOnePlayers.isEmpty()) {
                  PBMethods.sendPBChat(Strings.RoundStopped);
                  PBMethods.sendPBChat(Strings.TeamWon.replace("%team", PBMethods.TeamTwo));
                  PBMethods.matchStarted = false;
                  Bukkit.getServer().getScheduler().cancelTask(Commands.clockTask);
                  PBMethods.playingTeams.clear();
                  PBMethods.TeamOne = null;
                  PBMethods.TeamTwo = null;
                  PBMethods.allowedZone.clear();
                  PBMethods.restoreArmor();
                }
              }
            }
          }
        }
        if (toRegions.contains(PBMethods.t2z2)) {
          if (!PBMethods.allowedZone.containsKey(p.getName())) return;
          if (!PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t2z2)) {
            // Check TeamTwoZoneOne
            if (fromRegions.contains(PBMethods.t2z1)
                && PBMethods.allowedZone.get(p.getName()).equals(PBMethods.t2z1)) {
              if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t2z2);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamTwo, PBMethods.t2z1)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamOne, "One");
                }
              }
              if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t1z1);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamOne, PBMethods.t2z1)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamTwo, "Two");
                }
              }
            }
            // Check TeamTwoZoneThree
            if (fromRegions.contains(PBMethods.t2z3)
                && PBMethods.allowedZone.get(p.getName()).equals(PBMethods.t2z3)) {
              if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
                PBMethods.allowedZone.remove(p.getName());
                PBMethods.sendPBChat(Strings.PlayerEliminated.replace("%player", p.getName()));
                p.getInventory().setArmorContents(null);
                p.getInventory().setArmorContents(Commands.tmpArmor.get(p));
                Commands.tmpArmor.remove(p);
                PBMethods.teamTwoPlayers.remove(p.getName());
                if (PBMethods.teamTwoPlayers.isEmpty()) {
                  PBMethods.sendPBChat(Strings.RoundStopped);
                  PBMethods.sendPBChat(Strings.TeamWon.replace("%team", PBMethods.TeamOne));
                  PBMethods.matchStarted = false;
                  Bukkit.getServer().getScheduler().cancelTask(Commands.clockTask);
                  PBMethods.playingTeams.clear();
                  PBMethods.TeamOne = null;
                  PBMethods.TeamTwo = null;
                  PBMethods.allowedZone.clear();
                  PBMethods.restoreArmor();
                }
              }
            }
          }
        }
        if (toRegions.contains(PBMethods.t2z1)) {
          if (!PBMethods.allowedZone.containsKey(p.getName())) return;
          if (!PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t2z1)) {
            // Check Team Two Zone Two
            if (fromRegions.contains(PBMethods.t2z2)
                && PBMethods.allowedZone.get(p.getName()).equals(PBMethods.t2z2)) {
              if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t2z3);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamTwo, PBMethods.t2z2)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamOne, "One");
                }
              }
              if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t2z1);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamOne, PBMethods.t2z2)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamTwo, "Two");
                }
              }
            }
            // Check Team One Zone One
            if (fromRegions.contains(PBMethods.t1z1)
                && PBMethods.allowedZone
                    .get(p.getName())
                    .equals(PBMethods.t1z1)) { // They are coming from Team One Zone One
              if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t1z2);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamOne, PBMethods.t1z1)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamTwo, "Two");
                }
              }
              if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t2z1);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamTwo, PBMethods.t1z1)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamOne, "One");
                }
              }
            }
          }
        }
        if (toRegions.contains(PBMethods.t1z1)) {
          if (!PBMethods.allowedZone.containsKey(p.getName())) return;
          if (!PBMethods.allowedZone.get(p.getName()).equalsIgnoreCase(PBMethods.t1z1)) {
            // Check Team One Zone Two
            if (fromRegions.contains(PBMethods.t1z2)
                && PBMethods.allowedZone
                    .get(p.getName())
                    .equals(PBMethods.t1z2)) { // They are coming from Team One's Second Zone.
              if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) { // They are on Team One
                PBMethods.allowedZone.put(
                    p.getName(), PBMethods.t1z3); // They were fouled back to Zone 3.
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamOne, PBMethods.t1z2)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamTwo, "Two");
                }
              }
              if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) { // They are on Team Two
                PBMethods.allowedZone.put(
                    p.getName(), PBMethods.t1z1); // Send them back to Team One Zone 1.
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamTwo, PBMethods.t1z2)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamOne, "One");
                }
              }
            }
            // Check Team Two Zone One
            if (fromRegions.contains(PBMethods.t2z1)
                && PBMethods.allowedZone
                    .get(p.getName())
                    .equals(PBMethods.t2z1)) { // They are coming from Team Two's First Zone.
              if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) { // Team One Player
                PBMethods.allowedZone.put(
                    p.getName(), PBMethods.t1z1); // Stick them to Zone One on Team One's Side.
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamOne, PBMethods.t2z1)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamTwo, "Two");
                }
              }
              if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
                PBMethods.allowedZone.put(p.getName(), PBMethods.t2z2);
                PBMethods.sendPBChat(
                    Strings.PlayerFouled.replace("%player", p.getName())
                        .replace("%zone", PBMethods.allowedZone.get(p.getName())));
                if (PBMethods.isZoneEmpty(PBMethods.TeamTwo, PBMethods.t2z1)) {
                  PBMethods.MovePlayersUp(PBMethods.TeamOne, "One");
                }
              }
            }
          }
        }
      }
    }
  }