Merge branch 'master' of github.com:cabaletta/baritone

This commit is contained in:
Leijurv 2018-08-23 12:54:23 -07:00
commit e9308d7e70
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 5 additions and 11 deletions

View File

@ -32,7 +32,7 @@ import java.util.Map;
public class Waypoint {
public final String name;
public final Tag tag;
public final long creationTimestamp;
private final long creationTimestamp;
public final BlockPos location;
public Waypoint(String name, Tag tag, BlockPos location) {

View File

@ -79,11 +79,11 @@ public class Waypoints {
try (
FileOutputStream fileOut = new FileOutputStream(fileName.toFile());
BufferedOutputStream bufOut = new BufferedOutputStream(fileOut);
DataOutputStream out = new DataOutputStream(bufOut);
DataOutputStream out = new DataOutputStream(bufOut)
) {
for (Waypoint waypoint : waypoints.get(tag)) {
out.writeUTF(waypoint.name);
out.writeLong(waypoint.creationTimestamp);
out.writeLong(waypoint.creationTimestamp());
out.writeInt(waypoint.location.getX());
out.writeInt(waypoint.location.getY());
out.writeInt(waypoint.location.getZ());
@ -98,14 +98,8 @@ public class Waypoints {
}
public Waypoint getMostRecentByTag(Waypoint.Tag tag) {
Set<Waypoint> pts = waypoints.get(tag);
Waypoint best = null;
for (Waypoint waypoint : pts) {
if (best == null || waypoint.creationTimestamp > best.creationTimestamp) {
best = waypoint;
}
}
return best;
// Find a waypoint of the given tag which has the greatest timestamp value, indicating the most recent
return this.waypoints.get(tag).stream().min(Comparator.comparingLong(w -> -w.creationTimestamp())).orElse(null);
}
public void addWaypoint(Waypoint waypoint) {