Пример #1
0
  /** This method is from GPSListener, used to notify the ProximityListener. */
  public void sentenceReceived(NMEASentence sen) {
    // Check if this sentence has location info
    if (sen.getHeader().equals(GGASentence.HEADER)) {
      Coordinates cur = null;
      Location loc = null;
      try {

        loc = this.getLocation(-1);
        cur = loc.getQualifiedCoordinates();
      } catch (InterruptedException e) {
        // TODO: This method should bail properly if it fails.
        System.err.println("Fail 1");
      } catch (LocationException e) {
        // TODO: This method should bail properly if it fails.
        System.err.println("Fail 2");
      }
      for (int i = 0; i < listeners.size(); i++) {
        Object[] array = listeners.get(i);
        ProximityListener pl = (ProximityListener) array[0];
        Coordinates to = (Coordinates) array[1];
        Float rad = (Float) array[2];
        // Now check radius against coordinate and notify listener.
        if (cur.distance(to) <= rad.floatValue()) {
          // Remove this ProximityListener because it should be notified only once.
          // I prefer to do this BEFORE notifying the pl because the user might try
          // to re-add the pl in proximityEvent().
          LocationProvider.removeProximityListener(pl);
          pl.proximityEvent(to, loc);
        }
      }

      // TODO: Handle LocationListeners here instead of inner?
    }
  }
 /** if this line can not be current => stepOver & return true. return false on the other hand. */
 boolean resolveCanBeCurrent(ThreadReference tr) {
   try {
     Location l = tr.frame(0).location();
     if (l == null) return false;
     return resolveCanBeCurrent(
         tr, Utils.getLineForSource(l.declaringType().name(), l.sourceName(), l.lineNumber()));
   } catch (Exception e) {
   }
   return false;
 }
Пример #3
0
  private Orderable parseMove(ParseContext pc, OrderPrefix op, final String[] tokens)
      throws OrderException {
    /*

    	3-StP: Army St Petersburg -> Moscow.  (*bounce*)

    	1-Smy: Army Constantinople -> Aegean Sea -> Greece.


    	keep parsing Locations until END or a -> is reached.
    	so we keep looking for a -> until no more are found.

    	if we have more than one, we'll add them to a list
    	and then add that to the order Move order.
    */

    LinkedList pathList = new LinkedList();
    int idx = op.tokenIndex;
    int movTokIdx = findNextMoveToken(idx, tokens);

    while (movTokIdx != -1) {
      Location loc = parseLocation(pc, idx, movTokIdx, tokens);
      pathList.addLast(loc.getProvince());

      idx = movTokIdx + 1;
      movTokIdx = findNextMoveToken(idx, tokens);
    }

    // add last location
    final Location loc = parseLocation(pc, idx, tokens.length, tokens);
    pathList.addLast(loc.getProvince());

    // create Move order
    if (pathList.size() == 1) {
      if (pc.isRetreatPhase()) {
        return pc.orderFactory.createRetreat(op.power, op.location, op.unit, loc);
      } else {
        return pc.orderFactory.createMove(op.power, op.location, op.unit, loc);
      }
    } else if (pathList.size() > 1) {
      if (pc.isRetreatPhase()) {
        throw new OrderException("Convoyed Retreat orders are not allowed. Order: " + pc.orderText);
      }

      // add source location at beginning of move list
      pathList.addFirst(op.location.getProvince());

      final Province[] route = (Province[]) pathList.toArray(new Province[pathList.size()]);

      return pc.orderFactory.createMove(op.power, op.location, op.unit, loc, route);
    } else {
      // this probably will not occur....
      throw new OrderException("Invalid movement path in Move order: " + pc.orderText);
    }
  } // parseMove()
  /**
   * Calculates whether certain Location is suitable for spawning a new Building (out of bounds,
   * overlapping)
   *
   * @param loc Location that should be checked
   * @return Boolean indicating elgibility to spawn new Building
   * @see Building
   */
  public Boolean checkPositionElgibility(Location loc) {
    for (Building b : WorldManager.getInstance().getBuildings()) {
      if (loc.X() >= b.getPosition().X() - SimulationConfig.getBuildingSpriteWidth()
          && loc.X() <= b.getPosition().X() + SimulationConfig.getBuildingSpriteWidth()
          && loc.Y() >= b.getPosition().Y() - SimulationConfig.getBuildingSpriteHeight()
          && loc.Y() <= b.getPosition().Y() + SimulationConfig.getBuildingSpriteHeight())
        return false;
    }

    return true;
  }
  public void move() {
    if (last_move_time == null || last_move_time.doubleValue() < world.time) {
      last_move_time = new Double(world.time);
      double max_dist, dist_right, dist_left, theta, x, y, dist_diff;
      double delta_theta, turn_radius, new_theta, new_x, new_y;
      Location location;
      Orientation orientation;

      orientation = orientation();
      location = location();

      max_dist = max_speed / world.ticks_per_second;
      dist_right = right_motor.output() * max_dist;
      dist_left = left_motor.output() * max_dist;
      theta = orientation.theta;
      x = location.x;
      y = location.y;
      old_location.x = x;
      old_location.y = y;
      dist_diff = dist_right - dist_left;

      //			System.out.println("dist_diff: " + dist_diff);

      delta_theta = dist_diff / wheel_base;
      if (Math.abs(dist_diff) < .0001) {
        turn_radius = 0.0;
      } else {
        turn_radius = (dist_right / delta_theta) - (wheel_base / 2);
      }

      //			System.out.println("turn_radius: " + turn_radius);

      new_theta = theta + delta_theta;
      if (turn_radius == 0.0) {

        //				System.out.println("turn_radius == 0");

        new_x = x + Math.cos(theta) * dist_left;
        new_y = y + Math.sin(theta) * dist_left;
      } else {

        //				System.out.println("new_theta= " + new_theta + " theta= " + theta);

        new_x = x + ((Math.sin(new_theta) - Math.sin(theta)) * turn_radius);
        new_y = y - ((Math.cos(new_theta) - Math.cos(theta)) * turn_radius);
      }
      orientation.theta = new_theta;
      location.x = new_x;
      location.y = new_y;

      maybe_fire_guns();
    }
  }
