mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Switch to using QueueCoordinators everywhere
This commit is contained in:
parent
ed77522c08
commit
9fefe57c90
@ -90,7 +90,6 @@ import com.plotsquared.core.plot.message.PlainChatManager;
|
|||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
|
||||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
||||||
import com.plotsquared.core.util.ChatManager;
|
import com.plotsquared.core.util.ChatManager;
|
||||||
@ -156,9 +155,11 @@ import static com.plotsquared.core.util.PremiumVerification.getResourceID;
|
|||||||
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
||||||
import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||||
|
|
||||||
@SuppressWarnings("unused") public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPlatform<Player> {
|
@SuppressWarnings("unused")
|
||||||
|
public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPlatform<Player> {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitPlatform.class.getSimpleName());
|
private static final Logger logger =
|
||||||
|
LoggerFactory.getLogger("P2/" + BukkitPlatform.class.getSimpleName());
|
||||||
private static final int BSTATS_ID = 1404;
|
private static final int BSTATS_ID = 1404;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@ -233,7 +234,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
|
|
||||||
// We create the injector after PlotSquared has been initialized, so that we have access
|
// We create the injector after PlotSquared has been initialized, so that we have access
|
||||||
// to generated instances and settings
|
// to generated instances and settings
|
||||||
this.injector = Guice.createInjector(Stage.PRODUCTION, new WorldManagerModule(), new PlotSquaredModule(),
|
this.injector = Guice
|
||||||
|
.createInjector(Stage.PRODUCTION, new WorldManagerModule(), new PlotSquaredModule(),
|
||||||
new BukkitModule(this), new BackupModule());
|
new BukkitModule(this), new BackupModule());
|
||||||
this.injector.injectMembers(this);
|
this.injector.injectMembers(this);
|
||||||
|
|
||||||
@ -288,34 +290,37 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
||||||
try {
|
try {
|
||||||
logger.info("[P2] {} hooked into WorldEdit", this.getPluginName());
|
logger.info("[P2] {} hooked into WorldEdit", this.getPluginName());
|
||||||
WorldEdit.getInstance().getEventBus().register(this.getInjector().getInstance(WESubscriber.class));
|
WorldEdit.getInstance().getEventBus()
|
||||||
|
.register(this.getInjector().getInstance(WESubscriber.class));
|
||||||
if (Settings.Enabled_Components.COMMANDS) {
|
if (Settings.Enabled_Components.COMMANDS) {
|
||||||
new WE_Anywhere();
|
new WE_Anywhere();
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("[P2] Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
|
logger.error(
|
||||||
|
"[P2] Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.Enabled_Components.EVENTS) {
|
if (Settings.Enabled_Components.EVENTS) {
|
||||||
getServer().getPluginManager().registerEvents(getInjector().getInstance(PlayerEvents.class), this);
|
getServer().getPluginManager()
|
||||||
getServer().getPluginManager().registerEvents(getInjector().getInstance(EntitySpawnListener.class), this);
|
.registerEvents(getInjector().getInstance(PlayerEvents.class), this);
|
||||||
|
getServer().getPluginManager()
|
||||||
|
.registerEvents(getInjector().getInstance(EntitySpawnListener.class), this);
|
||||||
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
|
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
|
||||||
getServer().getPluginManager().registerEvents(getInjector().getInstance(PaperListener.class), this);
|
getServer().getPluginManager()
|
||||||
|
.registerEvents(getInjector().getInstance(PaperListener.class), this);
|
||||||
}
|
}
|
||||||
this.plotListener.startRunnable();
|
this.plotListener.startRunnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required
|
// Required
|
||||||
getServer().getPluginManager().registerEvents(getInjector().getInstance(WorldEvents.class), this);
|
getServer().getPluginManager()
|
||||||
|
.registerEvents(getInjector().getInstance(WorldEvents.class), this);
|
||||||
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
||||||
getServer().getPluginManager().registerEvents(getInjector().getInstance(ChunkListener.class), this);
|
getServer().getPluginManager()
|
||||||
|
.registerEvents(getInjector().getInstance(ChunkListener.class), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start the global block queue
|
|
||||||
final GlobalBlockQueue globalBlockQueue = this.injector.getInstance(GlobalBlockQueue.class);
|
|
||||||
globalBlockQueue.runTask();
|
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
if (Settings.Enabled_Components.COMMANDS) {
|
if (Settings.Enabled_Components.COMMANDS) {
|
||||||
this.registerCommands();
|
this.registerCommands();
|
||||||
@ -344,7 +349,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// World generators:
|
// World generators:
|
||||||
final ConfigurationSection section = this.worldConfiguration.getConfigurationSection("worlds");
|
final ConfigurationSection section =
|
||||||
|
this.worldConfiguration.getConfigurationSection("worlds");
|
||||||
final WorldUtil worldUtil = getInjector().getInstance(WorldUtil.class);
|
final WorldUtil worldUtil = getInjector().getInstance(WorldUtil.class);
|
||||||
|
|
||||||
if (section != null) {
|
if (section != null) {
|
||||||
@ -362,11 +368,15 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!worldUtil.isWorld(world) && !world.equals("*")) {
|
if (!worldUtil.isWorld(world) && !world.equals("*")) {
|
||||||
logger.warn("[P2] `{}` was not properly loaded - {} will now try to load it properly",
|
logger.warn(
|
||||||
|
"[P2] `{}` was not properly loaded - {} will now try to load it properly",
|
||||||
world, this.getPluginName());
|
world, this.getPluginName());
|
||||||
logger.warn("[P2] - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
|
logger.warn(
|
||||||
logger.warn("[P2] - Your world management plugin may be faulty (or non existent)");
|
"[P2] - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
|
||||||
logger.warn("[P2] This message may also be a false positive and could be ignored.");
|
logger.warn(
|
||||||
|
"[P2] - Your world management plugin may be faulty (or non existent)");
|
||||||
|
logger.warn(
|
||||||
|
"[P2] This message may also be a false positive and could be ignored.");
|
||||||
this.setGenerator(world);
|
this.setGenerator(world);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -374,7 +384,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Services are accessed in order
|
// Services are accessed in order
|
||||||
final CacheUUIDService cacheUUIDService = new CacheUUIDService(Settings.UUID.UUID_CACHE_SIZE);
|
final CacheUUIDService cacheUUIDService =
|
||||||
|
new CacheUUIDService(Settings.UUID.UUID_CACHE_SIZE);
|
||||||
this.impromptuPipeline.registerService(cacheUUIDService);
|
this.impromptuPipeline.registerService(cacheUUIDService);
|
||||||
this.backgroundPipeline.registerService(cacheUUIDService);
|
this.backgroundPipeline.registerService(cacheUUIDService);
|
||||||
this.impromptuPipeline.registerConsumer(cacheUUIDService);
|
this.impromptuPipeline.registerConsumer(cacheUUIDService);
|
||||||
@ -390,7 +401,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.UUID.SERVICE_BUKKIT) {
|
if (Settings.UUID.SERVICE_BUKKIT) {
|
||||||
final OfflinePlayerUUIDService offlinePlayerUUIDService = new OfflinePlayerUUIDService();
|
final OfflinePlayerUUIDService offlinePlayerUUIDService =
|
||||||
|
new OfflinePlayerUUIDService();
|
||||||
this.impromptuPipeline.registerService(offlinePlayerUUIDService);
|
this.impromptuPipeline.registerService(offlinePlayerUUIDService);
|
||||||
this.backgroundPipeline.registerService(offlinePlayerUUIDService);
|
this.backgroundPipeline.registerService(offlinePlayerUUIDService);
|
||||||
}
|
}
|
||||||
@ -406,8 +418,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
}
|
}
|
||||||
|
|
||||||
final LuckPermsUUIDService luckPermsUUIDService;
|
final LuckPermsUUIDService luckPermsUUIDService;
|
||||||
if (Settings.UUID.SERVICE_LUCKPERMS &&
|
if (Settings.UUID.SERVICE_LUCKPERMS
|
||||||
Bukkit.getPluginManager().getPlugin("LuckPerms") != null) {
|
&& Bukkit.getPluginManager().getPlugin("LuckPerms") != null) {
|
||||||
luckPermsUUIDService = new LuckPermsUUIDService();
|
luckPermsUUIDService = new LuckPermsUUIDService();
|
||||||
logger.info("[P2] (UUID) Using LuckPerms as a complementary UUID service");
|
logger.info("[P2] (UUID) Using LuckPerms as a complementary UUID service");
|
||||||
} else {
|
} else {
|
||||||
@ -415,8 +427,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
}
|
}
|
||||||
|
|
||||||
final BungeePermsUUIDService bungeePermsUUIDService;
|
final BungeePermsUUIDService bungeePermsUUIDService;
|
||||||
if (Settings.UUID.SERVICE_BUNGEE_PERMS &&
|
if (Settings.UUID.SERVICE_BUNGEE_PERMS
|
||||||
Bukkit.getPluginManager().getPlugin("BungeePerms") != null) {
|
&& Bukkit.getPluginManager().getPlugin("BungeePerms") != null) {
|
||||||
bungeePermsUUIDService = new BungeePermsUUIDService();
|
bungeePermsUUIDService = new BungeePermsUUIDService();
|
||||||
logger.info("[P2] (UUID) Using BungeePerms as a complementary UUID service");
|
logger.info("[P2] (UUID) Using BungeePerms as a complementary UUID service");
|
||||||
} else {
|
} else {
|
||||||
@ -424,7 +436,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
}
|
}
|
||||||
|
|
||||||
final EssentialsUUIDService essentialsUUIDService;
|
final EssentialsUUIDService essentialsUUIDService;
|
||||||
if (Settings.UUID.SERVICE_ESSENTIALSX && Bukkit.getPluginManager().getPlugin("Essentials") != null) {
|
if (Settings.UUID.SERVICE_ESSENTIALSX
|
||||||
|
&& Bukkit.getPluginManager().getPlugin("Essentials") != null) {
|
||||||
essentialsUUIDService = new EssentialsUUIDService();
|
essentialsUUIDService = new EssentialsUUIDService();
|
||||||
logger.info("[P2] (UUID) Using EssentialsX as a complementary UUID service");
|
logger.info("[P2] (UUID) Using EssentialsX as a complementary UUID service");
|
||||||
} else {
|
} else {
|
||||||
@ -511,8 +524,10 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
// Clean up potential memory leak
|
// Clean up potential memory leak
|
||||||
Bukkit.getScheduler().runTaskTimer(this, () -> {
|
Bukkit.getScheduler().runTaskTimer(this, () -> {
|
||||||
try {
|
try {
|
||||||
for (final PlotPlayer<? extends Player> player : this.getPlayerManager().getPlayers()) {
|
for (final PlotPlayer<? extends Player> player : this.getPlayerManager()
|
||||||
if (player.getPlatformPlayer() == null || !player.getPlatformPlayer().isOnline()) {
|
.getPlayers()) {
|
||||||
|
if (player.getPlatformPlayer() == null || !player.getPlatformPlayer()
|
||||||
|
.isOnline()) {
|
||||||
this.getPlayerManager().removePlayer(player);
|
this.getPlayerManager().removePlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -626,7 +641,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
// Now fetch names for all known UUIDs
|
// Now fetch names for all known UUIDs
|
||||||
final int totalSize = uuidQueue.size();
|
final int totalSize = uuidQueue.size();
|
||||||
int read = 0;
|
int read = 0;
|
||||||
logger.info("[P2] (UUID) PlotSquared will fetch UUIDs in groups of {}", Settings.UUID.BACKGROUND_LIMIT);
|
logger.info("[P2] (UUID) PlotSquared will fetch UUIDs in groups of {}",
|
||||||
|
Settings.UUID.BACKGROUND_LIMIT);
|
||||||
final List<UUID> uuidList = new ArrayList<>(Settings.UUID.BACKGROUND_LIMIT);
|
final List<UUID> uuidList = new ArrayList<>(Settings.UUID.BACKGROUND_LIMIT);
|
||||||
|
|
||||||
// Used to indicate that the second retrieval has been attempted
|
// Used to indicate that the second retrieval has been attempted
|
||||||
@ -659,7 +675,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
// Print progress
|
// Print progress
|
||||||
final double percentage = ((double) read / (double) totalSize) * 100.0D;
|
final double percentage = ((double) read / (double) totalSize) * 100.0D;
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
logger.info("[P2] (UUID) PlotSquared has cached {} of UUIDs", String.format("%.1f%%", percentage));
|
logger.info("[P2] (UUID) PlotSquared has cached {} of UUIDs",
|
||||||
|
String.format("%.1f%%", percentage));
|
||||||
}
|
}
|
||||||
} catch (final InterruptedException | ExecutionException e) {
|
} catch (final InterruptedException | ExecutionException e) {
|
||||||
logger.error("[P2] (UUID) Failed to retrieve last batch. Will try again", e);
|
logger.error("[P2] (UUID) Failed to retrieve last batch. Will try again", e);
|
||||||
@ -845,7 +862,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
if (currentPlotId != null) {
|
if (currentPlotId != null) {
|
||||||
entity.setMetadata("shulkerPlot",
|
entity.setMetadata("shulkerPlot",
|
||||||
new FixedMetadataValue(
|
new FixedMetadataValue(
|
||||||
(Plugin) PlotSquared.platform(), currentPlotId));
|
(Plugin) PlotSquared.platform(),
|
||||||
|
currentPlotId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -970,7 +988,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
if (id != null && id.equalsIgnoreCase("single")) {
|
if (id != null && id.equalsIgnoreCase("single")) {
|
||||||
result = getInjector().getInstance(SingleWorldGenerator.class);
|
result = getInjector().getInstance(SingleWorldGenerator.class);
|
||||||
} else {
|
} else {
|
||||||
result = getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
|
result = getInjector()
|
||||||
|
.getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
|
||||||
if (!PlotSquared.get().setupPlotWorld(worldName, id, result)) {
|
if (!PlotSquared.get().setupPlotWorld(worldName, id, result)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -992,7 +1011,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
return new BukkitPlotGenerator(world, gen, this.plotAreaManager);
|
return new BukkitPlotGenerator(world, gen, this.plotAreaManager);
|
||||||
} else {
|
} else {
|
||||||
return new BukkitPlotGenerator(world, getInjector()
|
return new BukkitPlotGenerator(world, getInjector()
|
||||||
.getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class)), this.plotAreaManager);
|
.getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class)),
|
||||||
|
this.plotAreaManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1035,7 +1055,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
World world = BukkitUtil.getWorld(worldName);
|
World world = BukkitUtil.getWorld(worldName);
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
// create world
|
// create world
|
||||||
ConfigurationSection worldConfig = this.worldConfiguration.getConfigurationSection("worlds." + worldName);
|
ConfigurationSection worldConfig =
|
||||||
|
this.worldConfiguration.getConfigurationSection("worlds." + worldName);
|
||||||
String manager = worldConfig.getString("generator.plugin", getPluginName());
|
String manager = worldConfig.getString("generator.plugin", getPluginName());
|
||||||
PlotAreaBuilder builder = PlotAreaBuilder.newBuilder().plotManager(manager)
|
PlotAreaBuilder builder = PlotAreaBuilder.newBuilder().plotManager(manager)
|
||||||
.generatorName(worldConfig.getString("generator.init", manager))
|
.generatorName(worldConfig.getString("generator.init", manager))
|
||||||
@ -1061,7 +1082,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
if (gen instanceof BukkitPlotGenerator) {
|
if (gen instanceof BukkitPlotGenerator) {
|
||||||
PlotSquared.get().loadWorld(worldName, (BukkitPlotGenerator) gen);
|
PlotSquared.get().loadWorld(worldName, (BukkitPlotGenerator) gen);
|
||||||
} else if (gen != null) {
|
} else if (gen != null) {
|
||||||
PlotSquared.get().loadWorld(worldName, new BukkitPlotGenerator(worldName, gen, this.plotAreaManager));
|
PlotSquared.get().loadWorld(worldName,
|
||||||
|
new BukkitPlotGenerator(worldName, gen, this.plotAreaManager));
|
||||||
} else if (this.worldConfiguration.contains("worlds." + worldName)) {
|
} else if (this.worldConfiguration.contains("worlds." + worldName)) {
|
||||||
PlotSquared.get().loadWorld(worldName, null);
|
PlotSquared.get().loadWorld(worldName, null);
|
||||||
}
|
}
|
||||||
@ -1128,7 +1150,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public com.plotsquared.core.location.World<?> getPlatformWorld(@Nonnull final String worldName) {
|
@Override public com.plotsquared.core.location.World<?> getPlatformWorld(
|
||||||
|
@Nonnull final String worldName) {
|
||||||
return BukkitWorld.of(worldName);
|
return BukkitWorld.of(worldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ import com.plotsquared.core.generator.IndependentPlotGenerator;
|
|||||||
import com.plotsquared.core.location.ChunkWrapper;
|
import com.plotsquared.core.location.ChunkWrapper;
|
||||||
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.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
@ -44,7 +44,7 @@ final class BlockStatePopulator extends BlockPopulator {
|
|||||||
private final IndependentPlotGenerator plotGenerator;
|
private final IndependentPlotGenerator plotGenerator;
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
private LocalBlockQueue queue;
|
private QueueCoordinator queue;
|
||||||
|
|
||||||
public BlockStatePopulator(@Nonnull final IndependentPlotGenerator plotGenerator,
|
public BlockStatePopulator(@Nonnull final IndependentPlotGenerator plotGenerator,
|
||||||
@Nonnull final PlotAreaManager plotAreaManager) {
|
@Nonnull final PlotAreaManager plotAreaManager) {
|
||||||
@ -65,9 +65,9 @@ final class BlockStatePopulator extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
final ChunkWrapper wrap =
|
final ChunkWrapper wrap =
|
||||||
new ChunkWrapper(area.getWorldName(), source.getX(), source.getZ());
|
new ChunkWrapper(area.getWorldName(), source.getX(), source.getZ());
|
||||||
final ScopedLocalBlockQueue chunk = this.queue.getForChunk(wrap.x, wrap.z);
|
final ScopedQueueCoordinator chunk = this.queue.getForChunk(wrap.x, wrap.z);
|
||||||
if (this.plotGenerator.populateChunk(chunk, area)) {
|
if (this.plotGenerator.populateChunk(chunk, area)) {
|
||||||
this.queue.flush();
|
this.queue.enqueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import com.plotsquared.core.generator.SingleWorldGenerator;
|
|||||||
import com.plotsquared.core.location.ChunkWrapper;
|
import com.plotsquared.core.location.ChunkWrapper;
|
||||||
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.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
@ -190,7 +190,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
return result.getChunkData();
|
return result.getChunkData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generate(BlockVector2 loc, World world, ScopedLocalBlockQueue result) {
|
private void generate(BlockVector2 loc, World world, ScopedQueueCoordinator result) {
|
||||||
// Load if improperly loaded
|
// Load if improperly loaded
|
||||||
if (!this.loaded) {
|
if (!this.loaded) {
|
||||||
String name = world.getName();
|
String name = world.getName();
|
||||||
|
@ -31,16 +31,16 @@ import com.plotsquared.core.generator.IndependentPlotGenerator;
|
|||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import org.jetbrains.annotations.Range;
|
import org.jetbrains.annotations.Range;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
final class DelegatePlotGenerator extends IndependentPlotGenerator {
|
final class DelegatePlotGenerator extends IndependentPlotGenerator {
|
||||||
@ -64,7 +64,7 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
|
|||||||
return PlotSquared.platform().getDefaultGenerator().getNewPlotArea(world, id, min, max);
|
return PlotSquared.platform().getDefaultGenerator().getNewPlotArea(world, id, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings) {
|
@Override public void generateChunk(final ScopedQueueCoordinator result, PlotArea settings) {
|
||||||
World world = BukkitUtil.getWorld(this.world);
|
World world = BukkitUtil.getWorld(this.world);
|
||||||
Location min = result.getMin();
|
Location min = result.getMin();
|
||||||
int chunkX = min.getX() >> 4;
|
int chunkX = min.getX() >> 4;
|
||||||
@ -72,8 +72,7 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
|
|||||||
Random random = new Random(MathMan.pair((short) chunkX, (short) chunkZ));
|
Random random = new Random(MathMan.pair((short) chunkX, (short) chunkZ));
|
||||||
try {
|
try {
|
||||||
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
|
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
|
||||||
@Override
|
@Override public void setBiome(@Range(from = 0, to = 15) int x,
|
||||||
public void setBiome(@Range(from = 0, to = 15) int x,
|
|
||||||
@Range(from = 0, to = 15) int z, @Nonnull Biome biome) {
|
@Range(from = 0, to = 15) int z, @Nonnull Biome biome) {
|
||||||
result.setBiome(x, z, BukkitAdapter.adapt(biome));
|
result.setBiome(x, z, BukkitAdapter.adapt(biome));
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
|
|||||||
import com.google.inject.util.Providers;
|
import com.google.inject.util.Providers;
|
||||||
import com.plotsquared.bukkit.BukkitPlatform;
|
import com.plotsquared.bukkit.BukkitPlatform;
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
||||||
import com.plotsquared.bukkit.queue.BukkitLocalQueue;
|
import com.plotsquared.bukkit.queue.BukkitQueueCoordinator;
|
||||||
import com.plotsquared.bukkit.schematic.BukkitSchematicHandler;
|
import com.plotsquared.bukkit.schematic.BukkitSchematicHandler;
|
||||||
import com.plotsquared.bukkit.util.BukkitChunkManager;
|
import com.plotsquared.bukkit.util.BukkitChunkManager;
|
||||||
import com.plotsquared.bukkit.util.BukkitEconHandler;
|
import com.plotsquared.bukkit.util.BukkitEconHandler;
|
||||||
@ -66,9 +66,11 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
@RequiredArgsConstructor public class BukkitModule extends AbstractModule {
|
@RequiredArgsConstructor
|
||||||
|
public class BukkitModule extends AbstractModule {
|
||||||
|
|
||||||
private final BukkitPlatform bukkitPlatform;
|
private final BukkitPlatform bukkitPlatform;
|
||||||
|
|
||||||
@ -76,16 +78,19 @@ import javax.annotation.Nonnull;
|
|||||||
bind(PlayerManager.class).to(BukkitPlayerManager.class);
|
bind(PlayerManager.class).to(BukkitPlayerManager.class);
|
||||||
bind(JavaPlugin.class).toInstance(bukkitPlatform);
|
bind(JavaPlugin.class).toInstance(bukkitPlatform);
|
||||||
bind(PlotPlatform.class).toInstance(bukkitPlatform);
|
bind(PlotPlatform.class).toInstance(bukkitPlatform);
|
||||||
bind(IndependentPlotGenerator.class).annotatedWith(DefaultGenerator.class).to(HybridGen.class);
|
bind(IndependentPlotGenerator.class).annotatedWith(DefaultGenerator.class)
|
||||||
|
.to(HybridGen.class);
|
||||||
// Console actor
|
// Console actor
|
||||||
@Nonnull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
@Nonnull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||||
WorldEditPlugin wePlugin = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
WorldEditPlugin wePlugin =
|
||||||
bind(Actor.class).annotatedWith(ConsoleActor.class).toInstance(wePlugin.wrapCommandSender(console));
|
((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
||||||
|
bind(Actor.class).annotatedWith(ConsoleActor.class)
|
||||||
|
.toInstance(wePlugin.wrapCommandSender(console));
|
||||||
bind(InventoryUtil.class).to(BukkitInventoryUtil.class);
|
bind(InventoryUtil.class).to(BukkitInventoryUtil.class);
|
||||||
bind(SetupUtils.class).to(BukkitSetupUtils.class);
|
bind(SetupUtils.class).to(BukkitSetupUtils.class);
|
||||||
bind(WorldUtil.class).to(BukkitUtil.class);
|
bind(WorldUtil.class).to(BukkitUtil.class);
|
||||||
bind(GlobalBlockQueue.class).toInstance(new GlobalBlockQueue(
|
bind(GlobalBlockQueue.class).toInstance(new GlobalBlockQueue(
|
||||||
QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class), 1, Settings.QUEUE.TARGET_TIME));
|
QueueProvider.of(BukkitQueueCoordinator.class, BukkitQueueCoordinator.class)));
|
||||||
bind(ChunkManager.class).to(BukkitChunkManager.class);
|
bind(ChunkManager.class).to(BukkitChunkManager.class);
|
||||||
bind(RegionManager.class).to(BukkitRegionManager.class);
|
bind(RegionManager.class).to(BukkitRegionManager.class);
|
||||||
bind(SchematicHandler.class).to(BukkitSchematicHandler.class);
|
bind(SchematicHandler.class).to(BukkitSchematicHandler.class);
|
||||||
@ -108,7 +113,8 @@ import javax.annotation.Nonnull;
|
|||||||
bind(PermHandler.class).toProvider(Providers.of(null));
|
bind(PermHandler.class).toProvider(Providers.of(null));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final BukkitEconHandler bukkitEconHandler = new BukkitEconHandler(bukkitPermHandler);
|
final BukkitEconHandler bukkitEconHandler =
|
||||||
|
new BukkitEconHandler(bukkitPermHandler);
|
||||||
bind(EconHandler.class).toInstance(bukkitEconHandler);
|
bind(EconHandler.class).toInstance(bukkitEconHandler);
|
||||||
} catch (final Exception ignored) {
|
} catch (final Exception ignored) {
|
||||||
bind(EconHandler.class).toProvider(Providers.of(null));
|
bind(EconHandler.class).toProvider(Providers.of(null));
|
||||||
|
@ -53,6 +53,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
|||||||
|
|
||||||
private final World world;
|
private final World world;
|
||||||
private final SideEffectSet sideEffectSet;
|
private final SideEffectSet sideEffectSet;
|
||||||
|
private Runnable whenDone;
|
||||||
|
|
||||||
public BukkitQueueCoordinator(World world) {
|
public BukkitQueueCoordinator(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -74,7 +75,8 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
|||||||
@Override public boolean enqueue() {
|
@Override public boolean enqueue() {
|
||||||
BukkitChunkCoordinator.builder().inWorld(BukkitAdapter.adapt(world))
|
BukkitChunkCoordinator.builder().inWorld(BukkitAdapter.adapt(world))
|
||||||
.withChunks(getBlockChunks().keySet()).withInitialBatchSize(3).withMaxIterationTime(40)
|
.withChunks(getBlockChunks().keySet()).withInitialBatchSize(3).withMaxIterationTime(40)
|
||||||
.withThrowableConsumer(Throwable::printStackTrace).withConsumer(chunk -> {
|
.withThrowableConsumer(Throwable::printStackTrace).withFinalAction(whenDone)
|
||||||
|
.withConsumer(chunk -> {
|
||||||
LocalChunk localChunk =
|
LocalChunk localChunk =
|
||||||
getBlockChunks().get(BlockVector2.at(chunk.getX(), chunk.getZ()));
|
getBlockChunks().get(BlockVector2.at(chunk.getX(), chunk.getZ()));
|
||||||
if (localChunk == null) {
|
if (localChunk == null) {
|
||||||
@ -150,8 +152,8 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
|||||||
worldObj.setBlock(blockVector3, block, sideEffectSet);
|
worldObj.setBlock(blockVector3, block, sideEffectSet);
|
||||||
} catch (WorldEditException ignored) {
|
} catch (WorldEditException ignored) {
|
||||||
StateWrapper sw = new StateWrapper(tag);
|
StateWrapper sw = new StateWrapper(tag);
|
||||||
sw.restoreTag(worldObj.getName(), blockVector3.getX(), blockVector3.getY(),
|
sw.restoreTag(worldObj.getName(), blockVector3.getX(),
|
||||||
blockVector3.getZ());
|
blockVector3.getY(), blockVector3.getZ());
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -159,6 +161,10 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
|
|||||||
return super.enqueue();
|
return super.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void setCompleteTask(Runnable whenDone) {
|
||||||
|
this.whenDone = whenDone;
|
||||||
|
}
|
||||||
|
|
||||||
private void setMaterial(@Nonnull final BlockState plotBlock, @Nonnull final Block block) {
|
private void setMaterial(@Nonnull final BlockState plotBlock, @Nonnull final Block block) {
|
||||||
Material material = BukkitAdapter.adapt(plotBlock.getBlockType());
|
Material material = BukkitAdapter.adapt(plotBlock.getBlockType());
|
||||||
block.setType(material, false);
|
block.setType(material, false);
|
||||||
|
@ -30,7 +30,7 @@ import com.plotsquared.bukkit.util.BukkitBlockUtil;
|
|||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.core.location.ChunkWrapper;
|
import com.plotsquared.core.location.ChunkWrapper;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.PatternUtil;
|
import com.plotsquared.core.util.PatternUtil;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
@ -41,16 +41,17 @@ import com.sk89q.worldedit.world.block.BlockState;
|
|||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class GenChunk extends ScopedLocalBlockQueue {
|
public class GenChunk extends ScopedQueueCoordinator {
|
||||||
|
|
||||||
public final Biome[] biomes;
|
public final Biome[] biomes;
|
||||||
public BlockState[][] result;
|
public BlockState[][] result;
|
||||||
@ -191,16 +192,18 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
|||||||
return chunk == null ? chunkZ : chunk.getZ();
|
return chunk == null ? chunkZ : chunk.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String getWorld() {
|
@Override public com.sk89q.worldedit.world.World getWorld() {
|
||||||
return chunk == null ? world : chunk.getWorld().getName();
|
return chunk == null ?
|
||||||
|
BukkitAdapter.adapt(Bukkit.getWorld(world)) :
|
||||||
|
BukkitAdapter.adapt(chunk.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Location getMax() {
|
@Override public Location getMax() {
|
||||||
return Location.at(getWorld(), 15 + (getX() << 4), 255, 15 + (getZ() << 4));
|
return Location.at(getWorld().getName(), 15 + (getX() << 4), 255, 15 + (getZ() << 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Location getMin() {
|
@Override public Location getMin() {
|
||||||
return Location.at(getWorld(), getX() << 4, 0, getZ() << 4);
|
return Location.at(getWorld().getName(), getX() << 4, 0, getZ() << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenChunk clone() {
|
public GenChunk clone() {
|
||||||
|
@ -27,7 +27,7 @@ package com.plotsquared.bukkit.schematic;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
@ -43,7 +43,7 @@ import javax.annotation.Nonnull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean restoreTile(LocalBlockQueue queue, CompoundTag ct, int x, int y, int z) {
|
public boolean restoreTile(QueueCoordinator queue, CompoundTag ct, int x, int y, int z) {
|
||||||
return new StateWrapper(ct).restoreTag(queue.getWorld(), x, y, z);
|
return new StateWrapper(ct).restoreTag(queue.getWorld().getName(), x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ package com.plotsquared.bukkit.util;
|
|||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.listener.WEExtent;
|
import com.plotsquared.core.listener.WEExtent;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.entity.EntityCategories;
|
import com.plotsquared.core.util.entity.EntityCategories;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
@ -54,7 +54,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_MOB;
|
|||||||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER;
|
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER;
|
||||||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||||
|
|
||||||
@Singleton public class BukkitChunkManager extends ChunkManager {
|
@Singleton
|
||||||
|
public class BukkitChunkManager extends ChunkManager {
|
||||||
|
|
||||||
public static boolean isIn(CuboidRegion region, int x, int z) {
|
public static boolean isIn(CuboidRegion region, int x, int z) {
|
||||||
return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX()
|
return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX()
|
||||||
@ -79,8 +80,10 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
BukkitWorld bukkitWorld1 = new BukkitWorld(world1);
|
BukkitWorld bukkitWorld1 = new BukkitWorld(world1);
|
||||||
BukkitWorld bukkitWorld2 = new BukkitWorld(world2);
|
BukkitWorld bukkitWorld2 = new BukkitWorld(world2);
|
||||||
|
|
||||||
LocalBlockQueue queue1 = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName1, false);
|
QueueCoordinator queue1 =
|
||||||
LocalBlockQueue queue2 = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName2, false);
|
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName1, false);
|
||||||
|
QueueCoordinator queue2 =
|
||||||
|
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName2, false);
|
||||||
|
|
||||||
for (int x = Math.max(r1.getMinimumPoint().getX(), sx);
|
for (int x = Math.max(r1.getMinimumPoint().getX(), sx);
|
||||||
x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) {
|
x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) {
|
||||||
|
@ -35,8 +35,8 @@ import com.plotsquared.core.location.PlotLoc;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
import com.plotsquared.core.util.RegionManager;
|
||||||
@ -78,9 +78,11 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_MOB;
|
|||||||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER;
|
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER;
|
||||||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||||
|
|
||||||
@Singleton public class BukkitRegionManager extends RegionManager {
|
@Singleton
|
||||||
|
public class BukkitRegionManager extends RegionManager {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitRegionManager.class.getSimpleName());
|
private static final Logger logger =
|
||||||
|
LoggerFactory.getLogger("P2/" + BukkitRegionManager.class.getSimpleName());
|
||||||
|
|
||||||
@Inject public BukkitRegionManager(@Nonnull final ChunkManager chunkManager) {
|
@Inject public BukkitRegionManager(@Nonnull final ChunkManager chunkManager) {
|
||||||
super(chunkManager);
|
super(chunkManager);
|
||||||
@ -102,10 +104,12 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
final Semaphore semaphore = new Semaphore(1);
|
final Semaphore semaphore = new Semaphore(1);
|
||||||
try {
|
try {
|
||||||
semaphore.acquire();
|
semaphore.acquire();
|
||||||
Bukkit.getScheduler().runTask(BukkitPlatform.getPlugin(BukkitPlatform.class), () -> {
|
Bukkit.getScheduler()
|
||||||
|
.runTask(BukkitPlatform.getPlugin(BukkitPlatform.class), () -> {
|
||||||
for (Chunk chunk : Objects.requireNonNull(Bukkit.getWorld(world))
|
for (Chunk chunk : Objects.requireNonNull(Bukkit.getWorld(world))
|
||||||
.getLoadedChunks()) {
|
.getLoadedChunks()) {
|
||||||
BlockVector2 loc = BlockVector2.at(chunk.getX() >> 5, chunk.getZ() >> 5);
|
BlockVector2 loc =
|
||||||
|
BlockVector2.at(chunk.getX() >> 5, chunk.getZ() >> 5);
|
||||||
chunks.add(loc);
|
chunks.add(loc);
|
||||||
}
|
}
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
@ -198,8 +202,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public boolean copyRegion(Location pos1, Location pos2, Location newPos,
|
||||||
public boolean copyRegion(Location pos1, Location pos2, Location newPos,
|
|
||||||
final Runnable whenDone) {
|
final Runnable whenDone) {
|
||||||
final int relX = newPos.getX() - pos1.getX();
|
final int relX = newPos.getX() - pos1.getX();
|
||||||
final int relZ = newPos.getZ() - pos1.getZ();
|
final int relZ = newPos.getZ() - pos1.getZ();
|
||||||
@ -213,7 +216,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
assert oldWorld != null;
|
assert oldWorld != null;
|
||||||
final String newWorldName = newWorld.getName();
|
final String newWorldName = newWorld.getName();
|
||||||
final ContentMap map = new ContentMap();
|
final ContentMap map = new ContentMap();
|
||||||
final LocalBlockQueue queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(newWorldName, false);
|
final QueueCoordinator queue =
|
||||||
|
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(newWorldName, false);
|
||||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||||
@Override public void run(int[] value) {
|
@Override public void run(int[] value) {
|
||||||
int bx = value[2];
|
int bx = value[2];
|
||||||
@ -243,18 +247,17 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
queue.setCompleteTask(() -> {
|
||||||
PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(() -> {
|
|
||||||
//map.restoreBlocks(newWorld, 0, 0);
|
//map.restoreBlocks(newWorld, 0, 0);
|
||||||
map.restoreEntities(newWorld, relX, relZ);
|
map.restoreEntities(newWorld, relX, relZ);
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
});
|
});
|
||||||
|
queue.enqueue();
|
||||||
}, 5);
|
}, 5);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public boolean regenerateRegion(final Location pos1, final Location pos2,
|
||||||
public boolean regenerateRegion(final Location pos1, final Location pos2,
|
|
||||||
final boolean ignoreAugment, final Runnable whenDone) {
|
final boolean ignoreAugment, final Runnable whenDone) {
|
||||||
final String world = pos1.getWorldName();
|
final String world = pos1.getWorldName();
|
||||||
|
|
||||||
@ -292,8 +295,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
if (chunkObj == null) {
|
if (chunkObj == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final LocalBlockQueue queue = PlotSquared.platform().getGlobalBlockQueue()
|
final QueueCoordinator queue =
|
||||||
.getNewQueue(world, false);
|
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false);
|
||||||
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
|
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
|
||||||
AugmentedUtils.bypass(ignoreAugment,
|
AugmentedUtils.bypass(ignoreAugment,
|
||||||
() -> queue.regenChunkSafe(chunk.getX(), chunk.getZ()));
|
() -> queue.regenChunkSafe(chunk.getX(), chunk.getZ()));
|
||||||
@ -362,8 +365,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
||||||
map.saveEntitiesOut(chunkObj, currentPlotClear);
|
map.saveEntitiesOut(chunkObj, currentPlotClear);
|
||||||
AugmentedUtils.bypass(ignoreAugment, () -> ChunkManager
|
AugmentedUtils.bypass(ignoreAugment, () -> ChunkManager
|
||||||
.setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
|
.setChunkInPlotArea(null, new RunnableVal<ScopedQueueCoordinator>() {
|
||||||
@Override public void run(ScopedLocalBlockQueue value) {
|
@Override public void run(ScopedQueueCoordinator value) {
|
||||||
Location min = value.getMin();
|
Location min = value.getMin();
|
||||||
int bx = min.getX();
|
int bx = min.getX();
|
||||||
int bz = min.getZ();
|
int bz = min.getZ();
|
||||||
@ -429,8 +432,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public void swap(Location bot1, Location top1, Location bot2, Location top2,
|
||||||
public void swap(Location bot1, Location top1, Location bot2, Location top2,
|
|
||||||
final Runnable whenDone) {
|
final Runnable whenDone) {
|
||||||
CuboidRegion region1 =
|
CuboidRegion region1 =
|
||||||
RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
|
RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
|
||||||
@ -468,13 +470,14 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
region.getMinimumPoint().getY(), region.getMinimumPoint().getZ() - extendBiome);
|
region.getMinimumPoint().getY(), region.getMinimumPoint().getZ() - extendBiome);
|
||||||
Location pos2 = Location.at(world, region.getMaximumPoint().getX() + extendBiome,
|
Location pos2 = Location.at(world, region.getMaximumPoint().getX() + extendBiome,
|
||||||
region.getMaximumPoint().getY(), region.getMaximumPoint().getZ() + extendBiome);
|
region.getMaximumPoint().getY(), region.getMaximumPoint().getZ() + extendBiome);
|
||||||
final LocalBlockQueue queue = PlotSquared.platform().getGlobalBlockQueue()
|
final QueueCoordinator queue =
|
||||||
.getNewQueue(world, false);
|
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false);
|
||||||
|
|
||||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||||
@Override public void run(int[] value) {
|
@Override public void run(int[] value) {
|
||||||
BlockVector2 loc = BlockVector2.at(value[0], value[1]);
|
BlockVector2 loc = BlockVector2.at(value[0], value[1]);
|
||||||
PlotSquared.platform().getChunkManager().loadChunk(world, loc, false).thenRun(() -> {
|
PlotSquared.platform().getChunkManager().loadChunk(world, loc, false)
|
||||||
|
.thenRun(() -> {
|
||||||
MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome);
|
MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome);
|
||||||
queue.refreshChunk(value[0], value[1]);
|
queue.refreshChunk(value[0], value[1]);
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,7 @@ package com.plotsquared.core.command;
|
|||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
@ -50,12 +50,13 @@ public class Relight extends Command {
|
|||||||
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
|
public CompletableFuture<Boolean> execute(final PlotPlayer<?> player, String[] args,
|
||||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||||
RunnableVal2<Command, CommandResult> whenDone) {
|
RunnableVal2<Command, CommandResult> whenDone) {
|
||||||
final Plot plot = player.getCurrentPlot();
|
player.sendMessage("Not implemented.");
|
||||||
|
/* final Plot plot = player.getCurrentPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
Captions.NOT_IN_PLOT.send(player);
|
Captions.NOT_IN_PLOT.send(player);
|
||||||
return CompletableFuture.completedFuture(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
}
|
}
|
||||||
final LocalBlockQueue queue = plot.getArea().getQueue(false);
|
final QueueCoordinator queue = plot.getArea().getQueue(false);
|
||||||
ChunkManager.chunkTask(plot, new RunnableVal<int[]>() {
|
ChunkManager.chunkTask(plot, new RunnableVal<int[]>() {
|
||||||
@Override public void run(int[] value) {
|
@Override public void run(int[] value) {
|
||||||
queue.fixChunkLighting(value[0], value[1]);
|
queue.fixChunkLighting(value[0], value[1]);
|
||||||
@ -63,7 +64,7 @@ public class Relight extends Command {
|
|||||||
}, () -> {
|
}, () -> {
|
||||||
plot.refreshChunks();
|
plot.refreshChunks();
|
||||||
Captions.SET_BLOCK_ACTION_FINISHED.send(player);
|
Captions.SET_BLOCK_ACTION_FINISHED.send(player);
|
||||||
}, 5);
|
}, 5);*/
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(true);
|
return CompletableFuture.completedFuture(true);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.plot.expiration.ExpireManager;
|
import com.plotsquared.core.plot.expiration.ExpireManager;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
import com.plotsquared.core.util.RegionManager;
|
||||||
import com.plotsquared.core.util.RegionUtil;
|
import com.plotsquared.core.util.RegionUtil;
|
||||||
@ -188,7 +188,7 @@ public class Trim extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final LocalBlockQueue queue = blockQueue.getNewQueue(world, false);
|
final QueueCoordinator queue = blockQueue.getNewQueue(world, false);
|
||||||
TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() {
|
TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() {
|
||||||
@Override public void run(BlockVector2 value) {
|
@Override public void run(BlockVector2 value) {
|
||||||
queue.regenChunk(value.getX(), value.getZ());
|
queue.regenChunk(value.getX(), value.getZ());
|
||||||
|
@ -31,17 +31,17 @@ import com.plotsquared.core.plot.PlotArea;
|
|||||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.queue.AreaBoundDelegateLocalBlockQueue;
|
import com.plotsquared.core.queue.AreaBoundDelegateQueueCoordinator;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocationOffsetDelegateQueueCoordinator;
|
||||||
import com.plotsquared.core.queue.LocationOffsetDelegateLocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.RegionUtil;
|
import com.plotsquared.core.util.RegionUtil;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class AugmentedUtils {
|
public class AugmentedUtils {
|
||||||
@ -55,7 +55,7 @@ public class AugmentedUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean generate(@Nullable Object chunkObject, @Nonnull final String world,
|
public static boolean generate(@Nullable Object chunkObject, @Nonnull final String world,
|
||||||
final int chunkX, final int chunkZ, LocalBlockQueue queue) {
|
final int chunkX, final int chunkZ, QueueCoordinator queue) {
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,8 @@ public class AugmentedUtils {
|
|||||||
// entire chunk
|
// entire chunk
|
||||||
CuboidRegion region = RegionUtil.createRegion(blockX, blockX + 15, blockZ, blockZ + 15);
|
CuboidRegion region = RegionUtil.createRegion(blockX, blockX + 15, blockZ, blockZ + 15);
|
||||||
// Query for plot areas in the chunk
|
// Query for plot areas in the chunk
|
||||||
final Set<PlotArea> areas = PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world, region);
|
final Set<PlotArea> areas =
|
||||||
|
PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world, region);
|
||||||
if (areas.isEmpty()) {
|
if (areas.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -89,7 +90,7 @@ public class AugmentedUtils {
|
|||||||
queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false);
|
queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false);
|
||||||
queue.setChunkObject(chunkObject);
|
queue.setChunkObject(chunkObject);
|
||||||
}
|
}
|
||||||
LocalBlockQueue primaryMask;
|
QueueCoordinator primaryMask;
|
||||||
// coordinates
|
// coordinates
|
||||||
int relativeBottomX;
|
int relativeBottomX;
|
||||||
int relativeBottomZ;
|
int relativeBottomZ;
|
||||||
@ -102,14 +103,14 @@ public class AugmentedUtils {
|
|||||||
relativeTopX = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX);
|
relativeTopX = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX);
|
||||||
relativeTopZ = Math.min(15, area.getRegion().getMaximumPoint().getZ() - blockZ);
|
relativeTopZ = Math.min(15, area.getRegion().getMaximumPoint().getZ() - blockZ);
|
||||||
|
|
||||||
primaryMask = new AreaBoundDelegateLocalBlockQueue(area, queue);
|
primaryMask = new AreaBoundDelegateQueueCoordinator(area, queue);
|
||||||
} else {
|
} else {
|
||||||
relativeBottomX = relativeBottomZ = 0;
|
relativeBottomX = relativeBottomZ = 0;
|
||||||
relativeTopX = relativeTopZ = 15;
|
relativeTopX = relativeTopZ = 15;
|
||||||
primaryMask = queue;
|
primaryMask = queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalBlockQueue secondaryMask;
|
QueueCoordinator secondaryMask;
|
||||||
BlockState air = BlockTypes.AIR.getDefaultState();
|
BlockState air = BlockTypes.AIR.getDefaultState();
|
||||||
if (area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
if (area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
||||||
PlotManager manager = area.getPlotManager();
|
PlotManager manager = area.getPlotManager();
|
||||||
@ -133,7 +134,7 @@ public class AugmentedUtils {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
generationResult = true;
|
generationResult = true;
|
||||||
secondaryMask = new LocationOffsetDelegateLocalBlockQueue(canPlace, blockX, blockZ,
|
secondaryMask = new LocationOffsetDelegateQueueCoordinator(canPlace, blockX, blockZ,
|
||||||
primaryMask);
|
primaryMask);
|
||||||
} else {
|
} else {
|
||||||
secondaryMask = primaryMask;
|
secondaryMask = primaryMask;
|
||||||
@ -151,15 +152,15 @@ public class AugmentedUtils {
|
|||||||
secondaryMask.setChunkObject(chunkObject);
|
secondaryMask.setChunkObject(chunkObject);
|
||||||
secondaryMask.setForceSync(true);
|
secondaryMask.setForceSync(true);
|
||||||
|
|
||||||
ScopedLocalBlockQueue scoped =
|
ScopedQueueCoordinator scoped =
|
||||||
new ScopedLocalBlockQueue(secondaryMask, Location.at(world, blockX, 0, blockZ),
|
new ScopedQueueCoordinator(secondaryMask, Location.at(world, blockX, 0, blockZ),
|
||||||
Location.at(world, blockX + 15, 255, blockZ + 15));
|
Location.at(world, blockX + 15, 255, blockZ + 15));
|
||||||
generator.generateChunk(scoped, area);
|
generator.generateChunk(scoped, area);
|
||||||
generator.populateChunk(scoped, area);
|
generator.populateChunk(scoped, area);
|
||||||
}
|
}
|
||||||
if (queue != null) {
|
if (queue != null) {
|
||||||
queue.setForceSync(true);
|
queue.setForceSync(true);
|
||||||
queue.flush();
|
queue.enqueue();
|
||||||
}
|
}
|
||||||
return generationResult;
|
return generationResult;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ import com.plotsquared.core.plot.BlockBucket;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.BlockUtil;
|
import com.plotsquared.core.util.BlockUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
import com.plotsquared.core.util.RegionManager;
|
||||||
@ -136,7 +136,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location[] corners = plot.getCorners();
|
Location[] corners = plot.getCorners();
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
|
|
||||||
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
||||||
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
||||||
@ -157,7 +157,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||||
Location bottom = plot.getBottomAbs();
|
Location bottom = plot.getBottomAbs();
|
||||||
Location top = plot.getExtendedTopAbs();
|
Location top = plot.getExtendedTopAbs();
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
int maxY = classicPlotWorld.getPlotManager().getWorldHeight();
|
int maxY = classicPlotWorld.getPlotManager().getWorldHeight();
|
||||||
if (!plot.getMerged(Direction.NORTH)) {
|
if (!plot.getMerged(Direction.NORTH)) {
|
||||||
int z = bottom.getZ();
|
int z = bottom.getZ();
|
||||||
@ -221,7 +221,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
|
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
|
||||||
plot.getMerged(Direction.NORTH) ? 0 : 1);
|
plot.getMerged(Direction.NORTH) ? 0 : 1);
|
||||||
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
if (!plot.getMerged(Direction.NORTH)) {
|
if (!plot.getMerged(Direction.NORTH)) {
|
||||||
int z = bot.getZ();
|
int z = bot.getZ();
|
||||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||||
@ -274,7 +274,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
|
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
|
||||||
plot.getMerged(Direction.NORTH) ? 0 : 1);
|
plot.getMerged(Direction.NORTH) ? 0 : 1);
|
||||||
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
int y = classicPlotWorld.WALL_HEIGHT + 1;
|
int y = classicPlotWorld.WALL_HEIGHT + 1;
|
||||||
if (!plot.getMerged(Direction.NORTH)) {
|
if (!plot.getMerged(Direction.NORTH)) {
|
||||||
int z = bot.getZ();
|
int z = bot.getZ();
|
||||||
@ -315,7 +315,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||||
int sz = pos1.getZ() - 2;
|
int sz = pos1.getZ() - 2;
|
||||||
int ez = pos2.getZ() + 2;
|
int ez = pos2.getZ() + 2;
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
int maxY = getWorldHeight();
|
int maxY = getWorldHeight();
|
||||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
||||||
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz + 1),
|
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz + 1),
|
||||||
@ -353,7 +353,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||||
int sx = pos1.getX() - 2;
|
int sx = pos1.getX() - 2;
|
||||||
int ex = pos2.getX() + 2;
|
int ex = pos2.getX() + 2;
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1,
|
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx + 1,
|
||||||
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
||||||
Location.at(classicPlotWorld.getWorldName(), ex - 1,
|
Location.at(classicPlotWorld.getWorldName(), ex - 1,
|
||||||
@ -390,7 +390,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||||
int sz = pos2.getZ() + 1;
|
int sz = pos2.getZ() + 1;
|
||||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
queue.setCuboid(
|
queue.setCuboid(
|
||||||
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.ROAD_HEIGHT + 1,
|
Location.at(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.ROAD_HEIGHT + 1,
|
||||||
sz + 1), Location.at(classicPlotWorld.getWorldName(), ex - 1,
|
sz + 1), Location.at(classicPlotWorld.getWorldName(), ex - 1,
|
||||||
@ -412,7 +412,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||||
int sz = pos1.getZ() - 1;
|
int sz = pos1.getZ() - 1;
|
||||||
int ez = pos2.getZ() + 1;
|
int ez = pos2.getZ() + 1;
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
||||||
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
||||||
Location.at(classicPlotWorld.getWorldName(), ex,
|
Location.at(classicPlotWorld.getWorldName(), ex,
|
||||||
@ -435,7 +435,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||||
int sx = pos1.getX() - 1;
|
int sx = pos1.getX() - 1;
|
||||||
int ex = pos2.getX() + 1;
|
int ex = pos2.getX() + 1;
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
||||||
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
||||||
Location.at(classicPlotWorld.getWorldName(), ex,
|
Location.at(classicPlotWorld.getWorldName(), ex,
|
||||||
@ -457,7 +457,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||||
int sz = location.getZ() + 1;
|
int sz = location.getZ() + 1;
|
||||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
QueueCoordinator queue = classicPlotWorld.getQueue(false);
|
||||||
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
queue.setCuboid(Location.at(classicPlotWorld.getWorldName(), sx,
|
||||||
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz),
|
||||||
Location.at(classicPlotWorld.getWorldName(), ex,
|
Location.at(classicPlotWorld.getWorldName(), ex,
|
||||||
|
@ -33,7 +33,7 @@ import com.plotsquared.core.inject.factory.HybridPlotWorldFactory;
|
|||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
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;
|
||||||
@ -52,7 +52,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
return PlotSquared.platform().getPluginName();
|
return PlotSquared.platform().getPluginName();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX,
|
private void placeSchem(HybridPlotWorld world, ScopedQueueCoordinator result, short relativeX,
|
||||||
short relativeZ, int x, int z, boolean isRoad) {
|
short relativeZ, int x, int z, boolean isRoad) {
|
||||||
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
|
||||||
@ -76,7 +76,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateChunk(@Nonnull ScopedLocalBlockQueue result, @Nonnull PlotArea settings) {
|
public void generateChunk(@Nonnull ScopedQueueCoordinator result, @Nonnull PlotArea settings) {
|
||||||
Preconditions.checkNotNull(result, "result cannot be null");
|
Preconditions.checkNotNull(result, "result cannot be null");
|
||||||
Preconditions.checkNotNull(settings, "settings cannot be null");
|
Preconditions.checkNotNull(settings, "settings cannot be null");
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.FileBytes;
|
import com.plotsquared.core.util.FileBytes;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
@ -47,8 +47,8 @@ import com.sk89q.worldedit.world.block.BaseBlock;
|
|||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -106,20 +106,22 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
PlotId id2 = new PlotId(id.x + 1, id.y);
|
PlotId id2 = new PlotId(id.x + 1, id.y);
|
||||||
Location bot = getPlotBottomLocAbs(id2);
|
Location bot = getPlotBottomLocAbs(id2);
|
||||||
Location top = getPlotTopLocAbs(id);
|
Location top = getPlotTopLocAbs(id);
|
||||||
Location pos1 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
|
Location pos1 =
|
||||||
Location pos2 = Location.at(hybridPlotWorld.getWorldName(), bot.getX(),
|
Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1, 0, bot.getZ() - 1);
|
||||||
Math.min(getWorldHeight(), 255), top.getZ() + 1);
|
Location pos2 = Location
|
||||||
|
.at(hybridPlotWorld.getWorldName(), bot.getX(), Math.min(getWorldHeight(), 255),
|
||||||
|
top.getZ() + 1);
|
||||||
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
|
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
|
||||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
QueueCoordinator queue = hybridPlotWorld.getQueue(false);
|
||||||
createSchemAbs(queue, pos1, pos2, true);
|
createSchemAbs(queue, pos1, pos2, true);
|
||||||
queue.enqueue();
|
queue.enqueue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSchemAbs(LocalBlockQueue queue, Location pos1, Location pos2,
|
private void createSchemAbs(QueueCoordinator queue, Location pos1, Location pos2,
|
||||||
boolean isRoad) {
|
boolean isRoad) {
|
||||||
int size = hybridPlotWorld.SIZE;
|
int size = hybridPlotWorld.SIZE;
|
||||||
int minY;
|
int minY;
|
||||||
@ -167,14 +169,16 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
PlotId id2 = new PlotId(id.x, id.y + 1);
|
PlotId id2 = new PlotId(id.x, id.y + 1);
|
||||||
Location bot = getPlotBottomLocAbs(id2);
|
Location bot = getPlotBottomLocAbs(id2);
|
||||||
Location top = getPlotTopLocAbs(id);
|
Location top = getPlotTopLocAbs(id);
|
||||||
Location pos1 = Location.at(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
|
Location pos1 =
|
||||||
Location pos2 = Location.at(hybridPlotWorld.getWorldName(), top.getX() + 1,
|
Location.at(hybridPlotWorld.getWorldName(), bot.getX() - 1, 0, top.getZ() + 1);
|
||||||
Math.min(getWorldHeight(), 255), bot.getZ());
|
Location pos2 = Location
|
||||||
|
.at(hybridPlotWorld.getWorldName(), top.getX() + 1, Math.min(getWorldHeight(), 255),
|
||||||
|
bot.getZ());
|
||||||
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
|
MainUtil.resetBiome(hybridPlotWorld, pos1, pos2);
|
||||||
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
QueueCoordinator queue = hybridPlotWorld.getQueue(false);
|
||||||
createSchemAbs(queue, pos1, pos2, true);
|
createSchemAbs(queue, pos1, pos2, true);
|
||||||
queue.enqueue();
|
queue.enqueue();
|
||||||
return true;
|
return true;
|
||||||
@ -186,7 +190,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
PlotId id2 = new PlotId(id.x + 1, id.y + 1);
|
PlotId id2 = new PlotId(id.x + 1, id.y + 1);
|
||||||
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
|
Location pos1 = getPlotTopLocAbs(id).add(1, 0, 1).withY(0);
|
||||||
Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
|
Location pos2 = getPlotBottomLocAbs(id2).withY(Math.min(getWorldHeight(), 255));
|
||||||
LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
QueueCoordinator queue = hybridPlotWorld.getQueue(false);
|
||||||
createSchemAbs(queue, pos1, pos2, true);
|
createSchemAbs(queue, pos1, pos2, true);
|
||||||
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
createSchemAbs(queue, pos1, pos2, true);
|
createSchemAbs(queue, pos1, pos2, true);
|
||||||
@ -228,7 +232,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final BiomeType biome = hybridPlotWorld.getPlotBiome();
|
final BiomeType biome = hybridPlotWorld.getPlotBiome();
|
||||||
final LocalBlockQueue queue = hybridPlotWorld.getQueue(false);
|
final QueueCoordinator queue = hybridPlotWorld.getQueue(false);
|
||||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||||
@Override public void run(int[] value) {
|
@Override public void run(int[] value) {
|
||||||
// If the chunk isn't near the edge and it isn't an augmented world we can just regen the whole chunk
|
// If the chunk isn't near the edge and it isn't an augmented world we can just regen the whole chunk
|
||||||
@ -257,14 +261,14 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
pastePlotSchematic(queue, bot, top);
|
pastePlotSchematic(queue, bot, top);
|
||||||
}
|
}
|
||||||
}, () -> {
|
}, () -> {
|
||||||
queue.enqueue();
|
|
||||||
// And notify whatever called this when plot clearing is done
|
// And notify whatever called this when plot clearing is done
|
||||||
PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(whenDone);
|
queue.setCompleteTask(whenDone);
|
||||||
|
queue.enqueue();
|
||||||
}, 10);
|
}, 10);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pastePlotSchematic(LocalBlockQueue queue, Location bottom, Location top) {
|
public void pastePlotSchematic(QueueCoordinator queue, Location bottom, Location top) {
|
||||||
if (!hybridPlotWorld.PLOT_SCHEMATIC) {
|
if (!hybridPlotWorld.PLOT_SCHEMATIC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -42,9 +42,9 @@ import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
|||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
import com.plotsquared.core.plot.flag.implementations.AnalysisFlag;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.queue.ChunkBlockQueue;
|
import com.plotsquared.core.queue.ChunkQueueCoordinator;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
@ -128,7 +128,7 @@ public class HybridUtils {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
final LocalBlockQueue queue = blockQueue.getNewQueue(world, false);
|
final QueueCoordinator queue = blockQueue.getNewQueue(world, false);
|
||||||
|
|
||||||
final BlockVector3 bot = region.getMinimumPoint();
|
final BlockVector3 bot = region.getMinimumPoint();
|
||||||
final BlockVector3 top = region.getMaximumPoint();
|
final BlockVector3 top = region.getMaximumPoint();
|
||||||
@ -152,7 +152,7 @@ public class HybridUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) area;
|
HybridPlotWorld hpw = (HybridPlotWorld) area;
|
||||||
ChunkBlockQueue chunk = new ChunkBlockQueue(bot, top, false);
|
ChunkQueueCoordinator chunk = new ChunkQueueCoordinator(bot, top, false);
|
||||||
hpw.getGenerator().generateChunk(chunk, hpw);
|
hpw.getGenerator().generateChunk(chunk, hpw);
|
||||||
|
|
||||||
final BlockState[][][] oldBlocks = chunk.getBlocks();
|
final BlockState[][][] oldBlocks = chunk.getBlocks();
|
||||||
@ -374,7 +374,7 @@ public class HybridUtils {
|
|||||||
run.run();
|
run.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int checkModified(LocalBlockQueue queue, int x1, int x2, int y1, int y2, int z1, int z2,
|
public int checkModified(QueueCoordinator queue, int x1, int x2, int y1, int y2, int z1, int z2,
|
||||||
BlockState[] blocks) {
|
BlockState[] blocks) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int y = y1; y <= y2; y++) {
|
for (int y = y1; y <= y2; y++) {
|
||||||
@ -521,7 +521,7 @@ public class HybridUtils {
|
|||||||
|
|
||||||
public boolean setupRoadSchematic(Plot plot) {
|
public boolean setupRoadSchematic(Plot plot) {
|
||||||
final String world = plot.getWorldName();
|
final String world = plot.getWorldName();
|
||||||
final LocalBlockQueue queue = blockQueue.getNewQueue(world, false);
|
final QueueCoordinator queue = blockQueue.getNewQueue(world, false);
|
||||||
Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
||||||
Location top = plot.getTopAbs();
|
Location top = plot.getTopAbs();
|
||||||
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
|
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
|
||||||
@ -564,7 +564,7 @@ public class HybridUtils {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int get_ey(final PlotManager pm, LocalBlockQueue queue, int sx, int ex, int sz, int ez,
|
public int get_ey(final PlotManager pm, QueueCoordinator queue, int sx, int ex, int sz, int ez,
|
||||||
int sy) {
|
int sy) {
|
||||||
int ey = sy;
|
int ey = sy;
|
||||||
for (int x = sx; x <= ex; x++) {
|
for (int x = sx; x <= ex; x++) {
|
||||||
@ -608,7 +608,7 @@ public class HybridUtils {
|
|||||||
z -= plotWorld.ROAD_OFFSET_Z;
|
z -= plotWorld.ROAD_OFFSET_Z;
|
||||||
final int finalX = x;
|
final int finalX = x;
|
||||||
final int finalZ = z;
|
final int finalZ = z;
|
||||||
LocalBlockQueue queue = this.blockQueue.getNewQueue(plotWorld.getWorldName(), false);
|
QueueCoordinator queue = this.blockQueue.getNewQueue(plotWorld.getWorldName(), false);
|
||||||
if (id1 == null || id2 == null || id1 != id2) {
|
if (id1 == null || id2 == null || id1 != id2) {
|
||||||
this.chunkManager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
|
this.chunkManager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
|
||||||
if (id1 != null) {
|
if (id1 != null) {
|
||||||
|
@ -29,7 +29,7 @@ import com.plotsquared.core.PlotSquared;
|
|||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.plot.SetupObject;
|
import com.plotsquared.core.plot.SetupObject;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,9 +52,9 @@ public abstract class IndependentPlotGenerator {
|
|||||||
* @param result
|
* @param result
|
||||||
* @param settings
|
* @param settings
|
||||||
*/
|
*/
|
||||||
public abstract void generateChunk(ScopedLocalBlockQueue result, PlotArea settings);
|
public abstract void generateChunk(ScopedQueueCoordinator result, PlotArea settings);
|
||||||
|
|
||||||
public boolean populateChunk(ScopedLocalBlockQueue result, PlotArea setting) {
|
public boolean populateChunk(ScopedQueueCoordinator result, PlotArea setting) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,8 +75,7 @@ public abstract class IndependentPlotGenerator {
|
|||||||
*
|
*
|
||||||
* @param setup
|
* @param setup
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated public void processSetup(SetupObject setup) {
|
||||||
public void processSetup(SetupObject setup) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +84,8 @@ public abstract class IndependentPlotGenerator {
|
|||||||
*
|
*
|
||||||
* @param builder the area builder to modify
|
* @param builder the area builder to modify
|
||||||
*/
|
*/
|
||||||
public void processAreaSetup(PlotAreaBuilder builder) { }
|
public void processAreaSetup(PlotAreaBuilder builder) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It is preferred for the PlotArea object to do most of the initialization necessary.
|
* It is preferred for the PlotArea object to do most of the initialization necessary.
|
||||||
|
@ -32,7 +32,7 @@ import com.plotsquared.core.plot.PlotId;
|
|||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -56,7 +56,7 @@ public class SingleWorldGenerator extends IndependentPlotGenerator {
|
|||||||
return "PlotSquared:single";
|
return "PlotSquared:single";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings) {
|
@Override public void generateChunk(ScopedQueueCoordinator result, PlotArea settings) {
|
||||||
SinglePlotArea area = (SinglePlotArea) settings;
|
SinglePlotArea area = (SinglePlotArea) settings;
|
||||||
if (area.VOID) {
|
if (area.VOID) {
|
||||||
Location min = result.getMin();
|
Location min = result.getMin();
|
||||||
|
@ -56,7 +56,7 @@ import com.plotsquared.core.plot.flag.PlotFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.KeepFlag;
|
import com.plotsquared.core.plot.flag.implementations.KeepFlag;
|
||||||
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.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
@ -75,11 +75,11 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.PathIterator;
|
import java.awt.geom.PathIterator;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
@ -123,24 +123,13 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
|||||||
*/
|
*/
|
||||||
public class Plot {
|
public class Plot {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + Plot.class.getSimpleName());
|
|
||||||
|
|
||||||
public static final int MAX_HEIGHT = 256;
|
public static final int MAX_HEIGHT = 256;
|
||||||
|
private static final Logger logger =
|
||||||
|
LoggerFactory.getLogger("P2/" + Plot.class.getSimpleName());
|
||||||
private static Set<Plot> connected_cache;
|
private static Set<Plot> connected_cache;
|
||||||
private static Set<CuboidRegion> regions_cache;
|
private static Set<CuboidRegion> regions_cache;
|
||||||
|
|
||||||
@Nonnull private final PlotId id;
|
@Nonnull private final PlotId id;
|
||||||
|
|
||||||
// These will be injected
|
|
||||||
@Inject private EventDispatcher eventDispatcher;
|
|
||||||
@Inject private PlotListener plotListener;
|
|
||||||
@Inject private RegionManager regionManager;
|
|
||||||
@Inject private GlobalBlockQueue blockQueue;
|
|
||||||
@Inject private WorldUtil worldUtil;
|
|
||||||
@Inject private SchematicHandler schematicHandler;
|
|
||||||
@Inject @ImpromptuPipeline private UUIDPipeline impromptuPipeline;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot flag container
|
* Plot flag container
|
||||||
*/
|
*/
|
||||||
@ -149,7 +138,6 @@ public class Plot {
|
|||||||
* Has the plot changed since the last save cycle?
|
* Has the plot changed since the last save cycle?
|
||||||
*/
|
*/
|
||||||
public boolean countsTowardsMax = true;
|
public boolean countsTowardsMax = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents whatever the database manager needs it to: <br>
|
* Represents whatever the database manager needs it to: <br>
|
||||||
* - A value of -1 usually indicates the plot will not be stored in the DB<br>
|
* - A value of -1 usually indicates the plot will not be stored in the DB<br>
|
||||||
@ -158,6 +146,14 @@ public class Plot {
|
|||||||
* @deprecated magical
|
* @deprecated magical
|
||||||
*/
|
*/
|
||||||
@Deprecated public int temp;
|
@Deprecated public int temp;
|
||||||
|
// These will be injected
|
||||||
|
@Inject private EventDispatcher eventDispatcher;
|
||||||
|
@Inject private PlotListener plotListener;
|
||||||
|
@Inject private RegionManager regionManager;
|
||||||
|
@Inject private GlobalBlockQueue blockQueue;
|
||||||
|
@Inject private WorldUtil worldUtil;
|
||||||
|
@Inject private SchematicHandler schematicHandler;
|
||||||
|
@Inject @ImpromptuPipeline private UUIDPipeline impromptuPipeline;
|
||||||
/**
|
/**
|
||||||
* plot owner
|
* plot owner
|
||||||
* (Merged plots can have multiple owners)
|
* (Merged plots can have multiple owners)
|
||||||
@ -945,8 +941,7 @@ public class Plot {
|
|||||||
if (isDelete) {
|
if (isDelete) {
|
||||||
this.removeSign();
|
this.removeSign();
|
||||||
}
|
}
|
||||||
PlotUnlinkEvent event = this.eventDispatcher
|
PlotUnlinkEvent event = this.eventDispatcher.callUnlink(getArea(), this, true, !isDelete,
|
||||||
.callUnlink(getArea(), this, true, !isDelete,
|
|
||||||
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR);
|
isDelete ? PlotUnlinkEvent.REASON.DELETE : PlotUnlinkEvent.REASON.CLEAR);
|
||||||
if (event.getEventResult() != Result.DENY) {
|
if (event.getEventResult() != Result.DENY) {
|
||||||
this.unlinkPlot(event.isCreateRoad(), event.isCreateSign());
|
this.unlinkPlot(event.isCreateRoad(), event.isCreateSign());
|
||||||
@ -975,7 +970,8 @@ public class Plot {
|
|||||||
Plot current = queue.poll();
|
Plot current = queue.poll();
|
||||||
if (Plot.this.area.getTerrain() != PlotAreaTerrainType.NONE) {
|
if (Plot.this.area.getTerrain() != PlotAreaTerrainType.NONE) {
|
||||||
try {
|
try {
|
||||||
regionManager.regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false,
|
regionManager
|
||||||
|
.regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false,
|
||||||
this);
|
this);
|
||||||
} catch (UnsupportedOperationException exception) {
|
} catch (UnsupportedOperationException exception) {
|
||||||
MainUtil.sendMessage(null,
|
MainUtil.sendMessage(null,
|
||||||
@ -1099,7 +1095,8 @@ public class Plot {
|
|||||||
"%plr%", name),
|
"%plr%", name),
|
||||||
Captions.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll(
|
Captions.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll(
|
||||||
"%plr%", name)};
|
"%plr%", name)};
|
||||||
this.worldUtil.setSign(this.getWorldName(), location.getX(), location.getY(), location.getZ(),
|
this.worldUtil
|
||||||
|
.setSign(this.getWorldName(), location.getX(), location.getY(), location.getZ(),
|
||||||
lines);
|
lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1348,8 +1345,8 @@ public class Plot {
|
|||||||
|
|
||||||
if (Settings.Backup.DELETE_ON_UNCLAIM) {
|
if (Settings.Backup.DELETE_ON_UNCLAIM) {
|
||||||
// Destroy all backups when the plot is unclaimed
|
// Destroy all backups when the plot is unclaimed
|
||||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(current)
|
Objects.requireNonNull(PlotSquared.platform()).getBackupManager()
|
||||||
.destroy();
|
.getProfile(current).destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
getArea().removePlot(getId());
|
getArea().removePlot(getId());
|
||||||
@ -1377,7 +1374,8 @@ public class Plot {
|
|||||||
Location[] corners = getCorners();
|
Location[] corners = getCorners();
|
||||||
Location top = corners[0];
|
Location top = corners[0];
|
||||||
Location bot = corners[1];
|
Location bot = corners[1];
|
||||||
Location location = Location.at(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
|
Location location = Location
|
||||||
|
.at(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
|
||||||
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
result.accept(location);
|
result.accept(location);
|
||||||
@ -1399,12 +1397,14 @@ public class Plot {
|
|||||||
Location[] corners = getCorners();
|
Location[] corners = getCorners();
|
||||||
Location top = corners[0];
|
Location top = corners[0];
|
||||||
Location bot = corners[1];
|
Location bot = corners[1];
|
||||||
Location location = Location.at(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
|
Location location = Location
|
||||||
|
.at(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
|
||||||
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
int y = this.worldUtil.getHighestBlockSynchronous(getWorldName(), location.getX(), location.getZ());
|
int y = this.worldUtil
|
||||||
|
.getHighestBlockSynchronous(getWorldName(), location.getX(), location.getZ());
|
||||||
if (area.allowSigns()) {
|
if (area.allowSigns()) {
|
||||||
y = Math.max(y, getManager().getSignLoc(this).getY());
|
y = Math.max(y, getManager().getSignLoc(this).getY());
|
||||||
}
|
}
|
||||||
@ -1459,14 +1459,16 @@ public class Plot {
|
|||||||
return this.getDefaultHomeSynchronous(true);
|
return this.getDefaultHomeSynchronous(true);
|
||||||
} else {
|
} else {
|
||||||
Location bottom = this.getBottomAbs();
|
Location bottom = this.getBottomAbs();
|
||||||
Location location = Location.at(bottom.getWorldName(), bottom.getX() + home.getX(),
|
Location location = Location
|
||||||
bottom.getY() + home.getY(), bottom.getZ() + home.getZ(), home.getYaw(),
|
.at(bottom.getWorldName(), bottom.getX() + home.getX(), bottom.getY() + home.getY(),
|
||||||
home.getPitch());
|
bottom.getZ() + home.getZ(), home.getYaw(), home.getPitch());
|
||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
if (!this.worldUtil.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
|
if (!this.worldUtil.getBlockSynchronous(location).getBlockType().getMaterial()
|
||||||
location = location.withY(Math.max(1 + this.worldUtil.getHighestBlockSynchronous(this.getWorldName(), location.getX(),
|
.isAir()) {
|
||||||
|
location = location.withY(Math.max(1 + this.worldUtil
|
||||||
|
.getHighestBlockSynchronous(this.getWorldName(), location.getX(),
|
||||||
location.getZ()), bottom.getY()));
|
location.getZ()), bottom.getY()));
|
||||||
}
|
}
|
||||||
return location;
|
return location;
|
||||||
@ -1482,16 +1484,17 @@ public class Plot {
|
|||||||
this.getDefaultHome(result);
|
this.getDefaultHome(result);
|
||||||
} else {
|
} else {
|
||||||
Location bottom = this.getBottomAbs();
|
Location bottom = this.getBottomAbs();
|
||||||
Location location = Location.at(bottom.getWorldName(), bottom.getX() + home.getX(),
|
Location location = Location
|
||||||
bottom.getY() + home.getY(), bottom.getZ() + home.getZ(), home.getYaw(),
|
.at(bottom.getWorldName(), bottom.getX() + home.getX(), bottom.getY() + home.getY(),
|
||||||
home.getPitch());
|
bottom.getZ() + home.getZ(), home.getYaw(), home.getPitch());
|
||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
result.accept(location);
|
result.accept(location);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.worldUtil.getBlock(location, block -> {
|
this.worldUtil.getBlock(location, block -> {
|
||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
this.worldUtil.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
|
this.worldUtil
|
||||||
|
.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
|
||||||
y -> result.accept(location.withY(Math.max(1 + y, bottom.getY()))));
|
y -> result.accept(location.withY(Math.max(1 + y, bottom.getY()))));
|
||||||
} else {
|
} else {
|
||||||
result.accept(location);
|
result.accept(location);
|
||||||
@ -1683,7 +1686,7 @@ public class Plot {
|
|||||||
* This should not need to be called
|
* This should not need to be called
|
||||||
*/
|
*/
|
||||||
public void refreshChunks() {
|
public void refreshChunks() {
|
||||||
LocalBlockQueue queue = this.blockQueue.getNewQueue(getWorldName(), false);
|
QueueCoordinator queue = this.blockQueue.getNewQueue(getWorldName(), false);
|
||||||
HashSet<BlockVector2> chunks = new HashSet<>();
|
HashSet<BlockVector2> chunks = new HashSet<>();
|
||||||
for (CuboidRegion region : Plot.this.getRegions()) {
|
for (CuboidRegion region : Plot.this.getRegions()) {
|
||||||
for (int x = region.getMinimumPoint().getX() >> 4;
|
for (int x = region.getMinimumPoint().getX() >> 4;
|
||||||
@ -1707,10 +1710,10 @@ public class Plot {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = manager.getSignLoc(this);
|
Location location = manager.getSignLoc(this);
|
||||||
LocalBlockQueue queue = this.blockQueue.getNewQueue(getWorldName(), false);
|
QueueCoordinator queue = this.blockQueue.getNewQueue(getWorldName(), false);
|
||||||
queue.setBlock(location.getX(), location.getY(), location.getZ(),
|
queue.setBlock(location.getX(), location.getY(), location.getZ(),
|
||||||
BlockTypes.AIR.getDefaultState());
|
BlockTypes.AIR.getDefaultState());
|
||||||
queue.flush();
|
queue.enqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1721,8 +1724,8 @@ public class Plot {
|
|||||||
this.setSign("unknown");
|
this.setSign("unknown");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.impromptuPipeline.getSingle(this.getOwnerAbs(), (username, sign) ->
|
this.impromptuPipeline
|
||||||
this.setSign(username));
|
.getSingle(this.getOwnerAbs(), (username, sign) -> this.setSign(username));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1749,7 +1752,8 @@ public class Plot {
|
|||||||
|
|
||||||
if (updateDB) {
|
if (updateDB) {
|
||||||
if (!create(player.getUUID(), true)) {
|
if (!create(player.getUUID(), true)) {
|
||||||
logger.error("[P2] Player {} attempted to claim plot {}, but the database failed to update",
|
logger.error(
|
||||||
|
"[P2] Player {} attempted to claim plot {}, but the database failed to update",
|
||||||
player.getName(), this.getId().toCommaSeparatedString());
|
player.getName(), this.getId().toCommaSeparatedString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2919,13 +2923,16 @@ public class Plot {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String string =
|
final String string =
|
||||||
Captions.PLOT_DEBUG.getTranslated().replace("%plot%", this.toString()).replace("%message%", message);
|
Captions.PLOT_DEBUG.getTranslated().replace("%plot%", this.toString())
|
||||||
|
.replace("%message%", message);
|
||||||
for (final PlotPlayer<?> player : players) {
|
for (final PlotPlayer<?> player : players) {
|
||||||
if (isOwner(player.getUUID()) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_DEBUG_OTHER)) {
|
if (isOwner(player.getUUID()) || Permissions
|
||||||
|
.hasPermission(player, Captions.PERMISSION_ADMIN_DEBUG_OTHER)) {
|
||||||
player.sendMessage(string);
|
player.sendMessage(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception ignored) {}
|
} catch (final Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2977,8 +2984,7 @@ public class Plot {
|
|||||||
Consumer<Boolean> resultConsumer) {
|
Consumer<Boolean> resultConsumer) {
|
||||||
Plot plot = this.getBasePlot(false);
|
Plot plot = this.getBasePlot(false);
|
||||||
Result result =
|
Result result =
|
||||||
this.eventDispatcher.callTeleport(player, player.getLocation(), plot)
|
this.eventDispatcher.callTeleport(player, player.getLocation(), plot).getEventResult();
|
||||||
.getEventResult();
|
|
||||||
if (result == Result.DENY) {
|
if (result == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
|
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
|
||||||
resultConsumer.accept(false);
|
resultConsumer.accept(false);
|
||||||
@ -3214,8 +3220,10 @@ public class Plot {
|
|||||||
Location[] corners = MainUtil.getCorners(getWorldName(), region);
|
Location[] corners = MainUtil.getCorners(getWorldName(), region);
|
||||||
Location pos1 = corners[0];
|
Location pos1 = corners[0];
|
||||||
Location pos2 = corners[1];
|
Location pos2 = corners[1];
|
||||||
Location pos3 = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
Location pos3 =
|
||||||
Location pos4 = pos2.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
||||||
|
Location pos4 =
|
||||||
|
pos2.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
||||||
regionManager.swap(pos1, pos2, pos3, pos4, this);
|
regionManager.swap(pos1, pos2, pos3, pos4, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3246,7 +3254,8 @@ public class Plot {
|
|||||||
Location[] corners = MainUtil.getCorners(getWorldName(), region);
|
Location[] corners = MainUtil.getCorners(getWorldName(), region);
|
||||||
final Location pos1 = corners[0];
|
final Location pos1 = corners[0];
|
||||||
final Location pos2 = corners[1];
|
final Location pos2 = corners[1];
|
||||||
Location newPos = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
Location newPos =
|
||||||
|
pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
||||||
regionManager.copyRegion(pos1, pos2, newPos, task);
|
regionManager.copyRegion(pos1, pos2, newPos, task);
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
@ -3340,7 +3349,8 @@ public class Plot {
|
|||||||
Location[] corners = MainUtil.getCorners(getWorldName(), region);
|
Location[] corners = MainUtil.getCorners(getWorldName(), region);
|
||||||
Location pos1 = corners[0];
|
Location pos1 = corners[0];
|
||||||
Location pos2 = corners[1];
|
Location pos2 = corners[1];
|
||||||
Location newPos = pos1 .add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
Location newPos =
|
||||||
|
pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
||||||
regionManager.copyRegion(pos1, pos2, newPos, this);
|
regionManager.copyRegion(pos1, pos2, newPos, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -27,7 +27,6 @@ package com.plotsquared.core.plot;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.collection.QuadMap;
|
import com.plotsquared.core.collection.QuadMap;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
@ -49,7 +48,7 @@ import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
|||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
import com.plotsquared.core.util.Expression;
|
import com.plotsquared.core.util.Expression;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
@ -172,7 +171,7 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
@Nonnull protected abstract PlotManager createManager();
|
@Nonnull protected abstract PlotManager createManager();
|
||||||
|
|
||||||
public LocalBlockQueue getQueue(final boolean autoQueue) {
|
public QueueCoordinator getQueue(final boolean autoQueue) {
|
||||||
return this.globalBlockQueue.getNewQueue(worldName, autoQueue);
|
return this.globalBlockQueue.getNewQueue(worldName, autoQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +75,13 @@ public class AreaBoundDelegateQueueCoordinator extends DelegateQueueCoordinator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
if (area.contains(x, z)) {
|
||||||
|
return super.setBiome(x, y, z, biome);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
@Override public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||||
if (area.contains(x, z)) {
|
if (area.contains(x, z)) {
|
||||||
return super.setTile(x, y, z, tag);
|
return super.setTile(x, y, z, tag);
|
||||||
|
@ -99,7 +99,16 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator {
|
|||||||
|
|
||||||
@Override public final boolean setBiome(int x, int z, BiomeType biomeType) {
|
@Override public final boolean setBiome(int x, int z, BiomeType biomeType) {
|
||||||
LocalChunk chunk = getChunk(x >> 4, z >> 4);
|
LocalChunk chunk = getChunk(x >> 4, z >> 4);
|
||||||
chunk.setBiome(x & 15, z & 15, biomeType);
|
for (int y = 0; y < 256; y++) {
|
||||||
|
chunk.setBiome(x & 15, y, z & 15, biomeType);
|
||||||
|
}
|
||||||
|
settingBiomes = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public final boolean setBiome(int x, int y, int z, BiomeType biomeType) {
|
||||||
|
LocalChunk chunk = getChunk(x >> 4, z >> 4);
|
||||||
|
chunk.setBiome(x & 15, y, z & 15, biomeType);
|
||||||
settingBiomes = true;
|
settingBiomes = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,10 @@ import com.sk89q.worldedit.world.block.BlockState;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class ChunkQueueCoordinator extends ScopedQueueCoordinator {
|
public class ChunkQueueCoordinator extends ScopedQueueCoordinator {
|
||||||
|
|
||||||
public final BiomeType[] biomeGrid;
|
public final BiomeType[][][] biomeResult;
|
||||||
public final BlockState[][][] result;
|
public final BlockState[][][] result;
|
||||||
private final int width;
|
private final int width;
|
||||||
private final int length;
|
private final int length;
|
||||||
@ -51,7 +50,7 @@ public class ChunkQueueCoordinator extends ScopedQueueCoordinator {
|
|||||||
this.width = top.getX() - bot.getX() + 1;
|
this.width = top.getX() - bot.getX() + 1;
|
||||||
this.length = top.getZ() - bot.getZ() + 1;
|
this.length = top.getZ() - bot.getZ() + 1;
|
||||||
this.result = new BlockState[256][][];
|
this.result = new BlockState[256][][];
|
||||||
this.biomeGrid = biomes ? new BiomeType[width * length] : null;
|
this.biomeResult = biomes ? new BiomeType[256][][] : null;
|
||||||
this.bot = bot;
|
this.bot = bot;
|
||||||
this.top = top;
|
this.top = top;
|
||||||
}
|
}
|
||||||
@ -60,16 +59,19 @@ public class ChunkQueueCoordinator extends ScopedQueueCoordinator {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void fillBiome(BiomeType biomeType) {
|
@Override public boolean setBiome(int x, int z, BiomeType biomeType) {
|
||||||
if (biomeGrid == null) {
|
if (this.biomeResult != null) {
|
||||||
return;
|
for (int y = 0; y < 256; y++) {
|
||||||
|
this.storeCacheBiome(x, y, z, biomeType);
|
||||||
}
|
}
|
||||||
Arrays.fill(biomeGrid, biomeType);
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int z, BiomeType biomeType) {
|
@Override public boolean setBiome(int x, int y, int z, BiomeType biomeType) {
|
||||||
if (this.biomeGrid != null) {
|
if (this.biomeResult != null) {
|
||||||
biomeGrid[(z * width) + x] = biomeType;
|
this.storeCacheBiome(x, y, z, biomeType);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -97,6 +99,18 @@ public class ChunkQueueCoordinator extends ScopedQueueCoordinator {
|
|||||||
resultYZ[x] = id;
|
resultYZ[x] = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void storeCacheBiome(final int x, final int y, final int z, final BiomeType id) {
|
||||||
|
BiomeType[][] resultY = biomeResult[y];
|
||||||
|
if (resultY == null) {
|
||||||
|
biomeResult[y] = resultY = new BiomeType[length][];
|
||||||
|
}
|
||||||
|
BiomeType[] resultYZ = resultY[z];
|
||||||
|
if (resultYZ == null) {
|
||||||
|
resultY[z] = resultYZ = new BiomeType[width];
|
||||||
|
}
|
||||||
|
resultYZ[x] = id;
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
||||||
this.storeCache(x, y, z, id.toImmutableState());
|
this.storeCache(x, y, z, id.toImmutableState());
|
||||||
return true;
|
return true;
|
||||||
|
@ -81,6 +81,10 @@ public class DelegateQueueCoordinator extends QueueCoordinator {
|
|||||||
return parent.setBiome(x, z, biome);
|
return parent.setBiome(x, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
return parent.setBiome(x, y, z, biome);
|
||||||
|
}
|
||||||
|
|
||||||
@Override public boolean isSettingBiomes() {
|
@Override public boolean isSettingBiomes() {
|
||||||
return parent.isSettingBiomes();
|
return parent.isSettingBiomes();
|
||||||
}
|
}
|
||||||
@ -103,4 +107,8 @@ public class DelegateQueueCoordinator extends QueueCoordinator {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public void setCompleteTask(Runnable whenDone) {
|
||||||
|
parent.setCompleteTask(whenDone);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.queue;
|
package com.plotsquared.core.queue;
|
||||||
|
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@ -42,6 +43,16 @@ public class GlobalBlockQueue {
|
|||||||
this.activeQueues = new ConcurrentLinkedDeque<>();
|
this.activeQueues = new ConcurrentLinkedDeque<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QueueCoordinator getNewQueue(String world, boolean autoQueue) {
|
||||||
|
QueueCoordinator queue = provider.getNewQueue(world);
|
||||||
|
// Auto-inject into the queue
|
||||||
|
PlotSquared.platform().getInjector().injectMembers(queue);
|
||||||
|
if (autoQueue) {
|
||||||
|
queue.enqueue();
|
||||||
|
}
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Documentation needed.
|
* TODO Documentation needed.
|
||||||
*
|
*
|
||||||
|
@ -31,16 +31,11 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class LocationOffsetDelegateQueueCoordinator extends DelegateQueueCoordinator {
|
public class LocationOffsetDelegateQueueCoordinator extends DelegateQueueCoordinator {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory
|
|
||||||
.getLogger("P2/" + LocationOffsetDelegateQueueCoordinator.class.getSimpleName());
|
|
||||||
|
|
||||||
private final boolean[][] canPlace;
|
private final boolean[][] canPlace;
|
||||||
private final int blockX;
|
private final int blockX;
|
||||||
private final int blockZ;
|
private final int blockZ;
|
||||||
@ -76,8 +71,12 @@ public class LocationOffsetDelegateQueueCoordinator extends DelegateQueueCoordin
|
|||||||
return this.setBlock(x, y, z, pattern.apply(blockVector3));
|
return this.setBlock(x, y, z, pattern.apply(blockVector3));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int y, BiomeType biome) {
|
@Override public boolean setBiome(int x, int z, BiomeType biome) {
|
||||||
return super.setBiome(x, y, biome);
|
return super.setBiome(x, z, biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
return super.setBiome(x, y, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
@Override public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||||
|
@ -42,8 +42,12 @@ public class OffsetQueueCoordinator extends DelegateQueueCoordinator {
|
|||||||
this.oz = oz;
|
this.oz = oz;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBiome(int x, int y, BiomeType biome) {
|
@Override public boolean setBiome(int x, int z, BiomeType biome) {
|
||||||
return super.setBiome(ox + x, oy + y, biome);
|
return super.setBiome(ox + x, oz + z, biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
return super.setBiome(ox + x, oy + y, oz + z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
|
||||||
|
@ -52,6 +52,13 @@ public abstract class QueueCoordinator {
|
|||||||
PlotSquared.platform().getInjector().injectMembers(this);
|
PlotSquared.platform().getInjector().injectMembers(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ScopedQueueCoordinator getForChunk(int x, int z) {
|
||||||
|
int bx = x << 4;
|
||||||
|
int bz = z << 4;
|
||||||
|
return new ScopedQueueCoordinator(this, Location.at(getWorld().getName(), bx, 0, bz),
|
||||||
|
Location.at(getWorld().getName(), bx + 15, 255, bz + 255));
|
||||||
|
}
|
||||||
|
|
||||||
public abstract int size();
|
public abstract int size();
|
||||||
|
|
||||||
public abstract void setModified(long modified);
|
public abstract void setModified(long modified);
|
||||||
@ -78,7 +85,9 @@ public abstract class QueueCoordinator {
|
|||||||
|
|
||||||
public abstract BlockState getBlock(int x, int y, int z);
|
public abstract BlockState getBlock(int x, int y, int z);
|
||||||
|
|
||||||
public abstract boolean setBiome(int x, int z, BiomeType biome);
|
@Deprecated public abstract boolean setBiome(int x, int z, BiomeType biome);
|
||||||
|
|
||||||
|
public abstract boolean setBiome(int x, int y, int z, BiomeType biome);
|
||||||
|
|
||||||
public abstract boolean isSettingBiomes();
|
public abstract boolean isSettingBiomes();
|
||||||
|
|
||||||
@ -92,6 +101,8 @@ public abstract class QueueCoordinator {
|
|||||||
return blockQueue.enqueue(this);
|
return blockQueue.enqueue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void setCompleteTask(Runnable whenDone);
|
||||||
|
|
||||||
public void setCuboid(Location pos1, Location pos2, BlockState block) {
|
public void setCuboid(Location pos1, Location pos2, BlockState block) {
|
||||||
int yMin = Math.min(pos1.getY(), pos2.getY());
|
int yMin = Math.min(pos1.getY(), pos2.getY());
|
||||||
int yMax = Math.min(255, Math.max(pos1.getY(), pos2.getY()));
|
int yMax = Math.min(255, Math.max(pos1.getY(), pos2.getY()));
|
||||||
|
@ -64,10 +64,17 @@ public class ScopedQueueCoordinator extends DelegateQueueCoordinator {
|
|||||||
return x >= 0 && x <= dx && z >= 0 && z <= dz && super.setBiome(x + minX, z + minZ, biome);
|
return x >= 0 && x <= dx && z >= 0 && z <= dz && super.setBiome(x + minX, z + minZ, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
return x >= 0 && x <= dx && y >= 0 && y <= dy && z >= 0 && z <= dz && super
|
||||||
|
.setBiome(x + minX, y + minY, z + minZ, biome);
|
||||||
|
}
|
||||||
|
|
||||||
public void fillBiome(BiomeType biome) {
|
public void fillBiome(BiomeType biome) {
|
||||||
|
for (int y = 0; y <= dy; y++) {
|
||||||
for (int x = 0; x <= dx; x++) {
|
for (int x = 0; x <= dx; x++) {
|
||||||
for (int z = 0; z < dz; z++) {
|
for (int z = 0; z < dz; z++) {
|
||||||
setBiome(x, z, biome);
|
setBiome(x, y, z, biome);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ package com.plotsquared.core.util;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
@ -42,19 +42,21 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
public abstract class ChunkManager {
|
public abstract class ChunkManager {
|
||||||
|
|
||||||
private static final Map<BlockVector2, RunnableVal<ScopedLocalBlockQueue>> forceChunks =
|
private static final Map<BlockVector2, RunnableVal<ScopedQueueCoordinator>> forceChunks =
|
||||||
new ConcurrentHashMap<>();
|
new ConcurrentHashMap<>();
|
||||||
private static final Map<BlockVector2, RunnableVal<ScopedLocalBlockQueue>> addChunks =
|
private static final Map<BlockVector2, RunnableVal<ScopedQueueCoordinator>> addChunks =
|
||||||
new ConcurrentHashMap<>();
|
new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static void setChunkInPlotArea(RunnableVal<ScopedLocalBlockQueue> force,
|
public static void setChunkInPlotArea(RunnableVal<ScopedQueueCoordinator> force,
|
||||||
RunnableVal<ScopedLocalBlockQueue> add, String world, BlockVector2 loc) {
|
RunnableVal<ScopedQueueCoordinator> add, String world, BlockVector2 loc) {
|
||||||
LocalBlockQueue queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false);
|
QueueCoordinator queue =
|
||||||
if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get().isNonStandardGeneration(world, loc)) {
|
PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false);
|
||||||
|
if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get()
|
||||||
|
.isNonStandardGeneration(world, loc)) {
|
||||||
int blockX = loc.getX() << 4;
|
int blockX = loc.getX() << 4;
|
||||||
int blockZ = loc.getZ() << 4;
|
int blockZ = loc.getZ() << 4;
|
||||||
ScopedLocalBlockQueue scoped =
|
ScopedQueueCoordinator scoped =
|
||||||
new ScopedLocalBlockQueue(queue, Location.at(world, blockX, 0, blockZ),
|
new ScopedQueueCoordinator(queue, Location.at(world, blockX, 0, blockZ),
|
||||||
Location.at(world, blockX + 15, 255, blockZ + 15));
|
Location.at(world, blockX + 15, 255, blockZ + 15));
|
||||||
if (force != null) {
|
if (force != null) {
|
||||||
force.run(scoped);
|
force.run(scoped);
|
||||||
@ -64,7 +66,7 @@ public abstract class ChunkManager {
|
|||||||
add.run(scoped);
|
add.run(scoped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.flush();
|
queue.enqueue();
|
||||||
} else {
|
} else {
|
||||||
if (force != null) {
|
if (force != null) {
|
||||||
forceChunks.put(loc, force);
|
forceChunks.put(loc, force);
|
||||||
@ -76,8 +78,8 @@ public abstract class ChunkManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean preProcessChunk(BlockVector2 loc, ScopedLocalBlockQueue queue) {
|
public static boolean preProcessChunk(BlockVector2 loc, ScopedQueueCoordinator queue) {
|
||||||
final RunnableVal<ScopedLocalBlockQueue> forceChunk = forceChunks.get(loc);
|
final RunnableVal<ScopedQueueCoordinator> forceChunk = forceChunks.get(loc);
|
||||||
if (forceChunk != null) {
|
if (forceChunk != null) {
|
||||||
forceChunk.run(queue);
|
forceChunk.run(queue);
|
||||||
forceChunks.remove(loc);
|
forceChunks.remove(loc);
|
||||||
@ -86,8 +88,8 @@ public abstract class ChunkManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean postProcessChunk(BlockVector2 loc, ScopedLocalBlockQueue queue) {
|
public static boolean postProcessChunk(BlockVector2 loc, ScopedQueueCoordinator queue) {
|
||||||
final RunnableVal<ScopedLocalBlockQueue> addChunk = forceChunks.get(loc);
|
final RunnableVal<ScopedQueueCoordinator> addChunk = forceChunks.get(loc);
|
||||||
if (addChunk != null) {
|
if (addChunk != null) {
|
||||||
addChunk.run(queue);
|
addChunk.run(queue);
|
||||||
addChunks.remove(loc);
|
addChunks.remove(loc);
|
||||||
|
@ -30,7 +30,7 @@ import com.plotsquared.core.location.Location;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
@ -39,8 +39,8 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -48,9 +48,15 @@ import java.util.Set;
|
|||||||
|
|
||||||
public abstract class RegionManager {
|
public abstract class RegionManager {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + RegionManager.class.getSimpleName());
|
private static final Logger logger =
|
||||||
|
LoggerFactory.getLogger("P2/" + RegionManager.class.getSimpleName());
|
||||||
|
|
||||||
public static RegionManager manager = null;
|
public static RegionManager manager = null;
|
||||||
|
private final ChunkManager chunkManager;
|
||||||
|
|
||||||
|
public RegionManager(@Nonnull final ChunkManager chunkManager) {
|
||||||
|
this.chunkManager = chunkManager;
|
||||||
|
}
|
||||||
|
|
||||||
public static BlockVector2 getRegion(Location location) {
|
public static BlockVector2 getRegion(Location location) {
|
||||||
int x = location.getX() >> 9;
|
int x = location.getX() >> 9;
|
||||||
@ -58,12 +64,6 @@ public abstract class RegionManager {
|
|||||||
return BlockVector2.at(x, z);
|
return BlockVector2.at(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ChunkManager chunkManager;
|
|
||||||
|
|
||||||
public RegionManager(@Nonnull final ChunkManager chunkManager) {
|
|
||||||
this.chunkManager = chunkManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void largeRegionTask(final String world, final CuboidRegion region,
|
public void largeRegionTask(final String world, final CuboidRegion region,
|
||||||
final RunnableVal<BlockVector2> task, final Runnable whenDone) {
|
final RunnableVal<BlockVector2> task, final Runnable whenDone) {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@ -96,8 +96,7 @@ public abstract class RegionManager {
|
|||||||
}
|
}
|
||||||
TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() {
|
TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() {
|
||||||
@Override public void run(BlockVector2 value) {
|
@Override public void run(BlockVector2 value) {
|
||||||
chunkManager.loadChunk(world, value, false)
|
chunkManager.loadChunk(world, value, false).thenRun(() -> task.run(value));
|
||||||
.thenRun(() -> task.run(value));
|
|
||||||
}
|
}
|
||||||
}, whenDone);
|
}, whenDone);
|
||||||
});
|
});
|
||||||
@ -164,7 +163,7 @@ public abstract class RegionManager {
|
|||||||
|
|
||||||
public boolean setCuboids(final PlotArea area, final Set<CuboidRegion> regions,
|
public boolean setCuboids(final PlotArea area, final Set<CuboidRegion> regions,
|
||||||
final Pattern blocks, int minY, int maxY) {
|
final Pattern blocks, int minY, int maxY) {
|
||||||
LocalBlockQueue queue = area.getQueue(false);
|
QueueCoordinator queue = area.getQueue(false);
|
||||||
for (CuboidRegion region : regions) {
|
for (CuboidRegion region : regions) {
|
||||||
Location pos1 = Location.at(area.getWorldName(), region.getMinimumPoint().getX(), minY,
|
Location pos1 = Location.at(area.getWorldName(), region.getMinimumPoint().getX(), minY,
|
||||||
region.getMinimumPoint().getZ());
|
region.getMinimumPoint().getZ());
|
||||||
|
@ -32,7 +32,7 @@ import com.plotsquared.core.location.Location;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.schematic.Schematic;
|
import com.plotsquared.core.plot.schematic.Schematic;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.jnbt.ByteArrayTag;
|
import com.sk89q.jnbt.ByteArrayTag;
|
||||||
@ -58,12 +58,12 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
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 javax.annotation.Nonnull;
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -96,12 +96,11 @@ import java.util.zip.GZIPOutputStream;
|
|||||||
|
|
||||||
public abstract class SchematicHandler {
|
public abstract class SchematicHandler {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + SchematicHandler.class.getSimpleName());
|
private static final Logger logger =
|
||||||
|
LoggerFactory.getLogger("P2/" + SchematicHandler.class.getSimpleName());
|
||||||
public static SchematicHandler manager;
|
public static SchematicHandler manager;
|
||||||
|
|
||||||
private boolean exportAll = false;
|
|
||||||
|
|
||||||
private final WorldUtil worldUtil;
|
private final WorldUtil worldUtil;
|
||||||
|
private boolean exportAll = false;
|
||||||
|
|
||||||
public SchematicHandler(@Nonnull final WorldUtil worldUtil) {
|
public SchematicHandler(@Nonnull final WorldUtil worldUtil) {
|
||||||
this.worldUtil = worldUtil;
|
this.worldUtil = worldUtil;
|
||||||
@ -158,7 +157,8 @@ public abstract class SchematicHandler {
|
|||||||
@Override public void run(final CompoundTag value) {
|
@Override public void run(final CompoundTag value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
boolean result = save(value, directory + File.separator + name + ".schem");
|
boolean result =
|
||||||
|
save(value, directory + File.separator + name + ".schem");
|
||||||
if (!result) {
|
if (!result) {
|
||||||
logger.error("[P2] Failed to save {}", plot.getId());
|
logger.error("[P2] Failed to save {}", plot.getId());
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ public abstract class SchematicHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final LocalBlockQueue queue = plot.getArea().getQueue(false);
|
final QueueCoordinator queue = plot.getArea().getQueue(false);
|
||||||
BlockVector3 dimension = schematic.getClipboard().getDimensions();
|
BlockVector3 dimension = schematic.getClipboard().getDimensions();
|
||||||
final int WIDTH = dimension.getX();
|
final int WIDTH = dimension.getX();
|
||||||
final int LENGTH = dimension.getZ();
|
final int LENGTH = dimension.getZ();
|
||||||
@ -229,8 +229,9 @@ public abstract class SchematicHandler {
|
|||||||
y_offset_actual = yOffset;
|
y_offset_actual = yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Location pos1 = Location.at(plot.getWorldName(), region.getMinimumPoint().getX() + xOffset, y_offset_actual,
|
final Location pos1 = Location
|
||||||
region.getMinimumPoint().getZ() + zOffset);
|
.at(plot.getWorldName(), region.getMinimumPoint().getX() + xOffset,
|
||||||
|
y_offset_actual, region.getMinimumPoint().getZ() + zOffset);
|
||||||
final Location pos2 = pos1.add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
final Location pos2 = pos1.add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
||||||
|
|
||||||
final int p1x = pos1.getX();
|
final int p1x = pos1.getX();
|
||||||
@ -300,7 +301,7 @@ public abstract class SchematicHandler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean restoreTile(LocalBlockQueue queue, CompoundTag tag, int x, int y,
|
public abstract boolean restoreTile(QueueCoordinator queue, CompoundTag tag, int x, int y,
|
||||||
int z);
|
int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user