コード例 #1
0
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   List<Gamer> gamers = pm.getAliveGamers();
   ArrayList<String> gamerNames = new ArrayList<String>();
   for (Gamer game : gamers) gamerNames.add(game.getPlayer().getDisplayName());
   Collections.sort(gamerNames);
   String gamersName = "No gamers";
   if (gamerNames.size() > 0)
     gamersName = StringUtils.join(gamerNames, ChatColor.GRAY + ", " + ChatColor.GRAY);
   sender.sendMessage(
       String.format(
           cm.getCommandPlayers(),
           gamers.size(),
           (pm.getGamers().size() - gamers.size()),
           gamersName));
   if (hg.currentTime >= 0)
     sender.sendMessage(
         String.format(cm.getCommandPlayersTimeStatusStarted(), hg.returnTime(hg.currentTime)));
   else
     sender.sendMessage(
         String.format(cm.getCommandPlayersTimeStatusStarting(), hg.returnTime(hg.currentTime)));
   return true;
 }
コード例 #2
0
 public void checkWinner() {
   if (doSeconds) {
     List<Gamer> aliveGamers = pm.getAliveGamers();
     if (aliveGamers.size() == 1) {
       doSeconds = false;
       final Gamer winner = aliveGamers.get(0);
       Bukkit.getPluginManager().callEvent(new PlayerWinEvent(winner));
       int reward = getPrize(1);
       if (reward > 0) winner.addBalance(reward);
       winner.getPlayer().setAllowFlight(true);
       Bukkit.getScheduler()
           .scheduleSyncRepeatingTask(
               this,
               new Runnable() {
                 public void run() {
                   Bukkit.broadcastMessage(
                       String.format(
                           translationsConfig.getBroadcastWinnerWon(), winner.getName()));
                 }
               },
               0,
               mainConfig.getWonBroadcastsDelay() * 20);
       Bukkit.getScheduler()
           .scheduleSyncDelayedTask(
               this,
               new Runnable() {
                 public void run() {
                   String kick =
                       String.format(translationsConfig.getKickMessageWon(), winner.getName());
                   shutdown(kick);
                 }
               },
               mainConfig.getGameShutdownDelay() * 20);
     } else if (aliveGamers.size() == 0) {
       doSeconds = false;
       shutdown(translationsConfig.getKickNobodyWonMessage());
     }
   }
 }