Exemplo n.º 1
0
 @Override
 public boolean onCommand(Player player, String[] args) {
   if (!player.hasPermission(permission()) && !player.isOp()) {
     MessageManager.getInstance()
         .sendFMessage(MessageManager.PrefixType.ERROR, "error.nopermission", player.getName());
     return true;
   }
   try {
     if (args.length == 0) {
       for (Game g : GameManager.getInstance().getGames()) {
         QueueManager.getInstance().rollback(g.getID(), true);
         g.disable();
       }
       MessageManager.getInstance()
           .sendFMessage(
               MessageManager.PrefixType.INFO, "game.all", player.getName(), "input-disabled");
     } else {
       Game g = GameManager.getInstance().getGame(Integer.parseInt(args[0]));
       g.disable();
       QueueManager.getInstance().rollback(g.getID(), true);
       MessageManager.getInstance()
           .sendFMessage(
               MessageManager.PrefixType.INFO,
               "game.state",
               player.getName(),
               "arena-" + args[0],
               "input-disabled");
     }
   } catch (NumberFormatException e) {
     MessageManager.getInstance()
         .sendFMessage(
             MessageManager.PrefixType.ERROR, "error.notanumber", player.getName(), "input-Arena");
   } catch (NullPointerException e) {
     MessageManager.getInstance()
         .sendFMessage(
             MessageManager.PrefixType.ERROR,
             "error.gamedoesntexist",
             player.getName(),
             "arena-" + args[0]);
   }
   return true;
 }
    public void run() {
      datafolder = p.getDataFolder();

      PluginManager pm = getServer().getPluginManager();
      setCommands();

      SettingsManager.getInstance().setup(p);
      MessageManager.getInstance().setup();
      GameManager.getInstance().setup(p);

      try { // try loading everything that uses SQL.
        FileConfiguration c = SettingsManager.getInstance().getConfig();
        if (c.getBoolean("stats.enabled")) DatabaseManager.getInstance().setup(p);
        QueueManager.getInstance().setup();
        StatsManager.getInstance().setup(p, c.getBoolean("stats.enabled"));
        dbcon = true;
      } catch (Exception e) {
        dbcon = false;
        e.printStackTrace();
        logger.severe(
            "!!!Failed to connect to the database. Please check the settings and try again!!!");
        return;
      } finally {
        LobbyManager.getInstance().setup(p);
      }

      ChestRatioStorage.getInstance().setup();
      HookManager.getInstance().setup();
      pm.registerEvents(new PlaceEvent(), p);
      pm.registerEvents(new BreakEvent(), p);
      pm.registerEvents(new DeathEvent(), p);
      pm.registerEvents(new MoveEvent(), p);
      pm.registerEvents(new CommandCatch(), p);
      pm.registerEvents(new SignClickEvent(), p);
      pm.registerEvents(new ChestReplaceEvent(), p);
      pm.registerEvents(new LogoutEvent(), p);
      pm.registerEvents(new JoinEvent(p), p);
      pm.registerEvents(new TeleportEvent(), p);
      pm.registerEvents(LoggingManager.getInstance(), p);
      pm.registerEvents(new SpectatorEvents(), p);
      pm.registerEvents(new BandageUse(), p);
      pm.registerEvents(new KitEvents(), p);

      for (Player p : Bukkit.getOnlinePlayers()) {
        if (GameManager.getInstance().getBlockGameId(p.getLocation()) != -1) {
          p.teleport(SettingsManager.getInstance().getLobbySpawn());
        }
      }

      //   new Webserver().start();
    }
Exemplo n.º 3
0
  /*
   *
   * ################################################
   *
   * 				RESET
   *
   * ################################################
   *
   *
   */
  public void resetArena() {

    for (Integer i : tasks) {
      Bukkit.getScheduler().cancelTask(i);
    }

    tasks.clear();
    vote = 0;
    voted.clear();

    mode = GameMode.RESETING;
    endgameRunning = false;

    Bukkit.getScheduler().cancelTask(endgameTaskID);
    GameManager.getInstance().gameEndCallBack(gameID);
    QueueManager.getInstance().rollback(gameID, false);
    LobbyManager.getInstance().updateWall(gameID);

    scoreBoard.reset();
  }
  public void onDisable() {
    disabling = false;
    PluginDescriptionFile pdfFile = p.getDescription();
    SettingsManager.getInstance().saveSpawns();
    SettingsManager.getInstance().saveSystemConfig();
    for (Game g : GameManager.getInstance().getGames()) {
      try {
        g.disable();
      } catch (Exception e) {
        // will throw useless "tried to register task blah blah error." Use the method below to
        // reset the arena without a task.
      }
      QueueManager.getInstance().rollback(g.getID(), true);
    }

    logger.info(
        pdfFile.getName()
            + " version "
            + pdfFile.getVersion()
            + " has now been disabled and reset");
  }