예제 #1
0
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   if (sender.hasPermission("hungergames.invis")) {
     Gamer gamer = pm.getGamer(sender.getName());
     Player p = gamer.getPlayer();
     if (args.length > 0) {
       if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfShow())) {
         p.sendMessage(cm.getCommandInvisShow());
         gamer.seeInvis(true);
         gamer.updateOthersToSelf();
       } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfHide())) {
         gamer.seeInvis(false);
         gamer.updateOthersToSelf();
         p.sendMessage(cm.getCommandInvisHide());
       } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfShowAll())) {
         for (Gamer game : pm.getGamers()) {
           game.seeInvis(true);
           game.updateSelfToOthers();
         }
         p.sendMessage(cm.getCommandInvisShowAll());
       } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfHideAll())) {
         for (Gamer game : pm.getGamers()) {
           game.seeInvis(false);
           game.updateSelfToOthers();
         }
         p.sendMessage(cm.getCommandInvisHideAll());
       } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfHidePlayer())) {
         if (args.length > 1) {
           if (Bukkit.getPlayer(args[1]) != null) {
             pm.getGamer(Bukkit.getPlayer(args[1])).hide();
             p.sendMessage(
                 String.format(
                     cm.getCommandInvisHidePlayerSuccess(), Bukkit.getPlayer(args[1]).getName()));
           } else p.sendMessage(String.format(cm.getCommandInvisHidePlayerFail(), args[1]));
         } else p.sendMessage(cm.getCommandInvisHidePlayerNoArgs());
       } else if (args[0].toLowerCase().equals(cm.getCommandInvisNameOfShowPlayer())) {
         if (args.length > 1) {
           Player player = Bukkit.getPlayer(args[1]);
           if (player != null) {
             pm.getGamer(player).show();
             p.sendMessage(String.format(cm.getCommandInvisShowPlayerSuccess(), player.getName()));
           } else p.sendMessage(String.format(cm.getCommandInvisShowPlayerFail(), args[1]));
         } else p.sendMessage(cm.getCommandInvisShowPlayerNoArgs());
       } else p.sendMessage(cm.getCommandInvisNotEnoughArguments());
     } else p.sendMessage(cm.getCommandInvisNotEnoughArguments());
   } else sender.sendMessage(cm.getCommandInvisNoPermission());
   return true;
 }
예제 #2
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;
 }
