mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Merge branch '1.16' of https://github.com/IntellectualSites/FastAsyncWorldEdit into fixEntities
This commit is contained in:
@ -563,10 +563,13 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
ChunkSection section = getSections()[layer];
|
||||
// Section is null, return empty array
|
||||
if (section == null) {
|
||||
return FaweCache.IMP.EMPTY_CHAR_4096;
|
||||
data = new char[4096];
|
||||
Arrays.fill(data, (char) 1);
|
||||
return data;
|
||||
}
|
||||
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
|
||||
data = new char[4096];
|
||||
Arrays.fill(data, (char) 1);
|
||||
}
|
||||
DelegateLock lock = BukkitAdapter_1_14.applyLock(section);
|
||||
synchronized (lock) {
|
||||
@ -606,6 +609,10 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
} else {
|
||||
ordinal = adapter.adaptToChar(ibd);
|
||||
}
|
||||
// Don't read "empty".
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
}
|
||||
paletteToBlockChars[paletteVal] = ordinal;
|
||||
}
|
||||
data[i] = ordinal;
|
||||
@ -633,10 +640,18 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
|
||||
val = ordinal(palette.a(i), adapter);
|
||||
paletteToOrdinal[i] = val;
|
||||
}
|
||||
// Don't read "empty".
|
||||
if (val == 0) {
|
||||
val = 1;
|
||||
}
|
||||
data[i] = val;
|
||||
}
|
||||
} else {
|
||||
char ordinal = ordinal(palette.a(0), adapter);
|
||||
// Don't read "empty".
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
}
|
||||
Arrays.fill(data, ordinal);
|
||||
}
|
||||
} finally {
|
||||
|
@ -581,10 +581,13 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
ChunkSection section = getSections()[layer];
|
||||
// Section is null, return empty array
|
||||
if (section == null) {
|
||||
return FaweCache.IMP.EMPTY_CHAR_4096;
|
||||
data = new char[4096];
|
||||
Arrays.fill(data, (char) 1);
|
||||
return data;
|
||||
}
|
||||
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
|
||||
data = new char[4096];
|
||||
Arrays.fill(data, (char) 1);
|
||||
}
|
||||
DelegateLock lock = BukkitAdapter_1_15_2.applyLock(section);
|
||||
synchronized (lock) {
|
||||
@ -626,6 +629,10 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
}
|
||||
paletteToBlockChars[paletteVal] = ordinal;
|
||||
}
|
||||
// Don't read "empty".
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
}
|
||||
data[i] = ordinal;
|
||||
}
|
||||
} finally {
|
||||
@ -651,10 +658,18 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
|
||||
val = ordinal(palette.a(i), adapter);
|
||||
paletteToOrdinal[i] = val;
|
||||
}
|
||||
// Don't read "empty".
|
||||
if (val == 0) {
|
||||
val = 1;
|
||||
}
|
||||
data[i] = val;
|
||||
}
|
||||
} else {
|
||||
char ordinal = ordinal(palette.a(0), adapter);
|
||||
// Don't read "empty".
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
}
|
||||
Arrays.fill(data, ordinal);
|
||||
}
|
||||
} finally {
|
||||
|
@ -552,10 +552,13 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
ChunkSection section = getSections()[layer];
|
||||
// Section is null, return empty array
|
||||
if (section == null) {
|
||||
return FaweCache.IMP.EMPTY_CHAR_4096;
|
||||
data = new char[4096];
|
||||
Arrays.fill(data, (char) 1);
|
||||
return data;
|
||||
}
|
||||
if (data == null || data == FaweCache.IMP.EMPTY_CHAR_4096) {
|
||||
data = new char[4096];
|
||||
Arrays.fill(data, (char) 1);
|
||||
}
|
||||
DelegateLock lock = BukkitAdapter_1_16_1.applyLock(section);
|
||||
synchronized (lock) {
|
||||
@ -597,6 +600,10 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
}
|
||||
paletteToBlockChars[paletteVal] = ordinal;
|
||||
}
|
||||
// Don't read "empty".
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
}
|
||||
data[i] = ordinal;
|
||||
}
|
||||
} finally {
|
||||
@ -622,10 +629,18 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
|
||||
val = ordinal(palette.a(i), adapter);
|
||||
paletteToOrdinal[i] = val;
|
||||
}
|
||||
// Don't read "empty".
|
||||
if (val == 0) {
|
||||
val = 1;
|
||||
}
|
||||
data[i] = val;
|
||||
}
|
||||
} else {
|
||||
char ordinal = ordinal(palette.a(0), adapter);
|
||||
// Don't read "empty".
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
}
|
||||
Arrays.fill(data, ordinal);
|
||||
}
|
||||
} finally {
|
||||
|
@ -2,14 +2,22 @@ package com.boydti.fawe.bukkit.regions.plotsquared;
|
||||
|
||||
import com.boydti.fawe.util.EditSessionBuilder;
|
||||
import com.boydti.fawe.util.TaskManager;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.generator.HybridPlotManager;
|
||||
import com.plotsquared.core.generator.HybridPlotWorld;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||
import com.plotsquared.core.plot.PlotAreaType;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.util.RegionManager;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.biome.BiomeReplace;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
@ -21,7 +29,12 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.bukkit.Bukkit.getWorld;
|
||||
@ -65,6 +78,75 @@ public class FaweRegionManager extends RegionManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean notifyClear(PlotManager manager) {
|
||||
if (!(manager instanceof HybridPlotManager)) {
|
||||
return false;
|
||||
}
|
||||
final HybridPlotWorld hpw = ((HybridPlotManager) manager).getHybridPlotWorld();
|
||||
return hpw.getType() != PlotAreaType.AUGMENTED || hpw.getTerrain() == PlotAreaTerrainType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleClear(final Plot plot, final Runnable whenDone, final PlotManager manager) {
|
||||
if (!(manager instanceof HybridPlotManager)) {
|
||||
return false;
|
||||
}
|
||||
TaskManager.IMP.async(() -> {
|
||||
synchronized (FaweRegionManager.class) {
|
||||
final HybridPlotWorld hybridPlotWorld = ((HybridPlotManager) manager).getHybridPlotWorld();
|
||||
EditSession editSession = new EditSessionBuilder(BukkitAdapter.adapt(getWorld(hybridPlotWorld.getWorldName()))).checkMemory(false).fastmode(true).limitUnlimited().changeSetNull().autoQueue(false).build();
|
||||
|
||||
if (!hybridPlotWorld.PLOT_SCHEMATIC || !Settings.Schematics.PASTE_ON_TOP) {
|
||||
final BlockType bedrock;
|
||||
final BlockType air = BlockTypes.AIR;
|
||||
if (hybridPlotWorld.PLOT_BEDROCK) {
|
||||
bedrock = BlockTypes.BEDROCK;
|
||||
} else {
|
||||
bedrock = air;
|
||||
}
|
||||
|
||||
final Pattern filling = hybridPlotWorld.MAIN_BLOCK.toPattern();
|
||||
final Pattern plotfloor = hybridPlotWorld.TOP_BLOCK.toPattern();
|
||||
|
||||
BlockVector3 pos1 = plot.getBottomAbs().getBlockVector3();
|
||||
BlockVector3 pos2 = plot.getExtendedTopAbs().getBlockVector3();
|
||||
|
||||
Region bedrockRegion = new CuboidRegion(pos1.withY(0), pos2.withY(0));
|
||||
Region fillingRegion = new CuboidRegion(pos1.withY(1), pos2.withY(hybridPlotWorld.PLOT_HEIGHT - 1));
|
||||
Region floorRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT),
|
||||
pos2.withY(hybridPlotWorld.PLOT_HEIGHT));
|
||||
Region airRegion = new CuboidRegion(pos1.withY(hybridPlotWorld.PLOT_HEIGHT + 1),
|
||||
pos2.withY(manager.getWorldHeight()));
|
||||
|
||||
editSession.setBlocks(bedrockRegion, bedrock);
|
||||
editSession.setBlocks(fillingRegion, filling);
|
||||
editSession.setBlocks(floorRegion, plotfloor);
|
||||
editSession.setBlocks(airRegion, air);
|
||||
}
|
||||
|
||||
if (hybridPlotWorld.PLOT_SCHEMATIC) {
|
||||
File schematicFile = new File(hybridPlotWorld.getRoot(), "plot.schem");
|
||||
if (!schematicFile.exists()) {
|
||||
schematicFile = new File(hybridPlotWorld.getRoot(), "plot.schematic");
|
||||
}
|
||||
BlockVector3 to = plot.getBottomAbs().getBlockVector3().withY(Settings.Schematics.PASTE_ON_TOP ? hybridPlotWorld.SCHEM_Y : 1);
|
||||
try {
|
||||
Clipboard clip = ClipboardFormats.findByFile(schematicFile).getReader(new FileInputStream(schematicFile)).read();
|
||||
clip.paste(editSession, to, true, true, true);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
editSession.flushQueue();
|
||||
|
||||
TaskManager.IMP.task(whenDone);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swap(final Location pos1, final Location pos2, final Location pos3, final Location pos4, final Runnable whenDone) {
|
||||
TaskManager.IMP.async(() -> {
|
||||
|
@ -45,7 +45,7 @@ public class PlotSetBiome extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.admin.command.generatebiome"), Captions.NO_PLOT_PERMS);
|
||||
|
@ -5,11 +5,11 @@ import com.boydti.fawe.object.RegionWrapper;
|
||||
import com.boydti.fawe.regions.FaweMask;
|
||||
import com.boydti.fawe.regions.FaweMaskManager;
|
||||
import com.boydti.fawe.regions.general.RegionFilter;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.command.MainCommand;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.database.DBFunc;
|
||||
import com.plotsquared.core.generator.HybridPlotManager;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
@ -18,7 +18,6 @@ import com.plotsquared.core.plot.flag.implementations.NoWorldeditFlag;
|
||||
import com.plotsquared.core.util.RegionManager;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.WEManager;
|
||||
import com.plotsquared.core.util.uuid.UUIDHandler;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
@ -76,9 +75,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
// If it's going to fail, throw an error now rather than later
|
||||
//QueueProvider provider = QueueProvider.of(FaweLocalBlockQueue.class, null);
|
||||
//GlobalBlockQueue.IMP.setProvider(provider);
|
||||
HybridPlotManager.REGENERATIVE_CLEAR = false;
|
||||
//HybridPlotManager.REGENERATIVE_CLEAR = false;
|
||||
//log.debug(" - QueueProvider: " + FaweLocalBlockQueue.class);
|
||||
log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
|
||||
//log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
|
||||
}
|
||||
|
||||
private void setupRegionManager() throws RuntimeException {
|
||||
|
@ -77,9 +77,9 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
// If it's going to fail, throw an error now rather than later
|
||||
//QueueProvider provider = QueueProvider.of(FaweLocalBlockQueue.class, null);
|
||||
//GlobalBlockQueue.IMP.setProvider(provider);
|
||||
HybridPlotManager.REGENERATIVE_CLEAR = false;
|
||||
//HybridPlotManager.REGENERATIVE_CLEAR = false;
|
||||
//log.debug(" - QueueProvider: " + FaweLocalBlockQueue.class);
|
||||
log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
|
||||
//log.debug(" - HybridPlotManager.REGENERATIVE_CLEAR: " + HybridPlotManager.REGENERATIVE_CLEAR);
|
||||
}
|
||||
|
||||
private void setupChunkManager() throws RuntimeException {
|
||||
|
@ -55,6 +55,8 @@ import java.lang.ref.WeakReference;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
@ -78,7 +80,8 @@ public class BukkitWorld extends AbstractWorld {
|
||||
}
|
||||
}
|
||||
|
||||
private final WeakReference<World> worldRef;
|
||||
private WeakReference<World> worldRef;
|
||||
private final String worldNameRef;
|
||||
private final WorldNativeAccess<?, ?, ?> worldNativeAccess;
|
||||
|
||||
/**
|
||||
@ -88,6 +91,7 @@ public class BukkitWorld extends AbstractWorld {
|
||||
*/
|
||||
public BukkitWorld(World world) {
|
||||
this.worldRef = new WeakReference<>(world);
|
||||
this.worldNameRef = world.getName();
|
||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||
if (adapter != null) {
|
||||
this.worldNativeAccess = adapter.createWorldNativeAccess(world);
|
||||
@ -125,7 +129,12 @@ public class BukkitWorld extends AbstractWorld {
|
||||
* @return the world
|
||||
*/
|
||||
public World getWorld() {
|
||||
return checkNotNull(worldRef.get(), "The world was unloaded and the reference is unavailable");
|
||||
World tmp = worldRef.get();
|
||||
if (tmp == null) {
|
||||
tmp = Bukkit.getWorld(worldNameRef);
|
||||
if (tmp != null) worldRef = new WeakReference<>(tmp);
|
||||
}
|
||||
return checkNotNull(tmp, "The world was unloaded and the reference is unavailable");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user