geforkt von Mirrors/FastAsyncWorldEdit
Fix wna when used internally
Dieser Commit ist enthalten in:
Ursprung
6f0180447f
Commit
6bc3dd2293
@ -16,7 +16,7 @@ import com.boydti.fawe.bukkit.regions.GriefPreventionFeature;
|
||||
import com.boydti.fawe.bukkit.regions.ResidenceFeature;
|
||||
import com.boydti.fawe.bukkit.regions.TownyFeature;
|
||||
import com.boydti.fawe.bukkit.regions.Worldguard;
|
||||
import com.boydti.fawe.bukkit.util.BukkitTaskMan;
|
||||
import com.boydti.fawe.bukkit.util.BukkitTaskManager;
|
||||
import com.boydti.fawe.bukkit.util.ItemUtil;
|
||||
import com.boydti.fawe.bukkit.util.image.BukkitImageViewer;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
@ -187,7 +187,7 @@ public class FaweBukkit implements IFawe, Listener {
|
||||
* The task manager handles sync/async tasks.
|
||||
*/
|
||||
@Override public TaskManager getTaskManager() {
|
||||
return new BukkitTaskMan(plugin);
|
||||
return new BukkitTaskManager(plugin);
|
||||
}
|
||||
|
||||
public Plugin getPlugin() {
|
||||
|
@ -1,15 +1,17 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_15_2;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.IntPair;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_15_R2;
|
||||
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
|
||||
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.server.v1_15_R1.Block;
|
||||
import net.minecraft.server.v1_15_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_15_R1.Chunk;
|
||||
@ -26,7 +28,10 @@ import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FAWEWorldNativeAccess_1_15_2 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||
@ -36,10 +41,13 @@ public class FAWEWorldNativeAccess_1_15_2 implements WorldNativeAccess<Chunk, IB
|
||||
private final FAWE_Spigot_v1_15_R2 adapter;
|
||||
private final WeakReference<World> world;
|
||||
private SideEffectSet sideEffectSet;
|
||||
private final AtomicInteger lastTick;
|
||||
private final Set<CachedChange> cachedChanges = new ConcurrentSet<>();
|
||||
|
||||
public FAWEWorldNativeAccess_1_15_2(FAWE_Spigot_v1_15_R2 adapter, WeakReference<World> world) {
|
||||
this.adapter = adapter;
|
||||
this.world = world;
|
||||
this.lastTick = new AtomicInteger(getWorld().getServer().getCurrentTick());
|
||||
}
|
||||
|
||||
private World getWorld() {
|
||||
@ -72,9 +80,23 @@ public class FAWEWorldNativeAccess_1_15_2 implements WorldNativeAccess<Chunk, IB
|
||||
@Nullable
|
||||
@Override
|
||||
public IBlockData setBlockState(Chunk chunk, BlockPosition position, IBlockData state) {
|
||||
int currentTick = getWorld().getServer().getCurrentTick();
|
||||
if (Fawe.isMainThread()) {
|
||||
if (lastTick.get() > currentTick) {
|
||||
lastTick.set(currentTick);
|
||||
flush();
|
||||
}
|
||||
return chunk.setType(position, state,
|
||||
this.sideEffectSet != null && this.sideEffectSet.shouldApply(SideEffect.UPDATE));
|
||||
}
|
||||
// Since FAWE is.. Async we need to do it on the main thread (wooooo.. :( )
|
||||
cachedChanges.add(new CachedChange(chunk, position, state));
|
||||
if (lastTick.get() > currentTick || cachedChanges.size() > 1024) {
|
||||
lastTick.set(currentTick);
|
||||
flush();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockData getValidBlockForPosition(IBlockData block, BlockPosition position) {
|
||||
@ -167,4 +189,41 @@ public class FAWEWorldNativeAccess_1_15_2 implements WorldNativeAccess<Chunk, IB
|
||||
public void onBlockStateChange(BlockPosition pos, IBlockData oldState, IBlockData newState) {
|
||||
getWorld().a(pos, oldState, newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void flush() {
|
||||
Set<IntPair> toSend = new LinkedHashSet<>();
|
||||
RunnableVal<Object> r = new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
cachedChanges.forEach(cc -> {
|
||||
cc.chunk.setType(cc.position, cc.blockData,
|
||||
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE));
|
||||
toSend.add(new IntPair(cc.chunk.getBukkitChunk().getX(), cc.chunk.bukkitChunk.getZ()));
|
||||
});
|
||||
for (IntPair chunk : toSend) {
|
||||
BukkitAdapter_1_15_2.sendChunk(getWorld().getWorld().getHandle(), chunk.x, chunk.z, 0, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Fawe.isMainThread()) {
|
||||
r.run();
|
||||
} else {
|
||||
TaskManager.IMP.sync(r);
|
||||
}
|
||||
cachedChanges.clear();
|
||||
}
|
||||
|
||||
private static final class CachedChange {
|
||||
|
||||
private final Chunk chunk;
|
||||
private final BlockPosition position;
|
||||
private final IBlockData blockData;
|
||||
|
||||
private CachedChange(Chunk chunk, BlockPosition position, IBlockData blockData) {
|
||||
this.chunk = chunk;
|
||||
this.position = position;
|
||||
this.blockData = blockData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,18 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_1;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.IntPair;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R1;
|
||||
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
|
||||
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.server.v1_16_R1.Block;
|
||||
import net.minecraft.server.v1_16_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R1.Chunk;
|
||||
@ -27,20 +29,26 @@ import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||
public class FAWEWorldNativeAccess_1_16_R1 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||
private static final int UPDATE = 1;
|
||||
private static final int NOTIFY = 2;
|
||||
|
||||
private final FAWE_Spigot_v1_16_R1 adapter;
|
||||
private final WeakReference<World> world;
|
||||
private SideEffectSet sideEffectSet;
|
||||
private final AtomicInteger lastTick;
|
||||
private final Set<CachedChange> cachedChanges = new ConcurrentSet<>();
|
||||
|
||||
public FAWEWorldNativeAccess_1_16(FAWE_Spigot_v1_16_R1 adapter, WeakReference<World> world) {
|
||||
public FAWEWorldNativeAccess_1_16_R1(FAWE_Spigot_v1_16_R1 adapter, WeakReference<World> world) {
|
||||
this.adapter = adapter;
|
||||
this.world = world;
|
||||
this.lastTick = new AtomicInteger(getWorld().getServer().getCurrentTick());
|
||||
}
|
||||
|
||||
private World getWorld() {
|
||||
@ -73,9 +81,23 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlo
|
||||
@Nullable
|
||||
@Override
|
||||
public IBlockData setBlockState(Chunk chunk, BlockPosition position, IBlockData state) {
|
||||
int currentTick = getWorld().getServer().getCurrentTick();
|
||||
if (Fawe.isMainThread()) {
|
||||
if (lastTick.get() > currentTick) {
|
||||
lastTick.set(currentTick);
|
||||
flush();
|
||||
}
|
||||
return chunk.setType(position, state,
|
||||
this.sideEffectSet != null && this.sideEffectSet.shouldApply(SideEffect.UPDATE));
|
||||
}
|
||||
// Since FAWE is.. Async we need to do it on the main thread (wooooo.. :( )
|
||||
cachedChanges.add(new CachedChange(chunk, position, state));
|
||||
if (lastTick.get() > currentTick || cachedChanges.size() > 1024) {
|
||||
lastTick.set(currentTick);
|
||||
flush();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockData getValidBlockForPosition(IBlockData block, BlockPosition position) {
|
||||
@ -168,4 +190,41 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlo
|
||||
public void onBlockStateChange(BlockPosition pos, IBlockData oldState, IBlockData newState) {
|
||||
getWorld().a(pos, oldState, newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void flush() {
|
||||
Set<IntPair> toSend = new LinkedHashSet<>();
|
||||
RunnableVal<Object> r = new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
cachedChanges.forEach(cc -> {
|
||||
cc.chunk.setType(cc.position, cc.blockData,
|
||||
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE));
|
||||
toSend.add(new IntPair(cc.chunk.getBukkitChunk().getX(), cc.chunk.bukkitChunk.getZ()));
|
||||
});
|
||||
for (IntPair chunk : toSend) {
|
||||
BukkitAdapter_1_16_1.sendChunk(getWorld().getWorld().getHandle(), chunk.x, chunk.z, 0, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Fawe.isMainThread()) {
|
||||
r.run();
|
||||
} else {
|
||||
TaskManager.IMP.sync(r);
|
||||
}
|
||||
cachedChanges.clear();
|
||||
}
|
||||
|
||||
private static final class CachedChange {
|
||||
|
||||
private final Chunk chunk;
|
||||
private final BlockPosition position;
|
||||
private final IBlockData blockData;
|
||||
|
||||
private CachedChange(Chunk chunk, BlockPosition position, IBlockData blockData) {
|
||||
this.chunk = chunk;
|
||||
this.position = position;
|
||||
this.blockData = blockData;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,18 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_2;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.IntPair;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R2;
|
||||
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
|
||||
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.server.v1_16_R2.Block;
|
||||
import net.minecraft.server.v1_16_R2.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R2.Chunk;
|
||||
@ -27,20 +29,26 @@ import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||
public class FAWEWorldNativeAccess_1_16_R2 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||
private static final int UPDATE = 1;
|
||||
private static final int NOTIFY = 2;
|
||||
|
||||
private final FAWE_Spigot_v1_16_R2 adapter;
|
||||
private final WeakReference<World> world;
|
||||
private SideEffectSet sideEffectSet;
|
||||
private final AtomicInteger lastTick;
|
||||
private final Set<CachedChange> cachedChanges = new ConcurrentSet<>();
|
||||
|
||||
public FAWEWorldNativeAccess_1_16(FAWE_Spigot_v1_16_R2 adapter, WeakReference<World> world) {
|
||||
public FAWEWorldNativeAccess_1_16_R2(FAWE_Spigot_v1_16_R2 adapter, WeakReference<World> world) {
|
||||
this.adapter = adapter;
|
||||
this.world = world;
|
||||
this.lastTick = new AtomicInteger(getWorld().getServer().getCurrentTick());
|
||||
}
|
||||
|
||||
private World getWorld() {
|
||||
@ -73,9 +81,23 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlo
|
||||
@Nullable
|
||||
@Override
|
||||
public IBlockData setBlockState(Chunk chunk, BlockPosition position, IBlockData state) {
|
||||
int currentTick = getWorld().getServer().getCurrentTick();
|
||||
if (Fawe.isMainThread()) {
|
||||
if (lastTick.get() > currentTick) {
|
||||
lastTick.set(currentTick);
|
||||
flush();
|
||||
}
|
||||
return chunk.setType(position, state,
|
||||
this.sideEffectSet != null && this.sideEffectSet.shouldApply(SideEffect.UPDATE));
|
||||
}
|
||||
// Since FAWE is.. Async we need to do it on the main thread (wooooo.. :( )
|
||||
cachedChanges.add(new CachedChange(chunk, position, state));
|
||||
if (lastTick.get() > currentTick || cachedChanges.size() > 1024) {
|
||||
lastTick.set(currentTick);
|
||||
flush();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockData getValidBlockForPosition(IBlockData block, BlockPosition position) {
|
||||
@ -168,4 +190,41 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlo
|
||||
public void onBlockStateChange(BlockPosition pos, IBlockData oldState, IBlockData newState) {
|
||||
getWorld().a(pos, oldState, newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void flush() {
|
||||
Set<IntPair> toSend = new LinkedHashSet<>();
|
||||
RunnableVal<Object> r = new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
cachedChanges.forEach(cc -> {
|
||||
cc.chunk.setType(cc.position, cc.blockData,
|
||||
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE));
|
||||
toSend.add(new IntPair(cc.chunk.getBukkitChunk().getX(), cc.chunk.bukkitChunk.getZ()));
|
||||
});
|
||||
for (IntPair chunk : toSend) {
|
||||
BukkitAdapter_1_16_2.sendChunk(getWorld().getWorld().getHandle(), chunk.x, chunk.z, 0, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Fawe.isMainThread()) {
|
||||
r.run();
|
||||
} else {
|
||||
TaskManager.IMP.sync(r);
|
||||
}
|
||||
cachedChanges.clear();
|
||||
}
|
||||
|
||||
private static final class CachedChange {
|
||||
|
||||
private final Chunk chunk;
|
||||
private final BlockPosition position;
|
||||
private final IBlockData blockData;
|
||||
|
||||
private CachedChange(Chunk chunk, BlockPosition position, IBlockData blockData) {
|
||||
this.chunk = chunk;
|
||||
this.position = position;
|
||||
this.blockData = blockData;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,18 @@
|
||||
package com.boydti.fawe.bukkit.adapter.mc1_16_4;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.object.IntPair;
|
||||
import com.boydti.fawe.object.RunnableVal;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R2;
|
||||
import com.sk89q.worldedit.bukkit.adapter.impl.FAWE_Spigot_v1_16_R3;
|
||||
import com.sk89q.worldedit.internal.block.BlockStateIdAccess;
|
||||
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.server.v1_16_R3.Block;
|
||||
import net.minecraft.server.v1_16_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R3.Chunk;
|
||||
@ -29,19 +30,25 @@ import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||
public class FAWEWorldNativeAccess_1_16_R3 implements WorldNativeAccess<Chunk, IBlockData, BlockPosition> {
|
||||
private static final int UPDATE = 1;
|
||||
private static final int NOTIFY = 2;
|
||||
|
||||
private final FAWE_Spigot_v1_16_R3 adapter;
|
||||
private final WeakReference<World> world;
|
||||
private SideEffectSet sideEffectSet;
|
||||
private final AtomicInteger lastTick;
|
||||
private final Set<CachedChange> cachedChanges = new ConcurrentSet<>();
|
||||
|
||||
public FAWEWorldNativeAccess_1_16(FAWE_Spigot_v1_16_R3 adapter, WeakReference<World> world) {
|
||||
public FAWEWorldNativeAccess_1_16_R3(FAWE_Spigot_v1_16_R3 adapter, WeakReference<World> world) {
|
||||
this.adapter = adapter;
|
||||
this.world = world;
|
||||
this.lastTick = new AtomicInteger(getWorld().getServer().getCurrentTick());
|
||||
}
|
||||
|
||||
private World getWorld() {
|
||||
@ -73,10 +80,24 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlo
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBlockData setBlockState(Chunk chunk, BlockPosition position, IBlockData state) {
|
||||
public synchronized IBlockData setBlockState(Chunk chunk, BlockPosition position, IBlockData state) {
|
||||
int currentTick = getWorld().getServer().getCurrentTick();
|
||||
if (Fawe.isMainThread()) {
|
||||
if (lastTick.get() > currentTick) {
|
||||
lastTick.set(currentTick);
|
||||
flush();
|
||||
}
|
||||
return chunk.setType(position, state,
|
||||
this.sideEffectSet != null && this.sideEffectSet.shouldApply(SideEffect.UPDATE));
|
||||
}
|
||||
// Since FAWE is.. Async we need to do it on the main thread (wooooo.. :( )
|
||||
cachedChanges.add(new CachedChange(chunk, position, state));
|
||||
if (lastTick.get() > currentTick || cachedChanges.size() > 1024) {
|
||||
lastTick.set(currentTick);
|
||||
flush();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockData getValidBlockForPosition(IBlockData block, BlockPosition position) {
|
||||
@ -169,4 +190,41 @@ public class FAWEWorldNativeAccess_1_16 implements WorldNativeAccess<Chunk, IBlo
|
||||
public void onBlockStateChange(BlockPosition pos, IBlockData oldState, IBlockData newState) {
|
||||
getWorld().a(pos, oldState, newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void flush() {
|
||||
Set<IntPair> toSend = new LinkedHashSet<>();
|
||||
RunnableVal<Object> r = new RunnableVal<Object>() {
|
||||
@Override
|
||||
public void run(Object value) {
|
||||
cachedChanges.forEach(cc -> {
|
||||
cc.chunk.setType(cc.position, cc.blockData,
|
||||
sideEffectSet != null && sideEffectSet.shouldApply(SideEffect.UPDATE));
|
||||
toSend.add(new IntPair(cc.chunk.getBukkitChunk().getX(), cc.chunk.bukkitChunk.getZ()));
|
||||
});
|
||||
for (IntPair chunk : toSend) {
|
||||
BukkitAdapter_1_16_4.sendChunk(getWorld().getWorld().getHandle(), chunk.x, chunk.z, 0, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Fawe.isMainThread()) {
|
||||
r.run();
|
||||
} else {
|
||||
TaskManager.IMP.sync(r);
|
||||
}
|
||||
cachedChanges.clear();
|
||||
}
|
||||
|
||||
private static final class CachedChange {
|
||||
|
||||
private final Chunk chunk;
|
||||
private final BlockPosition position;
|
||||
private final IBlockData blockData;
|
||||
|
||||
private CachedChange(Chunk chunk, BlockPosition position, IBlockData blockData) {
|
||||
this.chunk = chunk;
|
||||
this.position = position;
|
||||
this.blockData = blockData;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,11 +6,11 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BukkitTaskMan extends TaskManager {
|
||||
public class BukkitTaskManager extends TaskManager {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
public BukkitTaskMan(final Plugin plugin) {
|
||||
public BukkitTaskManager(final Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -63,6 +63,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
@ -561,4 +562,11 @@ public class BukkitWorld extends AbstractWorld {
|
||||
org.bukkit.entity.Player bukkitPlayer = BukkitAdapter.adapt(player);
|
||||
WorldEditPlugin.getInstance().getBukkitImplAdapter().sendFakeChunk(getWorld(), bukkitPlayer, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
if (worldNativeAccess != null) {
|
||||
worldNativeAccess.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_1.BlockMaterial_1_16_1;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_1.BukkitAdapter_1_16_1;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_1.BukkitGetBlocks_1_16_1;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_1.FAWEWorldNativeAccess_1_16;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_1.FAWEWorldNativeAccess_1_16_R1;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_1.MapChunkUtil_1_16_1;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt.LazyCompoundTag_1_16_1;
|
||||
import com.google.common.base.Preconditions;
|
||||
@ -244,7 +244,7 @@ public final class FAWE_Spigot_v1_16_R1 extends CachedBukkitAdapter implements I
|
||||
|
||||
@Override
|
||||
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(org.bukkit.World world) {
|
||||
return new FAWEWorldNativeAccess_1_16(this,
|
||||
return new FAWEWorldNativeAccess_1_16_R1(this,
|
||||
new WeakReference<>(((CraftWorld)world).getHandle()));
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.BlockMaterial_1_16_2;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.BukkitAdapter_1_16_2;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.BukkitGetBlocks_1_16_2;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.FAWEWorldNativeAccess_1_16;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.FAWEWorldNativeAccess_1_16_R2;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.MapChunkUtil_1_16_2;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_2.nbt.LazyCompoundTag_1_16_2;
|
||||
import com.google.common.base.Preconditions;
|
||||
@ -246,7 +246,7 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
|
||||
|
||||
@Override
|
||||
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(org.bukkit.World world) {
|
||||
return new FAWEWorldNativeAccess_1_16(this,
|
||||
return new FAWEWorldNativeAccess_1_16_R2(this,
|
||||
new WeakReference<>(((CraftWorld)world).getHandle()));
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.BlockMaterial_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.BukkitAdapter_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.BukkitGetBlocks_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.FAWEWorldNativeAccess_1_16;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.FAWEWorldNativeAccess_1_16_R3;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.MapChunkUtil_1_16_4;
|
||||
import com.boydti.fawe.bukkit.adapter.mc1_16_4.nbt.LazyCompoundTag_1_16_4;
|
||||
import com.google.common.base.Preconditions;
|
||||
@ -246,7 +246,7 @@ public final class FAWE_Spigot_v1_16_R3 extends CachedBukkitAdapter implements I
|
||||
|
||||
@Override
|
||||
public WorldNativeAccess<?, ?, ?> createWorldNativeAccess(org.bukkit.World world) {
|
||||
return new FAWEWorldNativeAccess_1_16(this,
|
||||
return new FAWEWorldNativeAccess_1_16_R3(this,
|
||||
new WeakReference<>(((CraftWorld)world).getHandle()));
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -102,4 +103,7 @@ public class MCAWorld extends AbstractWorld {
|
||||
public void sendFakeChunk(@Nullable Player player, ChunkPacket packet) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {}
|
||||
}
|
||||
|
@ -77,8 +77,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable,
|
||||
VirtualWorld {
|
||||
public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Drawable, VirtualWorld {
|
||||
|
||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
@ -94,6 +93,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
protected final CFIPrimitives primitives = new CFIPrimitives();
|
||||
private CFIPrimitives oldPrimitives = new CFIPrimitives();
|
||||
|
||||
@Override
|
||||
public void flush() {}
|
||||
|
||||
public final class CFIPrimitives implements Cloneable {
|
||||
|
||||
int waterHeight;
|
||||
|
@ -67,6 +67,7 @@ public class EditSessionBuilder {
|
||||
private EditSessionEvent event;
|
||||
private String command;
|
||||
private RelightMode relightMode;
|
||||
private Boolean wnaMode;
|
||||
|
||||
/**
|
||||
* An EditSession builder<br>
|
||||
@ -203,6 +204,11 @@ public class EditSessionBuilder {
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
public EditSessionBuilder forceWNA() {
|
||||
this.wnaMode = true;
|
||||
return setDirty();
|
||||
}
|
||||
|
||||
private EditSessionBuilder setDirty() {
|
||||
compiled = false;
|
||||
return this;
|
||||
@ -303,7 +309,8 @@ public class EditSessionBuilder {
|
||||
World unwrapped = WorldWrapper.unwrap(world);
|
||||
boolean placeChunks = this.fastmode || this.limit.FAST_PLACEMENT;
|
||||
|
||||
if (placeChunks) {
|
||||
if (placeChunks && (wnaMode == null || !wnaMode)) {
|
||||
wnaMode = false;
|
||||
if (unwrapped instanceof IQueueExtent) {
|
||||
extent = queue = (IQueueExtent) unwrapped;
|
||||
} else if (Settings.IMP.QUEUE.PARALLEL_THREADS > 1 && !Fawe.isMainThread()) {
|
||||
@ -314,6 +321,7 @@ public class EditSessionBuilder {
|
||||
extent = queue = Fawe.get().getQueueHandler().getQueue(world);
|
||||
}
|
||||
} else {
|
||||
wnaMode = true;
|
||||
extent = world;
|
||||
}
|
||||
Extent root = extent;
|
||||
@ -445,4 +453,8 @@ public class EditSessionBuilder {
|
||||
return blockBag;
|
||||
}
|
||||
|
||||
public boolean isWNAMode() {
|
||||
return wnaMode;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
@ -319,4 +320,9 @@ public class WorldWrapper extends AbstractWorld {
|
||||
public BiomeType getBiome(BlockVector3 position) {
|
||||
return parent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
parent.flush();
|
||||
}
|
||||
}
|
||||
|
@ -222,6 +222,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
private final int maxY;
|
||||
private final List<WatchdogTickingExtent> watchdogExtents = new ArrayList<>(2);
|
||||
|
||||
private final boolean wnaMode;
|
||||
|
||||
|
||||
@Deprecated
|
||||
public EditSession(@NotNull EventBus bus, World world, @Nullable Player player,
|
||||
@ -257,6 +259,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
this.maxY = world.getMaxY();
|
||||
this.blockBag = builder.getBlockBag();
|
||||
this.history = changeSet != null;
|
||||
this.wnaMode = builder.isWNAMode();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1075,6 +1078,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
player.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.level"));
|
||||
}
|
||||
}
|
||||
if (wnaMode) {
|
||||
getWorld().flush();
|
||||
}
|
||||
// Reset limit
|
||||
limit.set(originalLimit);
|
||||
// Enqueue it
|
||||
|
@ -30,6 +30,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.io.Flushable;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
@ -186,4 +188,6 @@ public interface WorldNativeAccess<NC, NBS, NP> {
|
||||
onBlockStateChange(pos, oldState, newState);
|
||||
}
|
||||
|
||||
void flush();
|
||||
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -233,4 +234,7 @@ public class NullWorld extends AbstractWorld {
|
||||
public boolean regenerate(Region region, Extent extent, RegenOptions options) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {}
|
||||
}
|
||||
|
@ -401,4 +401,6 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
|
||||
default boolean setBiome(BlockVector3 position, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void flush();
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren