mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Fixes #126
This commit is contained in:
parent
a523ef8176
commit
aaa39d1d32
@ -79,16 +79,12 @@ public class Rollback extends FaweCommand {
|
|||||||
long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000;
|
long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000;
|
||||||
total += edit.getBDFile().length();
|
total += edit.getBDFile().length();
|
||||||
int size = summary.getSize();
|
int size = summary.getSize();
|
||||||
Map<Integer, Double> percents = summary.getPercents();
|
Map<BlockState, Double> percents = summary.getPercents();
|
||||||
StringBuilder percentString = new StringBuilder();
|
StringBuilder percentString = new StringBuilder();
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
for (Map.Entry<Integer, Double> entry : percents.entrySet()) {
|
for (Map.Entry<BlockState, Double> entry : percents.entrySet()) {
|
||||||
int id = entry.getKey();
|
BlockState state = entry.getKey();
|
||||||
BlockStateHolder state = null;
|
String itemName = "#" + state;
|
||||||
try {
|
|
||||||
state = BlockState.getFromInternalId(id);
|
|
||||||
} catch (Throwable ignore) {};
|
|
||||||
String itemName = state == null ? "#" + id : state.getAsString();
|
|
||||||
percentString.append(prefix).append(entry.getValue()).append("% ").append(itemName);
|
percentString.append(prefix).append(entry.getValue()).append("% ").append(itemName);
|
||||||
prefix = ", ";
|
prefix = ", ";
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ import com.sk89q.jnbt.NBTOutputStream;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.World;
|
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 it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -18,6 +20,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -455,7 +458,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
|||||||
public int maxZ;
|
public int maxZ;
|
||||||
|
|
||||||
public DiskStorageSummary(int x, int z) {
|
public DiskStorageSummary(int x, int z) {
|
||||||
blocks = new int[256];
|
blocks = new int[BlockTypes.states.length];
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
minX = x;
|
minX = x;
|
||||||
@ -465,7 +468,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(int x, int z, int id) {
|
public void add(int x, int z, int id) {
|
||||||
blocks[id]++;
|
blocks[BlockState.getFromInternalId(id).getOrdinal()]++;
|
||||||
if (x < minX) {
|
if (x < minX) {
|
||||||
minX = x;
|
minX = x;
|
||||||
} else if (x > maxX) {
|
} else if (x > maxX) {
|
||||||
@ -478,22 +481,23 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, Integer> getBlocks() {
|
public Map<BlockState, Integer> getBlocks() {
|
||||||
Int2ObjectOpenHashMap<Integer> map = new Int2ObjectOpenHashMap<>();
|
HashMap<BlockState, Integer> map = new HashMap<>();
|
||||||
for (int i = 0; i < blocks.length; i++) {
|
for (int i = 0; i < blocks.length; i++) {
|
||||||
if (blocks[i] != 0) {
|
if (blocks[i] != 0) {
|
||||||
map.put(i, (Integer) blocks[i]);
|
BlockState state = BlockTypes.states[i];
|
||||||
|
map.put(state, (Integer) blocks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, Double> getPercents() {
|
public Map<BlockState, Double> getPercents() {
|
||||||
Map<Integer, Integer> map = getBlocks();
|
Map<BlockState, Integer> map = getBlocks();
|
||||||
int count = getSize();
|
int count = getSize();
|
||||||
Int2ObjectOpenHashMap<Double> newMap = new Int2ObjectOpenHashMap<>();
|
Map<BlockState, Double> newMap = new HashMap<>();
|
||||||
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
|
for (Map.Entry<BlockState, Integer> entry : map.entrySet()) {
|
||||||
int id = entry.getKey();
|
BlockState id = entry.getKey();
|
||||||
int changes = entry.getValue();
|
int changes = entry.getValue();
|
||||||
double percent = ((changes * 1000l) / count) / 10d;
|
double percent = ((changes * 1000l) / count) / 10d;
|
||||||
newMap.put(id, (Double) percent);
|
newMap.put(id, (Double) percent);
|
||||||
|
Loading…
Reference in New Issue
Block a user