Пример #6
0
 public WorldEditorException(final String msg, final Location loc) {
   super(
       msg
           + " at "
           + loc.getWorld().getName()
           + ":"
           + loc.getBlockX()
           + ":"
           + loc.getBlockY()
           + ":"
           + loc.getBlockZ());
   this.loc = loc;
 }
Пример #7
0
  static synchronized String sourceLine(Location location, int lineNumber) throws IOException {
    if (lineNumber == -1) {
      throw new IllegalArgumentException();
    }

    try {
      String fileName = location.sourceName();

      Iterator<SourceCode> iter = sourceCache.iterator();
      SourceCode code = null;
      while (iter.hasNext()) {
        SourceCode candidate = iter.next();
        if (candidate.fileName().equals(fileName)) {
          code = candidate;
          iter.remove();
          break;
        }
      }
      if (code == null) {
        BufferedReader reader = sourceReader(location);
        if (reader == null) {
          throw new FileNotFoundException(fileName);
        }
        code = new SourceCode(fileName, reader);
        if (sourceCache.size() == SOURCE_CACHE_SIZE) {
          sourceCache.remove(sourceCache.size() - 1);
        }
      }
      sourceCache.add(0, code);
      return code.sourceLine(lineNumber);
    } catch (AbsentInformationException e) {
      throw new IllegalArgumentException();
    }
  }
Пример #8
0
    public int compareTo(Object other) {
      int thisLoc = mStart.getLocation();
      int thatLoc = ((Entry) other).mStart.getLocation();

      if (thisLoc < thatLoc) {
        return -1;
      } else if (thisLoc > thatLoc) {
        return 1;
      } else {
        return 0;
      }
    }
 public void testLocation() throws Exception {
   JSONArray array = getJSONArrayFromClassPath("/dao/trends-available.json");
   ResponseList<Location> locations =
       LocationJSONImpl.createLocationList(array, conf.isJSONStoreEnabled());
   Assert.assertEquals(23, locations.size());
   Location location = locations.get(0);
   Assert.assertEquals("GB", location.getCountryCode());
   Assert.assertEquals("United Kingdom", location.getCountryName());
   Assert.assertEquals("United Kingdom", location.getName());
   Assert.assertEquals(12, location.getPlaceCode());
   Assert.assertEquals("Country", location.getPlaceName());
   Assert.assertEquals("http://where.yahooapis.com/v1/place/23424975", location.getURL());
   Assert.assertEquals(23424975, location.getWoeid());
 }
Пример #10
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());
 }
