Exemplo n.º 1
0
 @Override
 public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
   if (!(sender instanceof Player)) {
     sender.sendMessage("Must be a player!");
     return true;
   }
   if (label.equalsIgnoreCase("vote")) {
     Player p = (Player) sender;
     GameManager gm = plugin.getApi().getModuleForClass(GameManager.class);
     if (!gm.hasvoted(p)) {
       if (args[0].equalsIgnoreCase(plugin.getGame().world1)) {
         gm.AddVote(plugin.getGame().world1);
         gm.AddVoter(p.getName());
         sender.sendMessage(
             "Your vote for "
                 + plugin.getGame().world1
                 + "has been casted. The amount of votes now are "
                 + gm.getVotes(plugin.getGame().world1));
         return true;
       }
       if (args[0].equalsIgnoreCase(plugin.getGame().world2)) {
         gm.AddVote(plugin.getGame().world2);
         gm.AddVoter(p.getName());
         sender.sendMessage(
             "Your vote for "
                 + plugin.getGame().world2
                 + "has been casted. The amount of votes now are "
                 + gm.getVotes(plugin.getGame().world2));
         return true;
       }
     }
     sender.sendMessage("Please specify a map!");
     return true;
   }
   return false;
 }
Exemplo n.º 2
0
  @Override
  public void run() {
    if (SAD.bombholder.get(gm.GetCurrentWorld()).equalsIgnoreCase("none")) {
      if (Bukkit.getOnlinePlayers().length > 0) {
        for (Player p : getNearbyEntities(SAD.bomb.get(gm.GetCurrentWorld()), 2)) {
          if (SAD.bombholder.get(gm.GetCurrentWorld()).equalsIgnoreCase("none")) {
            SAD.bombholder.remove(gm.GetCurrentWorld());
            SAD.bombholder.put(gm.GetCurrentWorld(), p.getName());
            SAD.bomb.get(gm.GetCurrentWorld()).getBlock().setType(Material.AIR);
          }
        }
      }
    }
    if (SAD.bombholder.get(gm.GetCurrentWorld()).equalsIgnoreCase("droped")) {
      if (Bukkit.getOnlinePlayers().length > 0) {
        for (Player p : getNearbyEntities(SAD.bombdroped, 2)) {
          if (SAD.bombholder.get(gm.GetCurrentWorld()).equalsIgnoreCase("droped")) {
            SAD.bombholder.remove(gm.GetCurrentWorld());
            SAD.bombholder.put(gm.GetCurrentWorld(), p.getName());
            SAD.bomb.get(gm.GetCurrentWorld()).getBlock().setType(Material.AIR);
          }
        }
      }
    }
    plugin.getApi().getModuleForClass(GUI.class).newupdatePlayerList();
    for (Entry<World, ArrayList<Location>> w : MapLoader.Blocations.entrySet()) {
      Location loc1 = w.getValue().get(0);
      Location loc2 = w.getValue().get(1);
      for (Player p : getNearbyEntities(loc1, 2)) {
        if (SAD.bombholder.get(gm.GetCurrentWorld()).equalsIgnoreCase(p.getName())
            && t.getTeam(p) == plugin.getGame().O
            && !(SAD.Bomb1)) {
          if (SAD.Planters.get(1).size() >= 1) {
            break;
          }
          if (!SAD.Planters.get(1).containsKey(p.getName())) {
            SAD.Planters.get(1).put(p.getName(), 5);
          }
        }
        if (!(t.getTeam(p) == plugin.getGame().O) && (SAD.Bomb1)) {
          if (SAD.Defuseers.get(1).size() >= 1) {
            break;
          }
          if (!SAD.Defuseers.get(1).containsKey(p.getName())) {
            SAD.Defuseers.get(1).put(p.getName(), 5);
          }
        }
      }
      for (Player p : getNearbyEntities(loc2, 2)) {
        if (SAD.bombholder.get(gm.GetCurrentWorld()).equalsIgnoreCase(p.getName())
            && t.getTeam(p) == plugin.getGame().O
            && !(SAD.Bomb2)) {
          if (SAD.Planters.get(2).size() >= 1) {
            break;
          }
          if (!SAD.Planters.get(2).containsKey(p.getName())) {
            SAD.Planters.get(2).put(p.getName(), 5);
          }
        }
        if (!(t.getTeam(p) == plugin.getGame().O) && (SAD.Bomb2)) {
          if (SAD.Defuseers.get(2).size() >= 1) {
            break;
          }
          if (!SAD.Defuseers.get(2).containsKey(p.getName())) {
            SAD.Defuseers.get(2).put(p.getName(), 5);
          }
        }
      }
    }

    for (Entry<String, Integer> s : SAD.Planters.get(1).entrySet()) {
      SAD.Planters.get(1).put(s.getKey(), s.getValue() - 1);
      Player p = Bukkit.getPlayer(s.getKey());
      Boolean b = false;
      for (Entry<World, ArrayList<Location>> w : MapLoader.Blocations.entrySet()) {
        Location loc1 = w.getValue().get(0);
        Location loc2 = w.getValue().get(1);
        for (Player p1 : getNearbyEntities(loc1, 2)) {
          if (p == p1) {
            b = true;
          }
        }
        for (Player p1 : getNearbyEntities(loc2, 2)) {
          if (p == p1) {
            b = true;
          }
        }
      }
      if (!b) {
        SAD.Planters.get(1).remove(s.getKey());
      }

      if (s.getValue() == 0) {
        SAD.Planters.get(1).remove(s.getKey());
        SAD.Bomb1 = true;
        SAD.Bomb1Timer = 60;
      }
    }
    for (Entry<String, Integer> s : SAD.Planters.get(2).entrySet()) {
      SAD.Planters.get(2).put(s.getKey(), s.getValue() - 1);
      Player p = Bukkit.getPlayer(s.getKey());
      Boolean b = false;
      for (Entry<World, ArrayList<Location>> w : MapLoader.Blocations.entrySet()) {
        Location loc1 = w.getValue().get(0);
        Location loc2 = w.getValue().get(1);
        for (Player p1 : getNearbyEntities(loc1, 2)) {
          if (p == p1) {
            b = true;
          }
        }
        for (Player p1 : getNearbyEntities(loc2, 2)) {
          if (p == p1) {
            b = true;
          }
        }
      }
      if (!b) {
        SAD.Planters.get(2).remove(s.getKey());
      }

      if (s.getValue() == 0) {
        SAD.Planters.get(2).remove(s.getKey());
        SAD.Bomb2 = true;
        SAD.Bomb2Timer = 60;
      }
    }
    for (Entry<String, Integer> s : SAD.Defuseers.get(1).entrySet()) {
      SAD.Defuseers.get(1).put(s.getKey(), s.getValue() - 1);
      Player p = Bukkit.getPlayer(s.getKey());
      Boolean b = false;
      for (Entry<World, ArrayList<Location>> w : MapLoader.Blocations.entrySet()) {
        Location loc1 = w.getValue().get(0);
        Location loc2 = w.getValue().get(1);
        for (Player p1 : getNearbyEntities(loc1, 2)) {
          if (p == p1) {
            b = true;
          }
        }
        for (Player p1 : getNearbyEntities(loc2, 2)) {
          if (p == p1) {
            b = true;
          }
        }
      }
      if (!b) {
        SAD.Defuseers.get(1).remove(s.getKey());
      }
      if (s.getValue() == 0) {
        Game.RoundWinReason = "Time";
        gm.Win(0);
        SAD.Bomb1 = false;
        SAD.Defuseers.get(1).remove(s.getKey());
        SAD.Bomb1Timer = 0;
      }
    }
    for (Entry<String, Integer> s : SAD.Defuseers.get(2).entrySet()) {
      SAD.Defuseers.get(2).put(s.getKey(), s.getValue() - 1);
      Player p = Bukkit.getPlayer(s.getKey());
      Boolean b = false;
      for (Entry<World, ArrayList<Location>> w : MapLoader.Blocations.entrySet()) {
        Location loc1 = w.getValue().get(0);
        Location loc2 = w.getValue().get(1);
        for (Player p1 : getNearbyEntities(loc1, 2)) {
          if (p == p1) {
            b = true;
          }
        }
        for (Player p1 : getNearbyEntities(loc2, 2)) {
          if (p == p1) {
            b = true;
          }
        }
      }
      if (!b) {
        SAD.Defuseers.get(2).remove(s.getKey());
      }
      if (s.getValue() == 0) {
        Game.RoundWinReason = "Time";
        gm.Win(0);
        SAD.Bomb2 = false;
        SAD.Defuseers.get(2).remove(s.getKey());
        SAD.Bomb2Timer = 0;
      }
    }
    Bukkit.getScheduler().runTaskLater(plugin, new SADTimer(plugin, delay), delay);
  }