public String getPlayerGameId(Player p) {
   for (Game g : games) {
     if (g.isPlayerActive(p)) {
       return g.getID();
     }
   }
   return null;
 }
 public boolean isPlayerInactive(Player player) {
   for (Game g : games) {
     if (g.isPlayerActive(player)) {
       return true;
     }
   }
   return false;
 }
 public int getPlayerGameId(Player p) {
   for (Game g : games) {
     if (g.isPlayerActive(p)) {
       return g.getID();
     }
   }
   return -1;
 }
示例#4
0
  public void update() {
    // System.out.println(gameid);
    if (msgqueue.size() > 0) {
      display();
      Bukkit.getScheduler()
          .scheduleSyncDelayedTask(
              GameManager.getInstance().getPlugin(),
              new Runnable() {
                @Override
                public void run() {
                  display();
                  update();
                }
              },
              20L);
      return;
    }
    clear();
    final Game game = GameManager.getInstance().getGame(gameid);
    final Sign s0 = signs.get(0);
    final Sign s1 = signs.get(1);

    // sign 0
    s0.setLine(0, "[HungerGames]");
    s0.setLine(1, "Click to join");
    s0.setLine(2, "Arena " + gameid);

    // sign 1
    s1.setLine(0, game.getName());
    s1.setLine(1, game.getMode() + "");
    s1.setLine(
        2,
        game.getActivePlayers()
            + "/"
            + ChatColor.GRAY
            + game.getInactivePlayers()
            + ChatColor.BLACK
            + "/"
            + SettingsManager.getInstance().getSpawnCount(game.getID()));

    // live update line s1
    if (game.getMode() == Game.GameMode.STARTING) {
      s1.setLine(3, game.getCountdownTime() + "");
    } else if (game.getMode() == Game.GameMode.RESETING
        || game.getMode() == Game.GameMode.FINISHING) {
      s1.setLine(3, game.getRBStatus());
      if (game.getRBPercent() > 100) {
        s1.setLine(1, "Saving Queue");
        s1.setLine(3, (int) game.getRBPercent() + " left");
      } else s1.setLine(3, (int) game.getRBPercent() + "%");
    } else {
      s1.setLine(3, "");
    }

    // live player data
    final ArrayList<String> display = new ArrayList<String>();
    for (final Player p : game.getAllPlayers()) {
      display.add((game.isPlayerActive(p) ? ChatColor.BLACK : ChatColor.GRAY) + p.getName());
    }

    try {
      int no = 2;
      int line = 0;
      for (final String s : display) {
        signs.get(no).setLine(line, s);
        line++;
        if (line >= 4) {
          line = 0;
          no++;
        }
      }
    } catch (final Exception e) {
    }
    for (final Sign s : signs) {
      s.update();
    }
  }