This commit is contained in:
Jesse Boyd 2020-01-04 10:12:33 +00:00
commit c05cdd8faa
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
66 changed files with 878 additions and 862 deletions

View File

@ -43,7 +43,7 @@ fun Project.applyPlatformAndCoreConfiguration() {
} }
dependencies { dependencies {
"compileOnly"("org.jetbrains:annotations:17.0.0") "compileOnly"("org.jetbrains:annotations:18.0.0")
"testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}") "testImplementation"("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}")
"testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}") "testImplementation"("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT}")
"testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}") "testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}")

View File

@ -40,17 +40,17 @@ dependencies {
"compile"("org.spigotmcv1_14_r1:spigotmcv1_14_r1:1_14_r1") "compile"("org.spigotmcv1_14_r1:spigotmcv1_14_r1:1_14_r1")
"compile"("org.spigotmcv1_15_r1:spigotmcv1_15_r1:1_15_r1") "compile"("org.spigotmcv1_15_r1:spigotmcv1_15_r1:1_15_r1")
"compile"("it.unimi.dsi:fastutil:8.2.1") "compile"("it.unimi.dsi:fastutil:8.2.1")
"api"("com.destroystokyo.paper:paper-api:1.14.4-R0.1-SNAPSHOT") { "api"("com.destroystokyo.paper:paper-api:1.15.1-R0.1-SNAPSHOT") {
exclude("junit", "junit") exclude("junit", "junit")
isTransitive = false isTransitive = false
} }
"compileOnly"("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT") "compileOnly"("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT")
"compileOnly"("org.spigotmc:spigot:1.15-R0.1-SNAPSHOT") "compileOnly"("org.spigotmc:spigot:1.15.1-R0.1-SNAPSHOT")
"implementation"("io.papermc:paperlib:1.0.2") "implementation"("io.papermc:paperlib:1.0.2")
"compileOnly"("com.sk89q:dummypermscompat:1.10") "compileOnly"("com.sk89q:dummypermscompat:1.10")
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1") "implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
"testCompile"("org.mockito:mockito-core:1.9.0-rc1") "testCompile"("org.mockito:mockito-core:1.9.0-rc1")
"compileOnly"("com.sk89q.worldguard:worldguard-bukkit:7.0.0") { "compileOnly"("com.sk89q.worldguard:worldguard-bukkit:7.0.1") {
exclude("com.sk89q.worldedit", "worldedit-bukkit") exclude("com.sk89q.worldedit", "worldedit-bukkit")
exclude("com.sk89q.worldedit", "worldedit-core") exclude("com.sk89q.worldedit", "worldedit-core")
exclude("com.sk89q.worldedit.worldedit-libs", "bukkit") exclude("com.sk89q.worldedit.worldedit-libs", "bukkit")

View File

@ -41,7 +41,6 @@ import java.util.function.Supplier;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -50,7 +49,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -214,7 +212,7 @@ public class FaweBukkit implements IFawe, Listener {
@Override @Override
public String getDebugInfo() { public String getDebugInfo() {
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
msg.append("server.version: ").append(Bukkit.getVersion()).append("\n"); msg.append("Server Version: ").append(Bukkit.getVersion()).append("\n");
msg.append("Plugins: \n"); msg.append("Plugins: \n");
for (Plugin p : Bukkit.getPluginManager().getPlugins()) { for (Plugin p : Bukkit.getPluginManager().getPlugins()) {
msg.append(" - ").append(p.getName()).append(": ") msg.append(" - ").append(p.getName()).append(": ")
@ -353,7 +351,6 @@ public class FaweBukkit implements IFawe, Listener {
return null; return null;
} }
return null; return null;
// return ((BlocksHubBukkit) blocksHubPlugin).getApi();
} }
@Override @Override

View File

@ -1,5 +1,7 @@
package com.boydti.fawe.bukkit.adapter.mc1_13; package com.boydti.fawe.bukkit.adapter.mc1_13;
import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
@ -24,6 +26,19 @@ import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.AbstractSet;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.function.Function;
import javax.annotation.Nullable;
import net.minecraft.server.v1_13_R2.BiomeBase; import net.minecraft.server.v1_13_R2.BiomeBase;
import net.minecraft.server.v1_13_R2.BlockPosition; import net.minecraft.server.v1_13_R2.BlockPosition;
import net.minecraft.server.v1_13_R2.Chunk; import net.minecraft.server.v1_13_R2.Chunk;
@ -47,22 +62,6 @@ import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.AbstractSet;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.function.Function;
import static org.slf4j.LoggerFactory.getLogger;
public class BukkitGetBlocks_1_13 extends CharGetBlocks { public class BukkitGetBlocks_1_13 extends CharGetBlocks {
public ChunkSection[] sections; public ChunkSection[] sections;
public Chunk nmsChunk; public Chunk nmsChunk;
@ -102,19 +101,9 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
return new LazyCompoundTag_1_13(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); return new LazyCompoundTag_1_13(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
} }
private static final Function<BlockPosition, BlockVector3> posNms2We = new Function<BlockPosition, BlockVector3>() { private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
@Override
public BlockVector3 apply(BlockPosition v) {
return BlockVector3.at(v.getX(), v.getY(), v.getZ());
}
};
private final static Function<TileEntity, CompoundTag> nmsTile2We = new Function<TileEntity, CompoundTag>() { private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_13(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
@Override
public CompoundTag apply(TileEntity tileEntity) {
return new LazyCompoundTag_1_13(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
}
};
@Override @Override
public Map<BlockVector3, CompoundTag> getTiles() { public Map<BlockVector3, CompoundTag> getTiles() {
@ -243,9 +232,7 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
{ {
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities(); Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
if (!tiles.isEmpty()) { if (!tiles.isEmpty()) {
final Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator(); for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
while (iterator.hasNext()) {
final Map.Entry<BlockPosition, TileEntity> entry = iterator.next();
final BlockPosition pos = entry.getKey(); final BlockPosition pos = entry.getKey();
final int lx = pos.getX() & 15; final int lx = pos.getX() & 15;
final int ly = pos.getY(); final int ly = pos.getY();
@ -345,8 +332,7 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
public void run() { public void run() {
final List<Entity>[] entities = nmsChunk.getEntitySlices(); final List<Entity>[] entities = nmsChunk.getEntitySlices();
for (int i = 0; i < entities.length; i++) { for (final Collection<Entity> ents : entities) {
final Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
final Iterator<Entity> iter = ents.iterator(); final Iterator<Entity> iter = ents.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
@ -366,43 +352,40 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
if (entities != null && !entities.isEmpty()) { if (entities != null && !entities.isEmpty()) {
if (syncTasks == null) syncTasks = new Runnable[2]; if (syncTasks == null) syncTasks = new Runnable[2];
syncTasks[1] = new Runnable() { syncTasks[1] = () -> {
@Override for (final CompoundTag nativeTag : entities) {
public void run() { final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
for (final CompoundTag nativeTag : entities) { final StringTag idTag = (StringTag) entityTagMap.get("Id");
final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue()); final ListTag posTag = (ListTag) entityTagMap.get("Pos");
final StringTag idTag = (StringTag) entityTagMap.get("Id"); final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
final ListTag posTag = (ListTag) entityTagMap.get("Pos"); if (idTag == null || posTag == null || rotTag == null) {
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); getLogger(BukkitGetBlocks_1_13.class).debug("Unknown entity tag: " + nativeTag);
if (idTag == null || posTag == null || rotTag == null) { continue;
getLogger(BukkitGetBlocks_1_13.class).debug("Unknown entity tag: " + nativeTag); }
continue; final double x = posTag.getDouble(0);
} final double y = posTag.getDouble(1);
final double x = posTag.getDouble(0); final double z = posTag.getDouble(2);
final double y = posTag.getDouble(1); final float yaw = rotTag.getFloat(0);
final double z = posTag.getDouble(2); final float pitch = rotTag.getFloat(1);
final float yaw = rotTag.getFloat(0); final String id = idTag.getValue();
final float pitch = rotTag.getFloat(1);
final String id = idTag.getValue();
EntityTypes<?> type = EntityTypes.a(id); EntityTypes<?> type = EntityTypes.a(id);
if (type != null) { if (type != null) {
Entity entity = type.a(nmsWorld); Entity entity = type.a(nmsWorld);
if (entity != null) { if (entity != null) {
UUID uuid = entity.getUniqueID(); UUID uuid = entity.getUniqueID();
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits())); entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits())); entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
if (nativeTag != null) { if (nativeTag != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag); final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name); tag.remove(name);
}
entity.f(tag);
} }
entity.setLocation(x, y, z, yaw, pitch); entity.f(tag);
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
} }
entity.setLocation(x, y, z, yaw, pitch);
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
} }
} }
} }
@ -415,31 +398,28 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
if (tiles != null && !tiles.isEmpty()) { if (tiles != null && !tiles.isEmpty()) {
if (syncTasks == null) syncTasks = new Runnable[1]; if (syncTasks == null) syncTasks = new Runnable[1];
syncTasks[0] = new Runnable() { syncTasks[0] = () -> {
@Override for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
public void run() { final CompoundTag nativeTag = entry.getValue();
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) { final BlockVector3 blockHash = entry.getKey();
final CompoundTag nativeTag = entry.getValue(); final int x = blockHash.getX() + bx;
final BlockVector3 blockHash = entry.getKey(); final int y = blockHash.getY();
final int x = blockHash.getX() + bx; final int z = blockHash.getZ() + bz;
final int y = blockHash.getY(); final BlockPosition pos = new BlockPosition(x, y, z);
final int z = blockHash.getZ() + bz;
final BlockPosition pos = new BlockPosition(x, y, z);
synchronized (nmsWorld) { synchronized (nmsWorld) {
TileEntity tileEntity = nmsWorld.getTileEntity(pos); TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity == null || tileEntity.x()) { if (tileEntity == null || tileEntity.x()) {
nmsWorld.n(pos); nmsWorld.n(pos);
tileEntity = nmsWorld.getTileEntity(pos); tileEntity = nmsWorld.getTileEntity(pos);
} }
if (tileEntity != null) { if (tileEntity != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag); final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
tag.set("x", new NBTTagInt(x)); tag.set("x", new NBTTagInt(x));
tag.set("y", new NBTTagInt(y)); tag.set("y", new NBTTagInt(y));
tag.set("z", new NBTTagInt(z)); tag.set("z", new NBTTagInt(z));
tileEntity.load(tag); tileEntity.load(tag);
}
} }
} }
} }
@ -473,27 +453,23 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
Runnable[] finalSyncTasks = syncTasks; Runnable[] finalSyncTasks = syncTasks;
// Chain the sync tasks and the callback // Chain the sync tasks and the callback
Callable<Future> chain = new Callable<Future>() { Callable<Future> chain = () -> {
@Override try {
public Future call() { // Run the sync tasks
try { for (Runnable task : finalSyncTasks) {
// Run the sync tasks if (task != null) {
for (int i = 0; i < finalSyncTasks.length; i++) { task.run();
Runnable task = finalSyncTasks[i];
if (task != null) {
task.run();
}
} }
if (callback == null) {
if (finalizer != null) finalizer.run();
return null;
} else {
return queueHandler.async(callback, null);
}
} catch (Throwable e) {
e.printStackTrace();
throw e;
} }
if (callback == null) {
if (finalizer != null) finalizer.run();
return null;
} else {
return queueHandler.async(callback, null);
}
} catch (Throwable e) {
e.printStackTrace();
throw e;
} }
}; };
return (T) (Future) queueHandler.sync(chain); return (T) (Future) queueHandler.sync(chain);

View File

@ -1,9 +1,7 @@
package com.boydti.fawe.bukkit.adapter.mc1_14; package com.boydti.fawe.bukkit.adapter.mc1_14;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
import com.bekvon.bukkit.residence.commands.set;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
@ -14,7 +12,6 @@ import com.boydti.fawe.bukkit.adapter.mc1_14.nbt.LazyCompoundTag_1_14;
import com.boydti.fawe.object.collection.AdaptedMap; import com.boydti.fawe.object.collection.AdaptedMap;
import com.boydti.fawe.object.collection.BitArray4096; import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.TaskManager;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -42,13 +39,11 @@ import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.server.v1_14_R1.BiomeBase; import net.minecraft.server.v1_14_R1.BiomeBase;
import net.minecraft.server.v1_14_R1.BlockPosition; import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.Chunk; import net.minecraft.server.v1_14_R1.Chunk;
import net.minecraft.server.v1_14_R1.ChunkSection; import net.minecraft.server.v1_14_R1.ChunkSection;
import net.minecraft.server.v1_14_R1.ChunkStatus;
import net.minecraft.server.v1_14_R1.DataBits; import net.minecraft.server.v1_14_R1.DataBits;
import net.minecraft.server.v1_14_R1.DataPalette; import net.minecraft.server.v1_14_R1.DataPalette;
import net.minecraft.server.v1_14_R1.DataPaletteBlock; import net.minecraft.server.v1_14_R1.DataPaletteBlock;
@ -57,7 +52,6 @@ import net.minecraft.server.v1_14_R1.DataPaletteLinear;
import net.minecraft.server.v1_14_R1.Entity; import net.minecraft.server.v1_14_R1.Entity;
import net.minecraft.server.v1_14_R1.EntityTypes; import net.minecraft.server.v1_14_R1.EntityTypes;
import net.minecraft.server.v1_14_R1.IBlockData; import net.minecraft.server.v1_14_R1.IBlockData;
import net.minecraft.server.v1_14_R1.LightEngine;
import net.minecraft.server.v1_14_R1.LightEngineThreaded; import net.minecraft.server.v1_14_R1.LightEngineThreaded;
import net.minecraft.server.v1_14_R1.NBTTagCompound; import net.minecraft.server.v1_14_R1.NBTTagCompound;
import net.minecraft.server.v1_14_R1.NBTTagInt; import net.minecraft.server.v1_14_R1.NBTTagInt;
@ -109,19 +103,9 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
return new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); return new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
} }
private static final Function<BlockPosition, BlockVector3> posNms2We = new Function<BlockPosition, BlockVector3>() { private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
@Override
public BlockVector3 apply(BlockPosition v) {
return BlockVector3.at(v.getX(), v.getY(), v.getZ());
}
};
private final static Function<TileEntity, CompoundTag> nmsTile2We = new Function<TileEntity, CompoundTag>() { private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
@Override
public CompoundTag apply(TileEntity tileEntity) {
return new LazyCompoundTag_1_14(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
}
};
@Override @Override
public Map<BlockVector3, CompoundTag> getTiles() { public Map<BlockVector3, CompoundTag> getTiles() {
@ -249,9 +233,7 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
{ {
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities(); Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
if (!tiles.isEmpty()) { if (!tiles.isEmpty()) {
final Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator(); for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
while (iterator.hasNext()) {
final Map.Entry<BlockPosition, TileEntity> entry = iterator.next();
final BlockPosition pos = entry.getKey(); final BlockPosition pos = entry.getKey();
final int lx = pos.getX() & 15; final int lx = pos.getX() & 15;
final int ly = pos.getY(); final int ly = pos.getY();
@ -346,21 +328,17 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
if (entityRemoves != null && !entityRemoves.isEmpty()) { if (entityRemoves != null && !entityRemoves.isEmpty()) {
if (syncTasks == null) syncTasks = new Runnable[3]; if (syncTasks == null) syncTasks = new Runnable[3];
syncTasks[2] = new Runnable() { syncTasks[2] = () -> {
@Override final List<Entity>[] entities = nmsChunk.getEntitySlices();
public void run() {
final List<Entity>[] entities = nmsChunk.getEntitySlices();
for (int i = 0; i < entities.length; i++) { for (final Collection<Entity> ents : entities) {
final Collection<Entity> ents = entities[i]; if (!ents.isEmpty()) {
if (!ents.isEmpty()) { final Iterator<Entity> iter = ents.iterator();
final Iterator<Entity> iter = ents.iterator(); while (iter.hasNext()) {
while (iter.hasNext()) { final Entity entity = iter.next();
final Entity entity = iter.next(); if (entityRemoves.contains(entity.getUniqueID())) {
if (entityRemoves.contains(entity.getUniqueID())) { iter.remove();
iter.remove(); removeEntity(entity);
removeEntity(entity);
}
} }
} }
} }
@ -372,43 +350,40 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
if (entities != null && !entities.isEmpty()) { if (entities != null && !entities.isEmpty()) {
if (syncTasks == null) syncTasks = new Runnable[2]; if (syncTasks == null) syncTasks = new Runnable[2];
syncTasks[1] = new Runnable() { syncTasks[1] = () -> {
@Override for (final CompoundTag nativeTag : entities) {
public void run() { final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
for (final CompoundTag nativeTag : entities) { final StringTag idTag = (StringTag) entityTagMap.get("Id");
final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue()); final ListTag posTag = (ListTag) entityTagMap.get("Pos");
final StringTag idTag = (StringTag) entityTagMap.get("Id"); final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
final ListTag posTag = (ListTag) entityTagMap.get("Pos"); if (idTag == null || posTag == null || rotTag == null) {
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); getLogger(BukkitGetBlocks_1_14.class).debug("Unknown entity tag: " + nativeTag);
if (idTag == null || posTag == null || rotTag == null) { continue;
getLogger(BukkitGetBlocks_1_14.class).debug("Unknown entity tag: " + nativeTag); }
continue; final double x = posTag.getDouble(0);
} final double y = posTag.getDouble(1);
final double x = posTag.getDouble(0); final double z = posTag.getDouble(2);
final double y = posTag.getDouble(1); final float yaw = rotTag.getFloat(0);
final double z = posTag.getDouble(2); final float pitch = rotTag.getFloat(1);
final float yaw = rotTag.getFloat(0); final String id = idTag.getValue();
final float pitch = rotTag.getFloat(1);
final String id = idTag.getValue();
EntityTypes<?> type = EntityTypes.a(id).orElse(null); EntityTypes<?> type = EntityTypes.a(id).orElse(null);
if (type != null) { if (type != null) {
Entity entity = type.a(nmsWorld); Entity entity = type.a(nmsWorld);
if (entity != null) { if (entity != null) {
UUID uuid = entity.getUniqueID(); UUID uuid = entity.getUniqueID();
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits())); entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits())); entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
if (nativeTag != null) { if (nativeTag != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag); final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name); tag.remove(name);
}
entity.f(tag);
} }
entity.setLocation(x, y, z, yaw, pitch); entity.f(tag);
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
} }
entity.setLocation(x, y, z, yaw, pitch);
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
} }
} }
} }
@ -421,31 +396,28 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
if (tiles != null && !tiles.isEmpty()) { if (tiles != null && !tiles.isEmpty()) {
if (syncTasks == null) syncTasks = new Runnable[1]; if (syncTasks == null) syncTasks = new Runnable[1];
syncTasks[0] = new Runnable() { syncTasks[0] = () -> {
@Override for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
public void run() { final CompoundTag nativeTag = entry.getValue();
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) { final BlockVector3 blockHash = entry.getKey();
final CompoundTag nativeTag = entry.getValue(); final int x = blockHash.getX() + bx;
final BlockVector3 blockHash = entry.getKey(); final int y = blockHash.getY();
final int x = blockHash.getX() + bx; final int z = blockHash.getZ() + bz;
final int y = blockHash.getY(); final BlockPosition pos = new BlockPosition(x, y, z);
final int z = blockHash.getZ() + bz;
final BlockPosition pos = new BlockPosition(x, y, z);
synchronized (nmsWorld) { synchronized (nmsWorld) {
TileEntity tileEntity = nmsWorld.getTileEntity(pos); TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity == null || tileEntity.isRemoved()) { if (tileEntity == null || tileEntity.isRemoved()) {
nmsWorld.removeTileEntity(pos); nmsWorld.removeTileEntity(pos);
tileEntity = nmsWorld.getTileEntity(pos); tileEntity = nmsWorld.getTileEntity(pos);
} }
if (tileEntity != null) { if (tileEntity != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag); final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
tag.set("x", new NBTTagInt(x)); tag.set("x", new NBTTagInt(x));
tag.set("y", new NBTTagInt(y)); tag.set("y", new NBTTagInt(y));
tag.set("z", new NBTTagInt(z)); tag.set("z", new NBTTagInt(z));
tileEntity.load(tag); tileEntity.load(tag);
}
} }
} }
} }
@ -478,27 +450,23 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
Runnable[] finalSyncTasks = syncTasks; Runnable[] finalSyncTasks = syncTasks;
// Chain the sync tasks and the callback // Chain the sync tasks and the callback
Callable<Future> chain = new Callable<Future>() { Callable<Future> chain = () -> {
@Override try {
public Future call() { // Run the sync tasks
try { for (Runnable task : finalSyncTasks) {
// Run the sync tasks if (task != null) {
for (int i = 0; i < finalSyncTasks.length; i++) { task.run();
Runnable task = finalSyncTasks[i];
if (task != null) {
task.run();
}
} }
if (callback == null) {
if (finalizer != null) finalizer.run();
return null;
} else {
return queueHandler.async(callback, null);
}
} catch (Throwable e) {
e.printStackTrace();
throw e;
} }
if (callback == null) {
if (finalizer != null) finalizer.run();
return null;
} else {
return queueHandler.async(callback, null);
}
} catch (Throwable e) {
e.printStackTrace();
throw e;
} }
}; };
return (T) (Future) queueHandler.sync(chain); return (T) (Future) queueHandler.sync(chain);

View File

@ -1,5 +1,7 @@
package com.boydti.fawe.bukkit.adapter.mc1_15; package com.boydti.fawe.bukkit.adapter.mc1_15;
import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
@ -12,8 +14,11 @@ import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.LongTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.jnbt.*;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
@ -22,7 +27,37 @@ import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import net.minecraft.server.v1_15_R1.*; import java.util.AbstractSet;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.function.Function;
import javax.annotation.Nullable;
import net.minecraft.server.v1_15_R1.BiomeBase;
import net.minecraft.server.v1_15_R1.BiomeStorage;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.Chunk;
import net.minecraft.server.v1_15_R1.ChunkSection;
import net.minecraft.server.v1_15_R1.DataBits;
import net.minecraft.server.v1_15_R1.DataPalette;
import net.minecraft.server.v1_15_R1.DataPaletteBlock;
import net.minecraft.server.v1_15_R1.DataPaletteHash;
import net.minecraft.server.v1_15_R1.DataPaletteLinear;
import net.minecraft.server.v1_15_R1.Entity;
import net.minecraft.server.v1_15_R1.EntityTypes;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.LightEngineThreaded;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
import net.minecraft.server.v1_15_R1.NBTTagInt;
import net.minecraft.server.v1_15_R1.TileEntity;
import net.minecraft.server.v1_15_R1.WorldServer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
@ -30,14 +65,6 @@ import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.function.Function;
import static org.slf4j.LoggerFactory.getLogger;
public class BukkitGetBlocks_1_15 extends CharGetBlocks { public class BukkitGetBlocks_1_15 extends CharGetBlocks {
private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ()); private static final Function<BlockPosition, BlockVector3> posNms2We = v -> BlockVector3.at(v.getX(), v.getY(), v.getZ());
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_15(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound()))); private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_15(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
@ -214,9 +241,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
{ {
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities(); Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
if (!tiles.isEmpty()) { if (!tiles.isEmpty()) {
final Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator(); for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
while (iterator.hasNext()) {
final Map.Entry<BlockPosition, TileEntity> entry = iterator.next();
final BlockPosition pos = entry.getKey(); final BlockPosition pos = entry.getKey();
final int lx = pos.getX() & 15; final int lx = pos.getX() & 15;
final int ly = pos.getY(); final int ly = pos.getY();
@ -319,8 +344,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
syncTasks[2] = () -> { syncTasks[2] = () -> {
final List<Entity>[] entities = nmsChunk.getEntitySlices(); final List<Entity>[] entities = nmsChunk.getEntitySlices();
for (int i = 0; i < entities.length; i++) { for (final Collection<Entity> ents : entities) {
final Collection<Entity> ents = entities[i];
if (!ents.isEmpty()) { if (!ents.isEmpty()) {
final Iterator<Entity> iter = ents.iterator(); final Iterator<Entity> iter = ents.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
@ -339,43 +363,40 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
if (entities != null && !entities.isEmpty()) { if (entities != null && !entities.isEmpty()) {
if (syncTasks == null) syncTasks = new Runnable[2]; if (syncTasks == null) syncTasks = new Runnable[2];
syncTasks[1] = new Runnable() { syncTasks[1] = () -> {
@Override for (final CompoundTag nativeTag : entities) {
public void run() { final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
for (final CompoundTag nativeTag : entities) { final StringTag idTag = (StringTag) entityTagMap.get("Id");
final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue()); final ListTag posTag = (ListTag) entityTagMap.get("Pos");
final StringTag idTag = (StringTag) entityTagMap.get("Id"); final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
final ListTag posTag = (ListTag) entityTagMap.get("Pos"); if (idTag == null || posTag == null || rotTag == null) {
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation"); getLogger(BukkitGetBlocks_1_15.class).debug("Unknown entity tag: " + nativeTag);
if (idTag == null || posTag == null || rotTag == null) { continue;
getLogger(BukkitGetBlocks_1_15.class).debug("Unknown entity tag: " + nativeTag); }
continue; final double x = posTag.getDouble(0);
} final double y = posTag.getDouble(1);
final double x = posTag.getDouble(0); final double z = posTag.getDouble(2);
final double y = posTag.getDouble(1); final float yaw = rotTag.getFloat(0);
final double z = posTag.getDouble(2); final float pitch = rotTag.getFloat(1);
final float yaw = rotTag.getFloat(0); final String id = idTag.getValue();
final float pitch = rotTag.getFloat(1);
final String id = idTag.getValue();
EntityTypes<?> type = EntityTypes.a(id).orElse(null); EntityTypes<?> type = EntityTypes.a(id).orElse(null);
if (type != null) { if (type != null) {
Entity entity = type.a(nmsWorld); Entity entity = type.a(nmsWorld);
if (entity != null) { if (entity != null) {
UUID uuid = entity.getUniqueID(); UUID uuid = entity.getUniqueID();
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits())); entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits())); entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
if (nativeTag != null) { if (nativeTag != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag); final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name); tag.remove(name);
}
entity.f(tag);
} }
entity.setLocation(x, y, z, yaw, pitch); entity.f(tag);
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
} }
entity.setLocation(x, y, z, yaw, pitch);
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
} }
} }
} }
@ -416,11 +437,10 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
}; };
} }
{//Lighting //Lighting
// TODO optimize, cause this is really slow // TODO optimize, cause this is really slow
LightEngineThreaded engine = (LightEngineThreaded) nmsChunk.e(); LightEngineThreaded engine = (LightEngineThreaded) nmsChunk.e();
engine.a(nmsChunk, false); engine.a(nmsChunk, false);
}
Runnable callback; Runnable callback;
if (bitMask == 0 && biomes == null) { if (bitMask == 0 && biomes == null) {
@ -445,8 +465,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
Callable<Future> chain = () -> { Callable<Future> chain = () -> {
try { try {
// Run the sync tasks // Run the sync tasks
for (int i = 0; i < finalSyncTasks.length; i++) { for (Runnable task : finalSyncTasks) {
Runnable task = finalSyncTasks[i];
if (task != null) { if (task != null) {
task.run(); task.run();
} }

View File

@ -10,7 +10,6 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent; import com.sk89q.worldedit.extent.PassthroughExtent;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import java.io.File; import java.io.File;
@ -76,7 +75,8 @@ import org.jetbrains.annotations.Nullable;
* @see #wrap(World) * @see #wrap(World)
* @see #create(WorldCreator) * @see #create(WorldCreator)
*/ */
public class AsyncWorld extends PassthroughExtent implements World { public class AsyncWorld
extends PassthroughExtent implements World {
private World parent; private World parent;
private BukkitImplAdapter adapter; private BukkitImplAdapter adapter;
@ -181,13 +181,13 @@ public class AsyncWorld extends PassthroughExtent implements World {
} }
@Override @Override
public <T> void spawnParticle(Particle particle, double v, double v1, double v2, int i, T t) { public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, T data) {
parent.spawnParticle(particle, v, v1, v2, i, t); parent.spawnParticle(particle, x, y, z, count, data);
} }
@Override @Override
public void spawnParticle(Particle particle, Location location, int i, double v, double v1, double v2) { public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ) {
parent.spawnParticle(particle, location, i, v, v1, v2); parent.spawnParticle(particle, location, count, offsetX, offsetY, offsetZ);
} }
@Override @Override
@ -830,22 +830,43 @@ public class AsyncWorld extends PassthroughExtent implements World {
return adapter.adapt(getExtent().getBiomeType(x, 0, z)); return adapter.adapt(getExtent().getBiomeType(x, 0, z));
} }
@Override
public @NotNull Biome getBiome(int x, int y, int z) {
return adapter.adapt(getExtent().getBiomeType(x,y,z));
}
@Override @Override
public void setBiome(int x, int z, Biome bio) { public void setBiome(int x, int z, Biome bio) {
BiomeType biome = adapter.adapt(bio); BiomeType biome = adapter.adapt(bio);
getExtent().setBiome(x, 0, z, biome); getExtent().setBiome(x, 0, z, biome);
} }
@Override
public void setBiome(int x, int y, int z, @NotNull Biome bio) {
BiomeType biome = adapter.adapt(bio);
getExtent().setBiome(x, y, z, biome);
}
@Override @Override
public double getTemperature(int x, int z) { public double getTemperature(int x, int z) {
return parent.getTemperature(x, z); return parent.getTemperature(x, z);
} }
@Override
public double getTemperature(int x, int y, int z) {
return parent.getTemperature(x, y, z);
}
@Override @Override
public double getHumidity(int x, int z) { public double getHumidity(int x, int z) {
return parent.getHumidity(x, z); return parent.getHumidity(x, z);
} }
@Override
public double getHumidity(int x, int y, int z) {
return parent.getHumidity(x, y, z);
}
@Override @Override
public int getMaxHeight() { public int getMaxHeight() {
return parent.getMaxHeight(); return parent.getMaxHeight();
@ -1143,19 +1164,19 @@ public class AsyncWorld extends PassthroughExtent implements World {
} }
@Override @Override
public RayTraceResult rayTraceBlocks(Location arg0, Vector arg1, double arg2, FluidCollisionMode arg3) { public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode) {
return parent.rayTraceBlocks(arg0, arg1, arg2, arg3); return parent.rayTraceBlocks(start, direction, maxDistance, fluidCollisionMode);
} }
@Override @Override
public RayTraceResult rayTraceBlocks(Location arg0, Vector arg1, double arg2, FluidCollisionMode arg3, public RayTraceResult rayTraceBlocks(Location start, Vector direction, double arg2, FluidCollisionMode fluidCollisionMode,
boolean arg4) { boolean ignorePassableBlocks) {
return parent.rayTraceBlocks(arg0, arg1, arg2, arg3, arg4); return parent.rayTraceBlocks(start, direction, arg2, fluidCollisionMode, ignorePassableBlocks);
} }
@Override @Override
public RayTraceResult rayTraceEntities(Location arg0, Vector arg1, double arg2) { public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance) {
return parent.rayTraceEntities(arg0, arg1, arg2); return parent.rayTraceEntities(start, direction, maxDistance);
} }
@Override @Override
@ -1174,16 +1195,11 @@ public class AsyncWorld extends PassthroughExtent implements World {
return parent.rayTraceEntities(arg0, arg1, arg2, arg3, arg4); return parent.rayTraceEntities(arg0, arg1, arg2, arg3, arg4);
} }
@Override
public <T> void spawnParticle(Particle arg0, Location arg1, int arg2, double arg3, double arg4, double arg5,
double arg6, T arg7, boolean arg8) {
parent.spawnParticle(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}
@Override @Override
public <T> void spawnParticle(Particle arg0, double arg1, double arg2, double arg3, int arg4, double arg5, public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z,
double arg6, double arg7, double arg8, T arg9, boolean arg10) { int count, double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data,
parent.spawnParticle(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); boolean force) {
} }
@ -1340,4 +1356,11 @@ public class AsyncWorld extends PassthroughExtent implements World {
public <T> void spawnParticle(Particle particle, List<Player> list, Player player, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t, boolean b) { public <T> void spawnParticle(Particle particle, List<Player> list, Player player, double v, double v1, double v2, int i, double v3, double v4, double v5, double v6, T t, boolean b) {
parent.spawnParticle(particle, list, player, v, v1, v2, i, v3, v4, v5, v6, t, b); parent.spawnParticle(particle, list, player, v, v1, v2, i, v3, v4, v5, v6, t, b);
} }
@Override
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count,
double offsetX, double offsetY, double offsetZ, double extra, @Nullable T data,
boolean force) {
}
} }

View File

@ -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

View File

@ -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;

View File

@ -1,8 +1,6 @@
package com.boydti.fawe; package com.boydti.fawe;
import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
@ -31,6 +29,7 @@ import com.sk89q.worldedit.internal.registry.InputParser;
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.Component;
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;
@ -152,13 +151,12 @@ public class FaweAPI {
* Remember to commit when you're done!<br> * Remember to commit when you're done!<br>
* *
* @param world The name of the world * @param world The name of the world
* @param autoqueue If it should start dispatching before you enqueue it. * @param autoQueue If it should start dispatching before you enqueue it.
* @return * @return the queue extent
* @see IQueueExtent#enqueue()
*/ */
public static IQueueExtent createQueue(World world, boolean autoqueue) { public static IQueueExtent createQueue(World world, boolean autoQueue) {
IQueueExtent queue = Fawe.get().getQueueHandler().getQueue(world); IQueueExtent queue = Fawe.get().getQueueHandler().getQueue(world);
if (!autoqueue) { if (!autoQueue) {
queue.disableQueue(); queue.disableQueue();
} }
return queue; return queue;
@ -189,10 +187,9 @@ public class FaweAPI {
/** /**
* Just forwards to ClipboardFormat.SCHEMATIC.load(file) * Just forwards to ClipboardFormat.SCHEMATIC.load(file)
* *
* @param file * @param file the file to load
* @return * @return a clipboard containing the schematic
* @see ClipboardFormat * @see ClipboardFormat
* @see Schematic
*/ */
public static Clipboard load(File file) throws IOException { public static Clipboard load(File file) throws IOException {
return ClipboardFormats.findByFile(file).load(file); return ClipboardFormats.findByFile(file).load(file);

View File

@ -4,11 +4,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.beta.Trimable;
import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BitArray4096; import com.boydti.fawe.object.collection.BitArray4096;
import com.boydti.fawe.object.collection.CleanableThreadLocal; import com.boydti.fawe.object.collection.CleanableThreadLocal;
@ -18,6 +13,9 @@ import com.boydti.fawe.object.exception.FaweChunkLoadException;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.IOUtil; import com.boydti.fawe.util.IOUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -34,6 +32,7 @@ import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.MutableVector3; import com.sk89q.worldedit.math.MutableVector3;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
@ -192,7 +191,7 @@ public enum FaweCache implements Trimable {
} else { } else {
pool = cache::get; pool = cache::get;
} }
Pool previous = REGISTERED_POOLS.putIfAbsent(clazz, pool); Pool<T> previous = REGISTERED_POOLS.putIfAbsent(clazz, pool);
if (previous != null) { if (previous != null) {
throw new IllegalStateException("Previous key"); throw new IllegalStateException("Previous key");
} }

View File

@ -1,9 +1,7 @@
package com.boydti.fawe.beta; package com.boydti.fawe.beta;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock;
import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor; import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor;
import com.boydti.fawe.beta.implementation.processors.MultiBatchProcessor; import com.boydti.fawe.beta.implementation.processors.MultiBatchProcessor;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -68,10 +66,18 @@ public interface IBatchProcessor {
} }
} }
} }
for (int layer = (minY - 15) >> 4; layer < (maxY + 15) >> 4; layer++) { try {
if (set.hasSection(layer)) { int layer = (minY - 15) >> 4;
return true; while (layer < (maxY + 15) >> 4) {
if (set.hasSection(layer)) {
return true;
}
layer++;
} }
} catch (ArrayIndexOutOfBoundsException exception) {
Fawe.imp().debug("minY = " + minY);
Fawe.imp().debug("layer = " + ((minY - 15) >> 4));
exception.printStackTrace();
} }
return false; return false;
} }

View File

@ -8,12 +8,9 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockID;
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.registry.BlockRegistry; import com.sk89q.worldedit.world.registry.BlockRegistry;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;

View File

@ -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;
} }

View File

@ -4,13 +4,10 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.object.collection.MemBlockSet; import com.boydti.fawe.object.collection.MemBlockSet;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;

View File

@ -1,9 +1,11 @@
package com.boydti.fawe.beta.implementation.blocks; package com.boydti.fawe.beta.implementation.blocks;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.IBlocks; import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.IChunkSet;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
import org.jetbrains.annotations.Range;
public abstract class CharBlocks implements IBlocks { public abstract class CharBlocks implements IBlocks {
@ -66,7 +68,7 @@ public abstract class CharBlocks implements IBlocks {
return null; return null;
} }
public void reset(int layer) { public void reset(@Range(from = 0, to = 15) int layer) {
sections[layer] = EMPTY; sections[layer] = EMPTY;
} }
@ -81,12 +83,12 @@ public abstract class CharBlocks implements IBlocks {
} }
@Override @Override
public boolean hasSection(int layer) { public boolean hasSection(@Range(from = 0, to = 15) int layer) {
return sections[layer] == FULL; return sections[layer] == FULL;
} }
@Override @Override
public char[] load(int layer) { public char[] load(@Range(from = 0, to = 15) int layer) {
return sections[layer].get(this, layer); return sections[layer].get(this, layer);
} }
@ -104,18 +106,24 @@ public abstract class CharBlocks implements IBlocks {
public void set(int x, int y, int z, char value) { public void set(int x, int y, int z, char value) {
final int layer = y >> 4; final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x; final int index = (y & 15) << 8 | z << 4 | x;
set(layer, index, value); try {
set(layer, index, value);
} catch (ArrayIndexOutOfBoundsException exception) {
Fawe.imp().debug("Tried Setting Block at x:" + x + ", y:" + y + " , z:" + z);
Fawe.imp().debug("Layer variable was = " + layer);
exception.printStackTrace();
}
} }
/* /*
Section Section
*/ */
public final char get(int layer, int index) { public final char get(@Range(from = 0, to = 15)int layer, int index) {
return sections[layer].get(this, layer, index); return sections[layer].get(this, layer, index);
} }
public final void set(int layer, int index, char value) { public final void set(@Range(from = 0, to = 15) int layer, int index, char value) throws ArrayIndexOutOfBoundsException {
sections[layer].set(this, layer, index, value); sections[layer].set(this, layer, index, value);
} }

View File

@ -207,8 +207,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
} }
@Override @Override
public boolean setBlock(ChunkHolder chunk, int x, int y, int z, public boolean setBlock(ChunkHolder chunk, int x, int y, int z, BlockStateHolder block) {
BlockStateHolder block) {
return chunk.chunkSet.setBlock(x, y, z, block); return chunk.chunkSet.setBlock(x, y, z, block);
} }
@ -250,16 +249,14 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
} }
@Override @Override
public boolean setBiome(ChunkHolder chunk, int x, int y, int z, public boolean setBiome(ChunkHolder chunk, int x, int y, int z, BiomeType biome) {
BiomeType biome) {
chunk.getOrCreateSet(); chunk.getOrCreateSet();
chunk.delegate = SET; chunk.delegate = SET;
return chunk.setBiome(x, y, z, biome); return chunk.setBiome(x, y, z, biome);
} }
@Override @Override
public boolean setBlock(ChunkHolder chunk, int x, int y, int z, public boolean setBlock(ChunkHolder chunk, int x, int y, int z, BlockStateHolder block) {
BlockStateHolder block) {
chunk.getOrCreateSet(); chunk.getOrCreateSet();
chunk.delegate = SET; chunk.delegate = SET;
return chunk.setBlock(x, y, z, block); return chunk.setBlock(x, y, z, block);
@ -471,11 +468,9 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
IChunkGet get(ChunkHolder chunk); IChunkGet get(ChunkHolder chunk);
IChunkSet set(ChunkHolder chunk); IChunkSet set(ChunkHolder chunk);
boolean setBiome(ChunkHolder chunk, int x, int y, int z, boolean setBiome(ChunkHolder chunk, int x, int y, int z, BiomeType biome);
BiomeType biome);
boolean setBlock(ChunkHolder chunk, int x, int y, int z, boolean setBlock(ChunkHolder chunk, int x, int y, int z, BlockStateHolder holder);
BlockStateHolder holder);
BiomeType getBiome(ChunkHolder chunk, int x, int y, int z); BiomeType getBiome(ChunkHolder chunk, int x, int y, int z);

View File

@ -33,8 +33,8 @@ import java.util.concurrent.Future;
*/ */
public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent<IQueueChunk> { public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent<IQueueChunk> {
// // Pool discarded chunks for reuse (can safely be cleared by another thread) // Pool discarded chunks for reuse (can safely be cleared by another thread)
// private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>(); // private static final ConcurrentLinkedQueue<IChunk> CHUNK_POOL = new ConcurrentLinkedQueue<>();
// Chunks currently being queued / worked on // Chunks currently being queued / worked on
private final Long2ObjectLinkedOpenHashMap<IQueueChunk> chunks = new Long2ObjectLinkedOpenHashMap<>(); private final Long2ObjectLinkedOpenHashMap<IQueueChunk> chunks = new Long2ObjectLinkedOpenHashMap<>();

View File

@ -15,7 +15,7 @@ public class Settings extends Config {
@Ignore @Ignore
public boolean PROTOCOL_SUPPORT_FIX = false; public boolean PROTOCOL_SUPPORT_FIX = false;
@Ignore @Ignore
public boolean PLOTSQUARED_HOOK = true; public boolean PLOTSQUARED_HOOK = false;
@Comment("These first 6 aren't configurable") // This is a comment @Comment("These first 6 aren't configurable") // This is a comment
@Final // Indicates that this value isn't configurable @Final // Indicates that this value isn't configurable

View File

@ -48,7 +48,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
private @Language("SQLite") String GET_EDITS_USER = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC"; private @Language("SQLite") String GET_EDITS_USER = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC";
private @Language("SQLite") String GET_EDITS_USER_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC"; private @Language("SQLite") String GET_EDITS_USER_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC";
private @Language("SQLite") String GET_EDITS = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` DESC, `id` DESC"; private @Language("SQLite") String GET_EDITS = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` DESC, `id` DESC";
private @Language("SQLite") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` ASC, `id` ASC"; private @Language("SQLite") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` , `id` ";
private @Language("SQLite") String GET_EDIT_USER = "SELECT * FROM `{0}edits` WHERE `player`=? AND `id`=?"; private @Language("SQLite") String GET_EDIT_USER = "SELECT * FROM `{0}edits` WHERE `player`=? AND `id`=?";
private @Language("SQLite") String DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?"; private @Language("SQLite") String DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?";

View File

@ -51,7 +51,7 @@ public class MCAChunk implements IChunk {
public final char[] blocks = new char[65536]; public final char[] blocks = new char[65536];
public final BlockVector3ChunkMap<CompoundTag> tiles = new BlockVector3ChunkMap<CompoundTag>(); public final BlockVector3ChunkMap<CompoundTag> tiles = new BlockVector3ChunkMap<>();
public final Map<UUID, CompoundTag> entities = new HashMap<>(); public final Map<UUID, CompoundTag> entities = new HashMap<>();
public long inhabitedTime = System.currentTimeMillis(); public long inhabitedTime = System.currentTimeMillis();
public long lastUpdate; public long lastUpdate;
@ -142,7 +142,7 @@ public class MCAChunk implements IChunk {
for (Map.Entry<String, String> entry : properties.entrySet()) { for (Map.Entry<String, String> entry : properties.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String value = entry.getValue(); String value = entry.getValue();
Property property = type.getProperty(key); Property<Object> property = type.getProperty(key);
state = state.with(property, property.getValueFor(value)); state = state.with(property, property.getValueFor(value));
} }
} }
@ -246,8 +246,8 @@ public class MCAChunk implements IChunk {
int type = NBTConstants.TYPE_BYTE_ARRAY; int type = NBTConstants.TYPE_BYTE_ARRAY;
out.writeNamedTagName("Biomes", type); out.writeNamedTagName("Biomes", type);
out.writeInt(biomes.length); out.writeInt(biomes.length);
for (int i = 0; i < biomes.length; i++) { for (BiomeType biome : biomes) {
out.write(biomes[i].getLegacyId()); out.write(biome.getLegacyId());
} }
} }
int len = 0; int len = 0;
@ -430,9 +430,7 @@ public class MCAChunk implements IChunk {
if (tile != null) { if (tile != null) {
tiles.put(x, y, z, tile); tiles.put(x, y, z, tile);
} else { } else {
if (tiles.remove(x, y, z) == null) { return tiles.remove(x, y, z) != null;
return false;
}
} }
return true; return true;
} }
@ -520,18 +518,14 @@ public class MCAChunk implements IChunk {
@Override @Override
public void setBlocks(int layer, char[] data) { public void setBlocks(int layer, char[] data) {
int offset = layer << 12; int offset = layer << 12;
for (int i = 0; i < 4096; i++) { System.arraycopy(data, 0, blocks, offset, 4096);
blocks[offset + i] = data[i];
}
} }
@Override @Override
public char[] load(int layer) { public char[] load(int layer) {
char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get(); char[] tmp = FaweCache.IMP.SECTION_BITS_TO_CHAR.get();
int offset = layer << 12; int offset = layer << 12;
for (int i = 0; i < 4096; i++) { System.arraycopy(blocks, offset, tmp, 0, 4096);
tmp[i] = blocks[offset + i];
}
return tmp; return tmp;
} }

View File

@ -34,6 +34,7 @@ import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.stream.IntStream;
import java.util.zip.Deflater; import java.util.zip.Deflater;
import java.util.zip.Inflater; import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream; import java.util.zip.InflaterInputStream;
@ -397,10 +398,8 @@ public class MCAFile extends ExtentBatchProcessorHolder implements Trimable, ICh
} }
public List<MCAChunk> getCachedChunks() { public List<MCAChunk> getCachedChunks() {
int size = 0; int size = (int) IntStream.range(0, chunks.length)
for (int i = 0; i < chunks.length; i++) { .filter(i -> chunks[i] != null && this.chunkInitialized[i]).count();
if (chunks[i] != null && this.chunkInitialized[i]) size++;
}
ArrayList<MCAChunk> list = new ArrayList<>(size); ArrayList<MCAChunk> list = new ArrayList<>(size);
for (int i = 0; i < chunks.length; i++) { for (int i = 0; i < chunks.length; i++) {
MCAChunk chunk = chunks[i]; MCAChunk chunk = chunks[i];

View File

@ -13,6 +13,7 @@ import com.boydti.fawe.beta.implementation.filter.block.MultiFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket; import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.beta.implementation.blocks.FallbackChunkGet; import com.boydti.fawe.beta.implementation.blocks.FallbackChunkGet;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.jnbt.anvil.MCAChunk; import com.boydti.fawe.jnbt.anvil.MCAChunk;
import com.boydti.fawe.object.FaweInputStream; import com.boydti.fawe.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream; import com.boydti.fawe.object.FaweOutputStream;
@ -51,7 +52,6 @@ import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
@ -66,7 +66,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -1548,9 +1547,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
} }
public void setHeights(int value) { public void setHeights(int value) {
heights.record(() -> { heights.record(() -> Arrays.fill(heights.get(), (byte) value));
Arrays.fill(heights.get(), (byte) value);
});
} }
@Override @Override

View File

@ -18,6 +18,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.io.Closeable; import java.io.Closeable;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import org.jetbrains.annotations.NotNull;
/** /**
* Best used when clipboard selections are small, or using legacy formats * Best used when clipboard selections are small, or using legacy formats
@ -42,12 +43,12 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
* The locations provided are relative to the clipboard min * The locations provided are relative to the clipboard min
* *
* @param task * @param task
* @param air
*/ */
public abstract void streamBiomes(IntValueReader task); public abstract void streamBiomes(IntValueReader task);
public abstract Collection<CompoundTag> getTileEntities(); public abstract Collection<CompoundTag> getTileEntities();
@Override
public void close() {} public void close() {}
public void flush() {} public void flush() {}
@ -57,6 +58,7 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
close(); close();
} }
@NotNull
@Override @Override
public Iterator<BlockVector3> iterator() { public Iterator<BlockVector3> iterator() {
return iterator(Order.YZX); return iterator(Order.YZX);

View File

@ -9,8 +9,6 @@ import java.util.Spliterator;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**

View File

@ -1,8 +1,5 @@
package com.boydti.fawe.object.collection; package com.boydti.fawe.object.collection;
import java.util.function.Function;
import java.util.function.Supplier;
public class VariableThreadLocal extends CleanableThreadLocal<byte[]> { public class VariableThreadLocal extends CleanableThreadLocal<byte[]> {
public VariableThreadLocal() { public VariableThreadLocal() {
super(() -> null); super(() -> null);

View File

@ -6,7 +6,6 @@ import java.io.RandomAccessFile;
import java.io.Writer; import java.io.Writer;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator;
/** /**
@ -156,10 +155,8 @@ public class FastByteArrayOutputStream extends OutputStream {
public void writeTo(OutputStream out) throws IOException { public void writeTo(OutputStream out) throws IOException {
// Check if we have a list of buffers // Check if we have a list of buffers
if (buffers != null) { if (buffers != null) {
Iterator iter = buffers.iterator();
while (iter.hasNext()) { for (byte[] bytes : buffers) {
byte[] bytes = (byte[]) iter.next();
out.write(bytes, 0, blockSize); out.write(bytes, 0, blockSize);
} }
} }
@ -171,10 +168,8 @@ public class FastByteArrayOutputStream extends OutputStream {
public void writeTo(RandomAccessFile out) throws IOException { public void writeTo(RandomAccessFile out) throws IOException {
// Check if we have a list of buffers // Check if we have a list of buffers
if (buffers != null) { if (buffers != null) {
Iterator iter = buffers.iterator();
while (iter.hasNext()) { for (byte[] bytes : buffers) {
byte[] bytes = (byte[]) iter.next();
out.write(bytes, 0, blockSize); out.write(bytes, 0, blockSize);
} }
} }
@ -231,4 +226,4 @@ public class FastByteArrayOutputStream extends OutputStream {
size = 0; size = 0;
buffers.clear(); buffers.clear();
} }
} }

View File

@ -5,6 +5,7 @@ import java.io.FilterOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UTFDataFormatException; import java.io.UTFDataFormatException;
import org.jetbrains.annotations.NotNull;
public class LittleEndianOutputStream extends FilterOutputStream implements DataOutput { public class LittleEndianOutputStream extends FilterOutputStream implements DataOutput {
@ -18,7 +19,7 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* output stream specified by the out argument. * output stream specified by the out argument.
* *
* @param out the underlying output stream. * @param out the underlying output stream.
* @see java.io.FilterOutputStream#out * @see FilterOutputStream#out
*/ */
public LittleEndianOutputStream(OutputStream out) { public LittleEndianOutputStream(OutputStream out) {
super(out); super(out);
@ -27,24 +28,26 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
/** /**
* Writes the specified byte value to the underlying output stream. * Writes the specified byte value to the underlying output stream.
* *
* @param b the <code>byte</code> value to be written. * @param b the {@code byte} value to be written.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
*/ */
@Override
public synchronized void write(int b) throws IOException { public synchronized void write(int b) throws IOException {
out.write(b); out.write(b);
written++; written++;
} }
/** /**
* Writes <code>length</code> bytes from the specified byte array * Writes {@code length} bytes from the specified byte array
* starting at <code>offset</code> to the underlying output stream. * starting at {@code offset} to the underlying output stream.
* *
* @param data the data. * @param data the data.
* @param offset the start offset in the data. * @param offset the start offset in the data.
* @param length the number of bytes to write. * @param length the number of bytes to write.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
*/ */
public synchronized void write(byte[] data, int offset, int length) @Override
public synchronized void write(@NotNull byte[] data, int offset, int length)
throws IOException { throws IOException {
out.write(data, offset, length); out.write(data, offset, length);
written += length; written += length;
@ -52,13 +55,14 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
/** /**
* Writes a <code>boolean</code> to the underlying output stream as * Writes a {@code boolean} to the underlying output stream as
* a single byte. If the argument is true, the byte value 1 is written. * a single byte. If the argument is true, the byte value 1 is written.
* If the argument is false, the byte value <code>0</code> in written. * If the argument is false, the byte value {@code 0} in written.
* *
* @param b the <code>boolean</code> value to be written. * @param b the {@code boolean} value to be written.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
*/ */
@Override
public void writeBoolean(boolean b) throws IOException { public void writeBoolean(boolean b) throws IOException {
if (b) this.write(1); if (b) this.write(1);
@ -67,23 +71,25 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
} }
/** /**
* Writes out a <code>byte</code> to the underlying output stream * Writes out a {@code byte} to the underlying output stream
* *
* @param b the <code>byte</code> value to be written. * @param b the {@code byte} value to be written.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
*/ */
@Override
public void writeByte(int b) throws IOException { public void writeByte(int b) throws IOException {
out.write(b); out.write(b);
written++; written++;
} }
/** /**
* Writes a two byte <code>short</code> to the underlying output stream in * Writes a two byte {@code short} to the underlying output stream in
* little endian order, low byte first. * little endian order, low byte first.
* *
* @param s the <code>short</code> to be written. * @param s the {@code short} to be written.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
*/ */
@Override
public void writeShort(int s) throws IOException { public void writeShort(int s) throws IOException {
out.write(s & 0xFF); out.write(s & 0xFF);
@ -93,12 +99,13 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
} }
/** /**
* Writes a two byte <code>char</code> to the underlying output stream * Writes a two byte {@code char} to the underlying output stream
* in little endian order, low byte first. * in little endian order, low byte first.
* *
* @param c the <code>char</code> value to be written. * @param c the {@code char} value to be written.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
*/ */
@Override
public void writeChar(int c) throws IOException { public void writeChar(int c) throws IOException {
out.write(c & 0xFF); out.write(c & 0xFF);
@ -108,12 +115,13 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
} }
/** /**
* Writes a four-byte <code>int</code> to the underlying output stream * Writes a four-byte {@code int} to the underlying output stream
* in little endian order, low byte first, high byte last * in little endian order, low byte first, high byte last
* *
* @param i the <code>int</code> to be written. * @param i the {@code int} to be written.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
*/ */
@Override
public void writeInt(int i) throws IOException { public void writeInt(int i) throws IOException {
out.write(i & 0xFF); out.write(i & 0xFF);
@ -125,12 +133,13 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
} }
/** /**
* Writes an eight-byte <code>long</code> to the underlying output stream * Writes an eight-byte {@code long} to the underlying output stream
* in little endian order, low byte first, high byte last * in little endian order, low byte first, high byte last
* *
* @param l the <code>long</code> to be written. * @param l the {@code long} to be written.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
*/ */
@Override
public void writeLong(long l) throws IOException { public void writeLong(long l) throws IOException {
out.write((int) l & 0xFF); out.write((int) l & 0xFF);
@ -149,9 +158,10 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Writes a 4 byte Java float to the underlying output stream in * Writes a 4 byte Java float to the underlying output stream in
* little endian order. * little endian order.
* *
* @param f the <code>float</code> value to be written. * @param f the {@code float} value to be written.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
@Override
public final void writeFloat(float f) throws IOException { public final void writeFloat(float f) throws IOException {
this.writeInt(Float.floatToIntBits(f)); this.writeInt(Float.floatToIntBits(f));
@ -162,9 +172,10 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Writes an 8 byte Java double to the underlying output stream in * Writes an 8 byte Java double to the underlying output stream in
* little endian order. * little endian order.
* *
* @param d the <code>double</code> value to be written. * @param d the {@code double} value to be written.
* @exception IOException if an I/O error occurs. * @exception IOException if an I/O error occurs.
*/ */
@Override
public final void writeDouble(double d) throws IOException { public final void writeDouble(double d) throws IOException {
this.writeLong(Double.doubleToLongBits(d)); this.writeLong(Double.doubleToLongBits(d));
@ -174,13 +185,14 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
/** /**
* Writes a string to the underlying output stream as a sequence of * Writes a string to the underlying output stream as a sequence of
* bytes. Each character is written to the data output stream as * bytes. Each character is written to the data output stream as
* if by the <code>writeByte()</code> method. * if by the {@code writeByte()} method.
* *
* @param s the <code>String</code> value to be written. * @param s the {@code String} value to be written.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
* @see java.io.DataOutputStream#writeByte(int) * @see java.io.DataOutputStream#writeByte(int)
* @see java.io.DataOutputStream#out * @see java.io.DataOutputStream#out
*/ */
@Override
public void writeBytes(String s) throws IOException { public void writeBytes(String s) throws IOException {
int length = s.length(); int length = s.length();
@ -193,13 +205,14 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
/** /**
* Writes a string to the underlying output stream as a sequence of * Writes a string to the underlying output stream as a sequence of
* characters. Each character is written to the data output stream as * characters. Each character is written to the data output stream as
* if by the <code>writeChar</code> method. * if by the {@code writeChar} method.
* *
* @param s a <code>String</code> value to be written. * @param s a {@code String} value to be written.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
* @see java.io.DataOutputStream#writeChar(int) * @see java.io.DataOutputStream#writeChar(int)
* @see java.io.DataOutputStream#out * @see java.io.DataOutputStream#out
*/ */
@Override
public void writeChars(String s) throws IOException { public void writeChars(String s) throws IOException {
int length = s.length(); int length = s.length();
@ -227,6 +240,7 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* 65,535 characters. * 65,535 characters.
* @exception IOException if the underlying stream throws an IOException. * @exception IOException if the underlying stream throws an IOException.
*/ */
@Override
public void writeUTF(String s) throws IOException { public void writeUTF(String s) throws IOException {
int numchars = s.length(); int numchars = s.length();
@ -270,11 +284,10 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* (This class is not thread-safe with respect to this method. It is * (This class is not thread-safe with respect to this method. It is
* possible that this number is temporarily less than the actual * possible that this number is temporarily less than the actual
* number of bytes written.) * number of bytes written.)
* @return the value of the <code>written</code> field. * @return the value of the {@code written} field.
* @see java.io.DataOutputStream#written
*/ */
public int size() { public int size() {
return this.written; return this.written;
} }
} }

View File

@ -33,7 +33,6 @@ import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.Vector;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class PolyhedralRegion extends AbstractRegion { public class PolyhedralRegion extends AbstractRegion {
@ -69,7 +68,7 @@ public class PolyhedralRegion extends AbstractRegion {
private BlockVector3 centerAccum = BlockVector3.ZERO; private BlockVector3 centerAccum = BlockVector3.ZERO;
/** /**
* The last triangle that caused a {@link #contains(Vector)} to classify a point as "outside". Used for optimization. * The last triangle that caused a {@link #contains(BlockVector3)} to classify a point as "outside". Used for optimization.
*/ */
private Triangle lastTriangle; private Triangle lastTriangle;

View File

@ -1,13 +1,9 @@
package com.boydti.fawe.object.task; package com.boydti.fawe.object.task;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.TaskManager;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier; import java.util.function.Supplier;

View File

@ -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

View File

@ -7,12 +7,15 @@ import com.google.gson.JsonParser;
import com.sk89q.worldedit.util.paste.Paster; import com.sk89q.worldedit.util.paste.Paster;
import java.io.*; import java.io.*;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.*; import java.util.*;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
/** /**
* Single class paster for the Incendo paste service * Single class paster for the Incendo paste service
@ -212,18 +215,19 @@ public final class IncendoPaster implements Paster {
"# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your " "# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your "
+ "problem\n"); + "problem\n");
b.append("\n# Server Information\n"); b.append("\n# Server Information\n");
b.append("server.platform: ").append(Fawe.imp().getPlatform()).append('\n'); b.append(Fawe.imp().getDebugInfo());
b.append(Fawe.imp().getDebugInfo()).append('\n'); b.append("\n# YAY! Now, let's see what we can find in your JVM\n");
b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n");
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
b.append("memory.free: ").append(runtime.freeMemory()).append('\n'); RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
b.append("memory.max: ").append(runtime.maxMemory()).append('\n'); b.append("Uptime: ").append(TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS) + " minutes").append('\n');
b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n"); b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024 + " MB").append('\n');
b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n"); b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024 + " MB").append('\n');
b.append("java.version: '").append(System.getProperty("java.version")).append("'\n"); b.append("Java Name: ").append(rb.getVmName()).append('\n');
b.append("os.arch: '").append(System.getProperty("os.arch")).append("'\n"); b.append("Java Version: '").append(System.getProperty("java.version")).append("'\n");
b.append("os.name: '").append(System.getProperty("os.name")).append("'\n"); b.append("Java Vendor: '").append(System.getProperty("java.vendor")).append("'\n");
b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n"); b.append("Operating System: '").append(System.getProperty("os.name")).append("'\n");
b.append("OS Version: ").append(System.getProperty("os.version")).append('\n');
b.append("OS Arch: ").append(System.getProperty("os.arch")).append('\n');
b.append("# Okay :D Great. You are now ready to create your bug report!"); b.append("# Okay :D Great. You are now ready to create your bug report!");
b.append("\n# You can do so at https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues"); b.append("\n# You can do so at https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13/issues");
b.append("\n# or via our Discord at https://discord.gg/ngZCzbU"); b.append("\n# or via our Discord at https://discord.gg/ngZCzbU");

View File

@ -52,7 +52,7 @@ public class ReflectionUtils {
// 2. Copy it // 2. Copy it
T[] previousValues = (T[]) valuesField.get(enumType); T[] previousValues = (T[]) valuesField.get(enumType);
List values = new ArrayList(Arrays.asList(previousValues)); List<T> values = new ArrayList<>(Arrays.asList(previousValues));
// 3. build new enum // 3. build new enum
T newValue = (T) makeEnum(enumType, // The target enum class T newValue = (T) makeEnum(enumType, // The target enum class
@ -176,7 +176,7 @@ public class ReflectionUtils {
public static <T> List<T> getList(List<T> list) { public static <T> List<T> getList(List<T> list) {
try { try {
Class<? extends List> clazz = (Class<? extends List>) Class.forName("java.util.Collections$UnmodifiableList"); Class<? extends List<T>> clazz = (Class<? extends List<T>>) Class.forName("java.util.Collections$UnmodifiableList");
if (!clazz.isInstance(list)) return list; if (!clazz.isInstance(list)) return list;
Field m = clazz.getDeclaredField("list"); Field m = clazz.getDeclaredField("list");
m.setAccessible(true); m.setAccessible(true);
@ -566,10 +566,10 @@ public class ReflectionUtils {
* @throws RuntimeException if constructor not found * @throws RuntimeException if constructor not found
*/ */
public RefConstructor findConstructor(int number) { public RefConstructor findConstructor(int number) {
final List<Constructor> constructors = new ArrayList<>(); final List<Constructor<?>> constructors = new ArrayList<>();
Collections.addAll(constructors, this.clazz.getConstructors()); Collections.addAll(constructors, this.clazz.getConstructors());
Collections.addAll(constructors, this.clazz.getDeclaredConstructors()); Collections.addAll(constructors, this.clazz.getDeclaredConstructors());
for (Constructor m : constructors) { for (Constructor<?> m : constructors) {
if (m.getParameterTypes().length == number) { if (m.getParameterTypes().length == number) {
return new RefConstructor(m); return new RefConstructor(m);
} }

View File

@ -32,7 +32,7 @@ public class ReflectionUtils9 {
// 2. Copy it // 2. Copy it
T[] previousValues = (T[]) valuesField.get(enumType); T[] previousValues = (T[]) valuesField.get(enumType);
List values = new ArrayList<>(Arrays.asList(previousValues)); List<T> values = new ArrayList<>(Arrays.asList(previousValues));
// 3. build new enum // 3. build new enum
T newValue = (T) makeEnum(enumType, // The target enum class T newValue = (T) makeEnum(enumType, // The target enum class

View File

@ -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);

View File

@ -19,9 +19,14 @@
package com.sk89q.worldedit; package com.sk89q.worldedit;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.Caption; import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
@ -87,11 +92,11 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.internal.expression.EvaluationException; import com.sk89q.worldedit.internal.expression.EvaluationException;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.ExpressionTimeoutException;
import com.sk89q.worldedit.internal.expression.LocalSlot.Variable;
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.math.MathUtils; import com.sk89q.worldedit.math.MathUtils;
import com.sk89q.worldedit.internal.expression.ExpressionTimeoutException;
import com.sk89q.worldedit.internal.expression.LocalSlot.Variable;
import com.sk89q.worldedit.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector2;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.math.Vector2;
@ -114,6 +119,7 @@ import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.eventbus.EventBus; import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
@ -124,11 +130,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -138,12 +139,10 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.jetbrains.annotations.NotNull;
import static com.google.common.base.Preconditions.checkArgument; import org.jetbrains.annotations.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import org.slf4j.Logger;
import static com.sk89q.worldedit.regions.Regions.asFlatRegion; import org.slf4j.LoggerFactory;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
/** /**
* An {@link Extent} that handles history, {@link BlockBag}s, change limits, * An {@link Extent} that handles history, {@link BlockBag}s, change limits,
@ -192,15 +191,14 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
} }
} }
private final World world; @SuppressWarnings("ProtectedField")
protected final World world;
private final String worldName; private final String worldName;
private boolean wrapped; private boolean wrapped;
private Extent bypassHistory;
private Extent bypassAll;
private final FaweLimit originalLimit; private final FaweLimit originalLimit;
private final FaweLimit limit; private final FaweLimit limit;
private final Player player; private final Player player;
private FaweChangeSet changeTask; private FaweChangeSet changeSet;
private boolean history; private boolean history;
private final MutableBlockVector3 mutablebv = new MutableBlockVector3(); private final MutableBlockVector3 mutablebv = new MutableBlockVector3();
@ -208,6 +206,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
private int changes = -1; private int changes = -1;
private final BlockBag blockBag; private final BlockBag blockBag;
private Extent bypassHistory;
private Extent bypassAll;
private final int maxY; private final int maxY;
@Deprecated @Deprecated
@ -229,10 +230,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
this.originalLimit = builder.getLimit(); this.originalLimit = builder.getLimit();
this.limit = builder.getLimit().copy(); this.limit = builder.getLimit().copy();
this.player = builder.getPlayer(); this.player = builder.getPlayer();
this.changeTask = builder.getChangeTask(); this.changeSet = builder.getChangeTask();
this.maxY = builder.getMaxY(); this.maxY = builder.getMaxY();
this.blockBag = builder.getBlockBag(); this.blockBag = builder.getBlockBag();
this.history = changeTask != null; this.history = changeSet != null;
} }
/** /**
@ -244,7 +245,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @param blockBag an optional {@link BlockBag} to use, otherwise null * @param blockBag an optional {@link BlockBag} to use, otherwise null
* @param event the event to call with the extent * @param event the event to call with the extent
*/ */
public EditSession(EventBus eventBus, World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent event) { public EditSession(EventBus eventBus, @NotNull World world, int maxBlocks, @Nullable BlockBag blockBag, EditSessionEvent event) {
this(world, null, null, null, null, true, null, null, null, blockBag, eventBus, event); this(world, null, null, null, null, true, null, null, null, blockBag, eventBus, event);
} }
@ -384,15 +385,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @return the change set * @return the change set
*/ */
public ChangeSet getChangeSet() { public ChangeSet getChangeSet() {
return changeTask; return changeSet;
}
/**
* Will be removed very soon. Use getChangeSet()
*/
@Deprecated
public FaweChangeSet getChangeTask() {
return changeTask;
} }
/** /**
@ -401,7 +394,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @param set * @param set
*/ */
public void setRawChangeSet(@Nullable FaweChangeSet set) { public void setRawChangeSet(@Nullable FaweChangeSet set) {
changeTask = set; changeSet = set;
changes++; changes++;
} }
@ -432,7 +425,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @return whether the queue is enabled * @return whether the queue is enabled
* @deprecated Use {@link EditSession#getReorderMode()} with MULTI_STAGE instead. * @deprecated Use {@link EditSession#getReorderMode()} with MULTI_STAGE instead.
*/ */
@Override
@Deprecated @Deprecated
public boolean isQueueEnabled() { public boolean isQueueEnabled() {
return true; return true;
@ -444,7 +436,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* Uses {@link ReorderMode#MULTI_STAGE} * Uses {@link ReorderMode#MULTI_STAGE}
* @deprecated Use {@link EditSession#setReorderMode(ReorderMode)} with MULTI_STAGE instead. * @deprecated Use {@link EditSession#setReorderMode(ReorderMode)} with MULTI_STAGE instead.
*/ */
@Override
@Deprecated @Deprecated
public void enableQueue() { public void enableQueue() {
super.enableQueue(); super.enableQueue();
@ -453,7 +444,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
/** /**
* Disable the queue. This will close the queue. * Disable the queue. This will close the queue.
*/ */
@Override
@Deprecated @Deprecated
public void disableQueue() { public void disableQueue() {
super.disableQueue(); super.disableQueue();
@ -599,10 +589,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
} }
} else { } else {
if (this.history) { if (this.history) {
if (this.changeTask == null) { if (this.changeSet == null) {
throw new IllegalArgumentException("History was never provided, cannot enable"); throw new IllegalArgumentException("History was never provided, cannot enable");
} }
enableHistory(this.changeTask); enableHistory(this.changeSet);
} }
} }
} }
@ -634,6 +624,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @param blockBag the block bag to set, or null to use none * @param blockBag the block bag to set, or null to use none
*/ */
public void setBlockBag(BlockBag blockBag) { public void setBlockBag(BlockBag blockBag) {
//Not Supported in FAWE
throw new UnsupportedOperationException("TODO - this is never called anyway"); throw new UnsupportedOperationException("TODO - this is never called anyway");
} }
@ -728,21 +719,16 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @return {@code true} if any watchdog extent is enabled * @return {@code true} if any watchdog extent is enabled
*/ */
public boolean isTickingWatchdog() { public boolean isTickingWatchdog() {
/*
return watchdogExtents.stream().anyMatch(WatchdogTickingExtent::isEnabled); return watchdogExtents.stream().anyMatch(WatchdogTickingExtent::isEnabled);
*/
return false;
} }
/** /**
* Set all watchdog extents to the given mode. * Set all watchdog extents to the given mode.
*/ */
public void setTickingWatchdog(boolean active) { public void setTickingWatchdog(boolean active) {
/*
for (WatchdogTickingExtent extent : watchdogExtents) { for (WatchdogTickingExtent extent : watchdogExtents) {
extent.setEnabled(active); extent.setEnabled(active);
} }
*/
} }
/** /**
@ -777,7 +763,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @param maxY maximal height * @param maxY maximal height
* @return height of highest block found or 'minY' * @return height of highest block found or 'minY'
*/ */
@Override
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) { public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
for (int y = maxY; y >= minY; --y) { for (int y = maxY; y >= minY; --y) {
if (getBlock(x, y, z).getBlockType().getMaterial().isMovementBlocker()) { if (getBlock(x, y, z).getBlockType().getMaterial().isMovementBlocker()) {
@ -797,7 +782,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @param filter a mask of blocks to consider, or null to consider any solid (movement-blocking) block * @param filter a mask of blocks to consider, or null to consider any solid (movement-blocking) block
* @return height of highest block found or 'minY' * @return height of highest block found or 'minY'
*/ */
@Override
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) { public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
for (int y = maxY; y >= minY; --y) { for (int y = maxY; y >= minY; --y) {
if (filter.test(getExtent(), mutablebv.setComponents(x, y, z))) { if (filter.test(getExtent(), mutablebv.setComponents(x, y, z))) {

View File

@ -483,6 +483,7 @@ public class ClipboardCommands {
} else { } else {
actor.printInfo(TranslatableComponent.of("worldedit.paste.pasted", TextComponent.of(to.toString()))); actor.printInfo(TranslatableComponent.of("worldedit.paste.pasted", TextComponent.of(to.toString())));
} }
messages.forEach(actor::print);
} }
private void checkPaste(Actor player, EditSession editSession, BlockVector3 to, ClipboardHolder holder, Clipboard clipboard) { private void checkPaste(Actor player, EditSession editSession, BlockVector3 to, ClipboardHolder holder, Clipboard clipboard) {

View File

@ -18,6 +18,7 @@
*/ */
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL; import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
@ -25,7 +26,6 @@ import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgum
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Caption; import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
@ -41,8 +41,6 @@ import com.sk89q.worldedit.command.util.annotation.Confirm;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.generator.CavesGen; import com.sk89q.worldedit.function.generator.CavesGen;
import java.util.List;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
@ -53,23 +51,21 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator.TreeType; import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.List;
import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.Switch; import org.enginehub.piston.annotation.param.Switch;
import static com.google.common.base.Preconditions.checkNotNull;
import org.jetbrains.annotations.Range; import org.jetbrains.annotations.Range;
/** /**

View File

@ -1,5 +1,7 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.Caption; import com.boydti.fawe.config.Caption;
@ -37,14 +39,6 @@ import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent; import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
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.BlockState;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import org.jetbrains.annotations.Range;
import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
@ -54,8 +48,14 @@ import java.util.UUID;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.atomic.LongAdder;
import java.util.function.Supplier; import java.util.function.Supplier;
import javax.annotation.Nullable;
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Range;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class HistorySubCommands { public class HistorySubCommands {
@ -79,7 +79,7 @@ public class HistorySubCommands {
@AllowedRegion Region[] allowedRegions, @AllowedRegion Region[] allowedRegions,
@ArgFlag(name = 'u', desc = "String user", def="me") UUID other, @ArgFlag(name = 'u', desc = "String user", def="me") UUID other,
@ArgFlag(name = 'r', def = "0", desc = "radius") @ArgFlag(name = 'r', def = "0", desc = "radius")
@Range(from = 0, to=Integer.MAX_VALUE) int radius, @Range(from = 0, to = Integer.MAX_VALUE) int radius,
@ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0")
@Time long timeDiff) throws WorldEditException { @Time long timeDiff) throws WorldEditException {
rollback(player, world, database, allowedRegions, other, radius, timeDiff, true); rollback(player, world, database, allowedRegions, other, radius, timeDiff, true);
@ -96,7 +96,7 @@ public class HistorySubCommands {
@AllowedRegion Region[] allowedRegions, @AllowedRegion Region[] allowedRegions,
@ArgFlag(name = 'u', desc = "String user", def = "") UUID other, @ArgFlag(name = 'u', desc = "String user", def = "") UUID other,
@ArgFlag(name = 'r', def = "0", desc = "radius") @ArgFlag(name = 'r', def = "0", desc = "radius")
@Range(from = 0, to=Integer.MAX_VALUE) int radius, @Range(from = 0, to = Integer.MAX_VALUE) int radius,
@ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @Time long timeDiff, @ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @Time long timeDiff,
@Switch(name = 'f', desc = "Restore instead of rollback") boolean restore) throws WorldEditException { @Switch(name = 'f', desc = "Restore instead of rollback") boolean restore) throws WorldEditException {
if (!Settings.IMP.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
@ -278,7 +278,7 @@ public class HistorySubCommands {
public synchronized void find(Player player, World world, RollbackDatabase database, Arguments arguments, public synchronized void find(Player player, World world, RollbackDatabase database, Arguments arguments,
@ArgFlag(name = 'u', desc = "String user") UUID other, @ArgFlag(name = 'u', desc = "String user") UUID other,
@ArgFlag(name = 'r', def = "0", desc = "radius") @ArgFlag(name = 'r', def = "0", desc = "radius")
@Range(from = 0, to=Integer.MAX_VALUE) int radius, @Range(from = 0, to = Integer.MAX_VALUE) int radius,
@ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0")
@Time long timeDiff, @Time long timeDiff,
@ArgFlag(name = 'p', desc = "Page to view.", def = "1") int page) throws WorldEditException { @ArgFlag(name = 'p', desc = "Page to view.", def = "1") int page) throws WorldEditException {
@ -318,7 +318,7 @@ public class HistorySubCommands {
} }
PaginationBox pages = PaginationBox.fromStrings("Edits:", pageCommand, list, new Function<Supplier<RollbackOptimizedHistory>, Component>() { PaginationBox pages = PaginationBox.fromStrings("Edits:", pageCommand, list, new Function<Supplier<RollbackOptimizedHistory>, Component>() {
@Nullable @NotNull
@Override @Override
public Component apply(@Nullable Supplier<RollbackOptimizedHistory> input) { public Component apply(@Nullable Supplier<RollbackOptimizedHistory> input) {
RollbackOptimizedHistory edit = input.get(); RollbackOptimizedHistory edit = input.get();

View File

@ -223,7 +223,7 @@ public class SchematicCommands {
URI uri; URI uri;
if (filename.startsWith("url:")) { if (filename.startsWith("url:")) {
if (!actor.hasPermission("worldedit.schematic.load.web")) { if (!actor.hasPermission("worldedit.schematic.load.web")) {
actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.web")); actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.web"));
return; return;
} }
UUID uuid = UUID.fromString(filename.substring(4)); UUID uuid = UUID.fromString(filename.substring(4));
@ -250,7 +250,7 @@ public class SchematicCommands {
} }
} else { } else {
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) {
actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.other")); actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other"));
return; return;
} }
if (format == null && filename.matches(".*\\.[\\w].*")) { if (format == null && filename.matches(".*\\.[\\w].*")) {
@ -329,7 +329,7 @@ public class SchematicCommands {
if (filename.contains("../")) { if (filename.contains("../")) {
other = true; other = true;
if (!actor.hasPermission("worldedit.schematic.save.other")) { if (!actor.hasPermission("worldedit.schematic.save.other")) {
actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.save.other")); actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.save.other"));
return; return;
} }
if (filename.startsWith("../")) { if (filename.startsWith("../")) {
@ -347,7 +347,7 @@ public class SchematicCommands {
} }
if (other) { if (other) {
if (!actor.hasPermission("worldedit.schematic.delete.other")) { if (!actor.hasPermission("worldedit.schematic.delete.other")) {
actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.delete.other")); actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.delete.other"));
return; return;
} }
} }
@ -393,7 +393,7 @@ public class SchematicCommands {
return; return;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) {
player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.move.other")); player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.move.other"));
return; return;
} }
ClipboardHolder clipboard = session.getClipboard(); ClipboardHolder clipboard = session.getClipboard();
@ -414,7 +414,7 @@ public class SchematicCommands {
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) {
player.print(Caption.of("fawe.worldedit.schematic.schematic.move.failed", destFile, player.print(Caption.of("fawe.worldedit.schematic.schematic.move.failed", destFile,
Caption.of("fawe.error.no.perm", ("worldedit.schematic.move.other")))); Caption.of("fawe.error.no-perm", ("worldedit.schematic.move.other"))));
continue; continue;
} }
try { try {
@ -829,7 +829,7 @@ public class SchematicCommands {
continue; continue;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission("worldedit.schematic.delete.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission("worldedit.schematic.delete.other")) {
actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.delete.other")); actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.delete.other"));
continue; continue;
} }
if (!deleteFile(f)) { if (!deleteFile(f)) {

View File

@ -520,33 +520,6 @@ public class UtilityCommands {
return affected; return affected;
} }
private int killMatchingEntities(Integer radius, Actor actor, Supplier<EntityFunction> func) throws IncompleteRegionException,
MaxChangedBlocksException {
List<EntityVisitor> visitors = new ArrayList<>();
LocalSession session = we.getSessionManager().get(actor);
BlockVector3 center = session.getPlacementPosition(actor);
EditSession editSession = session.createEditSession(actor);
List<? extends Entity> entities;
if (radius >= 0) {
CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius);
entities = editSession.getEntities(region);
} else {
entities = editSession.getEntities();
}
visitors.add(new EntityVisitor(entities.iterator(), func.get()));
int killed = 0;
for (EntityVisitor visitor : visitors) {
Operations.completeLegacy(visitor);
killed += visitor.getAffected();
}
session.remember(editSession);
editSession.flushSession();
return killed;
}
@Command( @Command(
name = "extinguish", name = "extinguish",
aliases = { "/ex", "/ext", "/extinguish", "ex", "ext" }, aliases = { "/ex", "/ext", "/extinguish", "ex", "ext" },
@ -632,6 +605,55 @@ public class UtilityCommands {
return killed; return killed;
} }
@Command(
name = "remove",
aliases = { "rem", "rement" },
desc = "Remove all entities of a type"
)
@CommandPermissions("worldedit.remove")
@Logging(PLACEMENT)
public int remove(Actor actor,
@Arg(desc = "The type of entity to remove")
EntityRemover remover,
@Arg(desc = "The radius of the cuboid to remove from")
int radius) throws WorldEditException {
if (radius < -1) {
actor.printError(TranslatableComponent.of("worldedit.remove.explain-all"));
return 0;
}
int removed = killMatchingEntities(radius, actor, remover::createFunction);
actor.printInfo(TranslatableComponent.of("worldedit.remove.removed", TextComponent.of(removed)));
return removed;
}
private int killMatchingEntities(Integer radius, Actor actor, Supplier<EntityFunction> func) throws IncompleteRegionException,
MaxChangedBlocksException {
List<EntityVisitor> visitors = new ArrayList<>();
LocalSession session = we.getSessionManager().get(actor);
BlockVector3 center = session.getPlacementPosition(actor);
EditSession editSession = session.createEditSession(actor);
List<? extends Entity> entities;
if (radius >= 0) {
CylinderRegion region = CylinderRegion.createRadius(editSession, center, radius);
entities = editSession.getEntities(region);
} else {
entities = editSession.getEntities();
}
visitors.add(new EntityVisitor(entities.iterator(), func.get()));
int killed = 0;
for (EntityVisitor visitor : visitors) {
Operations.completeLegacy(visitor);
killed += visitor.getAffected();
}
session.remember(editSession);
editSession.flushSession();
return killed;
}
@Command( @Command(
name = "/help", name = "/help",
desc = "Displays help for WorldEdit commands" desc = "Displays help for WorldEdit commands"
@ -648,28 +670,6 @@ public class UtilityCommands {
we.getPlatformManager().getPlatformCommandManager().getCommandManager(), actor, "//help"); we.getPlatformManager().getPlatformCommandManager().getCommandManager(), actor, "//help");
} }
@Command(
name = "remove",
aliases = { "rem", "rement" },
desc = "Remove all entities of a type"
)
@CommandPermissions("worldedit.remove")
@Logging(PLACEMENT)
public int remove(Actor actor,
@Arg(desc = "The type of entity to remove")
EntityRemover remover,
@Arg(desc = "The radius of the cuboid to remove from")
int radius) throws WorldEditException {
if (radius < -1) {
actor.printError(TranslatableComponent.of("worldedit.remove.explain-all"));
return 0;
}
int removed = killMatchingEntities(radius, actor, remover::createFunction);
actor.printInfo(TranslatableComponent.of("worldedit.remove.removed", TextComponent.of(removed)));
return removed;
}
private DecimalFormat formatForLocale(Locale locale) { private DecimalFormat formatForLocale(Locale locale) {
DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(locale); DecimalFormat format = (DecimalFormat) NumberFormat.getInstance(locale);
format.applyPattern("#,##0.#####"); format.applyPattern("#,##0.#####");
@ -696,7 +696,7 @@ public class UtilityCommands {
double result = expression.evaluate( double result = expression.evaluate(
new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout()); new double[]{}, WorldEdit.getInstance().getSessionManager().get(actor).getTimeout());
String formatted = Double.isNaN(result) ? "NaN" : formatForLocale(actor.getLocale()).format(result); String formatted = Double.isNaN(result) ? "NaN" : formatForLocale(actor.getLocale()).format(result);
return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.GRAY)); return SubtleFormat.wrap(input + " = ").append(TextComponent.of(formatted, TextColor.LIGHT_PURPLE));
}, (Component) null); }, (Component) null);
} }

View File

@ -491,7 +491,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (brush == null) return false; if (brush == null) return false;
if (current.setWorld(player.getWorld().getName()) && !current.canUse(player)) { if (current.setWorld(player.getWorld().getName()) && !current.canUse(player)) {
player.print(Caption.of("fawe.error.no.perm" , StringMan.join(current.getPermissions(), ","))); player.print(Caption.of("fawe.error.no-perm" , StringMan.join(current.getPermissions(), ",")));
return false; return false;
} }
try (EditSession editSession = session.createEditSession(player, current.toString())) { try (EditSession editSession = session.createEditSession(player, current.toString())) {

View File

@ -619,7 +619,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public void checkPermission(String permission) throws AuthorizationException { public void checkPermission(String permission) throws AuthorizationException {
if (!hasPermission(permission)) { if (!hasPermission(permission)) {
throw new AuthorizationException(Caption.toString(Caption.of("fawe.error.no.perm", permission))); throw new AuthorizationException(Caption.toString(Caption.of("fawe.error.no-perm", permission)));
} }
} }

View File

@ -19,21 +19,20 @@
package com.sk89q.worldedit.extension.platform; package com.sk89q.worldedit.extension.platform;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.command.AnvilCommands; import com.boydti.fawe.command.AnvilCommands;
import com.boydti.fawe.command.AnvilCommandsRegistration; import com.boydti.fawe.command.AnvilCommandsRegistration;
import com.boydti.fawe.command.CFICommands; import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.command.CFICommandsRegistration; import com.boydti.fawe.command.CFICommandsRegistration;
import com.boydti.fawe.config.Caption; import com.boydti.fawe.config.Caption;
import com.boydti.fawe.util.StringMan;
import com.sk89q.worldedit.command.HistorySubCommands;
import com.sk89q.worldedit.command.HistorySubCommandsRegistration;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.changeset.CFIChangeSet; import com.boydti.fawe.object.changeset.CFIChangeSet;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.task.ThrowableSupplier; import com.boydti.fawe.object.task.ThrowableSupplier;
import com.boydti.fawe.util.StringMan;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -61,6 +60,8 @@ import com.sk89q.worldedit.command.GenerationCommands;
import com.sk89q.worldedit.command.GenerationCommandsRegistration; import com.sk89q.worldedit.command.GenerationCommandsRegistration;
import com.sk89q.worldedit.command.HistoryCommands; import com.sk89q.worldedit.command.HistoryCommands;
import com.sk89q.worldedit.command.HistoryCommandsRegistration; import com.sk89q.worldedit.command.HistoryCommandsRegistration;
import com.sk89q.worldedit.command.HistorySubCommands;
import com.sk89q.worldedit.command.HistorySubCommandsRegistration;
import com.sk89q.worldedit.command.MaskCommands; import com.sk89q.worldedit.command.MaskCommands;
import com.sk89q.worldedit.command.MaskCommandsRegistration; import com.sk89q.worldedit.command.MaskCommandsRegistration;
import com.sk89q.worldedit.command.NavigationCommands; import com.sk89q.worldedit.command.NavigationCommands;
@ -135,10 +136,26 @@ import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
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 com.sk89q.worldedit.util.logging.DynamicStreamHandler; import com.sk89q.worldedit.util.logging.DynamicStreamHandler;
import com.sk89q.worldedit.util.logging.LogFormat; import com.sk89q.worldedit.util.logging.LogFormat;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.enginehub.piston.Command; import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager; import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverter;
@ -160,27 +177,10 @@ import org.enginehub.piston.part.SubCommandPart;
import org.enginehub.piston.suggestion.Suggestion; import org.enginehub.piston.suggestion.Suggestion;
import org.enginehub.piston.util.HelpGenerator; import org.enginehub.piston.util.HelpGenerator;
import org.enginehub.piston.util.ValueProvider; import org.enginehub.piston.util.ValueProvider;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Handles the registration and invocation of commands. * Handles the registration and invocation of commands.
@ -333,15 +333,41 @@ public final class PlatformCommandManager {
} }
private <CI> void registerSubCommands(String name, List<String> aliases, String desc, private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
CommandManager commandManager, CommandRegistration<CI> registration, CI instance) {
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance) { registerSubCommands(name, aliases, desc, registration, instance, m -> {});
registerSubCommands(name, aliases, desc, commandManager, handlerInstance, m -> {}); }
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
CommandRegistration<CI> registration, CI instance,
Consumer<CommandManager> additionalConfig) {
commandManager.register(name, cmd -> {
cmd.aliases(aliases);
cmd.description(TextComponent.of(desc));
cmd.action(Command.Action.NULL_ACTION);
CommandManager manager = commandManagerService.newCommandManager();
this.registration.register(
manager,
registration,
instance
);
additionalConfig.accept(manager);
final List<Command> subCommands = manager.getAllCommands().collect(Collectors.toList());
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
TextComponent.of("Sub-command to run."))
.withCommands(subCommands)
.required()
.build());
cmd.condition(new SubCommandPermissionCondition.Generator(subCommands).build());
});
} }
private <CI> void registerSubCommands(String name, List<String> aliases, String desc, private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
CommandManager commandManager, CommandManager commandManager,
Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance, Consumer<BiConsumer<CommandRegistration, CI>> handlerInstance,
Consumer<CommandManager> additionalConfig) { @NotNull Consumer<CommandManager> additionalConfig) {
commandManager.register(name, cmd -> { commandManager.register(name, cmd -> {
cmd.aliases(aliases); cmd.aliases(aliases);
cmd.description(TextComponent.of(desc)); cmd.description(TextComponent.of(desc));
@ -356,7 +382,7 @@ public final class PlatformCommandManager {
instance instance
); );
}); });
if (additionalConfig != null) additionalConfig.accept(manager); additionalConfig.accept(manager);
final List<Command> subCommands = manager.getAllCommands().collect(Collectors.toList()); final List<Command> subCommands = manager.getAllCommands().collect(Collectors.toList());
cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"), cmd.addPart(SubCommandPart.builder(TranslatableComponent.of("worldedit.argument.action"),
@ -369,26 +395,21 @@ public final class PlatformCommandManager {
}); });
} }
public <CI> void registerSubCommands(String name, List<String> aliases, String desc,
CommandRegistration<CI> registration, CI instance) {
registerSubCommands(name, aliases, desc, commandManager, c -> c.accept(registration, instance));
}
public void registerAllCommands() { public void registerAllCommands() {
if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) { if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) {
registerSubCommands( registerSubCommands(
"patterns", "patterns",
ImmutableList.of(), ImmutableList.of(),
"Patterns determine what blocks are placed", "Patterns determine what blocks are placed",
PatternCommandsRegistration.builder(), PatternCommandsRegistration.builder(),
new PatternCommands() new PatternCommands()
); );
registerSubCommands( registerSubCommands(
"masks", "masks",
ImmutableList.of(), ImmutableList.of(),
"Masks determine which blocks are placed", "Masks determine which blocks are placed",
MaskCommandsRegistration.builder(), MaskCommandsRegistration.builder(),
new MaskCommands(worldEdit) new MaskCommands(worldEdit)
); );
registerSubCommands( registerSubCommands(
"transforms", "transforms",
@ -486,11 +507,11 @@ public final class PlatformCommandManager {
history history
); );
registerSubCommands( registerSubCommands(
"/history", "/history",
ImmutableList.of("/frb"), ImmutableList.of("/frb"),
"Manage your history", "Manage your history",
HistorySubCommandsRegistration.builder(), HistorySubCommandsRegistration.builder(),
new HistorySubCommands(history) new HistorySubCommands(history)
); );
this.registration.register( this.registration.register(
commandManager, commandManager,
@ -718,7 +739,7 @@ public final class PlatformCommandManager {
if (msg != TextComponent.empty()) { if (msg != TextComponent.empty()) {
actor.print(TextComponent.builder("") actor.print(TextComponent.builder("")
.color(TextColor.RED) .color(TextColor.RED)
.append(msg) .append(e.getRichMessage())
.build()); .build());
List<String> argList = parseArgs(event.getArguments()).map(Substring::getSubstring).collect(Collectors.toList()); List<String> argList = parseArgs(event.getArguments()).map(Substring::getSubstring).collect(Collectors.toList());
printUsage(actor, argList); printUsage(actor, argList);
@ -736,13 +757,16 @@ public final class PlatformCommandManager {
editSession.flushQueue(); editSession.flushQueue();
session.remember(editSession); session.remember(editSession);
long timems = System.currentTimeMillis() - start; long time = System.currentTimeMillis() - start;
if (timems > 1000) { double timeS = (time / 1000.0);
int changed = editSession.getBlockChangeCount();
double throughput = timeS == 0 ? changed : changed / timeS;
if (time > 1000) {
actor.printDebug(TranslatableComponent.of( actor.printDebug(TranslatableComponent.of(
"worldedit.command.time-elapsed", "worldedit.command.time-elapsed",
TextComponent.of(timems + "m"), TextComponent.of(timeS),
TextComponent.of(-1), TextComponent.of(changed),
TextComponent.of(Math.round(-1)) TextComponent.of(Math.round(throughput))
)); ));
} }

View File

@ -24,6 +24,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
@ -168,11 +169,10 @@ public class ConsumeBindings extends Bindings {
} }
/** /**
* Gets an {@link TreeType} from a {@link ArgumentStack}. * Gets an {@link TreeType} from a {@link Binding}.
* *
* @param context the context * @param argument the context
* @return a TreeType * @return a TreeType
* @throws ParameterException on error
* @throws WorldEditException on error * @throws WorldEditException on error
*/ */
@Binding @Binding
@ -192,11 +192,10 @@ public class ConsumeBindings extends Bindings {
} }
/** /**
* Gets an {@link BiomeType} from a {@link ArgumentStack}. * Gets an {@link BiomeType} from a {@link Binding}.
* *
* @param context the context * @param argument the context
* @return a BiomeType * @return a BiomeType
* @throws ParameterException on error
* @throws WorldEditException on error * @throws WorldEditException on error
*/ */
@Binding @Binding

View File

@ -18,13 +18,8 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector2; import com.sk89q.worldedit.math.Vector2;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.inject.InjectedValueStore;
import javax.annotation.Nullable;
import java.lang.annotation.Annotation;
import java.util.Locale; import java.util.Locale;
import javax.annotation.Nullable;
public class PrimitiveBindings extends Bindings { public class PrimitiveBindings extends Bindings {
public PrimitiveBindings(WorldEdit worldEdit) { public PrimitiveBindings(WorldEdit worldEdit) {
@ -50,9 +45,9 @@ public class PrimitiveBindings extends Bindings {
} }
/** /**
* Gets an {@link com.sk89q.worldedit.extent.Extent} from a {@link ArgumentStack}. * Gets an {@link Extent} from a {@link Binding}.
* *
* @param context the context * @param argument the context
* @return an extent * @return an extent
* @throws InputParseException on other error * @throws InputParseException on other error
*/ */
@ -74,9 +69,9 @@ public class PrimitiveBindings extends Bindings {
} }
/** /**
* Gets a type from a {@link ArgumentStack}. * Gets a type from a {@link Binding}.
* *
* @param context the context * @param argument the context
* @return the requested type * @return the requested type
* @throws InputParseException on error * @throws InputParseException on error
*/ */
@ -105,16 +100,15 @@ public class PrimitiveBindings extends Bindings {
} }
/** /**
* Gets a type from a {@link ArgumentStack}. * Gets a type from a {@link Binding}.
* *
* @param context the context * @param argument the context
* @return the requested type * @return the requested type
* @throws InputParseException on error * @throws InputParseException on error
*/ */
@Binding @Binding
public Vector3 getVector3(String argument) { public Vector3 getVector3(String argument) {
String radiusString = argument; String[] radii = argument.split(",");
String[] radii = radiusString.split(",");
final double radiusX, radiusY, radiusZ; final double radiusX, radiusY, radiusZ;
switch (radii.length) { switch (radii.length) {
case 1: case 1:
@ -135,9 +129,9 @@ public class PrimitiveBindings extends Bindings {
/** /**
* Gets a type from a {@link ArgumentStack}. * Gets a type from a {@link Binding}.
* *
* @param context the context * @param argument the context
* @return the requested type * @return the requested type
* @throws InputParseException on error * @throws InputParseException on error
*/ */
@ -163,9 +157,9 @@ public class PrimitiveBindings extends Bindings {
} }
/** /**
* Gets a type from a {@link ArgumentStack}. * Gets a type from a {@link Binding}.
* *
* @param context the context * @param argument the context
* @return the requested type * @return the requested type
* @throws InputParseException on error * @throws InputParseException on error
*/ */
@ -193,16 +187,15 @@ public class PrimitiveBindings extends Bindings {
/** /**
* Gets a type from a {@link ArgumentStack}. * Gets a type from a {@link Binding}.
* *
* @param context the context * @param argument the context
* @return the requested type * @return the requested type
* @throws InputParseException on error * @throws InputParseException on error
*/ */
@Binding @Binding
public BlockVector2 getBlockVector2(String argument) { public BlockVector2 getBlockVector2(String argument) {
String radiusString = argument; String[] radii = argument.split(",");
String[] radii = radiusString.split(",");
final double radiusX, radiusZ; final double radiusX, radiusZ;
switch (radii.length) { switch (radii.length) {
case 1: case 1:

View File

@ -44,6 +44,7 @@ import java.io.Closeable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.NotNull;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -240,6 +241,7 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
return getParent().getBiomeType(x, y, z); return getParent().getBiomeType(x, y, z);
} }
@NotNull
@Override @Override
public Iterator<BlockVector3> iterator() { public Iterator<BlockVector3> iterator() {
OffsetBlockVector3 mutable = new OffsetBlockVector3(offset); OffsetBlockVector3 mutable = new OffsetBlockVector3(offset);

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit.extent.clipboard; package com.sk89q.worldedit.extent.clipboard;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.clipboard.CPUOptimizedClipboard; import com.boydti.fawe.object.clipboard.CPUOptimizedClipboard;
@ -29,20 +31,16 @@ import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.MaskTraverser; import com.boydti.fawe.util.MaskTraverser;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
import com.sk89q.worldedit.extent.transform.BlockTransformExtent; import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.visitor.Order; import com.sk89q.worldedit.function.visitor.Order;
import com.sk89q.worldedit.function.visitor.RegionVisitor;
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.math.MutableBlockVector2; import com.sk89q.worldedit.math.MutableBlockVector2;
@ -52,9 +50,6 @@ import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; 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 javax.annotation.Nullable;
import java.io.Closeable; import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -63,19 +58,20 @@ import java.io.OutputStream;
import java.net.URI; import java.net.URI;
import java.util.Iterator; import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import org.jetbrains.annotations.NotNull;
/** /**
* Specifies an object that implements something suitable as a "clipboard." * Specifies an object that implements something suitable as a "clipboard."
*/ */
public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable { public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
static Clipboard create(Region region) { static Clipboard create(Region region) {
checkNotNull(region); checkNotNull(region);
checkNotNull(region.getWorld(), checkNotNull(region.getWorld(),
"World cannot be null (use the other constructor for the region)"); "World cannot be null (use the other constructor for the region)");
EditSession session = new EditSessionBuilder(region.getWorld()).allowedRegionsEverywhere() EditSession session = new EditSessionBuilder(region.getWorld()).allowedRegionsEverywhere()
.autoQueue(false).build(); .autoQueue(false).build();
return ReadOnlyClipboard.of(session, region); return ReadOnlyClipboard.of(session, region);
} }
@ -120,10 +116,11 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
void setOrigin(BlockVector3 origin); void setOrigin(BlockVector3 origin);
/** /**
* Returns true if the clipboard has biome data. This can be checked since {@link Extent#getBiome(BlockVector2)} * Returns true if the clipboard has biome data. This can be checked since {@link
* strongly suggests returning {@link com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null} * Extent#getBiome(BlockVector2)} strongly suggests returning {@link
* if biomes aren't present. However, it might not be desired to set areas to ocean if the clipboard is defaulting * com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null} if biomes aren't
* to ocean, instead of having biomes explicitly set. * present. However, it might not be desired to set areas to ocean if the clipboard is
* defaulting to ocean, instead of having biomes explicitly set.
* *
* @return true if the clipboard has biome data set * @return true if the clipboard has biome data set
*/ */
@ -133,7 +130,6 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
/** /**
* Remove entity from clipboard * Remove entity from clipboard
* @param entity
*/ */
void removeEntity(Entity entity); void removeEntity(Entity entity);
@ -161,6 +157,8 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
return order.create(getRegion()); return order.create(getRegion());
} }
@Override
@NotNull
default Iterator<BlockVector3> iterator() { default Iterator<BlockVector3> iterator() {
return getRegion().iterator(); return getRegion().iterator();
} }
@ -173,35 +171,20 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
return null; return null;
} }
// default void paste(Extent other, BlockVector3 to) {
// TODO FIXME
// }
@Override @Override
default <T extends Filter> T apply(Region region, T filter, boolean full) { default <T extends Filter> T apply(Region region, T filter, boolean full) {
if (region.equals(getRegion())) { if (region.equals(getRegion())) {
return apply(this, filter); return apply(this, filter);
} else {
return apply((Iterable<BlockVector3>) region, filter);
} }
return apply(region, filter);
} }
@Override @Override
default void close() { default void close() {
} }
/*
Utility methods
*/
/** /**
* Forwards to paste(world, to, true, true, null) * Forwards to paste(world, to, true, true, null)
*
* @param world
* @param to
* @return
*/ */
default EditSession paste(World world, BlockVector3 to) { default EditSession paste(World world, BlockVector3 to) {
return paste(world, to, true, true, null); return paste(world, to, true, true, null);
@ -222,10 +205,6 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
/** /**
* Save this schematic to a stream * Save this schematic to a stream
*
* @param stream
* @param format
* @throws IOException
*/ */
default void save(OutputStream stream, ClipboardFormat format) throws IOException { default void save(OutputStream stream, ClipboardFormat format) throws IOException {
checkNotNull(stream); checkNotNull(stream);
@ -236,22 +215,15 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
} }
default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir, default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
@Nullable Transform transform) { @Nullable Transform transform) {
return paste(world, to, allowUndo, pasteAir, true, transform); return paste(world, to, allowUndo, pasteAir, true, transform);
} }
/** /**
* Paste this schematic in a world * Paste this schematic in a world
*
* @param world
* @param to
* @param allowUndo
* @param pasteAir
* @param transform
* @return
*/ */
default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir, default EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
boolean copyEntities, @Nullable Transform transform) { boolean copyEntities, @Nullable Transform transform) {
checkNotNull(world); checkNotNull(world);
checkNotNull(to); checkNotNull(to);
EditSession editSession; EditSession editSession;
@ -259,7 +231,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
editSession = (EditSession) world; editSession = (EditSession) world;
} else { } else {
EditSessionBuilder builder = new EditSessionBuilder(world).autoQueue(true) EditSessionBuilder builder = new EditSessionBuilder(world).autoQueue(true)
.checkMemory(false).allowedRegionsEverywhere().limitUnlimited(); .checkMemory(false).allowedRegionsEverywhere().limitUnlimited();
if (allowUndo) { if (allowUndo) {
editSession = builder.build(); editSession = builder.build();
} else { } else {
@ -276,7 +248,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
return editSession; return editSession;
} }
ForwardExtentCopy copy = new ForwardExtentCopy(extent, this.getRegion(), ForwardExtentCopy copy = new ForwardExtentCopy(extent, this.getRegion(),
this.getOrigin(), editSession, to); this.getOrigin(), editSession, to);
if (transform != null && !transform.isIdentity()) { if (transform != null && !transform.isIdentity()) {
copy.setTransform(transform); copy.setTransform(transform);
} }
@ -298,12 +270,14 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
return editSession; return editSession;
} }
default void paste(Extent extent, BlockVector3 to, boolean pasteAir, @Nullable Transform transform) { default void paste(Extent extent, BlockVector3 to, boolean pasteAir,
@Nullable Transform transform) {
Extent source = this; Extent source = this;
if (transform != null && !transform.isIdentity()) { if (transform != null && !transform.isIdentity()) {
source = new BlockTransformExtent(this, transform); source = new BlockTransformExtent(this, transform);
} }
ForwardExtentCopy copy = new ForwardExtentCopy(source, this.getRegion(), this.getOrigin(), extent, to); ForwardExtentCopy copy = new ForwardExtentCopy(source, this.getRegion(), this.getOrigin(),
extent, to);
if (transform != null) { if (transform != null) {
copy.setTransform(transform); copy.setTransform(transform);
} }
@ -345,6 +319,9 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
if (!pasteAir && block.getBlockType().getMaterial().isAir()) { if (!pasteAir && block.getBlockType().getMaterial().isAir()) {
continue; continue;
} }
if (pos.getY() < 0) {
throw new RuntimeException("Y-Position cannot be less than 0!");
}
extent.setBlock(xx, pos.getY() + rely, zz, block); extent.setBlock(xx, pos.getY() + rely, zz, block);
} }
// Entity offset is the paste location subtract the clipboard origin (entity's location is already relative to the world origin) // Entity offset is the paste location subtract the clipboard origin (entity's location is already relative to the world origin)
@ -355,13 +332,13 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
for (Entity entity : this.getEntities()) { for (Entity entity : this.getEntities()) {
// skip players on pasting schematic // skip players on pasting schematic
if (entity.getState() != null && entity.getState().getType().getId() if (entity.getState() != null && entity.getState().getType().getId()
.equals("minecraft:player")) { .equals("minecraft:player")) {
continue; continue;
} }
Location pos = entity.getLocation(); Location pos = entity.getLocation();
Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX, Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX,
pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(), pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(),
pos.getPitch()); pos.getPitch());
extent.createEntity(newPos, entity.getState()); extent.createEntity(newPos, entity.getState());
} }
} }

View File

@ -170,7 +170,7 @@ public class ClipboardFormats {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
if (input.startsWith("url:")) { if (input.startsWith("url:")) {
if (!player.hasPermission("worldedit.schematic.load.web")) { if (!player.hasPermission("worldedit.schematic.load.web")) {
if (message) player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.web")); if (message) player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.web"));
return null; return null;
} }
URL base = new URL(Settings.IMP.WEB.URL); URL base = new URL(Settings.IMP.WEB.URL);
@ -178,7 +178,7 @@ public class ClipboardFormats {
} }
if (input.startsWith("http")) { if (input.startsWith("http")) {
if (!player.hasPermission("worldedit.schematic.load.asset")) { if (!player.hasPermission("worldedit.schematic.load.asset")) {
if (message) player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.asset")); if (message) player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.asset"));
return null; return null;
} }
URL url = new URL(input); URL url = new URL(input);
@ -190,7 +190,7 @@ public class ClipboardFormats {
return loadAllFromUrl(url); return loadAllFromUrl(url);
} else { } else {
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) {
player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.other")); player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other"));
return null; return null;
} }
File working = worldEdit.getWorkingDirectoryFile(config.saveDir); File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
@ -210,7 +210,7 @@ public class ClipboardFormats {
} }
} else { } else {
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) {
if (message) player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.other")); if (message) player.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other"));
return null; return null;
} }
if (format == null && input.matches(".*\\.[\\w].*")) { if (format == null && input.matches(".*\\.[\\w].*")) {

View File

@ -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
}
} }

View File

@ -262,9 +262,7 @@ public class BlockMaskBuilder {
} }
public BlockMaskBuilder addAll() { public BlockMaskBuilder addAll() {
for (int i = 0; i < bitSets.length; i++) { Arrays.fill(bitSets, ALL);
bitSets[i] = ALL;
}
reset(true); reset(true);
return this; return this;
} }
@ -275,9 +273,7 @@ public class BlockMaskBuilder {
} }
public BlockMaskBuilder clear() { public BlockMaskBuilder clear() {
for (int i = 0; i < bitSets.length; i++) { Arrays.fill(bitSets, null);
bitSets[i] = null;
}
reset(true); reset(true);
return this; return this;
} }

View File

@ -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);
} }
} }

View File

@ -69,7 +69,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
private BlockVector3 centerAccum = BlockVector3.ZERO; private BlockVector3 centerAccum = BlockVector3.ZERO;
/** /**
* The last triangle that caused a {@link #contains(Vector3)} to classify a point as "outside". Used for optimization. * The last triangle that caused a {@link #contains(BlockVector3)} to classify a point as "outside". Used for optimization.
*/ */
private Triangle lastTriangle; private Triangle lastTriangle;
@ -196,7 +196,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
} }
if (!vertexBacklog.isEmpty()) { if (!vertexBacklog.isEmpty()) {
// Remove the new vertex // Remove the new vertex
vertices.remove(vertex); vertices.remove(vertex);
// Clone, clear and work through the backlog // Clone, clear and work through the backlog
@ -226,7 +226,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
public BlockVector3 getMaximumPoint() { public BlockVector3 getMaximumPoint() {
return maximumPoint; return maximumPoint;
} }
@Override @Override
public Vector3 getCenter() { public Vector3 getCenter() {
return centerAccum.toVector3().divide(vertices.size()); return centerAccum.toVector3().divide(vertices.size());

View File

@ -49,10 +49,7 @@ import org.jetbrains.annotations.NotNull;
public class CuboidRegion extends AbstractRegion implements FlatRegion { public class CuboidRegion extends AbstractRegion implements FlatRegion {
private boolean useOldIterator;
private int minX, minY, minZ, maxX, maxY, maxZ; private int minX, minY, minZ, maxX, maxY, maxZ;
private BlockVector3 min;
private BlockVector3 max;
private BlockVector3 pos1; private BlockVector3 pos1;
private BlockVector3 pos2; private BlockVector3 pos2;
@ -82,10 +79,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
recalculate(); recalculate();
} }
public void setUseOldIterator(boolean useOldIterator) {
this.useOldIterator = useOldIterator;
}
/** /**
* Get the first cuboid-defining corner. * Get the first cuboid-defining corner.
* *
@ -139,8 +132,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
maxX = Math.max(pos1.getX(), pos2.getX()); maxX = Math.max(pos1.getX(), pos2.getX());
maxY = Math.max(pos1.getY(), pos2.getY()); maxY = Math.max(pos1.getY(), pos2.getY());
maxZ = Math.max(pos1.getZ(), pos2.getZ()); maxZ = Math.max(pos1.getZ(), pos2.getZ());
this.min = BlockVector3.at(minX, minY, minZ);
this.max = BlockVector3.at(maxX, maxY, maxZ);
} }
/** /**
@ -188,12 +179,22 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
@Override @Override
public BlockVector3 getMinimumPoint() { public BlockVector3 getMinimumPoint() {
return min; return pos1.getMinimum(pos2);
} }
@Override @Override
public BlockVector3 getMaximumPoint() { public BlockVector3 getMaximumPoint() {
return max; return pos1.getMaximum(pos2);
}
@Override
public int getMinimumY() {
return minY;
}
@Override
public int getMaximumY() {
return maxY;
} }
@Override @Override
@ -448,7 +449,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
@Override @Override
public Iterator<BlockVector3> iterator() { public Iterator<BlockVector3> iterator() {
if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9 || useOldIterator) { if (Settings.IMP.HISTORY.COMPRESSION_LEVEL >= 9) {
return iterator_old(); return iterator_old();
} }
return new Iterator<BlockVector3>() { return new Iterator<BlockVector3>() {
@ -644,16 +645,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
return new CuboidRegion(origin.subtract(size), origin.add(size)); return new CuboidRegion(origin.subtract(size), origin.add(size));
} }
@Override
public int getMinimumY() {
return minY;
}
@Override
public int getMaximumY() {
return maxY;
}
public int getMinimumX() { public int getMinimumX() {
return minX; return minX;
} }
@ -724,7 +715,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
trimNBT(set, this::contains); trimNBT(set, this::contains);
return set; return set;
} }
else if (tx >= minX && bx <= maxX && tz >= minZ && bz <= maxZ) { if (tx >= minX && bx <= maxX && tz >= minZ && bz <= maxZ) {
trimY(set, minY, maxY); trimY(set, minY, maxY);
final int lowerX = Math.max(0, minX - bx); final int lowerX = Math.max(0, minX - bx);
final int upperX = Math.min(15, 15 + maxX - tx); final int upperX = Math.min(15, 15 + maxX - tx);
@ -781,9 +772,8 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
} }
trimNBT(set, this::contains); trimNBT(set, this::contains);
return set; return set;
} else {
return null;
} }
return null;
} }

View File

@ -196,4 +196,4 @@ public abstract class PaginationBox extends MessageBox {
return lines.size(); return lines.size();
} }
} }
} }

View File

@ -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

View File

@ -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) {
@ -156,4 +160,4 @@ public class TranslationManager {
public Locale getDefaultLocale() { public Locale getDefaultLocale() {
return defaultLocale; return defaultLocale;
} }
} }

View File

@ -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();
} }

View File

@ -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);
} }

View File

@ -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();
} }

View File

@ -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

View File

@ -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() {
}
}

View File

@ -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) {

View File

@ -14,15 +14,14 @@ package net.jpountz.lz4;
* limitations under the License. * limitations under the License.
*/ */
import java.nio.ByteBuffer;
import static net.jpountz.util.ByteBufferUtils.checkNotReadOnly; import static net.jpountz.util.ByteBufferUtils.checkNotReadOnly;
import static net.jpountz.util.ByteBufferUtils.checkRange; import static net.jpountz.util.ByteBufferUtils.checkRange;
import static net.jpountz.util.SafeUtils.checkRange; import static net.jpountz.util.SafeUtils.checkRange;
import java.nio.ByteBuffer;
/** /**
* Fast {@link LZ4FastCompressor}s implemented with JNI bindings to the original C * Fast {@link LZ4Compressor} implemented with JNI bindings to the original C
* implementation of LZ4. * implementation of LZ4.
*/ */
final class LZ4JNICompressor extends LZ4Compressor { final class LZ4JNICompressor extends LZ4Compressor {

View File

@ -6,11 +6,11 @@
"fawe.worldedit.history.find.element": "&8 - &2{0}: {1} &7ago &3{2}m &6{3} &c/{4}", "fawe.worldedit.history.find.element": "&8 - &2{0}: {1} &7ago &3{2}m &6{3} &c/{4}",
"fawe.worldedit.history.find.hover": "{0} blocks changed, click for more info", "fawe.worldedit.history.find.hover": "{0} blocks changed, click for more info",
"fawe.info.lighting.propagate.selection": "Lighting has been propogated in {0} chunks. (Note: To remove light use //removelight)", "fawe.info.lighting.propagate.selection": "Lighting has been propagated in {0} chunks. (Note: To remove light use //removelight)",
"fawe.info.updated.lighting.selection": "Lighting has been updated in {0} chunks. (It may take a second for the packets to send)", "fawe.info.updated.lighting.selection": "Lighting has been updated in {0} chunks. (It may take a second for the packets to send)",
"fawe.info.set.region": "Selection set to your current allowed region", "fawe.info.set.region": "Selection set to your current allowed region",
"fawe.info.worldedit.command.limit": "Please wait until your current action completes", "fawe.info.worldedit.command.limit": "Please wait until your current action completes",
"fawe.info.worldedit.delayed": "Please wait while we process your FAWE action...", "fawe.info.worldedit.delayed": "Please wait while we process your FAWE action...",
"fawe.info.worldedit.run": "Apologies for the delay. Now executing: {0}", "fawe.info.worldedit.run": "Apologies for the delay. Now executing: {0}",
@ -216,7 +216,7 @@
"fawe.worldedit.cycler.block.cycler.cannot.cycle": "That block's data cannot be cycled!", "fawe.worldedit.cycler.block.cycler.cannot.cycle": "That block's data cannot be cycled!",
"fawe.worldedit.cycler.block.cycler.limit": "Max blocks change limit reached.", "fawe.worldedit.cycler.block.cycler.limit": "Max blocks change limit reached.",
"fawe.worldedit.cycler.block.cycler.no.perm": "You are not permitted to cycle the data value of that block.", "fawe.worldedit.cycler.block.cycler.no-perm": "You are not permitted to cycle the data value of that block.",
"fawe.worldedit.command.command.invalid.syntax": "The command was not used properly (no more help available).", "fawe.worldedit.command.command.invalid.syntax": "The command was not used properly (no more help available).",
@ -236,7 +236,7 @@
"fawe.progress.progress.finished": "[ Done! ]", "fawe.progress.progress.finished": "[ Done! ]",
"fawe.error.command.syntax": "Usage: {0}", "fawe.error.command.syntax": "Usage: {0}",
"fawe.error.no.perm": "You are lacking the permission node: {0}", "fawe.error.no-perm": "You are lacking the permission node: {0}",
"fawe.error.block.not.allowed": "You are not allowed to use", "fawe.error.block.not.allowed": "You are not allowed to use",
"fawe.error.setting.disable": "Lacking setting: {0}", "fawe.error.setting.disable": "Lacking setting: {0}",
"fawe.error.brush.not.found": "Available brushes: {0}", "fawe.error.brush.not.found": "Available brushes: {0}",
@ -291,9 +291,9 @@
"fawe.selection.sel.list": "For a list of selection types use: //sel list", "fawe.selection.sel.list": "For a list of selection types use: //sel list",
"fawe.selection.sel.modes": "Select one of the modes below:", "fawe.selection.sel.modes": "Select one of the modes below:",
"fawe.worldedit.scripting.scripting.no.perm": "You do not have permission to execute this craft script", "fawe.worldedit.scripting.scripting.no-perm": "You do not have permission to execute this craft script",
"fawe.worldedit.scripting.scripting.cs": "Use /cs with a script name first.", "fawe.worldedit.scripting.scripting.cs": "Use /cs with a script name first.",
"fawe.worldedit.scripting.scripting.error": "An error occured while executing a craft script", "fawe.worldedit.scripting.scripting.error": "An error occurred while executing a craft script",
"fawe.tips.tip.sel.list": "Tip: See the different selection modes with //sel list", "fawe.tips.tip.sel.list": "Tip: See the different selection modes with //sel list",
"fawe.tips.tip.select.connected": "Tip: Select all connected blocks with //sel fuzzy", "fawe.tips.tip.select.connected": "Tip: Select all connected blocks with //sel fuzzy",
@ -331,7 +331,7 @@
"fawe.tips.tip.regen.1": "Tip: Use a seed with /regen [biome] [seed]", "fawe.tips.tip.regen.1": "Tip: Use a seed with /regen [biome] [seed]",
"fawe.tips.tip.biome.pattern": "Tip: The #biome[forest] pattern can be used in any command", "fawe.tips.tip.biome.pattern": "Tip: The #biome[forest] pattern can be used in any command",
"fawe.tips.tip.biome.mask": "Tip: Restrict to a biome with the `$jungle` mask", "fawe.tips.tip.biome.mask": "Tip: Restrict to a biome with the `$jungle` mask",
"worldedit.expand.description.vert": "Vertically expand the selection to world limits.", "worldedit.expand.description.vert": "Vertically expand the selection to world limits.",
"worldedit.expand.expanded": "Region expanded {0} blocks", "worldedit.expand.expanded": "Region expanded {0} blocks",
"worldedit.expand.expanded.vert": "Region expanded {0} blocks (top-to-bottom).", "worldedit.expand.expanded.vert": "Region expanded {0} blocks (top-to-bottom).",
@ -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.",
@ -502,7 +503,7 @@
"worldedit.paste.pasted": "The clipboard has been pasted at {0}", "worldedit.paste.pasted": "The clipboard has been pasted at {0}",
"worldedit.paste.selected": "Selected clipboard paste region.", "worldedit.paste.selected": "Selected clipboard paste region.",
"worldedit.rotate.no-interpolation": "Note: Interpolation is not yet supported, so angles that are multiples of 90 is recommended.", "worldedit.rotate.no-interpolation": "Note: Interpolation is not yet supported, so angles that are multiples of 90 is recommended.",
"worldedit.rotate.rotated": "The clipboard copy has been rotated.", "worldedit.rotate.rotated": "The clipboard copy has been rotated.",
"worldedit.flip.flipped": "The clipboard copy has been flipped.", "worldedit.flip.flipped": "The clipboard copy has been flipped.",
@ -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.",