mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Upstream and debugging changes.
This commit is contained in:
parent
9efdd886c5
commit
0d1e32efcb
@ -108,11 +108,6 @@ public class ClipboardWorld extends AbstractWorld implements Clipboard, CLIWorld
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Entity> getEntities(Region region) {
|
|
||||||
return clipboard.getEntities(region);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position)
|
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
@ -120,13 +115,18 @@ public class ClipboardWorld extends AbstractWorld implements Clipboard, CLIWorld
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities() {
|
public BlockVector3 getSpawnPosition() {
|
||||||
return clipboard.getEntities();
|
return clipboard.getOrigin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getSpawnPosition() {
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
return clipboard.getOrigin();
|
return clipboard.getEntities(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Entity> getEntities() {
|
||||||
|
return clipboard.getEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.boydti.fawe;
|
package com.boydti.fawe;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
|
||||||
import com.boydti.fawe.config.Caption;
|
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.brush.visualization.VisualQueue;
|
import com.boydti.fawe.object.brush.visualization.VisualQueue;
|
||||||
import com.boydti.fawe.regions.general.integrations.plotquared.PlotSquaredFeature;
|
import com.boydti.fawe.regions.general.integrations.plotquared.PlotSquaredFeature;
|
||||||
|
@ -10,7 +10,7 @@ public interface IQueueChunk<T extends Future<T>> extends IChunk, Callable<T> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
default IQueueChunk reset() {
|
default IQueueChunk<T> reset() {
|
||||||
init(null, getX(), getZ());
|
init(null, getX(), getZ());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,12 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID uid = player.getUniqueId();
|
UUID uid = player.getUniqueId();
|
||||||
return !Flags.NO_WORLDEDIT.isTrue(plot) && ((plot.isOwner(uid) || (type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted().contains(DBFunc.EVERYONE) || ((plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE)) && player.hasPermission("fawe.plotsquared.member"))))) || player.hasPermission("fawe.plotsquared.admin"));
|
return !Flags.NO_WORLDEDIT.isTrue(plot) && (plot.isOwner(uid)
|
||||||
|
|| type == MaskType.MEMBER && (plot.getTrusted().contains(uid) || plot.getTrusted()
|
||||||
|
.contains(DBFunc.EVERYONE)
|
||||||
|
|| (plot.getMembers().contains(uid) || plot.getMembers().contains(DBFunc.EVERYONE))
|
||||||
|
&& player.hasPermission("fawe.plotsquared.member")) || player
|
||||||
|
.hasPermission("fawe.plotsquared.admin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,6 +13,7 @@ import com.sk89q.worldedit.extent.Extent;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -92,6 +93,7 @@ public class WEManager {
|
|||||||
backupRegions.add(region);
|
backupRegions.add(region);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
player.printDebug(TextComponent.of("Invalid Mask"));
|
||||||
removed = true;
|
removed = true;
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
@ -115,6 +117,8 @@ public class WEManager {
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
player.printError(TextComponent.of("Missing permission " + "fawe." + manager.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
regions.addAll(backupRegions);
|
regions.addAll(backupRegions);
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.factory;
|
package com.sk89q.worldedit.function.factory;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -39,9 +42,6 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
|||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.sk89q.worldedit.util.GuavaUtil.firstNonNull;
|
|
||||||
|
|
||||||
public class Deform implements Contextual<Operation> {
|
public class Deform implements Contextual<Operation> {
|
||||||
|
|
||||||
private Extent destination;
|
private Extent destination;
|
||||||
@ -157,12 +157,6 @@ public class Deform implements Contextual<Operation> {
|
|||||||
session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout());
|
session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Mode {
|
|
||||||
RAW_COORD,
|
|
||||||
OFFSET,
|
|
||||||
UNIT_CUBE
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class DeformOperation implements Operation {
|
private static final class DeformOperation implements Operation {
|
||||||
private final Extent destination;
|
private final Extent destination;
|
||||||
private final Region region;
|
private final Region region;
|
||||||
@ -199,9 +193,15 @@ public class Deform implements Contextual<Operation> {
|
|||||||
@Override
|
@Override
|
||||||
public Iterable<Component> getStatusMessages() {
|
public Iterable<Component> getStatusMessages() {
|
||||||
return ImmutableList.of(TranslatableComponent.of("worldedit.operation.deform.expression",
|
return ImmutableList.of(TranslatableComponent.of("worldedit.operation.deform.expression",
|
||||||
TextComponent.of(expression).color(TextColor.GRAY)));
|
TextComponent.of(expression).color(TextColor.LIGHT_PURPLE)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Mode {
|
||||||
|
RAW_COORD,
|
||||||
|
OFFSET,
|
||||||
|
UNIT_CUBE
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,6 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public interface Operation {
|
public interface Operation {
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an internal field, and should not be touched.
|
|
||||||
*/
|
|
||||||
Set<String> warnedDeprecatedClasses = new HashSet<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete the next step. If this method returns true, then the method may
|
* Complete the next step. If this method returns true, then the method may
|
||||||
* be called again in the future, or possibly never. If this method
|
* be called again in the future, or possibly never. If this method
|
||||||
@ -74,6 +69,11 @@ public interface Operation {
|
|||||||
default void addStatusMessages(List<String> messages) {
|
default void addStatusMessages(List<String> messages) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an internal field, and should not be touched.
|
||||||
|
*/
|
||||||
|
Set<String> warnedDeprecatedClasses = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an iterable of messages that describe the current status of the
|
* Gets an iterable of messages that describe the current status of the
|
||||||
* operation.
|
* operation.
|
||||||
@ -87,7 +87,7 @@ public interface Operation {
|
|||||||
if (oldMessages.size() > 0) {
|
if (oldMessages.size() > 0) {
|
||||||
String className = getClass().getName();
|
String className = getClass().getName();
|
||||||
if (!warnedDeprecatedClasses.contains(className)) {
|
if (!warnedDeprecatedClasses.contains(className)) {
|
||||||
WorldEdit.logger.warn("An operation is using the old status message API. This will be removed in further versions. Class: " + className);
|
WorldEdit.logger.warn("An operation is using the old status message API. This will be removed in WorldEdit 8. Class: " + className);
|
||||||
warnedDeprecatedClasses.add(className);
|
warnedDeprecatedClasses.add(className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,27 @@ public final class Closer implements Closeable {
|
|||||||
return zipFile;
|
return zipFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call {@link #rethrow(Throwable)} with the given exception, but before throwing the exception,
|
||||||
|
* also close this Closer. Exceptions from closing are added to {@code t} as suppressed
|
||||||
|
* exceptions.
|
||||||
|
*
|
||||||
|
* @param t the throwable that should be re-thrown
|
||||||
|
* @throws IOException if {@code t} is an IOException, or one occurs
|
||||||
|
*/
|
||||||
|
public RuntimeException rethrowAndClose(Throwable t) throws IOException {
|
||||||
|
// bit of a hack here
|
||||||
|
try {
|
||||||
|
throw rethrow(t);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
close();
|
||||||
|
} catch (Throwable closeThrown) {
|
||||||
|
t.addSuppressed(closeThrown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the given throwable and rethrows it. It will be rethrown as is if it is an
|
* Stores the given throwable and rethrows it. It will be rethrown as is if it is an
|
||||||
* {@code IOException}, {@code RuntimeException} or {@code Error}. Otherwise, it will be rethrown
|
* {@code IOException}, {@code RuntimeException} or {@code Error}. Otherwise, it will be rethrown
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.util.translation;
|
package com.sk89q.worldedit.util.translation;
|
||||||
|
|
||||||
|
import static java.util.stream.Collectors.toMap;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
@ -26,7 +29,6 @@ import com.sk89q.worldedit.WorldEdit;
|
|||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.util.formatting.text.renderer.FriendlyComponentRenderer;
|
import com.sk89q.worldedit.util.formatting.text.renderer.FriendlyComponentRenderer;
|
||||||
import com.sk89q.worldedit.util.io.ResourceLoader;
|
import com.sk89q.worldedit.util.io.ResourceLoader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -76,8 +78,10 @@ public class TranslationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> filterTranslations(Map<String, String> translations) {
|
private Map<String, String> filterTranslations(Map<String, String> translations) {
|
||||||
translations.entrySet().removeIf(entry -> entry.getValue().isEmpty());
|
return translations.entrySet().stream()
|
||||||
return translations;
|
.filter(e -> !e.getValue().isEmpty())
|
||||||
|
.map(e -> Maps.immutableEntry(e.getKey(), e.getValue().replace("'", "''")))
|
||||||
|
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> parseTranslationFile(InputStream inputStream) {
|
private Map<String, String> parseTranslationFile(InputStream inputStream) {
|
||||||
|
@ -29,7 +29,6 @@ import com.sk89q.jnbt.Tag;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.world.World;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -55,11 +54,10 @@ public class AnvilChunk implements Chunk {
|
|||||||
/**
|
/**
|
||||||
* Construct the chunk with a compound tag.
|
* Construct the chunk with a compound tag.
|
||||||
*
|
*
|
||||||
* @param world the world to construct the chunk for
|
|
||||||
* @param tag the tag to read
|
* @param tag the tag to read
|
||||||
* @throws DataException on a data error
|
* @throws DataException on a data error
|
||||||
*/
|
*/
|
||||||
public AnvilChunk(World world, CompoundTag tag) throws DataException {
|
public AnvilChunk(CompoundTag tag) throws DataException {
|
||||||
rootTag = tag;
|
rootTag = tag;
|
||||||
|
|
||||||
rootX = NBTUtils.getChildTag(rootTag.getValue(), "xPos", IntTag.class).getValue();
|
rootX = NBTUtils.getChildTag(rootTag.getValue(), "xPos", IntTag.class).getValue();
|
||||||
@ -261,13 +259,11 @@ public class AnvilChunk implements Chunk {
|
|||||||
WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk.");
|
WorldEdit.logger.warn("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk.");
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
if (state.getMaterial().hasContainer()) {
|
|
||||||
CompoundTag tileEntity = getBlockTileEntity(position);
|
CompoundTag tileEntity = getBlockTileEntity(position);
|
||||||
|
|
||||||
if (tileEntity != null) {
|
if (tileEntity != null) {
|
||||||
return state.toBaseBlock(tileEntity);
|
return state.toBaseBlock(tileEntity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return state.toBaseBlock();
|
return state.toBaseBlock();
|
||||||
}
|
}
|
||||||
|
@ -226,9 +226,9 @@ public class AnvilChunk13 implements Chunk {
|
|||||||
BlockState[] sectionBlocks = blocks[section];
|
BlockState[] sectionBlocks = blocks[section];
|
||||||
BlockState state = sectionBlocks != null ? sectionBlocks[(yIndex << 8) | (z << 4) | x] : BlockTypes.AIR.getDefaultState();
|
BlockState state = sectionBlocks != null ? sectionBlocks[(yIndex << 8) | (z << 4) | x] : BlockTypes.AIR.getDefaultState();
|
||||||
|
|
||||||
if (state.getMaterial().hasContainer()) {
|
|
||||||
CompoundTag tileEntity = getBlockTileEntity(position);
|
CompoundTag tileEntity = getBlockTileEntity(position);
|
||||||
|
|
||||||
|
if (tileEntity != null) {
|
||||||
return state.toBaseBlock(tileEntity);
|
return state.toBaseBlock(tileEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ import com.sk89q.jnbt.Tag;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.world.World;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -55,11 +54,10 @@ public class OldChunk implements Chunk {
|
|||||||
/**
|
/**
|
||||||
* Construct the chunk with a compound tag.
|
* Construct the chunk with a compound tag.
|
||||||
*
|
*
|
||||||
* @param world the world
|
|
||||||
* @param tag the tag
|
* @param tag the tag
|
||||||
* @throws DataException
|
* @throws DataException
|
||||||
*/
|
*/
|
||||||
public OldChunk(World world, CompoundTag tag) throws DataException {
|
public OldChunk(CompoundTag tag) throws DataException {
|
||||||
rootTag = tag;
|
rootTag = tag;
|
||||||
|
|
||||||
blocks = NBTUtils.getChildTag(rootTag.getValue(), "Blocks", ByteArrayTag.class).getValue();
|
blocks = NBTUtils.getChildTag(rootTag.getValue(), "Blocks", ByteArrayTag.class).getValue();
|
||||||
@ -185,13 +183,12 @@ public class OldChunk implements Chunk {
|
|||||||
WorldEdit.logger.warn("Unknown legacy block " + id + ":" + dataVal + " found when loading legacy anvil chunk.");
|
WorldEdit.logger.warn("Unknown legacy block " + id + ":" + dataVal + " found when loading legacy anvil chunk.");
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
if (state.getBlockType().getMaterial().hasContainer()) {
|
|
||||||
CompoundTag tileEntity = getBlockTileEntity(position);
|
CompoundTag tileEntity = getBlockTileEntity(position);
|
||||||
|
|
||||||
if (tileEntity != null) {
|
if (tileEntity != null) {
|
||||||
return state.toBaseBlock(tileEntity);
|
return state.toBaseBlock(tileEntity);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return state.toBaseBlock();
|
return state.toBaseBlock();
|
||||||
}
|
}
|
||||||
|
@ -20,34 +20,19 @@
|
|||||||
package com.sk89q.worldedit.world.storage;
|
package com.sk89q.worldedit.world.storage;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.world.DataFixer;
|
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.chunk.AnvilChunk;
|
|
||||||
import com.sk89q.worldedit.world.chunk.AnvilChunk13;
|
|
||||||
import com.sk89q.worldedit.world.chunk.Chunk;
|
import com.sk89q.worldedit.world.chunk.Chunk;
|
||||||
import com.sk89q.worldedit.world.chunk.OldChunk;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents chunk storage mechanisms.
|
* Represents chunk storage mechanisms.
|
||||||
*/
|
*/
|
||||||
public abstract class ChunkStore implements Closeable {
|
public abstract class ChunkStore implements Closeable {
|
||||||
|
|
||||||
/**
|
|
||||||
* The DataVersion for Minecraft 1.13
|
|
||||||
*/
|
|
||||||
private static final int DATA_VERSION_MC_1_13 = 1519;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code >>} - to chunk
|
* {@code >>} - to chunk
|
||||||
* {@code <<} - from chunk
|
* {@code <<} - from chunk
|
||||||
@ -85,46 +70,7 @@ public abstract class ChunkStore implements Closeable {
|
|||||||
*/
|
*/
|
||||||
public Chunk getChunk(BlockVector2 position, World world) throws DataException, IOException {
|
public Chunk getChunk(BlockVector2 position, World world) throws DataException, IOException {
|
||||||
CompoundTag rootTag = getChunkTag(position, world);
|
CompoundTag rootTag = getChunkTag(position, world);
|
||||||
|
return ChunkStoreHelper.getChunk(rootTag);
|
||||||
Map<String, Tag> children = rootTag.getValue();
|
|
||||||
CompoundTag tag = null;
|
|
||||||
|
|
||||||
// Find Level tag
|
|
||||||
for (Map.Entry<String, Tag> entry : children.entrySet()) {
|
|
||||||
if (entry.getKey().equals("Level")) {
|
|
||||||
if (entry.getValue() instanceof CompoundTag) {
|
|
||||||
tag = (CompoundTag) entry.getValue();
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
throw new ChunkStoreException("CompoundTag expected for 'Level'; got " + entry.getValue().getClass().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag == null) {
|
|
||||||
throw new ChunkStoreException("Missing root 'Level' tag");
|
|
||||||
}
|
|
||||||
|
|
||||||
int dataVersion = rootTag.getInt("DataVersion");
|
|
||||||
if (dataVersion == 0) dataVersion = -1;
|
|
||||||
final Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
|
|
||||||
final int currentDataVersion = platform.getDataVersion();
|
|
||||||
if (tag.getValue().containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks
|
|
||||||
final DataFixer dataFixer = platform.getDataFixer();
|
|
||||||
if (dataFixer != null) {
|
|
||||||
return new AnvilChunk13((CompoundTag) dataFixer.fixUp(DataFixer.FixTypes.CHUNK, rootTag, dataVersion).getValue().get("Level"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dataVersion >= DATA_VERSION_MC_1_13) {
|
|
||||||
return new AnvilChunk13(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Tag> tags = tag.getValue();
|
|
||||||
if (tags.containsKey("Sections")) {
|
|
||||||
return new AnvilChunk(world, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new OldChunk(world, tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.world.storage;
|
||||||
|
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.NBTInputStream;
|
||||||
|
import com.sk89q.jnbt.Tag;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
import com.sk89q.worldedit.world.DataFixer;
|
||||||
|
import com.sk89q.worldedit.world.chunk.AnvilChunk;
|
||||||
|
import com.sk89q.worldedit.world.chunk.AnvilChunk13;
|
||||||
|
import com.sk89q.worldedit.world.chunk.Chunk;
|
||||||
|
import com.sk89q.worldedit.world.chunk.OldChunk;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ChunkStoreHelper {
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ChunkDataInputSupplier {
|
||||||
|
|
||||||
|
InputStream openInputStream() throws DataException, IOException;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CompoundTag readCompoundTag(ChunkDataInputSupplier input) throws DataException, IOException {
|
||||||
|
try (InputStream stream = input.openInputStream();
|
||||||
|
NBTInputStream nbt = new NBTInputStream(stream)) {
|
||||||
|
Tag tag = nbt.readNamedTag().getTag();
|
||||||
|
if (!(tag instanceof CompoundTag)) {
|
||||||
|
throw new ChunkStoreException("CompoundTag expected for chunk; got "
|
||||||
|
+ tag.getClass().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CompoundTag) tag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The DataVersion for Minecraft 1.13
|
||||||
|
*/
|
||||||
|
private static final int DATA_VERSION_MC_1_13 = 1519;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a chunk NBT tag into a {@link Chunk} implementation.
|
||||||
|
*
|
||||||
|
* @param rootTag the root tag of the chunk
|
||||||
|
* @return a Chunk implementation
|
||||||
|
* @throws DataException if the rootTag is not valid chunk data
|
||||||
|
*/
|
||||||
|
public static Chunk getChunk(CompoundTag rootTag) throws DataException {
|
||||||
|
Map<String, Tag> children = rootTag.getValue();
|
||||||
|
CompoundTag tag = null;
|
||||||
|
|
||||||
|
// Find Level tag
|
||||||
|
for (Map.Entry<String, Tag> entry : children.entrySet()) {
|
||||||
|
if (entry.getKey().equals("Level")) {
|
||||||
|
if (entry.getValue() instanceof CompoundTag) {
|
||||||
|
tag = (CompoundTag) entry.getValue();
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
throw new ChunkStoreException("CompoundTag expected for 'Level'; got " + entry.getValue().getClass().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag == null) {
|
||||||
|
throw new ChunkStoreException("Missing root 'Level' tag");
|
||||||
|
}
|
||||||
|
|
||||||
|
int dataVersion = rootTag.getInt("DataVersion");
|
||||||
|
if (dataVersion == 0) dataVersion = -1;
|
||||||
|
final Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
|
||||||
|
final int currentDataVersion = platform.getDataVersion();
|
||||||
|
if (tag.getValue().containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks
|
||||||
|
final DataFixer dataFixer = platform.getDataFixer();
|
||||||
|
if (dataFixer != null) {
|
||||||
|
return new AnvilChunk13((CompoundTag) dataFixer.fixUp(DataFixer.FixTypes.CHUNK, rootTag, dataVersion).getValue().get("Level"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dataVersion >= DATA_VERSION_MC_1_13) {
|
||||||
|
return new AnvilChunk13(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Tag> tags = tag.getValue();
|
||||||
|
if (tags.containsKey("Sections")) {
|
||||||
|
return new AnvilChunk(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OldChunk(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChunkStoreHelper() {
|
||||||
|
}
|
||||||
|
}
|
@ -20,12 +20,9 @@
|
|||||||
package com.sk89q.worldedit.world.storage;
|
package com.sk89q.worldedit.world.storage;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.NBTInputStream;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.world.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -78,18 +75,9 @@ public abstract class LegacyChunkStore extends ChunkStore {
|
|||||||
String filename = "c." + Integer.toString(x, 36)
|
String filename = "c." + Integer.toString(x, 36)
|
||||||
+ "." + Integer.toString(z, 36) + ".dat";
|
+ "." + Integer.toString(z, 36) + ".dat";
|
||||||
|
|
||||||
InputStream stream = getInputStream(folder1, folder2, filename);
|
return ChunkStoreHelper.readCompoundTag(() ->
|
||||||
Tag tag;
|
new GZIPInputStream(getInputStream(folder1, folder2, filename))
|
||||||
|
);
|
||||||
try (NBTInputStream nbt = new NBTInputStream(new GZIPInputStream(stream))) {
|
|
||||||
tag = nbt.readNamedTag().getTag();
|
|
||||||
if (!(tag instanceof CompoundTag)) {
|
|
||||||
throw new ChunkStoreException("CompoundTag expected for chunk; got "
|
|
||||||
+ tag.getClass().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
return (CompoundTag) tag;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int divisorMod(int a, int n) {
|
private static int divisorMod(int a, int n) {
|
||||||
|
@ -408,6 +408,7 @@
|
|||||||
"worldedit.restore.failed": "Failed to load snapshot: {0}",
|
"worldedit.restore.failed": "Failed to load snapshot: {0}",
|
||||||
"worldedit.restore.loaded": "Snapshot '{0}' loaded; now restoring...",
|
"worldedit.restore.loaded": "Snapshot '{0}' loaded; now restoring...",
|
||||||
"worldedit.restore.restored": "Restored; {0} missing chunks and {1} other errors.",
|
"worldedit.restore.restored": "Restored; {0} missing chunks and {1} other errors.",
|
||||||
|
"worldedit.restore.none-for-specific-world": "No snapshots were found for world '{0}'.",
|
||||||
"worldedit.restore.none-for-world": "No snapshots were found for this world.",
|
"worldedit.restore.none-for-world": "No snapshots were found for this world.",
|
||||||
"worldedit.restore.none-found": "No snapshots were found.",
|
"worldedit.restore.none-found": "No snapshots were found.",
|
||||||
"worldedit.restore.none-found-console": "No snapshots were found. See console for details.",
|
"worldedit.restore.none-found-console": "No snapshots were found. See console for details.",
|
||||||
@ -517,6 +518,7 @@
|
|||||||
"worldedit.replace.replaced": "{0} blocks have been replaced.",
|
"worldedit.replace.replaced": "{0} blocks have been replaced.",
|
||||||
"worldedit.stack.changed": "{0} blocks changed. Undo with //undo",
|
"worldedit.stack.changed": "{0} blocks changed. Undo with //undo",
|
||||||
"worldedit.regen.regenerated": "Region regenerated.",
|
"worldedit.regen.regenerated": "Region regenerated.",
|
||||||
|
"worldedit.regen.failed": "Unable to regenerate chunks. Check console for details.",
|
||||||
"worldedit.walls.changed": "{0} blocks have been changed.",
|
"worldedit.walls.changed": "{0} blocks have been changed.",
|
||||||
"worldedit.faces.changed": "{0} blocks have been changed.",
|
"worldedit.faces.changed": "{0} blocks have been changed.",
|
||||||
"worldedit.overlay.overlaid": "{0} blocks have been overlaid.",
|
"worldedit.overlay.overlaid": "{0} blocks have been overlaid.",
|
||||||
|
Loading…
Reference in New Issue
Block a user