A lot of small changes

Dieser Commit ist enthalten in:
MattBDev 2020-01-03 15:38:30 -05:00
Ursprung 6cb2d7cd5c
Commit f3e0109be2
30 geänderte Dateien mit 420 neuen und 533 gelöschten Zeilen

Datei anzeigen

@ -43,7 +43,7 @@ fun Project.applyPlatformAndCoreConfiguration() {
}
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-params:${Versions.JUNIT}")
"testImplementation"("org.mockito:mockito-core:${Versions.MOCKITO}")

Datei anzeigen

@ -40,17 +40,17 @@ dependencies {
"compile"("org.spigotmcv1_14_r1:spigotmcv1_14_r1:1_14_r1")
"compile"("org.spigotmcv1_15_r1:spigotmcv1_15_r1:1_15_r1")
"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")
isTransitive = false
}
"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")
"compileOnly"("com.sk89q:dummypermscompat:1.10")
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
"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-core")
exclude("com.sk89q.worldedit.worldedit-libs", "bukkit")

Datei anzeigen

@ -41,7 +41,6 @@ import java.util.function.Supplier;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -50,7 +49,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -353,7 +351,6 @@ public class FaweBukkit implements IFawe, Listener {
return null;
}
return null;
// return ((BlocksHubBukkit) blocksHubPlugin).getApi();
}
@Override

Datei anzeigen

