Skip to content

Commit

Permalink
Remove cache persistence logic
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed May 2, 2020
1 parent ba31206 commit 5bb346e
Showing 1 changed file with 0 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import org.bukkit.util.Vector;

import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

Expand Down Expand Up @@ -132,22 +130,6 @@ public void load(DataKey key) {
continue;
waypoints.add(waypoint);
}
for (DataKey root : key.getRelative("cache").getSubKeys()) {
String[] parts = Iterables.toArray(Splitter.on('/').split(root.name()), String.class);
Vector to = new Vector(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
for (DataKey sub : root.getSubKeys()) {
parts = Iterables.toArray(Splitter.on('/').split(sub.name()), String.class);
Vector from = new Vector(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]),
Integer.parseInt(parts[2]));
List<Vector> points = Lists.newArrayList();
for (DataKey path : sub.getIntegerSubKeys()) {
parts = Iterables.toArray(Splitter.on('/').split(path.getString("")), String.class);
points.add(new Vector(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]),
Integer.parseInt(parts[2])));
}
cachedPaths.put(new SourceDestinationPair(from, to), points);
}
}
}

@Override
Expand All @@ -174,17 +156,6 @@ public void save(DataKey key) {
for (int i = 0; i < waypoints.size(); ++i) {
PersistenceLoader.save(waypoints.get(i), root.getRelative(i));
}
key.removeKey("cache");
if (cachePaths) {
for (Map.Entry<SourceDestinationPair, Iterable<Vector>> entry : cachedPaths.entrySet()) {
root = key.getRelative("cache." + entry.getKey().getToKey() + "." + entry.getKey().getFromKey());
Vector[] path = Iterables.toArray(entry.getValue(), Vector.class);
for (int i = 0; i < path.length; i++) {
root.setString(Integer.toString(i),
Joiner.on('/').join(path[i].getBlockX(), path[i].getBlockY(), path[i].getBlockZ()));
}
}
}
}

@Override
Expand Down

0 comments on commit 5bb346e

Please sign in to comment.