Package org.mcsg.survivalgames

Examples of org.mcsg.survivalgames.Game


    }

    public void saveGame(int arenaid, Player winner,int players, long time ){
        if(!enabled)return;
        int gameno = 0;
        Game g = GameManager.getInstance().getGame(arenaid);

        try {
            long time1 = new Date().getTime();
            PreparedStatement s2 = dbman.createStatement("SELECT * FROM "+SettingsManager.getSqlPrefix() +
                    "gamestats ORDER BY gameno DESC LIMIT 1");
            ResultSet rs = s2.executeQuery();
            rs.next();
            gameno = rs.getInt(1) + 1;

            if(time1 + 5000 < new Date().getTime())System.out.println("Your database took a long time to respond. Check the connection between the server and database");
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            g.setRBStatus("Error: getno");
        }

        addSQL("INSERT INTO "+SettingsManager.getSqlPrefix()+"gamestats VALUES(NULL,"+arenaid+","+players+",'"+winner.getName()+"',"+time+")");

        for(PlayerStatsSession s:arenas.get(arenaid).values()){
View Full Code Here


      MessageManager.getInstance().sendFMessage(PrefixType.ERROR, "error.notenoughtplayers", player);
      return true;
    }


    Game g = GameManager.getInstance().getGame(game);
    if (g.getMode() != Game.GameMode.WAITING && !player.hasPermission("sg.arena.restart")) {
      MessageManager.getInstance().sendFMessage(PrefixType.ERROR, "error.alreadyingame", player);
      return true;
    }
    g.countdown(seconds);

    msgmgr.sendFMessage(PrefixType.INFO, "game.started", player, "arena-" + game);

    return true;
  }
View Full Code Here

        }
       
        FileConfiguration s = SettingsManager.getInstance().getSystemConfig();
        //FileConfiguration spawn = SettingsManager.getInstance().getSpawns();
        int arena = Integer.parseInt(args[0]);
        Game g = GameManager.getInstance().getGame(arena);
       
        if(g == null){
            MessageManager.getInstance().sendFMessage(PrefixType.ERROR, "error.gamedoesntexist", player, "arena-" + arena);
            return true;
        }
       
        g.disable();
        s.set("sg-system.arenas."+arena+".enabled", false);
        s.set("sg-system.arenano", s.getInt("sg-system.arenano") - 1);
        //spawn.set("spawns."+arena, null);
        MessageManager.getInstance().sendFMessage(PrefixType.INFO, "info.deleted", player, "input-Arena");
        SettingsManager.getInstance().saveSystemConfig();
View Full Code Here

        if(args.length < 2){
            player.sendMessage(help(player));
            return true;
        }
       
        Game g = GameManager.getInstance().getGame(Integer.parseInt(args[0]));
       
        if(g == null){
            MessageManager.getInstance().sendFMessage(MessageManager.PrefixType.ERROR, "error.gamedoesntexist", player, "arena-" + args[0]);
            return true;
        }
       
        HashMap<String, Object>z = SettingsManager.getInstance().getGameFlags(g.getID());
        z.put(args[1].toUpperCase(), g.getID());
        SettingsManager.getInstance().saveGameFlags(z, g.getID());
           

       
        return false;
    }
View Full Code Here

            }
            return;
        }


        Game g = GameManager.getInstance().getGame(pid);

        if(g.getMode() == Game.GameMode.DISABLED){
            return;
        }
        if(g.getMode() != Game.GameMode.INGAME){
            event.setCancelled(true);
            return;
        }

        if(!allowedBreak.contains(event.getBlock().getTypeId()))event.setCancelled(true);
View Full Code Here

    int gameid = GameManager.getInstance().getPlayerGameId(player);
    if(gameid==-1)
      return;
    if(!GameManager.getInstance().isPlayerActive(player))
      return;
    Game game = GameManager.getInstance().getGame(gameid);
    if(game.getMode() != Game.GameMode.INGAME){
      event.setCancelled(true);
      return;
    }
    if(game.isProtectionOn()){
      event.setCancelled(true);
      return;
    }
    if(player.getHealth() <= event.getDamage()){
      event.setCancelled(true);
View Full Code Here

        Player player = event.getPlayer();
        try{
            if(GameManager.getInstance().isSpectator(player) && player.isSneaking() && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR)||
                    GameManager.getInstance().isSpectator(player) && player.isSneaking() && (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR)){
                Player[]players = GameManager.getInstance().getGame(GameManager.getInstance().getPlayerSpectateId(player)).getPlayers()[0];
                Game g = GameManager.getInstance().getGame(GameManager.getInstance().getPlayerSpectateId(player));

                int i = g.getNextSpec().get(player);
                if((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR)){
                    i++;
                }
                else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_AIR){
                    i--;
                }
                if(i>players.length-1){
                    i = 0;
                }
                if(i<0){
                    i = players.length-1;
                }
                g.getNextSpec().put(player, i);
                Player tpto = players[i];
                Location l = tpto.getLocation();
                l.setYaw(0);
                l.setPitch(0);
                player.teleport(l);
View Full Code Here

            }
            return;
        }


        Game g = GameManager.getInstance().getGame(id);
        if(g.isPlayerinactive(p)){
            return;
        }
        if(g.getMode() == Game.GameMode.DISABLED){
            return;
        }
        if(g.getMode() != Game.GameMode.INGAME){
            event.setCancelled(true);
            return;

        }
View Full Code Here

      if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
        BlockState clicked = e.getClickedBlock().getState();
        if(clicked instanceof Chest || clicked instanceof DoubleChest){
          int gameid = GameManager.getInstance().getPlayerGameId(e.getPlayer());
          if(gameid != -1){
            Game game = GameManager.getInstance().getGame(gameid);
            if(game.getMode() == GameMode.INGAME){
              HashSet<Block>openedChest = GameManager.openedChest.get(gameid);
              openedChest = (openedChest == null)? new HashSet<Block>() : openedChest;
              if(!openedChest.contains(e.getClickedBlock())){
                Inventory[] invs = ((clicked instanceof Chest))? new Inventory[] {((Chest) clicked).getBlockInventory()}
                : new Inventory[] {((DoubleChest)clicked).getLeftSide().getInventory(), ((DoubleChest)clicked).getRightSide().getInventory()};
View Full Code Here

TOP

Related Classes of org.mcsg.survivalgames.Game

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.