示例#1
0
  public void startLobby() {
    server.broadcastMessage(GOLD + "[ServerGames]" + GREEN + " Countdown started.");

    clearAll();

    bets.clear();
    this.clearEnt();
    load();
    tpAll(waiting);
    ServerGames.current = worlds.get(new Random().nextInt(ServerGames.worlds.size()));

    for (Player p : server.getOnlinePlayers()) {
      showAllFor(p);
      showPlayer(p);

      if (isTribute(p) || isSpectator(p)) clearItems(p);
    }

    loaded.clear();

    this.resetPlayers();

    state = State.LOBBY;
    game = new Lobby(this);

    startTimer();
  }
示例#2
0
  public void startFinished() {
    if (bets != null && !bets.isEmpty() && bets.size() > 0) {
      for (int i = 0; i < bets.size(); i++) {
        try {
          Bet b = bets.get(i);

          if (isTribute(server.getPlayer(b.tribute))) {
            addScore(b.better, b.wager / 4);
            addScore(b.tribute, b.wager / 4);
          } else {
            subtractScore(b.better, b.wager);
          }

          bets.remove(b);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    clearAll();
    load();
    bets.clear();

    state = State.DONE;
    game = new Finished(this);

    startTimer();
  }
示例#3
0
  public void startGame() {
    state = State.IN_GAME;

    for (Tribute t : ServerGames.tributes) {
      t.player.setHealth(20);
      t.player.setFoodLevel(20);
      clearItems(t.player);
      if (!t.player.isOnline()) {
        ServerGames.tributes.remove(t);
      }
    }

    loaded.clear();
    Chests.resetChests();

    bets.clear();

    clearAll();
    load();

    for (Player p : getCorn().getWorld().getPlayers()) {
      p.setCompassTarget(getCorn());
    }

    server.broadcastMessage(GOLD + "[ServerGames]" + GREEN + " Let the game begin!");

    game = new Game(this);

    startTimer();
  }
示例#4
0
  public String topInGame() {
    String most = "";

    for (Player p : server.getOnlinePlayers()) {
      if (getScore(p) > getScore(most)) {
        most = p.getName();
      }
    }

    return most;
  }
示例#5
0
  public void startDeath() {
    server.broadcastMessage(GOLD + "[ServerGames] " + RED + "Do not run from the deathmatch.");
    for (Tribute t : ServerGames.tributes) {
      if (!t.player.isDead()) {
        t.player.teleport(toCenter(t.start));
        tell(t.player, GOLD + "[ServerGames] " + GREEN + "You have made it to the deathmatch.");
      }
    }

    for (Spectator s : ServerGames.spectators) {
      if (!s.player.isDead()) s.player.teleport(ServerGames.getCorn());
    }

    clearAll();
    load();

    state = State.DEATHMATCH;
    game = new Deathmatch(this);

    startTimer();
  }
示例#6
0
  @SuppressWarnings("unchecked")
  public void load() {
    for (String s : worlds) {
      //////////// --------- Tubes ------------ ///////////////
      try {
        ObjectInputStream ois =
            new ObjectInputStream(new FileInputStream(path + File.separator + s + "Tubes.loc"));
        Object result = ois.readObject();

        ArrayList<String> t = new ArrayList<String>();
        t = (ArrayList<String>) result;

        ArrayList<Location> holder = new ArrayList<Location>();

        for (String x : t) {
          String[] split = x.split(",");
          holder.add(
              new Location(
                  server.getWorld(split[0]), toInt(split[1]), toInt(split[2]), toInt(split[3])));
        }

        tubes.put(s, holder);

        if (tubes == null || tubes.get(s) == null) {
          tubes.put(s, new ArrayList<Location>());
        }
      } catch (Exception e) {
        // e.printStackTrace();
      }
      //////////// --------- Tubes End ------------ ///////////////
      //////////// --------- cornucopia ------------ ///////////////
      try {
        ObjectInputStream ois =
            new ObjectInputStream(new FileInputStream(path + File.separator + s + "Corn.loc"));
        Object result = ois.readObject();

        String[] split = ((String) result).split(",");
        Location c =
            new Location(
                server.getWorld(split[0]), toInt(split[1]), toInt(split[2]), toInt(split[3]));

        ServerGames.cornucopia.put(s, c);
      } catch (Exception e) {
        // e.printStackTrace();
      }
      //////////// --------- cornucopia End ------------ ///////////////
    }

    //////////// --------- Score ------------ ///////////////
    try {
      ObjectInputStream ois =
          new ObjectInputStream(new FileInputStream(path + File.separator + "Score.loc"));
      Object result = ois.readObject();

      score = (HashMap<String, Integer>) result;
    } catch (Exception e) {
      // e.printStackTrace();
    }
    //////////// --------- Score End ------------ ///////////////
    //////////// --------- Waiting ------------ ///////////////
    try {
      ObjectInputStream ois =
          new ObjectInputStream(new FileInputStream(path + File.separator + "Wait.loc"));
      Object result = ois.readObject();

      String[] split = ((String) result).split(",");
      Location w =
          new Location(
              server.getWorld(split[0]), toInt(split[1]), toInt(split[2]), toInt(split[3]));

      ServerGames.waiting = w;
    } catch (Exception e) {
      // e.printStackTrace();
    }
    //////////// --------- Waiting End ------------ ///////////////
    //////////// --------- Shop ------------ ///////////////
    try {
      ObjectInputStream ois =
          new ObjectInputStream(new FileInputStream(path + File.separator + "Shops.loc"));
      Object result = ois.readObject();

      ArrayList<String> it = ((ArrayList<String>) result);

      for (String i : it) {
        String[] split = i.split(",");
        int id = Integer.parseInt(split[0]);
        int score = Integer.parseInt(split[1]);
        Location w =
            new Location(
                server.getWorld(split[2]), toInt(split[3]), toInt(split[4]), toInt(split[5]));

        items.add(new ShopItem(w.getWorld().getBlockAt(w), id, score));
      }
    } catch (Exception e) {
      // e.printStackTrace();
    }
    //////////// --------- Shop End ------------ ///////////////
    //////////// --------- Shop ------------ ///////////////
    try {
      ObjectInputStream ois =
          new ObjectInputStream(new FileInputStream(path + File.separator + "Shop.loc"));
      Object result = ois.readObject();

      String[] split = ((String) result).split(",");
      Location s =
          new Location(
              server.getWorld(split[0]), toInt(split[1]), toInt(split[2]), toInt(split[3]));

      ServerGames.shop = s;
    } catch (Exception e) {
      // e.printStackTrace();
    }
    //////////// --------- Shop End ------------ ///////////////
  }
示例#7
0
  @SuppressWarnings("unused")
  public void onEnable() {
    if (getConfig().contains("worlds")) {
      String w = getConfig().getString("worlds");
      for (String s : w.split(" ")) {
        worlds.add(s);
        System.out.println(s + " added!");
      }
    } else {
      getConfig().set("worlds", "");
      saveConfig();
    }

    current = worlds.get(0);

    if (getConfig().contains("min-to-start")) {
      int mts = getConfig().getInt("min-to-start");
      min = mts;
    } else {
      getConfig().set("min-to-start", "");
      saveConfig();
    }

    final PluginManager pm = getServer().getPluginManager();
    final Plugin plugin = pm.getPlugin("LogBlock");

    server = this.getServer();
    log = this.getLogger();

    server.getPluginManager().registerEvents(Listener, this);

    new File(path).mkdir();
    load();

    hardResetPlayers();
    tpAll(waiting);

    // cornucopia.getWorld().setAutoSave(false);

    CommandExec cmd = new CommandExec(this);
    this.getCommand("start").setExecutor(cmd);
    this.getCommand("sgstart").setExecutor(cmd);
    this.getCommand("end").setExecutor(cmd);
    this.getCommand("dm").setExecutor(cmd);
    this.getCommand("edit").setExecutor(cmd);
    this.getCommand("bet").setExecutor(cmd);
    this.getCommand("bets").setExecutor(cmd);
    this.getCommand("score").setExecutor(cmd);
    this.getCommand("to").setExecutor(cmd);
    this.getCommand("setWait").setExecutor(cmd);
    this.getCommand("setCorn").setExecutor(cmd);
    this.getCommand("force").setExecutor(cmd);
    this.getCommand("sg").setExecutor(cmd);
    this.getCommand("watch").setExecutor(cmd);
    this.getCommand("see").setExecutor(cmd);
    this.getCommand("spec").setExecutor(cmd);
    this.getCommand("setmin").setExecutor(cmd);
    this.getCommand("addworld").setExecutor(cmd);
    this.getCommand("delworld").setExecutor(cmd);
    this.getCommand("map").setExecutor(cmd);
    this.getCommand("show").setExecutor(cmd);
    this.getCommand("hide").setExecutor(cmd);
    this.getCommand("shop").setExecutor(cmd);
    this.getCommand("toshop").setExecutor(cmd);
    this.getCommand("setshop").setExecutor(cmd);
    this.getCommand("quit").setExecutor(cmd);
    this.getCommand("join").setExecutor(cmd);
    this.getCommand("clearshop").setExecutor(cmd);
    this.getCommand("buy").setExecutor(cmd);
    this.getCommand("redeem").setExecutor(cmd);
  }
示例#8
0
 public static void showAllFor(Player player) {
   for (Player p : server.getOnlinePlayers()) {
     player.showPlayer(p);
   }
 }
示例#9
0
 public static void hideAllFrom(Player player) {
   for (Player p : server.getOnlinePlayers()) {
     player.hidePlayer(p);
   }
 }
示例#10
0
 public static void hidePlayer(Player player) {
   for (Player p : server.getOnlinePlayers()) {
     p.hidePlayer(player);
   }
 }
示例#11
0
  public void startSetup() {
    clearAll();

    int i = 0;

    for (Player p : server.getOnlinePlayers()) {
      if (!isSpectator(p) && !isTribute(p)) {
        hidePlayer(p);
      }

      if (isTribute(p)) {
        if (i >= getTubes().size()) i = 0;

        Location to = getTubes().get(i);
        p.setHealth(20);
        p.setFoodLevel(20);
        p.setSprinting(false);
        p.setSneaking(false);
        p.setPassenger(null);
        p.setGameMode(GameMode.SURVIVAL);
        p.setFireTicks(0);
        clearItems(p);
        getTribute(p).start = to;
        p.teleport(toCenter(to));

        i++;
      }
    }

    for (String s : ServerGames.worlds) {
      World w = ServerGames.server.getWorld(s);
      w.getEntities().clear();
      w.setThundering(false);
      w.setTime(0);
      w.setWeatherDuration(0);
      w.setStorm(false);
    }

    // ----- WORLD RESETTING -----
    LogBlock logblock = (LogBlock) getServer().getPluginManager().getPlugin("LogBlock");
    QueryParams params = new QueryParams(logblock);

    params.world = getCorn().getWorld();
    params.silent = false;

    try {
      logblock.getCommandsHandler()
      .new CommandRollback(this.getServer().getConsoleSender(), params, false);
    } catch (Exception e) {
    }

    clearEnt();

    // ----- WORLD RESETTING -----

    server.broadcastMessage(DARK_AQUA + "This plugin was created by Brenhien and NerdsWBNerds.");
    server.broadcastMessage(
        DARK_AQUA
            + "Email [email protected] or tweet us (@NerdsWBNerds) with ideas or bugs you have found.");

    load();

    state = State.SET_UP;
    game = new Setup(this);

    startTimer();
  }
示例#12
0
 public void hardResetPlayers() {
   for (Player p : server.getOnlinePlayers()) {
     tributes.add(new Tribute(p));
   }
 }