예제 #1
0
  public void setup() {
    mode = GameMode.LOADING;
    int x = system.getInt("sg-system.arenas." + gameID + ".x1");
    int y = system.getInt("sg-system.arenas." + gameID + ".y1");
    int z = system.getInt("sg-system.arenas." + gameID + ".z1");

    int x1 = system.getInt("sg-system.arenas." + gameID + ".x2");
    int y1 = system.getInt("sg-system.arenas." + gameID + ".y2");
    int z1 = system.getInt("sg-system.arenas." + gameID + ".z2");

    Location max =
        new Location(
            SettingsManager.getGameWorld(gameID),
            Math.max(x, x1),
            Math.max(y, y1),
            Math.max(z, z1));
    Location min =
        new Location(
            SettingsManager.getGameWorld(gameID),
            Math.min(x, x1),
            Math.min(y, y1),
            Math.min(z, z1));

    name = system.getString("sg-system.arenas." + gameID + ".name", name);

    arena = new Arena(min, max);

    int dmx = system.getInt("sg-system.arenas." + gameID + ".deathmatch.x", 0);
    int dmy = system.getInt("sg-system.arenas." + gameID + ".deathmatch.y", 65);
    int dmz = system.getInt("sg-system.arenas." + gameID + ".deathmatch.z", 0);
    dmspawn = new Location(SettingsManager.getGameWorld(gameID), dmx, dmy, dmz);

    dmradius = system.getInt("sg-system.arenas." + gameID + ".deathmatch.radius", 26);

    String winw = system.getString("sg-system.arenas." + gameID + ".win.world", "games");
    int winx = system.getInt("sg-system.arenas." + gameID + ".win.x", 0);
    int winy = system.getInt("sg-system.arenas." + gameID + ".win.y", 65);
    int winz = system.getInt("sg-system.arenas." + gameID + ".win.z", 0);
    float winyaw = system.getInt("sg-system.arenas." + gameID + ".win.yaw", 0);
    float winp = system.getInt("sg-system.arenas." + gameID + ".win.pitch", 0);
    winloc = new Location(Bukkit.getWorld(winw), winx, winy, winz, winyaw, winp);

    loadspawns();

    hookvars.put("arena", gameID + "");
    hookvars.put("maxplayers", spawnCount + "");
    hookvars.put("activeplayers", "0");

    mode = GameMode.WAITING;

    scoreBoard = new GameScoreboard(gameID);
  }
예제 #2
0
  /*
   *
   * ################################################
   *
   * 				PLAYER WIN
   *
   * ################################################
   *
   *
   */
  public void playerWin(Player p) {
    if (GameMode.DISABLED == mode) return;
    Player win = activePlayers.get(0);
    // clearInv(p);
    win.teleport(winloc);
    // restoreInv(win);
    scoreBoard.removePlayer(p);
    msgmgr.broadcastFMessage(
        PrefixType.INFO,
        "game.playerwin",
        "arena-" + gameID,
        "victim-" + p.getName(),
        "player-" + win.getName());

    mode = GameMode.FINISHING;
    LobbyManager.getInstance().updateWall(gameID);
    LobbyManager.getInstance().gameEnd(gameID, win);

    clearSpecs();
    win.setHealth(p.getMaxHealth());
    win.setFoodLevel(20);
    win.setFireTicks(0);
    win.setFallDistance(0);

    sm.playerWin(win, gameID, new Date().getTime() - startTime);
    sm.saveGame(
        gameID, win, getActivePlayers() + getInactivePlayers(), new Date().getTime() - startTime);

    activePlayers.clear();
    inactivePlayers.clear();
    spawns.clear();

    loadspawns();
    LobbyManager.getInstance().updateWall(gameID);
    MessageManager.getInstance()
        .broadcastFMessage(PrefixType.INFO, "broadcast.gameend", "arena-" + gameID);

    // Remove all entities in the world
    for (Entity entity : this.arena.getMax().getWorld().getEntities()) {
      if (entity instanceof Player) continue;
      entity.remove();
    }
  }