mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Add and apply .editorconfig from P2 (#1195)
* Consistenty use javax annotations. - Unfortunately jetbrains annotations seem to be exposed transitively via core somewhere, but with the correct IDE settings, annotations can be defaulted to javax - Cleaning up of import order in #1195 - Must be merged before #1195 * Add and apply .editorconfig from P2 - Does not rearrange entries * Address some comments * add back some javadoc comments * Address final comments Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
@ -73,7 +73,10 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
}
|
||||
|
||||
private void init(UUID uuid, String worldName) {
|
||||
final File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + worldName + File.separator + uuid);
|
||||
final File folder = MainUtil.getFile(
|
||||
Fawe.imp().getDirectory(),
|
||||
Settings.IMP.PATHS.HISTORY + File.separator + worldName + File.separator + uuid
|
||||
);
|
||||
|
||||
final int max = NEXT_INDEX.computeIfAbsent(worldName, _worldName -> new ConcurrentHashMap<>())
|
||||
.compute(uuid, (_uuid, id) -> (id == null ? MainUtil.getMaxFileId(folder) : id) + 1) - 1;
|
||||
@ -105,13 +108,15 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
private void init(UUID uuid, int i) {
|
||||
this.uuid = uuid;
|
||||
this.index = i;
|
||||
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + getWorld().getName() + File.separator + uuid);
|
||||
File folder = MainUtil.getFile(
|
||||
Fawe.imp().getDirectory(),
|
||||
Settings.IMP.PATHS.HISTORY + File.separator + getWorld().getName() + File.separator + uuid
|
||||
);
|
||||
initFiles(folder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
// Fawe.debug("Deleting history: " + getWorld().getName() + "/" + uuid + "/" + index);
|
||||
deleteFiles();
|
||||
if (Settings.IMP.HISTORY.USE_DATABASE) {
|
||||
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld());
|
||||
@ -437,4 +442,5 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ package com.fastasyncworldedit.core.history;
|
||||
|
||||
import com.fastasyncworldedit.core.configuration.Settings;
|
||||
import com.fastasyncworldedit.core.history.changeset.FaweStreamChangeSet;
|
||||
import com.fastasyncworldedit.core.internal.io.FaweInputStream;
|
||||
import com.fastasyncworldedit.core.internal.io.FaweOutputStream;
|
||||
import com.fastasyncworldedit.core.internal.io.FastByteArrayOutputStream;
|
||||
import com.fastasyncworldedit.core.internal.io.FastByteArraysInputStream;
|
||||
import com.fastasyncworldedit.core.internal.io.FaweInputStream;
|
||||
import com.fastasyncworldedit.core.internal.io.FaweOutputStream;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
@ -252,4 +252,5 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
public void setRecordChanges(boolean recordChanges) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,15 @@ public class RollbackOptimizedHistory extends DiskStorageHistory {
|
||||
this.time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public RollbackOptimizedHistory(World world, UUID uuid, int index, long time, long size, CuboidRegion region, String command) {
|
||||
public RollbackOptimizedHistory(
|
||||
World world,
|
||||
UUID uuid,
|
||||
int index,
|
||||
long time,
|
||||
long size,
|
||||
CuboidRegion region,
|
||||
String command
|
||||
) {
|
||||
super(world, uuid, index);
|
||||
this.time = time;
|
||||
this.minX = region.getMinimumX();
|
||||
@ -135,4 +143,5 @@ public class RollbackOptimizedHistory extends DiskStorageHistory {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return BlockVector3.at(maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.fastasyncworldedit.core.history.change;
|
||||
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.fastasyncworldedit.core.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
|
||||
public class MutableBiomeChange implements Change {
|
||||
@ -32,4 +32,5 @@ public class MutableBiomeChange implements Change {
|
||||
public void redo(UndoContext context) throws WorldEditException {
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.get(to));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,4 +33,5 @@ public class MutableBlockChange implements Change {
|
||||
public void create(UndoContext context) {
|
||||
context.getExtent().setBlock(x, y, z, BlockState.getFromOrdinal(ordinal));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,4 +56,5 @@ public class MutableFullBlockChange implements Change {
|
||||
}
|
||||
context.getExtent().setBlock(x, y, z, fromState);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,4 +35,5 @@ public class MutableTileChange implements Change {
|
||||
int z = tag.getInt("z");
|
||||
context.getExtent().setTile(x, y, z, tag);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface StreamChange {
|
||||
|
||||
void flushChanges(FaweOutputStream out) throws IOException;
|
||||
|
||||
void undoChanges(FaweInputStream in) throws IOException;
|
||||
@ -49,4 +50,5 @@ public interface StreamChange {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,15 +2,16 @@ package com.fastasyncworldedit.core.history.changeset;
|
||||
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.extent.HistoryExtent;
|
||||
import com.fastasyncworldedit.core.extent.processor.ProcessorScope;
|
||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.queue.IChunk;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
import com.fastasyncworldedit.core.queue.IChunkSet;
|
||||
import com.fastasyncworldedit.core.extent.processor.ProcessorScope;
|
||||
import com.fastasyncworldedit.core.extent.HistoryExtent;
|
||||
import com.fastasyncworldedit.core.util.EditSessionBuilder;
|
||||
import com.fastasyncworldedit.core.util.MainUtil;
|
||||
import com.fastasyncworldedit.core.util.TaskManager;
|
||||
import com.fastasyncworldedit.core.world.block.BlockID;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -27,7 +28,6 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.fastasyncworldedit.core.world.block.BlockID;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -202,7 +202,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
if (newBiome != null) {
|
||||
BiomeType oldBiome = get.getBiomeType(x, y, z);
|
||||
if (oldBiome != newBiome) {
|
||||
addBiomeChange(bx + (x << 2), y << 2,bz + (z << 2), oldBiome, newBiome);
|
||||
addBiomeChange(bx + (x << 2), y << 2, bz + (z << 2), oldBiome, newBiome);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,7 +213,7 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<IChunkSet> postProcessSet(final IChunk chunk, final IChunkGet get,final IChunkSet set) {
|
||||
public Future<IChunkSet> postProcessSet(final IChunk chunk, final IChunkGet get, final IChunkSet set) {
|
||||
return (Future<IChunkSet>) addWriteTask(() -> processSet(chunk, get, set));
|
||||
}
|
||||
|
||||
@ -244,8 +244,8 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
|
||||
public EditSession toEditSession(Player player, Region[] regions) {
|
||||
EditSessionBuilder builder =
|
||||
new EditSessionBuilder(getWorld()).player(player).autoQueue(false).fastmode(false)
|
||||
.checkMemory(false).changeSet(this).limitUnlimited();
|
||||
new EditSessionBuilder(getWorld()).player(player).autoQueue(false).fastmode(false)
|
||||
.checkMemory(false).changeSet(this).limitUnlimited();
|
||||
if (regions != null) {
|
||||
builder.allowedRegions(regions);
|
||||
} else {
|
||||
@ -364,4 +364,5 @@ public abstract class AbstractChangeSet implements ChangeSet, IBatchProcessor {
|
||||
return Fawe.get().getQueueHandler().submit(wrappedTask);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import java.util.Iterator;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
||||
|
||||
public final AbstractChangeSet parent;
|
||||
|
||||
public AbstractDelegateChangeSet(AbstractChangeSet parent) {
|
||||
@ -186,4 +187,5 @@ public class AbstractDelegateChangeSet extends AbstractChangeSet {
|
||||
public ChangeSetSummary summarize(Region region, boolean shallow) {
|
||||
return parent.summarize(region, shallow);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,15 +11,15 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockBagChangeSet extends AbstractDelegateChangeSet {
|
||||
|
||||
private final boolean mine;
|
||||
private int[] missingBlocks = new int[BlockTypes.size()];
|
||||
private final int[] missingBlocks = new int[BlockTypes.size()];
|
||||
private BlockBag blockBag;
|
||||
|
||||
public BlockBagChangeSet(AbstractChangeSet parent, BlockBag blockBag, boolean mine) {
|
||||
@ -85,10 +85,10 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
|
||||
try {
|
||||
blockBag.fetchPlacedBlock(typeTo.getDefaultState());
|
||||
} catch (UnplaceableBlockException e) {
|
||||
throw FaweCache.IMP.BLOCK_BAG;
|
||||
throw FaweCache.BLOCK_BAG;
|
||||
} catch (BlockBagException e) {
|
||||
missingBlocks[typeTo.getInternalId()]++;
|
||||
throw FaweCache.IMP.BLOCK_BAG;
|
||||
throw FaweCache.BLOCK_BAG;
|
||||
}
|
||||
}
|
||||
if (mine) {
|
||||
@ -117,4 +117,5 @@ public class BlockBagChangeSet extends AbstractDelegateChangeSet {
|
||||
}
|
||||
super.addTileCreate(nbt);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ChangeSetSummary {
|
||||
|
||||
Map<BlockState, Integer> getBlocks();
|
||||
|
||||
int getSize();
|
||||
@ -33,4 +34,5 @@ public interface ChangeSetSummary {
|
||||
}
|
||||
return newMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
}
|
||||
|
||||
public interface FaweStreamPositionDelegate {
|
||||
|
||||
void write(OutputStream out, int x, int y, int z) throws IOException;
|
||||
|
||||
int readX(FaweInputStream in) throws IOException;
|
||||
@ -69,14 +70,17 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
int readY(FaweInputStream in) throws IOException;
|
||||
|
||||
int readZ(FaweInputStream in) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
public interface FaweStreamIdDelegate {
|
||||
|
||||
void writeChange(FaweOutputStream out, int from, int to) throws IOException;
|
||||
|
||||
void readCombined(FaweInputStream in, MutableBlockChange change, boolean dir) throws IOException;
|
||||
|
||||
void readCombined(FaweInputStream in, MutableFullBlockChange change) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
protected void setupStreamDelegates(int mode) {
|
||||
@ -150,7 +154,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
out.write(b4);
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[4];
|
||||
final byte[] buffer = new byte[4];
|
||||
|
||||
@Override
|
||||
public int readX(FaweInputStream in) throws IOException {
|
||||
@ -516,7 +520,8 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
return getIterator(redo);
|
||||
}
|
||||
|
||||
public Iterator<MutableFullBlockChange> getFullBlockIterator(BlockBag blockBag, int inventory, final boolean dir) throws IOException {
|
||||
public Iterator<MutableFullBlockChange> getFullBlockIterator(BlockBag blockBag, int inventory, final boolean dir) throws
|
||||
IOException {
|
||||
final FaweInputStream is = new FaweInputStream(getBlockIS());
|
||||
final MutableFullBlockChange change = new MutableFullBlockChange(blockBag, inventory, dir);
|
||||
return new Iterator<MutableFullBlockChange>() {
|
||||
@ -677,7 +682,7 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
final Iterator<MutableBiomeChange> biomeChange = getBiomeIterator(dir);
|
||||
|
||||
return new Iterator<Change>() {
|
||||
Iterator<Change>[] iterators = new Iterator[]{tileCreate, tileRemove, entityCreate, entityRemove, blockChange, biomeChange};
|
||||
final Iterator<Change>[] iterators = new Iterator[]{tileCreate, tileRemove, entityCreate, entityRemove, blockChange, biomeChange};
|
||||
int i = 0;
|
||||
Iterator<Change> current = iterators[0];
|
||||
|
||||
@ -757,4 +762,5 @@ public abstract class FaweStreamChangeSet extends AbstractChangeSet {
|
||||
}
|
||||
return summary;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class NullChangeSet extends AbstractChangeSet {
|
||||
public NullChangeSet(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final void close() {
|
||||
}
|
||||
@ -75,4 +75,5 @@ public class NullChangeSet extends AbstractChangeSet {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.fastasyncworldedit.core.history.changeset;
|
||||
|
||||
import com.fastasyncworldedit.core.history.changeset.ChangeSetSummary;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
@ -8,6 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SimpleChangeSetSummary implements ChangeSetSummary {
|
||||
|
||||
public int[] blocks;
|
||||
|
||||
public int minX;
|
||||
@ -66,4 +66,5 @@ public class SimpleChangeSetSummary implements ChangeSetSummary {
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user