mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-04 06:34:42 +02:00
Compare commits
9 Commits
refactor/v
...
6.9.0
Author | SHA1 | Date | |
---|---|---|---|
d08381dfed | |||
b6c45f2df3 | |||
b9479405e1 | |||
a238ff19bf | |||
c93b08d0c7 | |||
1470b7117a | |||
7cbc67f4fc | |||
0a76bbb2b0 | |||
09cc59a1c1 |
@ -270,7 +270,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
|
|
||||||
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
|
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
|
||||||
|
|
||||||
// FAWE
|
// FastAsyncWorldEdit
|
||||||
if (Settings.FAWE_Components.FAWE_HOOK) {
|
if (Settings.FAWE_Components.FAWE_HOOK) {
|
||||||
Plugin fawe = getServer().getPluginManager().getPlugin("FastAsyncWorldEdit");
|
Plugin fawe = getServer().getPluginManager().getPlugin("FastAsyncWorldEdit");
|
||||||
if (fawe != null) {
|
if (fawe != null) {
|
||||||
@ -278,7 +278,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
Class.forName("com.fastasyncworldedit.bukkit.regions.plotsquared.FaweQueueCoordinator");
|
Class.forName("com.fastasyncworldedit.bukkit.regions.plotsquared.FaweQueueCoordinator");
|
||||||
faweHook = true;
|
faweHook = true;
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
LOGGER.error("Incompatible version of FAWE to enable hook, please upgrade: https://ci.athion" +
|
LOGGER.error("Incompatible version of FastAsyncWorldEdit to enable hook, please upgrade: https://ci.athion" +
|
||||||
".net/job/FastAsyncWorldEdit/");
|
".net/job/FastAsyncWorldEdit/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
|
|
||||||
plotSquared.startExpiryTasks();
|
plotSquared.startExpiryTasks();
|
||||||
|
|
||||||
// Once the server has loaded force updating all generators known to P2
|
// Once the server has loaded force updating all generators known to PlotSquared
|
||||||
TaskManager.runTaskLater(() -> PlotSquared.platform().setupUtils().updateGenerators(true), TaskTime.ticks(1L));
|
TaskManager.runTaskLater(() -> PlotSquared.platform().setupUtils().updateGenerators(true), TaskTime.ticks(1L));
|
||||||
|
|
||||||
// Services are accessed in order
|
// Services are accessed in order
|
||||||
|
@ -25,17 +25,18 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.generator;
|
package com.plotsquared.bukkit.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.bukkit.queue.LimitedRegionWrapperQueue;
|
||||||
|
import com.plotsquared.core.generator.HybridPlotWorld;
|
||||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
import com.plotsquared.core.location.ChunkWrapper;
|
import com.plotsquared.core.location.Location;
|
||||||
|
import com.plotsquared.core.location.UncheckedWorldLocation;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.queue.QueueCoordinator;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
import org.bukkit.generator.LimitedRegion;
|
||||||
|
import org.bukkit.generator.WorldInfo;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -43,35 +44,51 @@ import java.util.Random;
|
|||||||
final class BlockStatePopulator extends BlockPopulator {
|
final class BlockStatePopulator extends BlockPopulator {
|
||||||
|
|
||||||
private final IndependentPlotGenerator plotGenerator;
|
private final IndependentPlotGenerator plotGenerator;
|
||||||
private final PlotAreaManager plotAreaManager;
|
|
||||||
|
|
||||||
private QueueCoordinator queue;
|
/**
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
public BlockStatePopulator(
|
||||||
|
final @NonNull IndependentPlotGenerator plotGenerator
|
||||||
|
) {
|
||||||
|
this.plotGenerator = plotGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link BlockStatePopulator#BlockStatePopulator(IndependentPlotGenerator)} as plotAreManager is unused
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public BlockStatePopulator(
|
public BlockStatePopulator(
|
||||||
final @NonNull IndependentPlotGenerator plotGenerator,
|
final @NonNull IndependentPlotGenerator plotGenerator,
|
||||||
final @NonNull PlotAreaManager plotAreaManager
|
final @NonNull PlotAreaManager plotAreaManager
|
||||||
) {
|
) {
|
||||||
this.plotGenerator = plotGenerator;
|
this.plotGenerator = plotGenerator;
|
||||||
this.plotAreaManager = plotAreaManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(final @NonNull World world, final @NonNull Random random, final @NonNull Chunk source) {
|
public void populate(
|
||||||
if (this.queue == null) {
|
@NonNull final WorldInfo worldInfo,
|
||||||
this.queue = PlotSquared.platform().globalBlockQueue().getNewQueue(new BukkitWorld(world));
|
@NonNull final Random random,
|
||||||
}
|
final int chunkX,
|
||||||
final PlotArea area = this.plotAreaManager.getPlotArea(world.getName(), null);
|
final int chunkZ,
|
||||||
if (area == null) {
|
@NonNull final LimitedRegion limitedRegion
|
||||||
|
) {
|
||||||
|
PlotArea area = UncheckedWorldLocation.at(worldInfo.getName(), chunkX << 4, 0, chunkZ << 4).getPlotArea();
|
||||||
|
if (area == null || (area instanceof HybridPlotWorld hpw && !hpw.populationNeeded()) || area instanceof SinglePlotArea) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ChunkWrapper wrap = new ChunkWrapper(area.getWorldName(), source.getX(), source.getZ());
|
LimitedRegionWrapperQueue wrapped = new LimitedRegionWrapperQueue(limitedRegion);
|
||||||
final ScopedQueueCoordinator chunk = this.queue.getForChunk(wrap.x, wrap.z,
|
// It is possible for the region to be larger than the chunk, but there is no reason for P2 to need to populate
|
||||||
com.plotsquared.bukkit.util.BukkitWorld.getMinWorldHeight(world),
|
// outside of the actual chunk area.
|
||||||
com.plotsquared.bukkit.util.BukkitWorld.getMaxWorldHeight(world) - 1
|
Location min = UncheckedWorldLocation.at(worldInfo.getName(), chunkX << 4, worldInfo.getMinHeight(), chunkZ << 4);
|
||||||
|
Location max = UncheckedWorldLocation.at(
|
||||||
|
worldInfo.getName(),
|
||||||
|
(chunkX << 4) + 15,
|
||||||
|
worldInfo.getMaxHeight(),
|
||||||
|
(chunkZ << 4) + 15
|
||||||
);
|
);
|
||||||
if (this.plotGenerator.populateChunk(chunk, area)) {
|
ScopedQueueCoordinator offsetChunkQueue = new ScopedQueueCoordinator(wrapped, min, max);
|
||||||
this.queue.enqueue();
|
this.plotGenerator.populateChunk(offsetChunkQueue, area);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,7 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class BukkitPlotGenerator extends ChunkGenerator
|
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
||||||
implements GeneratorWrapper<ChunkGenerator> {
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final boolean PAPER_ASYNC_SAFE = true;
|
public final boolean PAPER_ASYNC_SAFE = true;
|
||||||
@ -73,7 +72,12 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
this.plotGenerator = generator;
|
this.plotGenerator = generator;
|
||||||
this.platformGenerator = this;
|
this.platformGenerator = this;
|
||||||
this.populators = new ArrayList<>();
|
this.populators = new ArrayList<>();
|
||||||
this.populators.add(new BlockStatePopulator(this.plotGenerator, this.plotAreaManager));
|
int minecraftMinorVersion = PlotSquared.platform().serverVersion()[1];
|
||||||
|
if (minecraftMinorVersion >= 17) {
|
||||||
|
this.populators.add(new BlockStatePopulator(this.plotGenerator));
|
||||||
|
} else {
|
||||||
|
this.populators.add(new LegacyBlockStatePopulator(this.plotGenerator));
|
||||||
|
}
|
||||||
this.full = true;
|
this.full = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +173,6 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
@NonNull World world, @NonNull Random random, int x, int z,
|
@NonNull World world, @NonNull Random random, int x, int z,
|
||||||
@NonNull BiomeGrid biome
|
@NonNull BiomeGrid biome
|
||||||
) {
|
) {
|
||||||
|
|
||||||
int minY = BukkitWorld.getMinWorldHeight(world);
|
int minY = BukkitWorld.getMinWorldHeight(world);
|
||||||
int maxY = BukkitWorld.getMaxWorldHeight(world);
|
int maxY = BukkitWorld.getMaxWorldHeight(world);
|
||||||
GenChunk result = new GenChunk(minY, maxY);
|
GenChunk result = new GenChunk(minY, maxY);
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2014 - 2022 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.bukkit.generator;
|
||||||
|
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
|
import com.plotsquared.core.generator.HybridPlotWorld;
|
||||||
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
|
import com.plotsquared.core.location.Location;
|
||||||
|
import com.plotsquared.core.location.UncheckedWorldLocation;
|
||||||
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.util.SideEffectSet;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
final class LegacyBlockStatePopulator extends BlockPopulator {
|
||||||
|
|
||||||
|
private final IndependentPlotGenerator plotGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
public LegacyBlockStatePopulator(
|
||||||
|
final @NonNull IndependentPlotGenerator plotGenerator
|
||||||
|
) {
|
||||||
|
this.plotGenerator = plotGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(@NotNull final World world, @NotNull final Random random, @NotNull final Chunk source) {
|
||||||
|
int chunkMinX = source.getX() << 4;
|
||||||
|
int chunkMinZ = source.getZ() << 4;
|
||||||
|
PlotArea area = Location.at(world.getName(), chunkMinX, 0, chunkMinZ).getPlotArea();
|
||||||
|
if (area == null || (area instanceof HybridPlotWorld hpw && !hpw.populationNeeded()) || area instanceof SinglePlotArea) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QueueCoordinator queue = PlotSquared.platform().globalBlockQueue().getNewQueue(new BukkitWorld(world));
|
||||||
|
queue.setForceSync(true);
|
||||||
|
queue.setSideEffectSet(SideEffectSet.none());
|
||||||
|
queue.setBiomesEnabled(false);
|
||||||
|
queue.setChunkObject(source);
|
||||||
|
Location min = UncheckedWorldLocation.at(world.getName(), chunkMinX, world.getMinHeight(), chunkMinZ);
|
||||||
|
Location max = UncheckedWorldLocation.at(world.getName(), chunkMinX + 15, world.getMaxHeight(), chunkMinZ + 15);
|
||||||
|
ScopedQueueCoordinator offsetChunkQueue = new ScopedQueueCoordinator(queue, min, max);
|
||||||
|
this.plotGenerator.populateChunk(offsetChunkQueue, area);
|
||||||
|
queue.enqueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -965,7 +965,12 @@ public class BlockEventListener implements Listener {
|
|||||||
public void onBlockDispense(BlockDispenseEvent event) {
|
public void onBlockDispense(BlockDispenseEvent event) {
|
||||||
Material type = event.getItem().getType();
|
Material type = event.getItem().getType();
|
||||||
switch (type.toString()) {
|
switch (type.toString()) {
|
||||||
case "SHULKER_BOX", "WHITE_SHULKER_BOX", "ORANGE_SHULKER_BOX", "MAGENTA_SHULKER_BOX", "LIGHT_BLUE_SHULKER_BOX", "YELLOW_SHULKER_BOX", "LIME_SHULKER_BOX", "PINK_SHULKER_BOX", "GRAY_SHULKER_BOX", "LIGHT_GRAY_SHULKER_BOX", "CYAN_SHULKER_BOX", "PURPLE_SHULKER_BOX", "BLUE_SHULKER_BOX", "BROWN_SHULKER_BOX", "GREEN_SHULKER_BOX", "RED_SHULKER_BOX", "BLACK_SHULKER_BOX", "CARVED_PUMPKIN", "WITHER_SKELETON_SKULL", "FLINT_AND_STEEL", "BONE_MEAL", "SHEARS", "GLASS_BOTTLE", "GLOWSTONE", "COD_BUCKET", "PUFFERFISH_BUCKET", "SALMON_BUCKET", "TROPICAL_FISH_BUCKET", "AXOLOTL_BUCKET", "BUCKET", "WATER_BUCKET", "LAVA_BUCKET" -> {
|
case "SHULKER_BOX", "WHITE_SHULKER_BOX", "ORANGE_SHULKER_BOX", "MAGENTA_SHULKER_BOX", "LIGHT_BLUE_SHULKER_BOX",
|
||||||
|
"YELLOW_SHULKER_BOX", "LIME_SHULKER_BOX", "PINK_SHULKER_BOX", "GRAY_SHULKER_BOX", "LIGHT_GRAY_SHULKER_BOX",
|
||||||
|
"CYAN_SHULKER_BOX", "PURPLE_SHULKER_BOX", "BLUE_SHULKER_BOX", "BROWN_SHULKER_BOX", "GREEN_SHULKER_BOX",
|
||||||
|
"RED_SHULKER_BOX", "BLACK_SHULKER_BOX", "CARVED_PUMPKIN", "WITHER_SKELETON_SKULL", "FLINT_AND_STEEL",
|
||||||
|
"BONE_MEAL", "SHEARS", "GLASS_BOTTLE", "GLOWSTONE", "COD_BUCKET", "PUFFERFISH_BUCKET", "SALMON_BUCKET",
|
||||||
|
"TROPICAL_FISH_BUCKET", "AXOLOTL_BUCKET", "BUCKET", "WATER_BUCKET", "LAVA_BUCKET", "TADPOLE_BUCKET" -> {
|
||||||
if (event.getBlock().getType() == Material.DROPPER) {
|
if (event.getBlock().getType() == Material.DROPPER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -92,9 +92,9 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator {
|
|||||||
@Assisted final @NonNull Collection<BlockVector2> requestedChunks,
|
@Assisted final @NonNull Collection<BlockVector2> requestedChunks,
|
||||||
@Assisted final @NonNull Runnable whenDone,
|
@Assisted final @NonNull Runnable whenDone,
|
||||||
@Assisted final @NonNull Consumer<Throwable> throwableConsumer,
|
@Assisted final @NonNull Consumer<Throwable> throwableConsumer,
|
||||||
@Assisted final boolean unloadAfter,
|
@Assisted("unloadAfter") final boolean unloadAfter,
|
||||||
@Assisted final @NonNull Collection<ProgressSubscriber> progressSubscribers,
|
@Assisted final @NonNull Collection<ProgressSubscriber> progressSubscribers,
|
||||||
@Assisted final boolean forceSync
|
@Assisted("forceSync") final boolean forceSync
|
||||||
) {
|
) {
|
||||||
this.requestedChunks = new LinkedBlockingQueue<>(requestedChunks);
|
this.requestedChunks = new LinkedBlockingQueue<>(requestedChunks);
|
||||||
this.availableChunks = new LinkedBlockingQueue<>();
|
this.availableChunks = new LinkedBlockingQueue<>();
|
||||||
|
@ -235,6 +235,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
|||||||
.withConsumer(consumer)
|
.withConsumer(consumer)
|
||||||
.unloadAfter(isUnloadAfter())
|
.unloadAfter(isUnloadAfter())
|
||||||
.withProgressSubscribers(getProgressSubscribers())
|
.withProgressSubscribers(getProgressSubscribers())
|
||||||
|
.forceSync(isForceSync())
|
||||||
.build();
|
.build();
|
||||||
return super.enqueue();
|
return super.enqueue();
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class GenChunk extends ScopedQueueCoordinator {
|
|||||||
/**
|
/**
|
||||||
* Set the world and XZ of the chunk being represented via {@link ChunkWrapper}
|
* Set the world and XZ of the chunk being represented via {@link ChunkWrapper}
|
||||||
*
|
*
|
||||||
* @param wrap P2 ChunkWrapper
|
* @param wrap PlotSquared ChunkWrapper
|
||||||
*/
|
*/
|
||||||
public void setChunk(@NonNull ChunkWrapper wrap) {
|
public void setChunk(@NonNull ChunkWrapper wrap) {
|
||||||
chunk = null;
|
chunk = null;
|
||||||
|
@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2014 - 2022 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.bukkit.queue;
|
||||||
|
|
||||||
|
import com.plotsquared.bukkit.schematic.StateWrapper;
|
||||||
|
import com.plotsquared.core.queue.DelegateQueueCoordinator;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.generator.LimitedRegion;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a {@link LimitedRegion} inside a {@link com.plotsquared.core.queue.QueueCoordinator} so it can be written to.
|
||||||
|
*
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
public class LimitedRegionWrapperQueue extends DelegateQueueCoordinator {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + LimitedRegionWrapperQueue.class.getSimpleName());
|
||||||
|
|
||||||
|
private final LimitedRegion limitedRegion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
public LimitedRegionWrapperQueue(LimitedRegion limitedRegion) {
|
||||||
|
super(null);
|
||||||
|
this.limitedRegion = limitedRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(final int x, final int y, final int z, @NonNull final Pattern pattern) {
|
||||||
|
return setBlock(x, y, z, pattern.applyBlock(BlockVector3.at(x, y, z)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(final int x, final int y, final int z, @NonNull final BaseBlock id) {
|
||||||
|
boolean result = setBlock(x, y, z, id.toImmutableState());
|
||||||
|
if (result && id.hasNbtData()) {
|
||||||
|
CompoundTag tag = id.getNbtData();
|
||||||
|
StateWrapper sw = new StateWrapper(tag);
|
||||||
|
try {
|
||||||
|
sw.restoreTag(limitedRegion.getBlockState(x, y, z).getBlock());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
LOGGER.error("Error attempting to populate tile entity into the world at location {},{},{}", x, y, z, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(final int x, final int y, final int z, @NonNull final BlockState id) {
|
||||||
|
try {
|
||||||
|
limitedRegion.setType(x, y, z, BukkitAdapter.adapt(id.getBlockType()));
|
||||||
|
limitedRegion.setBlockData(x, y, z, BukkitAdapter.adapt(id));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
LOGGER.error("Error attempting to populate block into the world at location {},{},{}", x, y, z, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setEntity(@NonNull final Entity entity) {
|
||||||
|
EntityType type = BukkitAdapter.adapt(entity.getState().getType());
|
||||||
|
double x = entity.getLocation().getX();
|
||||||
|
double y = entity.getLocation().getY();
|
||||||
|
double z = entity.getLocation().getZ();
|
||||||
|
Location location = new Location(limitedRegion.getWorld(), x, y, z);
|
||||||
|
try {
|
||||||
|
limitedRegion.spawnEntity(location, type);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
LOGGER.error("Error attempting to populate entity into the world at location {},{},{}", (int) x, (int) y, (int) z, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setTile(final int x, final int y, final int z, @NonNull final CompoundTag tag) {
|
||||||
|
StateWrapper sw = new StateWrapper(tag);
|
||||||
|
try {
|
||||||
|
return sw.restoreTag(limitedRegion.getBlockState(x, y, z).getBlock());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
LOGGER.error("Error attempting to populate tile entity into the world at location {},{},{}", x, y, z, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSettingTiles() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -35,11 +35,13 @@ import com.sk89q.jnbt.Tag;
|
|||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Container;
|
import org.bukkit.block.Container;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.block.Skull;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
@ -57,6 +59,11 @@ public class StateWrapper {
|
|||||||
public org.bukkit.block.BlockState state = null;
|
public org.bukkit.block.BlockState state = null;
|
||||||
public CompoundTag tag = null;
|
public CompoundTag tag = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated in favour of using WE methods for obtaining NBT, specifically by obtaining a
|
||||||
|
* {@link com.sk89q.worldedit.world.block.BaseBlock} and then using {@link com.sk89q.worldedit.world.block.BaseBlock#getNbtData()}
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public StateWrapper(org.bukkit.block.BlockState state) {
|
public StateWrapper(org.bukkit.block.BlockState state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
@ -230,10 +237,37 @@ public class StateWrapper {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case "skull" -> {
|
||||||
|
if (state instanceof Skull skull) {
|
||||||
|
CompoundTag skullOwner = ((CompoundTag) this.tag.getValue().get("SkullOwner"));
|
||||||
|
if (skullOwner == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
String player = skullOwner.getString("Name");
|
||||||
|
if (player == null || player.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
skull.setOwningPlayer(Bukkit.getOfflinePlayer(player));
|
||||||
|
skull.update(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a CompoundTag of the contents of a block's inventory (chest, furnace, etc.).
|
||||||
|
*
|
||||||
|
* @deprecated in favour of using WorldEdit methods for obtaining NBT, specifically by obtaining a
|
||||||
|
* {@link com.sk89q.worldedit.world.block.BaseBlock} and then using {@link com.sk89q.worldedit.world.block.BaseBlock#getNbtData()}
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public CompoundTag getTag() {
|
public CompoundTag getTag() {
|
||||||
if (this.tag != null) {
|
if (this.tag != null) {
|
||||||
return this.tag;
|
return this.tag;
|
||||||
|
@ -359,9 +359,9 @@ public interface PlotPlatform<P> extends LocaleHolder {
|
|||||||
@NonNull String toLegacyPlatformString(@NonNull Component component);
|
@NonNull String toLegacyPlatformString(@NonNull Component component);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the FAWE-P2 hook is active/enabled
|
* Returns if the FastAsyncWorldEdit-PlotSquared hook is active/enabled
|
||||||
*
|
*
|
||||||
* @return status of FAWE-P2 hook
|
* @return status of FastAsyncWorldEdit-PlotSquared hook
|
||||||
*/
|
*/
|
||||||
default boolean isFaweHooking() {
|
default boolean isFaweHooking() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1581,7 +1581,7 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get if the {@link PlatformReadyEvent} has been sent by WE. There is no way to query this within WE itself.
|
* Get if the {@link PlatformReadyEvent} has been sent by WorldEdit. There is no way to query this within WorldEdit itself.
|
||||||
*/
|
*/
|
||||||
public boolean isWeInitialised() {
|
public boolean isWeInitialised() {
|
||||||
return weInitialised;
|
return weInitialised;
|
||||||
|
@ -62,7 +62,7 @@ public class Music extends SubCommand {
|
|||||||
.asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp",
|
.asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp",
|
||||||
"music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal",
|
"music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal",
|
||||||
"music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait", "music_disc_otherside",
|
"music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait", "music_disc_otherside",
|
||||||
"music_disc_pigstep"
|
"music_disc_pigstep", "music_disc_5"
|
||||||
);
|
);
|
||||||
|
|
||||||
private final InventoryUtil inventoryUtil;
|
private final InventoryUtil inventoryUtil;
|
||||||
|
@ -44,7 +44,7 @@ public class Settings extends Config {
|
|||||||
|
|
||||||
@Comment("This value is not configurable. It shows the platform you are using.") // This is a comment
|
@Comment("This value is not configurable. It shows the platform you are using.") // This is a comment
|
||||||
@Final
|
@Final
|
||||||
public static String PLATFORM; // These values are set from P2 before loading
|
public static String PLATFORM; // These values are set from PlotSquared before loading
|
||||||
|
|
||||||
@Comment({"Show additional information in console. It helps us at IntellectualSites to find out more about an issue.",
|
@Comment({"Show additional information in console. It helps us at IntellectualSites to find out more about an issue.",
|
||||||
"Leave it off if you don't need it, it can spam your console."})
|
"Leave it off if you don't need it, it can spam your console."})
|
||||||
@ -634,10 +634,10 @@ public class Settings extends Config {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Comment("Enable or disable all of or parts of the FAWE-P2 hook")
|
@Comment("Enable or disable all of or parts of the FastAsyncWorldEdit-PlotSquared hook")
|
||||||
public static final class FAWE_Components {
|
public static final class FAWE_Components {
|
||||||
|
|
||||||
@Comment("Use FAWE for queue handling.")
|
@Comment("Use FastAsyncWorldEdit for queue handling.")
|
||||||
public static boolean FAWE_HOOK = true;
|
public static boolean FAWE_HOOK = true;
|
||||||
public static boolean CUBOIDS = true;
|
public static boolean CUBOIDS = true;
|
||||||
public static boolean CLEAR = true;
|
public static boolean CLEAR = true;
|
||||||
|
@ -35,13 +35,23 @@ import com.plotsquared.core.plot.PlotArea;
|
|||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||||
|
import com.sk89q.worldedit.world.NullWorld;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class HybridGen extends IndependentPlotGenerator {
|
public class HybridGen extends IndependentPlotGenerator {
|
||||||
|
|
||||||
|
private static final CuboidRegion CHUNK = new CuboidRegion(BlockVector3.ZERO, BlockVector3.at(15, 396, 15));
|
||||||
private final HybridPlotWorldFactory hybridPlotWorldFactory;
|
private final HybridPlotWorldFactory hybridPlotWorldFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -55,12 +65,17 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void placeSchem(
|
private void placeSchem(
|
||||||
HybridPlotWorld world, ScopedQueueCoordinator result, short relativeX,
|
HybridPlotWorld world,
|
||||||
short relativeZ, int x, int z, boolean isRoad
|
ScopedQueueCoordinator result,
|
||||||
|
short relativeX,
|
||||||
|
short relativeZ,
|
||||||
|
int x,
|
||||||
|
int z,
|
||||||
|
boolean isRoad,
|
||||||
|
boolean isPopulating
|
||||||
) {
|
) {
|
||||||
int minY; // Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT);
|
int minY; // Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT);
|
||||||
if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad
|
if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad && Settings.Schematics.PASTE_ON_TOP)) {
|
||||||
&& Settings.Schematics.PASTE_ON_TOP)) {
|
|
||||||
minY = world.SCHEM_Y;
|
minY = world.SCHEM_Y;
|
||||||
} else {
|
} else {
|
||||||
minY = world.getMinBuildHeight();
|
minY = world.getMinBuildHeight();
|
||||||
@ -69,10 +84,12 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (int y = 0; y < blocks.length; y++) {
|
for (int y = 0; y < blocks.length; y++) {
|
||||||
if (blocks[y] != null) {
|
if (blocks[y] != null) {
|
||||||
|
if (!isPopulating || blocks[y].hasNbtData()) {
|
||||||
result.setBlock(x, minY + y, z, blocks[y]);
|
result.setBlock(x, minY + y, z, blocks[y]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
BiomeType biome = world.G_SCH_B.get(MathMan.pair(relativeX, relativeZ));
|
BiomeType biome = world.G_SCH_B.get(MathMan.pair(relativeX, relativeZ));
|
||||||
if (biome != null) {
|
if (biome != null) {
|
||||||
result.setBiome(x, z, biome);
|
result.setBiome(x, z, biome);
|
||||||
@ -121,42 +138,38 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
short[] relativeX = new short[16];
|
short[] relativeX = new short[16];
|
||||||
boolean[] insideRoadX = new boolean[16];
|
boolean[] insideRoadX = new boolean[16];
|
||||||
boolean[] insideWallX = new boolean[16];
|
boolean[] insideWallX = new boolean[16];
|
||||||
|
short offsetX = relativeOffsetX;
|
||||||
for (short i = 0; i < 16; i++) {
|
for (short i = 0; i < 16; i++) {
|
||||||
short v = (short) (relativeOffsetX + i);
|
if (offsetX >= hybridPlotWorld.SIZE) {
|
||||||
while (v >= hybridPlotWorld.SIZE) {
|
offsetX -= hybridPlotWorld.SIZE;
|
||||||
v -= hybridPlotWorld.SIZE;
|
|
||||||
}
|
}
|
||||||
relativeX[i] = v;
|
relativeX[i] = offsetX;
|
||||||
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
||||||
insideRoadX[i] =
|
insideRoadX[i] = offsetX < hybridPlotWorld.PATH_WIDTH_LOWER || offsetX > hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER;
|
insideWallX[i] = offsetX == hybridPlotWorld.PATH_WIDTH_LOWER || offsetX == hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
insideWallX[i] =
|
|
||||||
v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER;
|
|
||||||
}
|
}
|
||||||
|
offsetX++;
|
||||||
}
|
}
|
||||||
// The Z-coordinate of a given Z coordinate, relative to the
|
// The Z-coordinate of a given Z coordinate, relative to the
|
||||||
// plot (Counting from the corner with the least positive
|
// plot (Counting from the corner with the least positive
|
||||||
// coordinates)
|
// coordinates)
|
||||||
short[] relativeZ = new short[16];
|
short[] relativeZ = new short[16];
|
||||||
// Whether or not the given Z coordinate belongs to the road
|
|
||||||
boolean[] insideRoadZ = new boolean[16];
|
boolean[] insideRoadZ = new boolean[16];
|
||||||
// Whether or not the given Z coordinate belongs to the wall
|
|
||||||
boolean[] insideWallZ = new boolean[16];
|
boolean[] insideWallZ = new boolean[16];
|
||||||
|
short offsetZ = relativeOffsetZ;
|
||||||
for (short i = 0; i < 16; i++) {
|
for (short i = 0; i < 16; i++) {
|
||||||
short v = (short) (relativeOffsetZ + i);
|
if (offsetZ >= hybridPlotWorld.SIZE) {
|
||||||
while (v >= hybridPlotWorld.SIZE) {
|
offsetZ -= hybridPlotWorld.SIZE;
|
||||||
v -= hybridPlotWorld.SIZE;
|
|
||||||
}
|
}
|
||||||
relativeZ[i] = v;
|
relativeZ[i] = offsetZ;
|
||||||
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
||||||
insideRoadZ[i] =
|
insideRoadZ[i] = offsetZ < hybridPlotWorld.PATH_WIDTH_LOWER || offsetZ > hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
v < hybridPlotWorld.PATH_WIDTH_LOWER || v > hybridPlotWorld.PATH_WIDTH_UPPER;
|
insideWallZ[i] = offsetZ == hybridPlotWorld.PATH_WIDTH_LOWER || offsetZ == hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
insideWallZ[i] =
|
|
||||||
v == hybridPlotWorld.PATH_WIDTH_LOWER || v == hybridPlotWorld.PATH_WIDTH_UPPER;
|
|
||||||
}
|
}
|
||||||
|
offsetZ++;
|
||||||
}
|
}
|
||||||
// generation
|
// generation
|
||||||
int startY = hybridPlotWorld.getMinGenHeight() + (hybridPlotWorld.PLOT_BEDROCK ? 1: 0);
|
int startY = hybridPlotWorld.getMinGenHeight() + (hybridPlotWorld.PLOT_BEDROCK ? 1 : 0);
|
||||||
for (short x = 0; x < 16; x++) {
|
for (short x = 0; x < 16; x++) {
|
||||||
if (insideRoadX[x]) {
|
if (insideRoadX[x]) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
@ -165,7 +178,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (insideWallX[x]) {
|
} else if (insideWallX[x]) {
|
||||||
@ -176,9 +189,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true, false);
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// wall
|
// wall
|
||||||
@ -187,14 +198,10 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
if (hybridPlotWorld.PLACE_TOP_BLOCK) {
|
if (hybridPlotWorld.PLACE_TOP_BLOCK) {
|
||||||
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z,
|
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, hybridPlotWorld.WALL_BLOCK.toPattern());
|
||||||
hybridPlotWorld.WALL_BLOCK.toPattern()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true, false);
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,9 +213,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.ROAD_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true, false);
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else if (insideWallZ[z]) {
|
} else if (insideWallZ[z]) {
|
||||||
// wall
|
// wall
|
||||||
@ -217,27 +222,19 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
if (hybridPlotWorld.PLACE_TOP_BLOCK) {
|
if (hybridPlotWorld.PLACE_TOP_BLOCK) {
|
||||||
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z,
|
result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, hybridPlotWorld.WALL_BLOCK.toPattern());
|
||||||
hybridPlotWorld.WALL_BLOCK.toPattern()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true, false);
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// plot
|
// plot
|
||||||
for (int y = startY; y < hybridPlotWorld.PLOT_HEIGHT; y++) {
|
for (int y = startY; y < hybridPlotWorld.PLOT_HEIGHT; y++) {
|
||||||
result.setBlock(x, y, z, hybridPlotWorld.MAIN_BLOCK.toPattern());
|
result.setBlock(x, y, z, hybridPlotWorld.MAIN_BLOCK.toPattern());
|
||||||
}
|
}
|
||||||
result.setBlock(x, hybridPlotWorld.PLOT_HEIGHT, z,
|
result.setBlock(x, hybridPlotWorld.PLOT_HEIGHT, z, hybridPlotWorld.TOP_BLOCK.toPattern());
|
||||||
hybridPlotWorld.TOP_BLOCK.toPattern()
|
|
||||||
);
|
|
||||||
if (hybridPlotWorld.PLOT_SCHEMATIC) {
|
if (hybridPlotWorld.PLOT_SCHEMATIC) {
|
||||||
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z,
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, false, false);
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,6 +242,138 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean populateChunk(final ScopedQueueCoordinator result, final PlotArea settings) {
|
||||||
|
HybridPlotWorld hybridPlotWorld = (HybridPlotWorld) settings;
|
||||||
|
if (!hybridPlotWorld.populationNeeded()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Coords
|
||||||
|
Location min = result.getMin();
|
||||||
|
int bx = min.getX() - hybridPlotWorld.ROAD_OFFSET_X;
|
||||||
|
int bz = min.getZ() - hybridPlotWorld.ROAD_OFFSET_Z;
|
||||||
|
// The relative X-coordinate (within the plot) of the minimum X coordinate
|
||||||
|
// contained in the scoped queue
|
||||||
|
short relativeOffsetX;
|
||||||
|
if (bx < 0) {
|
||||||
|
relativeOffsetX = (short) (hybridPlotWorld.SIZE + (bx % hybridPlotWorld.SIZE));
|
||||||
|
} else {
|
||||||
|
relativeOffsetX = (short) (bx % hybridPlotWorld.SIZE);
|
||||||
|
}
|
||||||
|
// The relative Z-coordinate (within the plot) of the minimum Z coordinate
|
||||||
|
// contained in the scoped queue
|
||||||
|
short relativeOffsetZ;
|
||||||
|
if (bz < 0) {
|
||||||
|
relativeOffsetZ = (short) (hybridPlotWorld.SIZE + (bz % hybridPlotWorld.SIZE));
|
||||||
|
} else {
|
||||||
|
relativeOffsetZ = (short) (bz % hybridPlotWorld.SIZE);
|
||||||
|
}
|
||||||
|
boolean allRoad = true;
|
||||||
|
boolean overlap = false;
|
||||||
|
|
||||||
|
// The X-coordinate of a given X coordinate, relative to the
|
||||||
|
// plot (Counting from the corner with the least positive
|
||||||
|
// coordinates)
|
||||||
|
short[] relativeX = new short[16];
|
||||||
|
boolean[] insideRoadX = new boolean[16];
|
||||||
|
boolean[] insideWallX = new boolean[16];
|
||||||
|
short offsetX = relativeOffsetX;
|
||||||
|
for (short i = 0; i < 16; i++) {
|
||||||
|
if (offsetX >= hybridPlotWorld.SIZE) {
|
||||||
|
offsetX -= hybridPlotWorld.SIZE;
|
||||||
|
overlap = true;
|
||||||
|
}
|
||||||
|
relativeX[i] = offsetX;
|
||||||
|
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
||||||
|
boolean insideRoad = offsetX < hybridPlotWorld.PATH_WIDTH_LOWER || offsetX > hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
|
boolean insideWall = offsetX == hybridPlotWorld.PATH_WIDTH_LOWER || offsetX == hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
|
insideRoadX[i] = insideRoad;
|
||||||
|
insideWallX[i] = insideWall;
|
||||||
|
allRoad &= insideRoad && insideWall;
|
||||||
|
}
|
||||||
|
offsetX++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The Z-coordinate of a given Z coordinate, relative to the
|
||||||
|
// plot (Counting from the corner with the least positive
|
||||||
|
// coordinates)
|
||||||
|
short[] relativeZ = new short[16];
|
||||||
|
boolean[] insideRoadZ = new boolean[16];
|
||||||
|
boolean[] insideWallZ = new boolean[16];
|
||||||
|
short offsetZ = relativeOffsetZ;
|
||||||
|
for (short i = 0; i < 16; i++) {
|
||||||
|
if (offsetZ >= hybridPlotWorld.SIZE) {
|
||||||
|
offsetZ -= hybridPlotWorld.SIZE;
|
||||||
|
overlap = true;
|
||||||
|
}
|
||||||
|
relativeZ[i] = offsetZ;
|
||||||
|
if (hybridPlotWorld.ROAD_WIDTH != 0) {
|
||||||
|
boolean insideRoad = offsetZ < hybridPlotWorld.PATH_WIDTH_LOWER || offsetZ > hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
|
boolean insideWall = offsetZ == hybridPlotWorld.PATH_WIDTH_LOWER || offsetZ == hybridPlotWorld.PATH_WIDTH_UPPER;
|
||||||
|
insideRoadZ[i] = insideRoad;
|
||||||
|
insideWallZ[i] = insideWall;
|
||||||
|
allRoad &= insideRoad && insideWall;
|
||||||
|
}
|
||||||
|
offsetZ++;
|
||||||
|
}
|
||||||
|
for (short x = 0; x < 16; x++) {
|
||||||
|
if (insideRoadX[x] || insideWallX[x]) {
|
||||||
|
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
for (short z = 0; z < 16; z++) {
|
||||||
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (short z = 0; z < 16; z++) {
|
||||||
|
if (insideRoadZ[z] || insideWallZ[z]) {
|
||||||
|
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true, true);
|
||||||
|
}
|
||||||
|
} else if (hybridPlotWorld.PLOT_SCHEMATIC) {
|
||||||
|
placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!allRoad && hybridPlotWorld.getPlotSchematicEntities() != null && !hybridPlotWorld
|
||||||
|
.getPlotSchematicEntities()
|
||||||
|
.isEmpty()) {
|
||||||
|
CuboidRegion region = CHUNK.clone();
|
||||||
|
try {
|
||||||
|
region.shift(hybridPlotWorld
|
||||||
|
.getPlotSchematicMinPoint()
|
||||||
|
.add(relativeOffsetX, 0, relativeOffsetZ)
|
||||||
|
.subtract(hybridPlotWorld.PATH_WIDTH_LOWER + 1, 0, hybridPlotWorld.PATH_WIDTH_LOWER + 1));
|
||||||
|
for (Entity entity : hybridPlotWorld.getPlotSchematicEntities()) {
|
||||||
|
if (region.contains(entity.getLocation().toVector().toBlockPoint())) {
|
||||||
|
Vector3 pos = (entity.getLocation().toVector()
|
||||||
|
.subtract(region.getMinimumPoint().withY(hybridPlotWorld.getPlotSchematicMinPoint().getY()).toVector3()))
|
||||||
|
.add(min.getBlockVector3().withY(hybridPlotWorld.SCHEM_Y).toVector3());
|
||||||
|
result.setEntity(new PopulatingEntity(
|
||||||
|
entity,
|
||||||
|
new com.sk89q.worldedit.util.Location(NullWorld.getInstance(), pos)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (RegionOperationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
if (overlap) {
|
||||||
|
try {
|
||||||
|
region.shift(BlockVector3.at(-hybridPlotWorld.SIZE, 0, -hybridPlotWorld.SIZE));
|
||||||
|
for (Entity entity : hybridPlotWorld.getPlotSchematicEntities()) {
|
||||||
|
if (region.contains(entity.getLocation().toVector().toBlockPoint())) {
|
||||||
|
result.setEntity(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (RegionOperationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||||
return this.hybridPlotWorldFactory.create(world, id, this, min, max);
|
return this.hybridPlotWorldFactory.create(world, id, this, min, max);
|
||||||
@ -255,4 +384,58 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
// All initialization is done in the PlotArea class
|
// All initialization is done in the PlotArea class
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper to allow a WorldEdit {@link Entity} to effectively have a mutable location as the location in its NBT should be changed
|
||||||
|
* when set to the world.
|
||||||
|
*
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
private static final class PopulatingEntity implements Entity {
|
||||||
|
|
||||||
|
private final Entity parent;
|
||||||
|
private com.sk89q.worldedit.util.Location location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
private PopulatingEntity(Entity parent, com.sk89q.worldedit.util.Location location) {
|
||||||
|
this.parent = parent;
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BaseEntity getState() {
|
||||||
|
return parent.getState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove() {
|
||||||
|
return parent.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public com.sk89q.worldedit.util.Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setLocation(final com.sk89q.worldedit.util.Location location) {
|
||||||
|
this.location = location;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Extent getExtent() {
|
||||||
|
return parent.getExtent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public <T> T getFacet(final Class<? extends T> cls) {
|
||||||
|
return parent.getFacet(cls);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,13 @@ import com.plotsquared.core.plot.PlotId;
|
|||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.plot.schematic.Schematic;
|
import com.plotsquared.core.plot.schematic.Schematic;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
|
import com.plotsquared.core.util.AnnotationHelper;
|
||||||
import com.plotsquared.core.util.FileUtils;
|
import com.plotsquared.core.util.FileUtils;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.CompoundTagBuilder;
|
import com.sk89q.jnbt.CompoundTagBuilder;
|
||||||
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||||
@ -58,11 +60,13 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class HybridPlotWorld extends ClassicPlotWorld {
|
public class HybridPlotWorld extends ClassicPlotWorld {
|
||||||
@ -71,6 +75,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
private static final AffineTransform transform = new AffineTransform().rotateY(90);
|
private static final AffineTransform transform = new AffineTransform().rotateY(90);
|
||||||
public boolean ROAD_SCHEMATIC_ENABLED;
|
public boolean ROAD_SCHEMATIC_ENABLED;
|
||||||
public boolean PLOT_SCHEMATIC = false;
|
public boolean PLOT_SCHEMATIC = false;
|
||||||
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public int PLOT_SCHEMATIC_HEIGHT = -1;
|
public int PLOT_SCHEMATIC_HEIGHT = -1;
|
||||||
public short PATH_WIDTH_LOWER;
|
public short PATH_WIDTH_LOWER;
|
||||||
public short PATH_WIDTH_UPPER;
|
public short PATH_WIDTH_UPPER;
|
||||||
@ -80,6 +85,11 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
private Location SIGN_LOCATION;
|
private Location SIGN_LOCATION;
|
||||||
private File root = null;
|
private File root = null;
|
||||||
private int lastOverlayHeightError = Integer.MIN_VALUE;
|
private int lastOverlayHeightError = Integer.MIN_VALUE;
|
||||||
|
private List<Entity> schem3Entities = null;
|
||||||
|
private BlockVector3 schem3MinPoint = null;
|
||||||
|
private boolean schem1PopulationNeeded = false;
|
||||||
|
private boolean schem2PopulationNeeded = false;
|
||||||
|
private boolean schem3PopulationNeeded = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SchematicHandler schematicHandler;
|
private SchematicHandler schematicHandler;
|
||||||
@ -98,6 +108,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
PlotSquared.platform().injector().injectMembers(this);
|
PlotSquared.platform().injector().injectMembers(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public static byte wrap(byte data, int start) {
|
public static byte wrap(byte data, int start) {
|
||||||
if ((data >= start) && (data < (start + 4))) {
|
if ((data >= start) && (data < (start + 4))) {
|
||||||
data = (byte) ((((data - start) + 2) & 3) + start);
|
data = (byte) ((((data - start) + 2) & 3) + start);
|
||||||
@ -105,6 +116,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public static byte wrap2(byte data, int start) {
|
public static byte wrap2(byte data, int start) {
|
||||||
if ((data >= start) && (data < (start + 2))) {
|
if ((data >= start) && (data < (start + 2))) {
|
||||||
data = (byte) ((((data - start) + 1) & 1) + start);
|
data = (byte) ((((data - start) + 1) & 1) + start);
|
||||||
@ -112,8 +124,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME depends on block ids
|
|
||||||
// Possibly make abstract?
|
|
||||||
public static BaseBlock rotate(BaseBlock id) {
|
public static BaseBlock rotate(BaseBlock id) {
|
||||||
|
|
||||||
CompoundTag tag = id.getNbtData();
|
CompoundTag tag = id.getNbtData();
|
||||||
@ -251,6 +261,14 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
Schematic schematic1 = this.schematicHandler.getSchematic(schematic1File);
|
Schematic schematic1 = this.schematicHandler.getSchematic(schematic1File);
|
||||||
Schematic schematic2 = this.schematicHandler.getSchematic(schematic2File);
|
Schematic schematic2 = this.schematicHandler.getSchematic(schematic2File);
|
||||||
Schematic schematic3 = this.schematicHandler.getSchematic(schematic3File);
|
Schematic schematic3 = this.schematicHandler.getSchematic(schematic3File);
|
||||||
|
|
||||||
|
// If the plot schematic contains entities, then they need to be populated upon generation.
|
||||||
|
if (schematic3 != null && !schematic3.getClipboard().getEntities().isEmpty()) {
|
||||||
|
this.schem3Entities = new ArrayList<>(schematic3.getClipboard().getEntities());
|
||||||
|
this.schem3MinPoint = schematic3.getClipboard().getMinimumPoint();
|
||||||
|
this.schem3PopulationNeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
int shift = this.ROAD_WIDTH / 2;
|
int shift = this.ROAD_WIDTH / 2;
|
||||||
int oddshift = (this.ROAD_WIDTH & 1);
|
int oddshift = (this.ROAD_WIDTH & 1);
|
||||||
|
|
||||||
@ -314,19 +332,28 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
for (short x = 0; x < w3; x++) {
|
for (short x = 0; x < w3; x++) {
|
||||||
for (short z = 0; z < l3; z++) {
|
for (short z = 0; z < l3; z++) {
|
||||||
for (short y = 0; y < h3; y++) {
|
for (short y = 0; y < h3; y++) {
|
||||||
BaseBlock id =
|
BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3.at(
|
||||||
blockArrayClipboard3.getFullBlock(BlockVector3.at(
|
|
||||||
x + min.getBlockX(),
|
x + min.getBlockX(),
|
||||||
y + min.getBlockY(),
|
y + min.getBlockY(),
|
||||||
z + min.getBlockZ()
|
z + min.getBlockZ()
|
||||||
));
|
));
|
||||||
if (!id.getBlockType().getMaterial().isAir()) {
|
if (!id.getBlockType().getMaterial().isAir()) {
|
||||||
addOverlayBlock((short) (x + shift + oddshift + centerShiftX), (short) (y + plotY),
|
schem3PopulationNeeded |= id.hasNbtData();
|
||||||
(short) (z + shift + oddshift + centerShiftZ), id, false, h3
|
addOverlayBlock(
|
||||||
|
(short) (x + shift + oddshift + centerShiftX),
|
||||||
|
(short) (y + plotY),
|
||||||
|
(short) (z + shift + oddshift + centerShiftZ),
|
||||||
|
id,
|
||||||
|
false,
|
||||||
|
h3
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BiomeType biome = blockArrayClipboard3.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
if (blockArrayClipboard3.hasBiomes()) {
|
||||||
|
BiomeType biome = blockArrayClipboard3.getBiome(BlockVector2.at(
|
||||||
|
x + min.getBlockX(),
|
||||||
|
z + min.getBlockZ()
|
||||||
|
));
|
||||||
addOverlayBiome(
|
addOverlayBiome(
|
||||||
(short) (x + shift + oddshift + centerShiftX),
|
(short) (x + shift + oddshift + centerShiftX),
|
||||||
(short) (z + shift + oddshift + centerShiftZ),
|
(short) (z + shift + oddshift + centerShiftZ),
|
||||||
@ -334,12 +361,13 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
LOGGER.info("- plot schematic: {}", schematic3File.getPath());
|
LOGGER.info("- plot schematic: {}", schematic3File.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((schematic1 == null&& schematic2 == null) || this.ROAD_WIDTH == 0) {
|
if ((schematic1 == null && schematic2 == null) || this.ROAD_WIDTH == 0) {
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
LOGGER.info("- schematic: false");
|
LOGGER.info("- schematic: false");
|
||||||
}
|
}
|
||||||
@ -370,6 +398,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
z + min.getBlockZ()
|
z + min.getBlockZ()
|
||||||
));
|
));
|
||||||
if (!id.getBlockType().getMaterial().isAir()) {
|
if (!id.getBlockType().getMaterial().isAir()) {
|
||||||
|
schem1PopulationNeeded |= id.hasNbtData();
|
||||||
addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z + shift + oddshift), id, false, h1);
|
addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z + shift + oddshift), id, false, h1);
|
||||||
addOverlayBlock(
|
addOverlayBlock(
|
||||||
(short) (z + shift + oddshift),
|
(short) (z + shift + oddshift),
|
||||||
@ -381,11 +410,13 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (blockArrayClipboard1.hasBiomes()) {
|
||||||
BiomeType biome = blockArrayClipboard1.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
BiomeType biome = blockArrayClipboard1.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
||||||
addOverlayBiome((short) (x - shift), (short) (z + shift + oddshift), biome);
|
addOverlayBiome((short) (x - shift), (short) (z + shift + oddshift), biome);
|
||||||
addOverlayBiome((short) (z + shift + oddshift), (short) (shift - x + (oddshift - 1)), biome);
|
addOverlayBiome((short) (z + shift + oddshift), (short) (shift - x + (oddshift - 1)), biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Clipboard blockArrayClipboard2 = schematic2.getClipboard();
|
Clipboard blockArrayClipboard2 = schematic2.getClipboard();
|
||||||
BlockVector3 d2 = blockArrayClipboard2.getDimensions();
|
BlockVector3 d2 = blockArrayClipboard2.getDimensions();
|
||||||
@ -406,14 +437,17 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
z + min.getBlockZ()
|
z + min.getBlockZ()
|
||||||
));
|
));
|
||||||
if (!id.getBlockType().getMaterial().isAir()) {
|
if (!id.getBlockType().getMaterial().isAir()) {
|
||||||
|
schem2PopulationNeeded |= id.hasNbtData();
|
||||||
addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z - shift), id, false, h2);
|
addOverlayBlock((short) (x - shift), (short) (y + roadY), (short) (z - shift), id, false, h2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (blockArrayClipboard2.hasBiomes()) {
|
||||||
BiomeType biome = blockArrayClipboard2.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
BiomeType biome = blockArrayClipboard2.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
||||||
addOverlayBiome((short) (x - shift), (short) (z - shift), biome);
|
addOverlayBiome((short) (x - shift), (short) (z - shift), biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addOverlayBlock(short x, short y, short z, BaseBlock id, boolean rotate, int height) {
|
public void addOverlayBlock(short x, short y, short z, BaseBlock id, boolean rotate, int height) {
|
||||||
if (z < 0) {
|
if (z < 0) {
|
||||||
@ -456,8 +490,52 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
this.G_SCH_B.put(pair, id);
|
this.G_SCH_B.put(pair, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the entities contained within the plot schematic for generation. Intended for internal use only.
|
||||||
|
*
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.")
|
||||||
|
public @Nullable List<Entity> getPlotSchematicEntities() {
|
||||||
|
return schem3Entities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the minimum point of the plot schematic for generation. Intended for internal use only.
|
||||||
|
*
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.")
|
||||||
|
public @Nullable BlockVector3 getPlotSchematicMinPoint() {
|
||||||
|
return schem3MinPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get if post-generation population of chunks with tiles/entities is needed for this world. Not for public API use.
|
||||||
|
*
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.")
|
||||||
|
public boolean populationNeeded() {
|
||||||
|
return schem1PopulationNeeded || schem2PopulationNeeded || schem3PopulationNeeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated in favour of {@link HybridPlotWorld#getSchematicRoot()}
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public File getRoot() {
|
public File getRoot() {
|
||||||
return this.root;
|
return this.root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the root folder for this world's generation schematics. May be null if schematics not initialised via
|
||||||
|
* {@link HybridPlotWorld#setupSchematics()}
|
||||||
|
*
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
public @Nullable File getSchematicRoot() {
|
||||||
|
return this.root;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,22 +47,25 @@ public abstract class IndependentPlotGenerator {
|
|||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the setBlock or setBiome method of the PlotChunk result parameter to make changes.
|
* Generate chunk block data
|
||||||
* The PlotArea settings is the same one this was initialized with.
|
|
||||||
* The PseudoRandom random is a fast random object.
|
|
||||||
*
|
*
|
||||||
* @param result queue
|
* @param result queue
|
||||||
* @param settings PlotArea (settings)
|
* @param settings PlotArea (settings)
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "TODO")
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public abstract void generateChunk(ScopedQueueCoordinator result, PlotArea settings);
|
public abstract void generateChunk(ScopedQueueCoordinator result, PlotArea settings);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Populates the queue representing a chunk area with tile entities and entities
|
||||||
|
*
|
||||||
|
* @param result Queue to write to
|
||||||
|
* @param settings PlotArea (settings)
|
||||||
|
* @return True if any population occurred
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "TODO")
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public boolean populateChunk(ScopedQueueCoordinator result, PlotArea setting) {
|
public boolean populateChunk(ScopedQueueCoordinator result, PlotArea settings) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.inject.factory;
|
package com.plotsquared.core.inject.factory;
|
||||||
|
|
||||||
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.plotsquared.core.queue.ChunkCoordinator;
|
import com.plotsquared.core.queue.ChunkCoordinator;
|
||||||
import com.plotsquared.core.queue.subscriber.ProgressSubscriber;
|
import com.plotsquared.core.queue.subscriber.ProgressSubscriber;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
@ -44,8 +45,9 @@ public interface ChunkCoordinatorFactory {
|
|||||||
final @NonNull Collection<BlockVector2> requestedChunks,
|
final @NonNull Collection<BlockVector2> requestedChunks,
|
||||||
final @NonNull Runnable whenDone,
|
final @NonNull Runnable whenDone,
|
||||||
final @NonNull Consumer<Throwable> throwableConsumer,
|
final @NonNull Consumer<Throwable> throwableConsumer,
|
||||||
final boolean unloadAfter,
|
@Assisted("unloadAfter") final boolean unloadAfter,
|
||||||
final @NonNull Collection<ProgressSubscriber> progressSubscribers
|
final @NonNull Collection<ProgressSubscriber> progressSubscribers,
|
||||||
|
@Assisted("forceSync") final boolean forceSync
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,14 +41,17 @@ import org.khelekore.prtree.SimpleMBR;
|
|||||||
* An unmodifiable 6-tuple (world,x,y,z,yaw,pitch)
|
* An unmodifiable 6-tuple (world,x,y,z,yaw,pitch)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class Location extends BlockLoc implements Comparable<Location> {
|
public sealed class Location extends BlockLoc implements Comparable<Location> permits UncheckedWorldLocation {
|
||||||
|
|
||||||
private final float yaw;
|
private final float yaw;
|
||||||
private final float pitch;
|
private final float pitch;
|
||||||
private final BlockVector3 blockVector3;
|
private final BlockVector3 blockVector3;
|
||||||
private final World<?> world;
|
private final World<?> world;
|
||||||
|
|
||||||
private Location(
|
/**
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
protected Location(
|
||||||
final @NonNull World<?> world, final @NonNull BlockVector3 blockVector3,
|
final @NonNull World<?> world, final @NonNull BlockVector3 blockVector3,
|
||||||
final float yaw, final float pitch
|
final float yaw, final float pitch
|
||||||
) {
|
) {
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2014 - 2022 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.location;
|
||||||
|
|
||||||
|
import com.plotsquared.core.util.AnnotationHelper;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used internally for generation to reference locations in worlds that "don't exist yet". There is no guarantee that the world
|
||||||
|
* name provided by {@link UncheckedWorldLocation#getWorldName()} exists on the server.
|
||||||
|
*
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.")
|
||||||
|
public final class UncheckedWorldLocation extends Location {
|
||||||
|
|
||||||
|
private final String worldName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
private UncheckedWorldLocation(
|
||||||
|
final @NonNull String worldName, final int x, final int y, final int z
|
||||||
|
) {
|
||||||
|
super(World.nullWorld(), BlockVector3.at(x, y, z), 0f, 0f);
|
||||||
|
this.worldName = worldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a new location with yaw and pitch equal to 0
|
||||||
|
*
|
||||||
|
* @param world World
|
||||||
|
* @param x X coordinate
|
||||||
|
* @param y Y coordinate
|
||||||
|
* @param z Z coordinate
|
||||||
|
* @return New location
|
||||||
|
*
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.")
|
||||||
|
public static @NonNull UncheckedWorldLocation at(
|
||||||
|
final @NonNull String world, final int x, final int y, final int z
|
||||||
|
) {
|
||||||
|
return new UncheckedWorldLocation(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.")
|
||||||
|
public @NonNull String getWorldName() {
|
||||||
|
return this.worldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -65,7 +65,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@ -965,7 +964,31 @@ public abstract class PlotArea {
|
|||||||
return this.plots.remove(id) != null;
|
return this.plots.remove(id) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge a list of plots together. This is non-blocking for the world-changes that will be made. To run a task when the
|
||||||
|
* world changes are complete, use {@link PlotArea#mergePlots(List, boolean, Runnable)};
|
||||||
|
*
|
||||||
|
* @param plotIds List of plot IDs to merge
|
||||||
|
* @param removeRoads If the roads between plots should be removed
|
||||||
|
* @return if merges were completed successfully.
|
||||||
|
*/
|
||||||
public boolean mergePlots(final @NonNull List<PlotId> plotIds, final boolean removeRoads) {
|
public boolean mergePlots(final @NonNull List<PlotId> plotIds, final boolean removeRoads) {
|
||||||
|
return mergePlots(plotIds, removeRoads, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge a list of plots together. This is non-blocking for the world-changes that will be made.
|
||||||
|
*
|
||||||
|
* @param plotIds List of plot IDs to merge
|
||||||
|
* @param removeRoads If the roads between plots should be removed
|
||||||
|
* @param whenDone Task to run when any merge world changes are complete. Also runs if no changes were made. Does not
|
||||||
|
* run if there was an error or if too few plots IDs were supplied.
|
||||||
|
* @return if merges were completed successfully.
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
public boolean mergePlots(
|
||||||
|
final @NonNull List<PlotId> plotIds, final boolean removeRoads, final @Nullable Runnable whenDone
|
||||||
|
) {
|
||||||
if (plotIds.size() < 2) {
|
if (plotIds.size() < 2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1028,6 +1051,9 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
manager.finishPlotMerge(plotIds, queue);
|
manager.finishPlotMerge(plotIds, queue);
|
||||||
|
if (whenDone != null) {
|
||||||
|
queue.setCompleteTask(whenDone);
|
||||||
|
}
|
||||||
queue.enqueue();
|
queue.enqueue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1379,7 +1405,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the min height from which P2 will generate blocks. Inclusive.
|
* Get the min height from which PlotSquared will generate blocks. Inclusive.
|
||||||
*
|
*
|
||||||
* @since 6.6.0
|
* @since 6.6.0
|
||||||
*/
|
*/
|
||||||
@ -1388,7 +1414,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the max height to which P2 will generate blocks. Inclusive.
|
* Get the max height to which PlotSquared will generate blocks. Inclusive.
|
||||||
*
|
*
|
||||||
* @since 6.6.0
|
* @since 6.6.0
|
||||||
*/
|
*/
|
||||||
|
@ -44,7 +44,7 @@ public enum PlotAreaTerrainType {
|
|||||||
ORE,
|
ORE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate everything using the vanilla generator but with PS roads.
|
* Generate everything using the vanilla generator but with PlotSquared roads.
|
||||||
*/
|
*/
|
||||||
ROAD,
|
ROAD,
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public abstract class ListFlag<V, F extends PlotFlag<List<V>, F>> extends PlotFl
|
|||||||
@Override
|
@Override
|
||||||
public F merge(@NonNull List<V> newValue) {
|
public F merge(@NonNull List<V> newValue) {
|
||||||
final List<V> mergedList = new ArrayList<>();
|
final List<V> mergedList = new ArrayList<>();
|
||||||
// If a server already used PS before this fix, we remove all present duplicates on an eventual merge
|
// If a server already used PlotSquared before this fix, we remove all present duplicates on an eventual merge
|
||||||
for (final V v : getValue()) {
|
for (final V v : getValue()) {
|
||||||
if (!mergedList.contains(v)) {
|
if (!mergedList.contains(v)) {
|
||||||
mergedList.add(v);
|
mergedList.add(v);
|
||||||
|
@ -58,6 +58,7 @@ public class ChunkCoordinatorBuilder {
|
|||||||
private long maxIterationTime = Settings.QUEUE.MAX_ITERATION_TIME; // A little over 1 tick;
|
private long maxIterationTime = Settings.QUEUE.MAX_ITERATION_TIME; // A little over 1 tick;
|
||||||
private int initialBatchSize = Settings.QUEUE.INITIAL_BATCH_SIZE;
|
private int initialBatchSize = Settings.QUEUE.INITIAL_BATCH_SIZE;
|
||||||
private boolean unloadAfter = true;
|
private boolean unloadAfter = true;
|
||||||
|
private boolean forceSync = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ChunkCoordinatorBuilder(@NonNull ChunkCoordinatorFactory chunkCoordinatorFactory) {
|
public ChunkCoordinatorBuilder(@NonNull ChunkCoordinatorFactory chunkCoordinatorFactory) {
|
||||||
@ -197,6 +198,18 @@ public class ChunkCoordinatorBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the chunks coordinator should be forced to be synchronous. This is not necessarily synchronous to the server,
|
||||||
|
* and simply effectively makes {@link ChunkCoordinator#start()} ()} a blocking operation.
|
||||||
|
*
|
||||||
|
* @param forceSync force sync or not
|
||||||
|
* @since 6.9.0
|
||||||
|
*/
|
||||||
|
public @NonNull ChunkCoordinatorBuilder forceSync(final boolean forceSync) {
|
||||||
|
this.forceSync = forceSync;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public @NonNull ChunkCoordinatorBuilder withProgressSubscriber(ProgressSubscriber progressSubscriber) {
|
public @NonNull ChunkCoordinatorBuilder withProgressSubscriber(ProgressSubscriber progressSubscriber) {
|
||||||
this.progressSubscribers.add(progressSubscriber);
|
this.progressSubscribers.add(progressSubscriber);
|
||||||
return this;
|
return this;
|
||||||
@ -227,7 +240,8 @@ public class ChunkCoordinatorBuilder {
|
|||||||
this.whenDone,
|
this.whenDone,
|
||||||
this.throwableConsumer,
|
this.throwableConsumer,
|
||||||
this.unloadAfter,
|
this.unloadAfter,
|
||||||
this.progressSubscribers
|
this.progressSubscribers,
|
||||||
|
this.forceSync
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
* Queue that is limited to a single chunk. It does not allow a delegate queue and should be treated as a cache for changes to
|
* Queue that is limited to a single chunk. It does not allow a delegate queue and should be treated as a cache for changes to
|
||||||
* be set to. Does not support tile entities or entities.
|
* be set to. Does not support tile entities or entities.
|
||||||
*
|
*
|
||||||
* @deprecated This class is poorly designed and will no longer be used in P2
|
* @deprecated This class is poorly designed and will no longer be used in PlotSquared
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "6.8.0")
|
@Deprecated(forRemoval = true, since = "6.8.0")
|
||||||
public class ChunkQueueCoordinator extends ScopedQueueCoordinator {
|
public class ChunkQueueCoordinator extends ScopedQueueCoordinator {
|
||||||
|
@ -40,14 +40,12 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public abstract class QueueCoordinator {
|
public abstract class QueueCoordinator {
|
||||||
@ -95,7 +93,7 @@ public abstract class QueueCoordinator {
|
|||||||
* @since 6.6.0
|
* @since 6.6.0
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "TODO")
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public ScopedQueueCoordinator getForChunk(int x, int z, int minY, int maxY) {
|
public ScopedQueueCoordinator getForChunk(int x, int z, int minY, int maxY) {
|
||||||
int bx = x << 4;
|
int bx = x << 4;
|
||||||
int bz = z << 4;
|
int bz = z << 4;
|
||||||
@ -119,7 +117,8 @@ public abstract class QueueCoordinator {
|
|||||||
public abstract void setModified(long modified);
|
public abstract void setModified(long modified);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the queue should be forced to be synchronous when enqueued.
|
* Returns true if the queue should be forced to be synchronous when enqueued. This is not necessarily synchronous to the
|
||||||
|
* server, and simply effectively makes {@link QueueCoordinator#enqueue()} a blocking operation.
|
||||||
*
|
*
|
||||||
* @return is force sync
|
* @return is force sync
|
||||||
*/
|
*/
|
||||||
@ -128,7 +127,8 @@ public abstract class QueueCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether the queue should be forced to be synchronous
|
* Set whether the queue should be forced to be synchronous. This is not necessarily synchronous to the server, and simply
|
||||||
|
* effectively makes {@link QueueCoordinator#enqueue()} a blocking operation.
|
||||||
*
|
*
|
||||||
* @param forceSync force sync or not
|
* @param forceSync force sync or not
|
||||||
*/
|
*/
|
||||||
|
@ -45,7 +45,7 @@ public abstract class ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "TODO")
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public static void setChunkInPlotArea(
|
public static void setChunkInPlotArea(
|
||||||
RunnableVal<ScopedQueueCoordinator> force,
|
RunnableVal<ScopedQueueCoordinator> force,
|
||||||
RunnableVal<ScopedQueueCoordinator> add,
|
RunnableVal<ScopedQueueCoordinator> add,
|
||||||
@ -86,7 +86,7 @@ public abstract class ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "TODO")
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public static boolean preProcessChunk(BlockVector2 loc, ScopedQueueCoordinator queue) {
|
public static boolean preProcessChunk(BlockVector2 loc, ScopedQueueCoordinator queue) {
|
||||||
final RunnableVal<ScopedQueueCoordinator> forceChunk = forceChunks.get(loc);
|
final RunnableVal<ScopedQueueCoordinator> forceChunk = forceChunks.get(loc);
|
||||||
if (forceChunk != null) {
|
if (forceChunk != null) {
|
||||||
@ -100,7 +100,7 @@ public abstract class ChunkManager {
|
|||||||
/**
|
/**
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "TODO")
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public static boolean postProcessChunk(BlockVector2 loc, ScopedQueueCoordinator queue) {
|
public static boolean postProcessChunk(BlockVector2 loc, ScopedQueueCoordinator queue) {
|
||||||
final RunnableVal<ScopedQueueCoordinator> addChunk = forceChunks.get(loc);
|
final RunnableVal<ScopedQueueCoordinator> addChunk = forceChunks.get(loc);
|
||||||
if (addChunk != null) {
|
if (addChunk != null) {
|
||||||
|
@ -174,7 +174,7 @@ public abstract class RegionManager {
|
|||||||
* @param whenDone task to run when complete
|
* @param whenDone task to run when complete
|
||||||
* @param manager plot manager
|
* @param manager plot manager
|
||||||
* @param actor the player running the clear
|
* @param actor the player running the clear
|
||||||
* @return {@code true} if the clear worked. {@code false} if someone went wrong so P2 can then handle the clear
|
* @return {@code true} if the clear worked. {@code false} if someone went wrong so PlotSquared can then handle the clear
|
||||||
*/
|
*/
|
||||||
public abstract boolean handleClear(
|
public abstract boolean handleClear(
|
||||||
@NonNull Plot plot,
|
@NonNull Plot plot,
|
||||||
|
@ -109,7 +109,7 @@ public class RegionUtil {
|
|||||||
return new Rectangle2D.Double(min.getX(), min.getZ(), max.getX(), max.getZ());
|
return new Rectangle2D.Double(min.getX(), min.getZ(), max.getX(), max.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Because WE (not fawe) lack this for CuboidRegion
|
// Because WorldEdit (not FastAsyncWorldEdit) lack this for CuboidRegion
|
||||||
public static boolean intersects(CuboidRegion region, CuboidRegion other) {
|
public static boolean intersects(CuboidRegion region, CuboidRegion other) {
|
||||||
BlockVector3 regionMin = region.getMinimumPoint();
|
BlockVector3 regionMin = region.getMinimumPoint();
|
||||||
BlockVector3 regionMax = region.getMaximumPoint();
|
BlockVector3 regionMax = region.getMaximumPoint();
|
||||||
|
@ -167,7 +167,7 @@ public final class TabCompletions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of completions corresponding to WorldEdit(/FAWE) patterns. This uses
|
* Get a list of completions corresponding to WorldEdit(/FastAsyncWorldEdit) patterns. This uses
|
||||||
* WorldEdit's pattern completer internally.
|
* WorldEdit's pattern completer internally.
|
||||||
*
|
*
|
||||||
* @param input Command input
|
* @param input Command input
|
||||||
|
29
README.md
29
README.md
@ -1,5 +1,5 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://raw.githubusercontent.com/IntellectualSites/Assets/main/plugins/PlotSquared/PlotSquared.svg" width="300">
|
<img src="https://raw.githubusercontent.com/IntellectualSites/Assets/main/plugins/PlotSquared/PlotSquared.svg" width="250">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -41,15 +41,20 @@ is to provide a lag-free and smooth experience.
|
|||||||
* [Plot2Dynmap](http://www.spigotmc.org/resources/plot2dynmap.1292/)
|
* [Plot2Dynmap](http://www.spigotmc.org/resources/plot2dynmap.1292/)
|
||||||
* [HoloPlots](https://www.spigotmc.org/resources/holoplots.4880/)
|
* [HoloPlots](https://www.spigotmc.org/resources/holoplots.4880/)
|
||||||
* [PlotHider](https://www.spigotmc.org/resources/plot-hider.20701/)
|
* [PlotHider](https://www.spigotmc.org/resources/plot-hider.20701/)
|
||||||
### Unmaintained or integrated into PlotSquared
|
|
||||||
* [AdvPlots](http://www.spigotmc.org/resources/advplots-%CE%B2.1500/)
|
|
||||||
* [PlotRankup](http://www.spigotmc.org/resources/plotrankup.1571/)
|
|
||||||
* [PlotZSux](https://www.spigotmc.org/resources/plotzsux.9563/)
|
|
||||||
* [IslandPlots](https://www.spigotmc.org/resources/islandplots.9421/)
|
|
||||||
* [BiomeGenerator](https://www.spigotmc.org/resources/biomegenerator.1663/)
|
|
||||||
* [PlotSquaredMG](https://www.spigotmc.org/resources/plotsquaredmg.8025/)
|
|
||||||
* [BasicPlots](https://www.spigotmc.org/resources/basicplots.6901/)
|
|
||||||
|
|
||||||
# Sponsors
|
### Edit The Code
|
||||||
Our official sponsor list can be found [here](https://intellectualsites.github.io/download/sponsors.html). <br>
|
|
||||||
If you are interested and want to be listed here, [contact us](https://intellectualsites.github.io/download/contact.html).
|
Want to add new features to PlotSquared or fix bugs yourself? You can get the game running, with PlotSquared, from the code here:
|
||||||
|
|
||||||
|
For additional information about compiling PlotSquared, see [CONTRIBUTING.md](https://github.com/IntellectualSites/.github/blob/main/CONTRIBUTING.md)
|
||||||
|
|
||||||
|
### Submitting Your Changes
|
||||||
|
PlotSquared is open source (specifically licensed under GPL v3), so note that your contributions will also be open source. The best way to submit a change is to create a fork on GitHub, put your changes there, and then create a "pull request" on our PlotSquared repository.
|
||||||
|
|
||||||
|
<a href="https://yourkit.com/">
|
||||||
|
<img src="https://www.yourkit.com/images/yklogo.png">
|
||||||
|
</a>
|
||||||
|
|
||||||
|
Thank you to YourKit for supporting our product by providing us with their innovative and intelligent tools
|
||||||
|
for monitoring and profiling Java and .NET applications.
|
||||||
|
YourKit is the creator of [YourKit Java Profiler](https://www.yourkit.com/java/profiler/), [YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/), and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
|
||||||
|
@ -18,7 +18,7 @@ plugins {
|
|||||||
idea
|
idea
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "6.8.2-SNAPSHOT"
|
version = "6.9.0"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "com.plotsquared"
|
group = "com.plotsquared"
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
],
|
],
|
||||||
"timezone": "Europe/Berlin",
|
"timezone": "Europe/Berlin",
|
||||||
"schedule": [
|
"schedule": [
|
||||||
"on monday after 9am"
|
"every monday"
|
||||||
],
|
],
|
||||||
"labels": ["Renovate"],
|
"labels": ["Renovate"],
|
||||||
"commitMessagePrefix": "build: ",
|
"commitMessagePrefix": "build: ",
|
||||||
|
Reference in New Issue
Block a user