Ejemplo n.º 1
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 ------------ ///////////////
  }