@ -1,5 +1,7 @@
package com.boydti.fawe.bukkit.adapter.mc1_13;
import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
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.world.biome.BiomeType;
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.BlockPosition;
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.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 ChunkSection[] sections;
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())));
}
private static final Function<BlockPosition, BlockVector3> posNms2We = new Function<BlockPosition, BlockVector3>() {
@Override
public BlockVector3 apply(BlockPosition v) {
return 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 = new Function<TileEntity, CompoundTag>() {
@Override
public CompoundTag apply(TileEntity tileEntity) {
return new LazyCompoundTag_1_13(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
}
};
private final static Function<TileEntity, CompoundTag> nmsTile2We = tileEntity -> new LazyCompoundTag_1_13(Suppliers.memoize(() -> tileEntity.save(new NBTTagCompound())));
@Override
public Map<BlockVector3, CompoundTag> getTiles() {
@ -243,9 +232,7 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
{
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
if (!tiles.isEmpty()) {
final Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<BlockPosition, TileEntity> entry = iterator.next();
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
final BlockPosition pos = entry.getKey();
final int lx = pos.getX() & 15;
final int ly = pos.getY();
@ -345,8 +332,7 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
public void run() {
final List<Entity>[] entities = nmsChunk.getEntitySlices();
for (int i = 0; i < entities.length; i++) {
final Collection<Entity> ents = entities[i];
for (final Collection<Entity> ents : entities) {
if (!ents.isEmpty()) {
final Iterator<Entity> iter = ents.iterator();
while (iter.hasNext()) {
@ -366,43 +352,40 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
if (entities != null && !entities.isEmpty()) {
if (syncTasks == null) syncTasks = new Runnable[2];
syncTasks[1] = new Runnable() {
@Override
public void run() {
for (final CompoundTag nativeTag : entities) {
final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
final StringTag idTag = (StringTag) entityTagMap.get("Id");
final ListTag posTag = (ListTag) entityTagMap.get("Pos");
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
if (idTag == null || posTag == null || rotTag == null) {
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 z = posTag.getDouble(2);
final float yaw = rotTag.getFloat(0);
final float pitch = rotTag.getFloat(1);
final String id = idTag.getValue();
syncTasks[1] = () -> {
for (final CompoundTag nativeTag : entities) {
final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
final StringTag idTag = (StringTag) entityTagMap.get("Id");
final ListTag posTag = (ListTag) entityTagMap.get("Pos");
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
if (idTag == null || posTag == null || rotTag == null) {
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 z = posTag.getDouble(2);
final float yaw = rotTag.getFloat(0);
final float pitch = rotTag.getFloat(1);
final String id = idTag.getValue();
EntityTypes<?> type = EntityTypes.a(id);
if (type != null) {
Entity entity = type.a(nmsWorld);
if (entity != null) {
UUID uuid = entity.getUniqueID();
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
if (nativeTag != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name);
}
entity.f(tag);
EntityTypes<?> type = EntityTypes.a(id);
if (type != null) {
Entity entity = type.a(nmsWorld);
if (entity != null) {
UUID uuid = entity.getUniqueID();
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
if (nativeTag != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name);
}
entity.setLocation(x, y, z, yaw, pitch);
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
entity.f(tag);
}
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 (syncTasks == null) syncTasks = new Runnable[1];
syncTasks[0] = new Runnable() {
@Override
public void run() {
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
final CompoundTag nativeTag = entry.getValue();
final BlockVector3 blockHash = entry.getKey();
final int x = blockHash.getX() + bx;
final int y = blockHash.getY();
final int z = blockHash.getZ() + bz;
final BlockPosition pos = new BlockPosition(x, y, z);
syncTasks[0] = () -> {
for (final Map.Entry<BlockVector3, CompoundTag> entry : tiles.entrySet()) {
final CompoundTag nativeTag = entry.getValue();
final BlockVector3 blockHash = entry.getKey();
final int x = blockHash.getX() + bx;
final int y = blockHash.getY();
final int z = blockHash.getZ() + bz;
final BlockPosition pos = new BlockPosition(x, y, z);
synchronized (nmsWorld) {
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity == null || tileEntity.x()) {
nmsWorld.n(pos);
tileEntity = nmsWorld.getTileEntity(pos);
}
if (tileEntity != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
tag.set("x", new NBTTagInt(x));
tag.set("y", new NBTTagInt(y));
tag.set("z", new NBTTagInt(z));
tileEntity.load(tag);
}
synchronized (nmsWorld) {
TileEntity tileEntity = nmsWorld.getTileEntity(pos);
if (tileEntity == null || tileEntity.x()) {
nmsWorld.n(pos);
tileEntity = nmsWorld.getTileEntity(pos);
}
if (tileEntity != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
tag.set("x", new NBTTagInt(x));
tag.set("y", new NBTTagInt(y));
tag.set("z", new NBTTagInt(z));
tileEntity.load(tag);
}
}
}
@ -473,27 +453,23 @@ public class BukkitGetBlocks_1_13 extends CharGetBlocks {
Runnable[] finalSyncTasks = syncTasks;
// Chain the sync tasks and the callback
Callable<Future> chain = new Callable<Future>() {
@Override
public Future call() {
try {
// Run the sync tasks
for (int i = 0; i < finalSyncTasks.length; i++) {
Runnable task = finalSyncTasks[i];
if (task != null) {
task.run();
}
Callable<Future> chain = () -> {
try {
// Run the sync tasks
for (Runnable task : finalSyncTasks) {
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);

Datei anzeigen

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

Datei anzeigen

@ -1,5 +1,7 @@
package com.boydti.fawe.bukkit.adapter.mc1_15;
import static org.slf4j.LoggerFactory.getLogger;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
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.google.common.base.Suppliers;
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.*;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
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.world.biome.BiomeType;
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.block.Biome;
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.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 {
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())));
@ -214,9 +241,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
{
Map<BlockPosition, TileEntity> tiles = nmsChunk.getTileEntities();
if (!tiles.isEmpty()) {
final Iterator<Map.Entry<BlockPosition, TileEntity>> iterator = tiles.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<BlockPosition, TileEntity> entry = iterator.next();
for (Map.Entry<BlockPosition, TileEntity> entry : tiles.entrySet()) {
final BlockPosition pos = entry.getKey();
final int lx = pos.getX() & 15;
final int ly = pos.getY();
@ -319,8 +344,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
syncTasks[2] = () -> {
final List<Entity>[] entities = nmsChunk.getEntitySlices();
for (int i = 0; i < entities.length; i++) {
final Collection<Entity> ents = entities[i];
for (final Collection<Entity> ents : entities) {
if (!ents.isEmpty()) {
final Iterator<Entity> iter = ents.iterator();
while (iter.hasNext()) {
@ -339,43 +363,40 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
if (entities != null && !entities.isEmpty()) {
if (syncTasks == null) syncTasks = new Runnable[2];
syncTasks[1] = new Runnable() {
@Override
public void run() {
for (final CompoundTag nativeTag : entities) {
final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
final StringTag idTag = (StringTag) entityTagMap.get("Id");
final ListTag posTag = (ListTag) entityTagMap.get("Pos");
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
if (idTag == null || posTag == null || rotTag == null) {
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 z = posTag.getDouble(2);
final float yaw = rotTag.getFloat(0);
final float pitch = rotTag.getFloat(1);
final String id = idTag.getValue();
syncTasks[1] = () -> {
for (final CompoundTag nativeTag : entities) {
final Map<String, Tag> entityTagMap = ReflectionUtils.getMap(nativeTag.getValue());
final StringTag idTag = (StringTag) entityTagMap.get("Id");
final ListTag posTag = (ListTag) entityTagMap.get("Pos");
final ListTag rotTag = (ListTag) entityTagMap.get("Rotation");
if (idTag == null || posTag == null || rotTag == null) {
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 z = posTag.getDouble(2);
final float yaw = rotTag.getFloat(0);
final float pitch = rotTag.getFloat(1);
final String id = idTag.getValue();
EntityTypes<?> type = EntityTypes.a(id).orElse(null);
if (type != null) {
Entity entity = type.a(nmsWorld);
if (entity != null) {
UUID uuid = entity.getUniqueID();
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
if (nativeTag != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name);
}
entity.f(tag);
EntityTypes<?> type = EntityTypes.a(id).orElse(null);
if (type != null) {
Entity entity = type.a(nmsWorld);
if (entity != null) {
UUID uuid = entity.getUniqueID();
entityTagMap.put("UUIDMost", new LongTag(uuid.getMostSignificantBits()));
entityTagMap.put("UUIDLeast", new LongTag(uuid.getLeastSignificantBits()));
if (nativeTag != null) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
final NBTTagCompound tag = (NBTTagCompound) adapter.fromNative(nativeTag);
for (final String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.remove(name);
}
entity.setLocation(x, y, z, yaw, pitch);
nmsWorld.addEntity(entity, CreatureSpawnEvent.SpawnReason.CUSTOM);
entity.f(tag);
}
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
// TODO optimize, cause this is really slow
LightEngineThreaded engine = (LightEngineThreaded) nmsChunk.e();
engine.a(nmsChunk, false);
}
//Lighting
// TODO optimize, cause this is really slow
LightEngineThreaded engine = (LightEngineThreaded) nmsChunk.e();
engine.a(nmsChunk, false);
Runnable callback;
if (bitMask == 0 && biomes == null) {
@ -445,8 +465,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
Callable<Future> chain = () -> {
try {
// Run the sync tasks
for (int i = 0; i < finalSyncTasks.length; i++) {
Runnable task = finalSyncTasks[i];
for (Runnable task : finalSyncTasks) {
if (task != null) {
task.run();
}

Datei anzeigen

@ -207,8 +207,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk {
}
@Override
public boolean setBlock(ChunkHolder chunk, int x, int y, int z,
BlockStateHolder block) {
public boolean setBlock(ChunkHolder chunk, int x, int y, int z, BlockStateHolder block) {
return chunk.chunkSet.setBlock(x, y, z, block);
}

Datei anzeigen

@ -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_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_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 DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?";

Datei anzeigen

@ -15,10 +15,12 @@ import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class JSON2NBT {
private static final Pattern INT_ARRAY_MATCHER = Pattern.compile("\\[[-+\\d|,\\s]+\\]");
@ -40,7 +42,7 @@ public class JSON2NBT {
public static int topTagsCount(String str) throws NBTException {
int i = 0;
boolean flag = false;
Stack stack = new Stack();
Stack<Character> stack = new Stack<>();
for (int j = 0; j < str.length(); ++j) {
char c0 = str.charAt(j);
@ -54,11 +56,11 @@ public class JSON2NBT {
}
} else if (!flag) {
if (c0 != 123 && c0 != 91) {
if (c0 == 125 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 123)) {
if (c0 == 125 && (stack.isEmpty() || stack.pop() != 123)) {
throw new NBTException("Unbalanced curly brackets {}: " + str);
}
if (c0 == 93 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 91)) {
if (c0 == 93 && (stack.isEmpty() || stack.pop() != 91)) {
throw new NBTException("Unbalanced square brackets []: " + str);
}
} else {
@ -66,7 +68,7 @@ public class JSON2NBT {
++i;
}
stack.push(Character.valueOf(c0));
stack.push(c0);
}
}
}
@ -91,7 +93,6 @@ public class JSON2NBT {
private static JSON2NBT.Any nameValueToNBT(String key, String value) throws NBTException {
value = value.trim();
String s;
boolean c0;
char c01;
if (value.startsWith("{")) {
value = value.substring(1, value.length() - 1);
@ -100,7 +101,6 @@ public class JSON2NBT {
for (JSON2NBT$list1 = new JSON2NBT.Compound(key); value.length() > 0; value = value.substring(s.length() + 1)) {
s = nextNameValuePair(value, true);
if (s.length() > 0) {
c0 = false;
JSON2NBT$list1.tagList.add(getTagFromNameValue(s, false));
}
@ -122,7 +122,6 @@ public class JSON2NBT {
for (JSON2NBT$list = new JSON2NBT.List(key); value.length() > 0; value = value.substring(s.length() + 1)) {
s = nextNameValuePair(value, false);
if (s.length() > 0) {
c0 = true;
JSON2NBT$list.tagList.add(getTagFromNameValue(s, true));
}
@ -145,7 +144,7 @@ public class JSON2NBT {
private static JSON2NBT.Any getTagFromNameValue(String str, boolean isArray) throws NBTException {
String s = locateName(str, isArray);
String s1 = locateValue(str, isArray);
return joinStrToNBT(new String[]{s, s1});
return joinStrToNBT(s, s1);
}
private static String nextNameValuePair(String str, boolean isCompound) throws NBTException {
@ -167,7 +166,7 @@ public class JSON2NBT {
}
private static String locateValueAt(String str, int index) throws NBTException {
Stack stack = new Stack();
Stack<Character> stack = new Stack<>();
int i = index + 1;
boolean flag = false;
boolean flag1 = false;
@ -192,11 +191,11 @@ public class JSON2NBT {
}
} else if (!flag) {
if (c0 != 123 && c0 != 91) {
if (c0 == 125 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 123)) {
if (c0 == 125 && (stack.isEmpty() || stack.pop() != 123)) {
throw new NBTException("Unbalanced curly brackets {}: " + str);
}
if (c0 == 93 && (stack.isEmpty() || ((Character) stack.pop()).charValue() != 91)) {
if (c0 == 93 && (stack.isEmpty() || stack.pop() != 91)) {
throw new NBTException("Unbalanced square brackets []: " + str);
}
@ -204,7 +203,7 @@ public class JSON2NBT {
return str.substring(0, i);
}
} else {
stack.push(Character.valueOf(c0));
stack.push(c0);
}
}
@ -343,14 +342,11 @@ public class JSON2NBT {
if (this.jsonValue.startsWith("[") && this.jsonValue.endsWith("]")) {
String var7 = this.jsonValue.substring(1, this.jsonValue.length() - 1);
String[] var8 = (String[]) ((String[]) Iterables.toArray(SPLITTER.split(var7), String.class));
String[] var8 = Iterables.toArray(SPLITTER.split(var7), String.class);
try {
int[] var5 = new int[var8.length];
for (int j = 0; j < var8.length; ++j) {
var5[j] = Integer.parseInt(var8[j].trim());
}
int[] var5 = Arrays.stream(var8).mapToInt(s -> Integer.parseInt(s.trim()))
.toArray();
return new IntArrayTag(var5);
} catch (NumberFormatException var51) {
@ -379,27 +375,23 @@ public class JSON2NBT {
}
private static class List extends JSON2NBT.Any {
protected java.util.List<JSON2NBT.Any> tagList = Lists.newArrayList();
protected List<JSON2NBT.Any> tagList = Lists.newArrayList();
public List(String json) {
this.json = json;
}
public Tag parse() throws NBTException {
ArrayList<Tag> list = new ArrayList<>();
Iterator var2 = this.tagList.iterator();
ArrayList<Tag> list = this.tagList.stream().map(Any::parse)
.collect(Collectors.toCollection(ArrayList::new));
while (var2.hasNext()) {
JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any) var2.next();
list.add(JSON2NBT$any.parse());
}
Class<? extends Tag> tagType = list.isEmpty() ? CompoundTag.class : list.get(0).getClass();
return new ListTag(tagType, list);
}
}
private static class Compound extends JSON2NBT.Any {
protected java.util.List<JSON2NBT.Any> tagList = Lists.newArrayList();
protected List<JSON2NBT.Any> tagList = Lists.newArrayList();
public Compound(String jsonIn) {
this.json = jsonIn;
@ -407,10 +399,8 @@ public class JSON2NBT {
public Tag parse() throws NBTException {
HashMap<String, Tag> map = new HashMap<>();
Iterator var2 = this.tagList.iterator();
while (var2.hasNext()) {
JSON2NBT.Any JSON2NBT$any = (JSON2NBT.Any) var2.next();
for (Any JSON2NBT$any : this.tagList) {
map.put(JSON2NBT$any.json, JSON2NBT$any.parse());
}

Datei anzeigen

@ -51,7 +51,7 @@ public class MCAChunk implements IChunk {
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 long inhabitedTime = System.currentTimeMillis();
public long lastUpdate;

Datei anzeigen

@ -7,8 +7,8 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
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.object.FaweInputStream;
import com.boydti.fawe.object.FaweOutputStream;
@ -46,7 +46,6 @@ import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.Location;
@ -60,7 +59,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
@ -1556,9 +1554,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
}
public void setHeights(int value) {
heights.record(() -> {
Arrays.fill(heights.get(), (byte) value);
});
heights.record(() -> Arrays.fill(heights.get(), (byte) value));
}
@Override

Datei anzeigen

@ -17,6 +17,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.io.Closeable;
import java.util.Collection;
import java.util.Iterator;
import org.jetbrains.annotations.NotNull;
/**
* Best used when clipboard selections are small, or using legacy formats
@ -46,6 +47,7 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
public abstract Collection<CompoundTag> getTileEntities();
@Override
public void close() {}
public void flush() {}
@ -55,6 +57,7 @@ public abstract class LinearClipboard extends SimpleClipboard implements Clipboa
close();
}
@NotNull
@Override
public Iterator<BlockVector3> iterator() {
return iterator(Order.YZX);

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -52,7 +52,7 @@ public class ReflectionUtils {
// 2. Copy it
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
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) {
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;
Field m = clazz.getDeclaredField("list");
m.setAccessible(true);
@ -566,10 +566,10 @@ public class ReflectionUtils {
* @throws RuntimeException if constructor not found
*/
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.getDeclaredConstructors());
for (Constructor m : constructors) {
for (Constructor<?> m : constructors) {
if (m.getParameterTypes().length == number) {
return new RefConstructor(m);
}

Datei anzeigen

@ -32,7 +32,7 @@ public class ReflectionUtils9 {
// 2. Copy it
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
T newValue = (T) makeEnum(enumType, // The target enum class

Datei anzeigen

@ -19,9 +19,14 @@
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.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit;
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.Expression;
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.BlockVector3;
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.MutableBlockVector3;
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.TreeGenerator;
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.biome.BiomeType;
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.BlockTypes;
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.util.ArrayList;
import java.util.Collection;
@ -138,12 +139,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
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 org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 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 boolean wrapped;
private Extent bypassHistory;
private Extent bypassAll;
private final FaweLimit originalLimit;
private final FaweLimit limit;
private final Player player;
private FaweChangeSet changeTask;
private FaweChangeSet changeSet;
private boolean history;
private final MutableBlockVector3 mutablebv = new MutableBlockVector3();
@ -208,6 +206,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
private int changes = -1;
private final BlockBag blockBag;
private Extent bypassHistory;
private Extent bypassAll;
private final int maxY;
@Deprecated
@ -229,10 +230,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
this.originalLimit = builder.getLimit();
this.limit = builder.getLimit().copy();
this.player = builder.getPlayer();
this.changeTask = builder.getChangeTask();
this.changeSet = builder.getChangeTask();
this.maxY = builder.getMaxY();
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 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);
}
@ -384,15 +385,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @return the change set
*/
public ChangeSet getChangeSet() {
return changeTask;
}
/**
* Will be removed very soon. Use getChangeSet()
*/
@Deprecated
public FaweChangeSet getChangeTask() {
return changeTask;
return changeSet;
}
/**
@ -401,7 +394,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @param set
*/
public void setRawChangeSet(@Nullable FaweChangeSet set) {
changeTask = set;
changeSet = set;
changes++;
}
@ -432,7 +425,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @return whether the queue is enabled
* @deprecated Use {@link EditSession#getReorderMode()} with MULTI_STAGE instead.
*/
@Override
@Deprecated
public boolean isQueueEnabled() {
return true;
@ -444,7 +436,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* Uses {@link ReorderMode#MULTI_STAGE}
* @deprecated Use {@link EditSession#setReorderMode(ReorderMode)} with MULTI_STAGE instead.
*/
@Override
@Deprecated
public void enableQueue() {
super.enableQueue();
@ -453,7 +444,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
/**
* Disable the queue. This will close the queue.
*/
@Override
@Deprecated
public void disableQueue() {
super.disableQueue();
@ -599,10 +589,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
}
} else {
if (this.history) {
if (this.changeTask == null) {
if (this.changeSet == null) {
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
*/
public void setBlockBag(BlockBag blockBag) {
//Not Supported in FAWE
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
*/
public boolean isTickingWatchdog() {
/*
return watchdogExtents.stream().anyMatch(WatchdogTickingExtent::isEnabled);
*/
return false;
}
/**
* Set all watchdog extents to the given mode.
*/
public void setTickingWatchdog(boolean active) {
/*
for (WatchdogTickingExtent extent : watchdogExtents) {
extent.setEnabled(active);
}
*/
}
/**
@ -777,7 +763,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
* @param maxY maximal height
* @return height of highest block found or 'minY'
*/
@Override
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
for (int y = maxY; y >= minY; --y) {
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
* @return height of highest block found or 'minY'
*/
@Override
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
for (int y = maxY; y >= minY; --y) {
if (filter.test(mutablebv.setComponents(x, y, z))) {

Datei anzeigen

@ -483,6 +483,7 @@ public class ClipboardCommands {
} else {
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) {

Datei anzeigen

@ -12,7 +12,6 @@ import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.util.MainUtil;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEditException;
@ -32,7 +31,6 @@ import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
@ -48,13 +46,11 @@ import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.LongAdder;
import java.util.function.Supplier;
import javax.annotation.Nullable;
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)
@ -317,44 +313,40 @@ public class HistorySubCommands {
player.setMeta(pageCommand, new SoftReference<>(list));
}
PaginationBox pages = PaginationBox.fromStrings("Edits:", pageCommand, list, new Function<Supplier<RollbackOptimizedHistory>, Component>() {
@NotNull
@Override
public Component apply(@Nullable Supplier<RollbackOptimizedHistory> input) {
RollbackOptimizedHistory edit = input.get();
UUID uuid = edit.getUUID();
int index = edit.getIndex();
if (!edit.isEmpty()) {
database.delete(uuid, index);
return TextComponent.empty();
}
String name = Fawe.imp().getName(edit.getUUID());
String cmd = edit.getCommand();
BlockVector3 pos1 = edit.getMinimumPoint();
BlockVector3 pos2 = edit.getMaximumPoint();
double distanceX = Math.min(Math.abs(pos1.getX() - origin.getX()), Math.abs(pos2.getX() - origin.getX()));
double distanceZ = Math.min(Math.abs(pos1.getZ() - origin.getZ()), Math.abs(pos2.getZ() - origin.getZ()));
int distance = (int) Math.sqrt(distanceX * distanceX + distanceZ * distanceZ);
BlockVector2 dirVec = BlockVector2.at(edit.getOriginX() - origin.getX(), edit.getOriginZ() - origin.getZ());
Direction direction = Direction.findClosest(dirVec.toVector3(), Direction.Flag.ALL);
long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000;
String timeStr = MainUtil.secToTime(seconds);
int size = edit.size();
TranslatableComponent elem = Caption.of("fawe.worldedit.history.find.element", name, timeStr, distance, direction.name(), cmd);
String infoCmd = "//history summary " + uuid + " " + index;
TranslatableComponent hover = Caption.of("fawe.worldedit.history.find.hover", size);
elem = elem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, hover));
elem = elem.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, infoCmd));
return elem;
PaginationBox pages = PaginationBox.fromStrings("Edits:", pageCommand, list, input -> {
RollbackOptimizedHistory edit = input.get();
UUID uuid = edit.getUUID();
int index = edit.getIndex();
if (!edit.isEmpty()) {
database.delete(uuid, index);
return TextComponent.empty();
}
String name = Fawe.imp().getName(edit.getUUID());
String cmd = edit.getCommand();
BlockVector3 pos1 = edit.getMinimumPoint();
BlockVector3 pos2 = edit.getMaximumPoint();
double distanceX = Math.min(Math.abs(pos1.getX() - origin.getX()), Math.abs(pos2.getX() - origin.getX()));
double distanceZ = Math.min(Math.abs(pos1.getZ() - origin.getZ()), Math.abs(pos2.getZ() - origin.getZ()));
int distance = (int) Math.sqrt(distanceX * distanceX + distanceZ * distanceZ);
BlockVector2 dirVec = BlockVector2.at(edit.getOriginX() - origin.getX(), edit.getOriginZ() - origin.getZ());
Direction direction = Direction.findClosest(dirVec.toVector3(), Direction.Flag.ALL);
long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000;
String timeStr = MainUtil.secToTime(seconds);
int size = edit.size();
TranslatableComponent elem = Caption.of("fawe.worldedit.history.find.element", name, timeStr, distance, direction.name(), cmd);
String infoCmd = "//history summary " + uuid + " " + index;
TranslatableComponent hover = Caption.of("fawe.worldedit.history.find.hover", size);
elem = elem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, hover));
elem = elem.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, infoCmd));
return elem;
});
player.print(pages.create(page));
}

Datei anzeigen

@ -223,7 +223,7 @@ public class SchematicCommands {
URI uri;
if (filename.startsWith("url:")) {
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;
}
UUID uuid = UUID.fromString(filename.substring(4));
@ -250,7 +250,7 @@ public class SchematicCommands {
}
} 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()) {
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;
}
if (format == null && filename.matches(".*\\.[\\w].*")) {
@ -329,7 +329,7 @@ public class SchematicCommands {
if (filename.contains("../")) {
other = true;
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;
}
if (filename.startsWith("../")) {
@ -347,7 +347,7 @@ public class SchematicCommands {
}
if (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;
}
}
@ -393,7 +393,7 @@ public class SchematicCommands {
return;
}
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;
}
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")) {
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;
}
try {
@ -829,7 +829,7 @@ public class SchematicCommands {
continue;
}
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;
}
if (!deleteFile(f)) {

Datei anzeigen

@ -23,14 +23,11 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.DelegateConsumer;
import com.boydti.fawe.object.function.QuadFunction;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.image.ImageUtil;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalConfiguration;
@ -45,6 +42,7 @@ import com.sk89q.worldedit.command.util.CreatureButcher;
import com.sk89q.worldedit.command.util.EntityRemover;
import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.command.util.PrintCommandHelp;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.command.util.annotation.SkipQueue;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player;
@ -52,19 +50,16 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.EntityFunction;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.command.util.WorldEditAsyncCommandBuilder;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.visitor.EntityVisitor;
import com.sk89q.worldedit.internal.annotation.Direction;
import com.sk89q.worldedit.internal.expression.EvaluationException;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import java.text.DecimalFormat;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.CylinderRegion;
@ -72,6 +67,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.text.Component;
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.world.World;
import com.sk89q.worldedit.world.block.BlockTypes;
@ -81,8 +77,9 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.AbstractMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
@ -91,7 +88,9 @@ import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
@ -713,11 +712,12 @@ public class UtilityCommands {
}
public static List<Map.Entry<URI, String>> filesToEntry(final File root, final List<File> files, final UUID uuid) {
return Lists.transform(files, input -> { // Keep this functional, as transform is evaluated lazily
URI uri = input.toURI();
String path = getPath(root, input, uuid);
return new AbstractMap.SimpleEntry<>(uri, path);
});
return files.stream()
.map(input -> { // Keep this functional, as transform is evaluated lazily
URI uri = input.toURI();
String path = getPath(root, input, uuid);
return new SimpleEntry<>(uri, path);
}).collect(Collectors.toList());
}
public static enum URIType {
@ -728,7 +728,7 @@ public class UtilityCommands {
}
public static List<Component> entryToComponent(File root, List<Map.Entry<URI, String>> entries, Function<URI, Boolean> isLoaded, QuadFunction<String, String, URIType, Boolean, Component> adapter) {
return Lists.transform(entries, input -> {
return entries.stream().map(input -> {
URI uri = input.getKey();
String path = input.getValue();
@ -745,11 +745,13 @@ public class UtilityCommands {
if (file.isDirectory()) {
type = URIType.DIRECTORY;
} else {
if (name.indexOf('.') != -1) name = name.substring(0, name.lastIndexOf('.'));
if (name.indexOf('.') != -1)
name = name.substring(0, name.lastIndexOf('.'));
}
try {
if (!MainUtil.isInSubDirectory(root, file)) {
throw new RuntimeException(new StopExecutionException(TextComponent.of("Invalid path")));
throw new RuntimeException(
new StopExecutionException(TextComponent.of("Invalid path")));
}
} catch (IOException ignore) {
}
@ -760,7 +762,7 @@ public class UtilityCommands {
}
return adapter.apply(name, path, type, loaded);
});
}).collect(Collectors.toList());
}
public static List<File> getFiles(File dir, Actor actor, List<String> args, String formatName, boolean playerFolder, boolean oldFirst, boolean newFirst) {
@ -810,8 +812,7 @@ public class UtilityCommands {
boolean listMine = false;
boolean listGlobal = !Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS;
if (len > 0) {
for (int i = 0; i < len; i++) {
String arg = args.get(i);
for (String arg : args) {
switch (arg.toLowerCase()) {
case "me":
case "mine":
@ -831,7 +832,10 @@ public class UtilityCommands {
if (arg.endsWith("/") || arg.endsWith(File.separator)) {
arg = arg.replace("/", File.separator);
String newDirFilter = dirFilter + arg;
boolean exists = new File(dir, newDirFilter).exists() || playerFolder && MainUtil.resolveRelative(new File(dir, actor.getUniqueId() + newDirFilter)).exists();
boolean exists =
new File(dir, newDirFilter).exists() || playerFolder && MainUtil
.resolveRelative(
new File(dir, actor.getUniqueId() + newDirFilter)).exists();
if (!exists) {
arg = arg.substring(0, arg.length() - File.separator.length());
if (arg.length() > 3 && arg.length() <= 16) {
@ -843,8 +847,7 @@ public class UtilityCommands {
}
}
dirFilter = newDirFilter;
}
else {
} else {
filters.add(arg);
}
break;

Datei anzeigen

@ -491,7 +491,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (brush == null) return false;
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;
}
try (EditSession editSession = session.createEditSession(player, current.toString())) {

Datei anzeigen

@ -619,7 +619,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public void checkPermission(String permission) throws AuthorizationException {
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)));
}
}

Datei anzeigen

@ -44,6 +44,7 @@ import java.io.Closeable;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.jetbrains.annotations.NotNull;
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);
}
@NotNull
@Override
public Iterator<BlockVector3> iterator() {
OffsetBlockVector3 mutable = new OffsetBlockVector3(offset);

Datei anzeigen

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

Datei anzeigen

@ -170,7 +170,7 @@ public class ClipboardFormats {
LocalConfiguration config = worldEdit.getConfiguration();
if (input.startsWith("url:")) {
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;
}
URL base = new URL(Settings.IMP.WEB.URL);
@ -178,7 +178,7 @@ public class ClipboardFormats {
}
if (input.startsWith("http")) {
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;
}
URL url = new URL(input);
@ -190,7 +190,7 @@ public class ClipboardFormats {
return loadAllFromUrl(url);
} 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")) {
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;
}
File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
@ -210,7 +210,7 @@ public class ClipboardFormats {
}
} 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 (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;
}
if (format == null && input.matches(".*\\.[\\w].*")) {

Datei anzeigen

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

Datei anzeigen

@ -19,23 +19,18 @@
package com.sk89q.worldedit.util.formatting.component;
import com.boydti.fawe.object.collection.AdaptedSetCollection;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
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.format.TextColor;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.function.Supplier;
import javax.annotation.Nullable;
public abstract class PaginationBox extends MessageBox {
@ -196,4 +191,4 @@ public abstract class PaginationBox extends MessageBox {
return lines.size();
}
}
}
}

Datei anzeigen

@ -7,7 +7,7 @@
"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.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.set.region": "Selection set to your current allowed region",
@ -216,7 +216,7 @@
"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.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).",
@ -236,7 +236,7 @@
"fawe.progress.progress.finished": "[ Done! ]",
"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.setting.disable": "Lacking setting: {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.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.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.select.connected": "Tip: Select all connected blocks with //sel fuzzy",