diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java index 82254d7a8..31b4d2dc4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java @@ -79,16 +79,12 @@ public class Rollback extends FaweCommand { long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000; total += edit.getBDFile().length(); int size = summary.getSize(); - Map percents = summary.getPercents(); + Map percents = summary.getPercents(); StringBuilder percentString = new StringBuilder(); String prefix = ""; - for (Map.Entry entry : percents.entrySet()) { - int id = entry.getKey(); - BlockStateHolder state = null; - try { - state = BlockState.getFromInternalId(id); - } catch (Throwable ignore) {}; - String itemName = state == null ? "#" + id : state.getAsString(); + for (Map.Entry entry : percents.entrySet()) { + BlockState state = entry.getKey(); + String itemName = "#" + state; percentString.append(prefix).append(entry.getValue()).append("% ").append(itemName); prefix = ", "; } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java index 742aeb3be..4113abfe4 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java @@ -11,6 +11,8 @@ import com.sk89q.jnbt.NBTOutputStream; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.block.BlockState; +import com.sk89q.worldedit.world.block.BlockTypes; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import java.io.DataOutput; import java.io.File; @@ -18,6 +20,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -455,7 +458,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet { public int maxZ; public DiskStorageSummary(int x, int z) { - blocks = new int[256]; + blocks = new int[BlockTypes.states.length]; this.x = x; this.z = z; minX = x; @@ -465,7 +468,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet { } public void add(int x, int z, int id) { - blocks[id]++; + blocks[BlockState.getFromInternalId(id).getOrdinal()]++; if (x < minX) { minX = x; } else if (x > maxX) { @@ -478,22 +481,23 @@ public class DiskStorageHistory extends FaweStreamChangeSet { } } - public Map getBlocks() { - Int2ObjectOpenHashMap map = new Int2ObjectOpenHashMap<>(); + public Map getBlocks() { + HashMap map = new HashMap<>(); for (int i = 0; i < blocks.length; i++) { if (blocks[i] != 0) { - map.put(i, (Integer) blocks[i]); + BlockState state = BlockTypes.states[i]; + map.put(state, (Integer) blocks[i]); } } return map; } - public Map getPercents() { - Map map = getBlocks(); + public Map getPercents() { + Map map = getBlocks(); int count = getSize(); - Int2ObjectOpenHashMap newMap = new Int2ObjectOpenHashMap<>(); - for (Map.Entry entry : map.entrySet()) { - int id = entry.getKey(); + Map newMap = new HashMap<>(); + for (Map.Entry entry : map.entrySet()) { + BlockState id = entry.getKey(); int changes = entry.getValue(); double percent = ((changes * 1000l) / count) / 10d; newMap.put(id, (Double) percent);