예제 #3
0
 private void onSecond() {
   currentTime++;
   if (currentTime < 0) {
     world.setTime(0);
     ScoreboardManager.makeScore(
         "Main",
         DisplaySlot.SIDEBAR,
         translationsConfig.getScoreBoardGameStartingIn(),
         -currentTime);
     if (mainConfig.isTeleportToSpawnLocationPregame()
         && -currentTime == mainConfig.getSecondsToTeleportPlayerToSpawn()) {
       for (Gamer gamer : HungergamesApi.getPlayerManager().getGamers()) {
         HungergamesApi.getPlayerManager().sendToSpawn(gamer);
         if (mainConfig.isPreventMovingFromSpawnUsingPotions()) {
           for (Player player : Bukkit.getOnlinePlayers()) {
             player.addPotionEffect(
                 new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 200), true);
             player.addPotionEffect(
                 new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 200), true);
           }
         }
       }
     }
     if (mainConfig.isGameStarting(currentTime))
       Bukkit.broadcastMessage(
           String.format(
               translationsConfig.getBroadcastGameStartingIn(), returnTime(currentTime)));
   } else if (currentTime == 0) {
     if (pm.getGamers().size() < mainConfig.getMinPlayersForGameStart()) {
       currentTime = -90;
       ScoreboardManager.makeScore(
           "Main",
           DisplaySlot.SIDEBAR,
           translationsConfig.getScoreBoardGameStartingIn(),
           -currentTime);
       Bukkit.broadcastMessage(translationsConfig.getBroadcastNotEnoughPlayers());
     } else {
       startGame();
       return;
     }
   } else if (mainConfig.getAmountBorderClosesInPerSecond() > 0
       && currentTime > mainConfig.getBorderStartsClosingIn()) {
     double borderSize =
         mainConfig.getBorderSize() - mainConfig.getAmountBorderClosesInPerSecond();
     if (borderSize < 0) borderSize = 0;
     mainConfig.setBorderSize(borderSize);
     ScoreboardManager.makeScore(
         "Main",
         DisplaySlot.SIDEBAR,
         translationsConfig.getScoreboardBorderSize(),
         (int) mainConfig.getBorderSize());
   }
   for (Gamer gamer : pm.getGamers()) {
     this.doBorder(gamer);
   }
   if (mainConfig.getTimeForInvincibility() > 0
       && currentTime <= mainConfig.getTimeForInvincibility()
       && currentTime >= 0) {
     ScoreboardManager.makeScore(
         "Main",
         DisplaySlot.SIDEBAR,
         translationsConfig.getScoreboardInvincibleRemaining(),
         mainConfig.getTimeForInvincibility() - currentTime);
     if (currentTime == mainConfig.getTimeForInvincibility()) {
       Bukkit.broadcastMessage(translationsConfig.getBroadcastInvincibilityWornOff());
       ScoreboardManager.hideScore(
           "Main", DisplaySlot.SIDEBAR, translationsConfig.getScoreboardInvincibleRemaining());
       Bukkit.getPluginManager().callEvent(new InvincibilityWearOffEvent());
     } else if (mainConfig.advertiseInvincibility(currentTime)) {
       Bukkit.broadcastMessage(
           String.format(
               translationsConfig.getBroadcastInvincibiltyWearsOffIn(),
               returnTime(mainConfig.getTimeForInvincibility() - currentTime)));
     }
   }
   ScoreboardManager.doStage();
 }
예제 #4
0
  public void startGame() {
    currentTime = 0;
    for (Kit kit : HungergamesApi.getKitManager().getKits()) {
      final int amount = kit.getPlayerSize();
      if (amount <= 0) continue;
      metrics
          .getKitsUsed()
          .addPlotter(
              new Metrics.Plotter(kit.getName()) {

                @Override
                public int getValue() {
                  return amount;
                }
              });
    }
    ScoreboardManager.hideScore(
        "Main", DisplaySlot.SIDEBAR, translationsConfig.getScoreBoardGameStartingIn());
    ScoreboardManager.makeScore("Main", DisplaySlot.PLAYER_LIST, "", 0);
    if (mainConfig.getTimeForInvincibility() > 0) {
      ScoreboardManager.makeScore(
          "Main",
          DisplaySlot.SIDEBAR,
          translationsConfig.getScoreboardInvincibleRemaining(),
          mainConfig.getTimeForInvincibility());
    } else {
      Bukkit.getPluginManager().callEvent(new InvincibilityWearOffEvent());
    }
    Bukkit.broadcastMessage(translationsConfig.getBroadcastGameStartedMessage());
    if (mainConfig.getTimeForInvincibility() > 0)
      Bukkit.broadcastMessage(
          String.format(
              translationsConfig.getBroadcastInvincibiltyWearsOffIn(),
              returnTime(mainConfig.getTimeForInvincibility() - currentTime)));
    for (Gamer gamer : pm.getGamers()) {
      if (mainConfig.isKitSelectorEnabled())
        gamer
            .getPlayer()
            .getInventory()
            .remove(HungergamesApi.getInventoryManager().getKitSelector());
      gamer.seeInvis(false);
      gamer.setAlive(true);
      if (mainConfig.isTeleportToSpawnLocationPregame()
          && mainConfig.isPreventMovingFromSpawnUsingPotions()) {
        gamer.getPlayer().removePotionEffect(PotionEffectType.SLOW);
        gamer.getPlayer().removePotionEffect(PotionEffectType.JUMP);
      }
      pm.sendToSpawn(gamer);
    }
    world.setGameRuleValue("doDaylightCycle", "true");
    world.setTime(mainConfig.getTimeOfDay());
    world.playSound(world.getSpawnLocation(), Sound.AMBIENCE_THUNDER, 1, 0.8F);
    Bukkit.getScheduler()
        .scheduleSyncDelayedTask(
            this,
            new Runnable() {
              public void run() {
                for (Gamer gamer : pm.getAliveGamers())
                  gamer.getPlayer().getInventory().addItem(new ItemStack(Material.COMPASS));
                for (me.libraryaddict.Hungergames.Types.Kit kit :
                    HungergamesApi.getKitManager().getKits()) kit.giveKit();
                HungergamesApi.getAbilityManager().registerAbilityListeners();
                Bukkit.getPluginManager().callEvent(new GameStartEvent());
                for (Location l : entitysToSpawn.keySet())
                  l.getWorld().spawnEntity(l, entitysToSpawn.get(l));
                entitysToSpawn.clear();
              }
            });
    checkWinner();
    HungergamesApi.getInventoryManager().updateSpectatorHeads();
    ScoreboardManager.doStage();
  }