Пример #11
0
 private void dumpStack(ThreadReference thread, boolean showPC) {
   // ### Check for these.
   // env.failure("Thread no longer exists.");
   // env.failure("Target VM must be in interrupted state.");
   // env.failure("Current thread isn't suspended.");
   // ### Should handle extremely long stack traces sensibly for user.
   List<StackFrame> stack = null;
   try {
     stack = thread.frames();
   } catch (IncompatibleThreadStateException e) {
     env.failure("Thread is not suspended.");
   }
   // ### Fix this!
   // ### Previously mishandled cases where thread was not current.
   // ### Now, prints all of the stack regardless of current frame.
   int frameIndex = 0;
   // int frameIndex = context.getCurrentFrameIndex();
   if (stack == null) {
     env.failure("Thread is not running (no stack).");
   } else {
     OutputSink out = env.getOutputSink();
     int nFrames = stack.size();
     for (int i = frameIndex; i < nFrames; i++) {
       StackFrame frame = stack.get(i);
       Location loc = frame.location();
       Method meth = loc.method();
       out.print("  [" + (i + 1) + "] ");
       out.print(meth.declaringType().name());
       out.print('.');
       out.print(meth.name());
       out.print(" (");
       if (meth.isNative()) {
         out.print("native method");
       } else if (loc.lineNumber() != -1) {
         try {
           out.print(loc.sourceName());
         } catch (AbsentInformationException e) {
           out.print("<unknown>");
         }
         out.print(':');
         out.print(loc.lineNumber());
       }
       out.print(')');
       if (showPC) {
         long pc = loc.codeIndex();
         if (pc != -1) {
           out.print(", pc = " + pc);
         }
       }
       out.println();
     }
     out.show();
   }
 }
Пример #12
0
  /** Executes breakpoint hit event. */
  public void exec(com.sun.jdi.event.Event ev) {
    // S ystem.out.println ("exec "); // NOI18N
    removeStepRequest();
    StepEvent event = (StepEvent) ev;
    ThreadReference tr = event.thread();
    Location loc = event.location();
    int ln = -1;
    String methodName = "?"; // NOI18N
    String className = "?"; // NOI18N
    String lineNumber = "?"; // NOI18N
    String threadName = tr.name();
    Line l = null;

    if (loc != null) {
      if (loc.method() != null) methodName = loc.method().name();
      className = loc.declaringType().name();
      ln = loc.lineNumber();
      if (ln >= 0) lineNumber = "" + loc.lineNumber();
    }

    if (ln != -1)
      try {
        l = Utils.getLineForSource(className, loc.sourceName(), ln);
      } catch (AbsentInformationException e) {
        l = Utils.getLine(className, ln);
      }

    if (resolveCanBeCurrent(tr, l))
      // if this line can not be current resolveCanBeCurrent () calls stepOver
      return;
    // line can be current

    if ((l == null) && (getLastAction() == ACTION_TRACE_INTO))
      // try to find another "intelligent" line of code
      traceToSourceCode(tr);
    // you know - intelligent means that one with source code
    else {
      makeCurrent(threadName, className, methodName, lineNumber, l != null, tr);
      operator.stopRequest();
    }
  }
Пример #13
0
 public static Location toCenter(Location l) {
   return new Location(l.getWorld(), l.getBlockX() + .5, l.getBlockY() + 1, l.getBlockZ() + .5);
 }
Пример #14
0
 private void commandList(StringTokenizer t) throws NoSessionException {
   ThreadReference current = context.getCurrentThread();
   if (current == null) {
     env.error("No thread specified.");
     return;
   }
   Location loc;
   try {
     StackFrame frame = context.getCurrentFrame(current);
     if (frame == null) {
       env.failure("Thread has not yet begun execution.");
       return;
     }
     loc = frame.location();
   } catch (VMNotInterruptedException e) {
     env.failure("Target VM must be in interrupted state.");
     return;
   }
   SourceModel source = sourceManager.sourceForLocation(loc);
   if (source == null) {
     if (loc.method().isNative()) {
       env.failure("Current method is native.");
       return;
     }
     env.failure("No source available for " + Utils.locationString(loc) + ".");
     return;
   }
   ReferenceType refType = loc.declaringType();
   int lineno = loc.lineNumber();
   if (t.hasMoreTokens()) {
     String id = t.nextToken();
     // See if token is a line number.
     try {
       lineno = Integer.valueOf(id).intValue();
     } catch (NumberFormatException nfe) {
       // It isn't -- see if it's a method name.
       List<Method> meths = refType.methodsByName(id);
       if (meths == null || meths.size() == 0) {
         env.failure(
             id + " is not a valid line number or " + "method name for class " + refType.name());
         return;
       } else if (meths.size() > 1) {
         env.failure(id + " is an ambiguous method name in" + refType.name());
         return;
       }
       loc = meths.get(0).location();
       lineno = loc.lineNumber();
     }
   }
   int startLine = (lineno > 4) ? lineno - 4 : 1;
   int endLine = startLine + 9;
   String sourceLine = source.sourceLine(lineno);
   if (sourceLine == null) {
     env.failure("" + lineno + " is an invalid line number for " + refType.name());
   } else {
     OutputSink out = env.getOutputSink();
     for (int i = startLine; i <= endLine; i++) {
       sourceLine = source.sourceLine(i);
       if (sourceLine == null) {
         break;
       }
       out.print(i);
       out.print("\t");
       if (i == lineno) {
         out.print("=> ");
       } else {
         out.print("   ");
       }
       out.println(sourceLine);
     }
     out.show();
   }
 }
