3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-20 01:40:06 +01:00

all hsitory types can summarize

Dieser Commit ist enthalten in:
Jesse Boyd 2020-01-06 09:06:38 +00:00
Ursprung 195c4a7647
Commit 9623c5cb3f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
4 geänderte Dateien mit 34 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -399,6 +399,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
return new SimpleChangeSetSummary(getOriginX(), getOriginZ());
}
@Override
public SimpleChangeSetSummary summarize(Region region, boolean shallow) {
if (bdFile.exists()) {
int ox = getOriginX();

Datei anzeigen

@ -1,3 +1,5 @@
package com.boydti.fawe.object.changeset;
import com.sk89q.worldedit.history.changeset.ChangeSetSummary;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache;
@ -14,6 +16,14 @@ public class SimpleChangeSetSummary implements ChangeSetSummary {
public int maxX;
public int maxZ;
public SimpleChangeSetSummary() {
blocks = new int[BlockTypesCache.states.length];
this.minX = Integer.MAX_VALUE;
this.minZ = Integer.MAX_VALUE;
this.maxX = Integer.MIN_VALUE;
this.maxZ = Integer.MIN_VALUE;
}
public SimpleChangeSetSummary(int x, int z) {
blocks = new int[BlockTypesCache.states.length];
minX = x;

Datei anzeigen

@ -21,8 +21,12 @@ package com.sk89q.worldedit.history.changeset;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.object.changeset.SimpleChangeSetSummary;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.history.change.BlockChange;
import com.sk89q.worldedit.history.change.Change;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import java.util.ArrayList;
import java.util.Iterator;
@ -70,4 +74,16 @@ public class ArrayListHistory implements ChangeSet {
return changes.size();
}
@Override
public ChangeSetSummary summarize(Region region, boolean shallow) {
SimpleChangeSetSummary summary = new SimpleChangeSetSummary();
for (Change change : changes) {
if (change instanceof BlockChange) {
BlockChange blockChange = (BlockChange) change;
BlockVector3 pos = blockChange.getPosition();
summary.add(pos.getX(), pos.getZ(), blockChange.getCurrent().getOrdinal());
}
}
return summary;
}
}

Datei anzeigen

@ -97,19 +97,13 @@ public interface ChangeSet extends Closeable {
*/
default void delete() {}
ChangeSetSummary summarize(Region region, boolean shallow) {
return new ChangeSetSummary() {
@Override
public Map<BlockState, Integer> getBlocks() {
return Collections.emptyMap();
}
@Override
public int getSize() {
return size();
}
};
}
/**
* Get a summary of this changeset
* @param region
* @param shallow
* @return
*/
ChangeSetSummary summarize(Region region, boolean shallow);
/**
* Get if the changeset is empty (i.e. size == 0)