Esempio n. 1
0
 public WorldEditorException(final String msg, final Location loc) {
   super(
       msg
           + " at "
           + loc.getWorld().getName()
           + ":"
           + loc.getBlockX()
           + ":"
           + loc.getBlockY()
           + ":"
           + loc.getBlockZ());
   this.loc = loc;
 }
Esempio n. 2
0
  public void save() {
    File file = null;
    for (String s : worlds) {
      //////////// --------- Tubes ------------ ///////////////
      if (tubes != null && tubes.get(s) != null) {
        file = new File(path + File.separator + s + "Tubes.loc");
        new File(path).mkdir();
        if (!file.exists()) {
          try {
            file.createNewFile();
          } catch (IOException e) {
            // e.printStackTrace();
          }
        }

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

        for (Location x : tubes.get(s)) {
          t.add(
              x.getWorld().getName()
                  + ","
                  + x.getBlockX()
                  + ","
                  + x.getBlockY()
                  + ","
                  + x.getBlockZ());
        }

        try {
          ObjectOutputStream oos =
              new ObjectOutputStream(new FileOutputStream(path + File.separator + s + "Tubes.loc"));
          oos.writeObject(t);
          oos.flush();
          oos.close();
        } catch (Exception e) {
          // e.printStackTrace();
        }
      }

      //////////// --------- Tubes End ------------ ///////////////
      //////////// --------- cornucopia ------------ ///////////////

      if (cornucopia.get(s) != null) {
        file = new File(path + File.separator + s + "Corn.loc");
        new File(path).mkdir();
        if (!file.exists()) {
          try {
            file.createNewFile();
          } catch (IOException e) {
            // e.printStackTrace();
          }
        }

        String c = "";
        c =
            (cornucopia.get(s).getWorld().getName()
                + ","
                + cornucopia.get(s).getBlockX()
                + ","
                + cornucopia.get(s).getBlockY()
                + ","
                + cornucopia.get(s).getBlockZ());

        cornucopia
            .get(s)
            .getWorld()
            .setSpawnLocation(
                cornucopia.get(s).getBlockX(),
                cornucopia.get(s).getBlockY(),
                cornucopia.get(s).getBlockZ());

        try {
          ObjectOutputStream oos =
              new ObjectOutputStream(new FileOutputStream(path + File.separator + s + "Corn.loc"));
          oos.writeObject(c);
          oos.flush();
          oos.close();
        } catch (Exception e) {
          // e.printStackTrace();
        }
      }
      //////////// --------- cornucopia End ------------ ///////////////
    }

    //////////// --------- Waiting ------------ ///////////////
    if (waiting != null) {
      file = new File(path + File.separator + "Wait.loc");
      new File(path).mkdir();
      if (!file.exists()) {
        try {
          file.createNewFile();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      String w = "";
      w =
          (waiting.getWorld().getName()
              + ","
              + waiting.getBlockX()
              + ","
              + waiting.getBlockY()
              + ","
              + waiting.getBlockZ());

      try {
        ObjectOutputStream oos =
            new ObjectOutputStream(new FileOutputStream(path + File.separator + "Wait.loc"));
        oos.writeObject(w);
        oos.flush();
        oos.close();
      } catch (Exception e) {
        // e.printStackTrace();
      }
    }

    //////////// --------- Waiting End ------------ ///////////////
    //////////// --------- Score ------------ ///////////////

    if (score != null) {
      file = new File(path + File.separator + "Score.loc");
      new File(path).mkdir();
      if (!file.exists()) {
        try {
          file.createNewFile();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      try {
        ObjectOutputStream oos =
            new ObjectOutputStream(new FileOutputStream(path + File.separator + "Score.loc"));
        oos.writeObject(score);
        oos.flush();
        oos.close();
      } catch (Exception e) {
        // e.printStackTrace();
      }
    }
    //////////// --------- Score End ------------ ///////////////
    //////////// --------- Shops ------------ ///////////////

    if (items != null) {
      file = new File(path + File.separator + "Shops.loc");
      new File(path).mkdir();
      if (!file.exists()) {
        try {
          file.createNewFile();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

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

      for (ShopItem i : items) {
        String ss =
            i.id
                + ","
                + i.price
                + ","
                + i.holder.getLocation().getWorld().getName()
                + ","
                + i.holder.getLocation().getX()
                + ","
                + i.holder.getLocation().getY()
                + ","
                + i.holder.getLocation().getZ();
        it.add(ss);
      }

      try {
        ObjectOutputStream oos =
            new ObjectOutputStream(new FileOutputStream(path + File.separator + "Shops.loc"));
        oos.writeObject(it);
        oos.flush();
        oos.close();
      } catch (Exception e) {
        // e.printStackTrace();
      }
    }
    //////////// --------- Shops End ------------ ///////////////
    //////////// --------- Shop ------------ ///////////////
    if (waiting != null) {
      file = new File(path + File.separator + "Shop.loc");
      new File(path).mkdir();
      if (!file.exists()) {
        try {
          file.createNewFile();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      String s = "";
      s =
          (shop.getWorld().getName()
              + ","
              + shop.getBlockX()
              + ","
              + shop.getBlockY()
              + ","
              + shop.getBlockZ());

      try {
        ObjectOutputStream oos =
            new ObjectOutputStream(new FileOutputStream(path + File.separator + "Shop.loc"));
        oos.writeObject(s);
        oos.flush();
        oos.close();
      } catch (Exception e) {
        // e.printStackTrace();
      }
    }

    //////////// --------- Shop End ------------ ///////////////
  }
Esempio n. 3
0
 public static Location toCenter(Location l) {
   return new Location(l.getWorld(), l.getBlockX() + .5, l.getBlockY() + 1, l.getBlockZ() + .5);
 }