public void removePlayer(Player p, boolean b) { for (Game g : games) { if (g.getAllPlayers().contains(p)) { // PlayerLeaveArenaEvent leavearena = new PlayerLeaveArenaEvent(p, g); // Bukkit.getServer().getPluginManager().callEvent(leavearena); } } getGame(getPlayerGameId(p)).removePlayer(p, b); }
private void createPlayerElements(Game game, long clientId) { Element parent = doc.createElement("players"); parent.setAttribute("turn", "" + game.getTurnPlayer().getIndex()); root.appendChild(parent); for(Player p : game.getAllPlayers()) { Element el = doc.createElement("player"); el.setAttribute("name", p.getNick()); el.setAttribute("points", "" + p.getPoints()); el.setAttribute("slot", "" + p.getSlot().getNumber()); if (Objects.equal(p.getOwnerId(),clientId)) { el.setAttribute("local", "true"); } if (p.getSlot().getType() == SlotType.AI) { el.setAttribute("ai-class", p.getSlot().getAiClassName()); } parent.appendChild(el); } }
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(); } }