Пример #15
0
  /**
   * Move through a list of stack frames, searching for references to code found in the current
   * sketch. Return with a RunnerException that contains the location of the error, or if nothing is
   * found, just return with a RunnerException that wraps the error message itself.
   */
  protected SketchException findException(
      String message, ObjectReference or, ThreadReference thread) {
    try {
      // use to dump the stack for debugging
      //      for (StackFrame frame : thread.frames()) {
      //        System.out.println("frame: " + frame);
      //      }

      List<StackFrame> frames = thread.frames();
      for (StackFrame frame : frames) {
        try {
          Location location = frame.location();
          String filename = null;
          filename = location.sourceName();
          int lineNumber = location.lineNumber() - 1;
          SketchException rex = build.placeException(message, filename, lineNumber);
          if (rex != null) {
            return rex;
          }
        } catch (AbsentInformationException e) {
          // Any of the thread.blah() methods can throw an AbsentInformationEx
          // if that bit of data is missing. If so, just write out the error
          // message to the console.
          // e.printStackTrace();  // not useful
          exception = new SketchException(message);
          exception.hideStackTrace();
          listener.statusError(exception);
        }
      }
    } catch (IncompatibleThreadStateException e) {
      // This shouldn't happen, but if it does, print the exception in case
      // it's something that needs to be debugged separately.
      e.printStackTrace();
    }
    // before giving up, try to extract from the throwable object itself
    // since sometimes exceptions are re-thrown from a different context
    try {
      // assume object reference is Throwable, get stack trace
      Method method =
          ((ClassType) or.referenceType())
              .concreteMethodByName("getStackTrace", "()[Ljava/lang/StackTraceElement;");
      ArrayReference result =
          (ArrayReference)
              or.invokeMethod(
                  thread, method, new ArrayList<Value>(), ObjectReference.INVOKE_SINGLE_THREADED);
      // iterate through stack frames and pull filename and line number for each
      for (Value val : result.getValues()) {
        ObjectReference ref = (ObjectReference) val;
        method =
            ((ClassType) ref.referenceType())
                .concreteMethodByName("getFileName", "()Ljava/lang/String;");
        StringReference strref =
            (StringReference)
                ref.invokeMethod(
                    thread, method, new ArrayList<Value>(), ObjectReference.INVOKE_SINGLE_THREADED);
        String filename = strref == null ? "Unknown Source" : strref.value();
        method = ((ClassType) ref.referenceType()).concreteMethodByName("getLineNumber", "()I");
        IntegerValue intval =
            (IntegerValue)
                ref.invokeMethod(
                    thread, method, new ArrayList<Value>(), ObjectReference.INVOKE_SINGLE_THREADED);
        int lineNumber = intval.intValue() - 1;
        SketchException rex = build.placeException(message, filename, lineNumber);
        if (rex != null) {
          return rex;
        }
      }
      //      for (Method m : ((ClassType) or.referenceType()).allMethods()) {
      //        System.out.println(m + " | " + m.signature() + " | " + m.genericSignature());
      //      }
      // Implemented for 2.0b9, writes a stack trace when there's an internal error inside core.
      method = ((ClassType) or.referenceType()).concreteMethodByName("printStackTrace", "()V");
      //      System.err.println("got method " + method);
      or.invokeMethod(
          thread, method, new ArrayList<Value>(), ObjectReference.INVOKE_SINGLE_THREADED);

    } catch (Exception e) {
      e.printStackTrace();
    }
    // Give up, nothing found inside the pile of stack frames
    SketchException rex = new SketchException(message);
    // exception is being created /here/, so stack trace is not useful
    rex.hideStackTrace();
    return rex;
  }
Пример #16
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 ------------ ///////////////
  }
Пример #17
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 ------------ ///////////////
  }
Пример #18
0
 /** Get source object associated with a Location. */
 public SourceModel sourceForLocation(Location loc) {
   return sourceForClass(loc.declaringType());
 }
Пример #19
0
 public boolean equals(Object other) {
   if (other instanceof Entry) {
     return mStart.getLocation() == ((Entry) other).mStart.getLocation();
   }
   return false;
 }
Пример #20
0
 public String toString() {
   return "start_pc=" + mStart.getLocation() + " => " + "line_number=" + mLineNumber;
 }