コード例 #1
0
 public void setProperty(final String path, final Location loc) {
   set((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
   set((path == null ? "" : path + ".") + "x", loc.getX());
   set((path == null ? "" : path + ".") + "y", loc.getY());
   set((path == null ? "" : path + ".") + "z", loc.getZ());
   set((path == null ? "" : path + ".") + "yaw", loc.getYaw());
   set((path == null ? "" : path + ".") + "pitch", loc.getPitch());
 }
コード例 #2
0
 public WorldEditorException(final String msg, final Location loc) {
   super(
       msg
           + " at "
           + loc.getWorld().getName()
           + ":"
           + loc.getBlockX()
           + ":"
           + loc.getBlockY()
           + ":"
           + loc.getBlockZ());
   this.loc = loc;
 }
コード例 #3
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 ------------ ///////////////
  }
コード例 #4
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 ------------ ///////////////
  }
コード例 #5
0
 public static Location toCenter(Location l) {
   return new Location(l.getWorld(), l.getBlockX() + .5, l.getBlockY() + 1, l.getBlockZ() + .5);
 }