Beispiel #1
0
 @EventHandler(priority = EventPriority.LOWEST)
 public void onGameStart(GameStartEvent event) {
   for (Player p : getMyPlayers()) {
     Kit kit = getViableKit(p);
     if (kit != null) {
       HungergamesApi.getKitManager().setKit(p, kit.getName());
       kit.giveKit(p);
       p.sendMessage(String.format(messageOnGive, kit.getName()));
     } else p.sendMessage(messageWhenNoKitFound);
   }
 }
Beispiel #2
0
 private boolean isBadKit(Kit kit) {
   for (String kitName : badKits) if (kit.getName().equalsIgnoreCase(kitName)) return true;
   return false;
 }
  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();
  }