예제 #5
0
 private void onSecond() {
   currentTime++;
   if (currentTime < 0) {
     world.setTime(0);
     ScoreboardManager.makeScore(
         "Main",
         DisplaySlot.SIDEBAR,
         translationsConfig.getScoreBoardGameStartingIn(),
         -currentTime);
     if (mainConfig.isGameStarting(currentTime))
       Bukkit.broadcastMessage(
           String.format(
               translationsConfig.getBroadcastGameStartingIn(), returnTime(currentTime)));
   } else if (currentTime == 0) {
     if (pm.getGamers().size() < mainConfig.getMinPlayersForGameStart()) {
       currentTime = -90;
       ScoreboardManager.makeScore(
           "Main",
           DisplaySlot.SIDEBAR,
           translationsConfig.getScoreBoardGameStartingIn(),
           -currentTime);
       Bukkit.broadcastMessage(translationsConfig.getBroadcastNotEnoughPlayers());
     } else {
       startGame();
       return;
     }
   } else if (mainConfig.getAmountBorderClosesInPerSecond() > 0
       && currentTime > mainConfig.getBorderStartsClosingIn()) {
     mainConfig.setBorderSize(
         mainConfig.getBorderSize() - mainConfig.getAmountBorderClosesInPerSecond());
     ScoreboardManager.makeScore(
         "Main",
         DisplaySlot.SIDEBAR,
         translationsConfig.getScoreboardBorderSize(),
         (int) mainConfig.getBorderSize());
   }
   for (Gamer gamer : pm.getGamers()) {
     this.doBorder(gamer);
   }
   if (mainConfig.getTimeForInvincibility() > 0
       && currentTime <= mainConfig.getTimeForInvincibility()
       && currentTime >= 0) {
     ScoreboardManager.makeScore(
         "Main",
         DisplaySlot.SIDEBAR,
         translationsConfig.getScoreboardInvincibleRemaining(),
         mainConfig.getTimeForInvincibility() - currentTime);
     if (currentTime == mainConfig.getTimeForInvincibility()) {
       Bukkit.broadcastMessage(translationsConfig.getBroadcastInvincibilityWornOff());
       ScoreboardManager.hideScore(
           "Main", DisplaySlot.SIDEBAR, translationsConfig.getScoreboardInvincibleRemaining());
       Bukkit.getPluginManager().callEvent(new InvincibilityWearOffEvent());
     } else if (mainConfig.advertiseInvincibility(currentTime)) {
       Bukkit.broadcastMessage(
           String.format(
               translationsConfig.getBroadcastInvincibiltyWearsOffIn(),
               returnTime(mainConfig.getTimeForInvincibility() - currentTime)));
     }
   }
   ScoreboardManager.doStage();
 }