mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Fix the injection
This commit is contained in:
parent
914429ab4f
commit
a451d2d6f2
@ -29,6 +29,7 @@ import com.google.inject.AbstractModule;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||||
|
import com.google.inject.assistedinject.FactoryProvider;
|
||||||
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.BukkitChunkCoordinator;
|
import com.plotsquared.bukkit.queue.BukkitChunkCoordinator;
|
||||||
@ -96,6 +97,7 @@ public class BukkitModule extends AbstractModule {
|
|||||||
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);
|
||||||
|
install(new FactoryModuleBuilder().implement(ProgressSubscriber.class, DefaultProgressSubscriber.class).build(ProgressSubscriberFactory.class));
|
||||||
bind(GlobalBlockQueue.class).toInstance(new GlobalBlockQueue(QueueProvider.of(BukkitQueueCoordinator.class)));
|
bind(GlobalBlockQueue.class).toInstance(new GlobalBlockQueue(QueueProvider.of(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);
|
||||||
@ -108,7 +110,6 @@ public class BukkitModule extends AbstractModule {
|
|||||||
install(new FactoryModuleBuilder().build(HybridPlotWorldFactory.class));
|
install(new FactoryModuleBuilder().build(HybridPlotWorldFactory.class));
|
||||||
install(new FactoryModuleBuilder().implement(ChunkCoordinator.class, BukkitChunkCoordinator.class).build(ChunkCoordinatorFactory.class));
|
install(new FactoryModuleBuilder().implement(ChunkCoordinator.class, BukkitChunkCoordinator.class).build(ChunkCoordinatorFactory.class));
|
||||||
install(new FactoryModuleBuilder().build(ChunkCoordinatorBuilderFactory.class));
|
install(new FactoryModuleBuilder().build(ChunkCoordinatorBuilderFactory.class));
|
||||||
install(new FactoryModuleBuilder().implement(ProgressSubscriber.class, DefaultProgressSubscriber.class).build(ProgressSubscriberFactory.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides @Singleton @Nonnull EconHandler provideEconHandler() {
|
@Provides @Singleton @Nonnull EconHandler provideEconHandler() {
|
||||||
|
@ -27,6 +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.inject.factory.ProgressSubscriberFactory;
|
||||||
import com.plotsquared.core.queue.QueueCoordinator;
|
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;
|
||||||
@ -39,8 +40,8 @@ import javax.annotation.Nonnull;
|
|||||||
*/
|
*/
|
||||||
@Singleton public class BukkitSchematicHandler extends SchematicHandler {
|
@Singleton public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
|
|
||||||
@Inject public BukkitSchematicHandler(@Nonnull final WorldUtil worldUtil) {
|
@Inject public BukkitSchematicHandler(@Nonnull final WorldUtil worldUtil, @Nonnull ProgressSubscriberFactory subscriberFactory) {
|
||||||
super(worldUtil);
|
super(worldUtil, subscriberFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,6 +28,7 @@ package com.plotsquared.bukkit.util;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.generator.AugmentedUtils;
|
import com.plotsquared.core.generator.AugmentedUtils;
|
||||||
|
import com.plotsquared.core.inject.factory.ProgressSubscriberFactory;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.location.PlotLoc;
|
import com.plotsquared.core.location.PlotLoc;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
@ -74,8 +75,9 @@ public class BukkitRegionManager extends RegionManager {
|
|||||||
|
|
||||||
private final GlobalBlockQueue blockQueue;
|
private final GlobalBlockQueue blockQueue;
|
||||||
|
|
||||||
@Inject public BukkitRegionManager(@Nonnull WorldUtil worldUtil, @Nonnull GlobalBlockQueue blockQueue) {
|
@Inject public BukkitRegionManager(@Nonnull WorldUtil worldUtil, @Nonnull GlobalBlockQueue blockQueue, @Nonnull
|
||||||
super(worldUtil, blockQueue);
|
ProgressSubscriberFactory subscriberFactory) {
|
||||||
|
super(worldUtil, blockQueue, subscriberFactory);
|
||||||
this.blockQueue = blockQueue;
|
this.blockQueue = blockQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.inject.factory.ProgressSubscriberFactory;
|
import com.plotsquared.core.inject.factory.ProgressSubscriberFactory;
|
||||||
import com.plotsquared.core.location.Direction;
|
import com.plotsquared.core.location.Direction;
|
||||||
@ -56,12 +57,13 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
|
|
||||||
private final ClassicPlotWorld classicPlotWorld;
|
private final ClassicPlotWorld classicPlotWorld;
|
||||||
private final RegionManager regionManager;
|
private final RegionManager regionManager;
|
||||||
@Inject private ProgressSubscriberFactory subscriberFactory;
|
private final ProgressSubscriberFactory subscriberFactory;
|
||||||
|
|
||||||
@Inject public ClassicPlotManager(@Nonnull final ClassicPlotWorld classicPlotWorld, @Nonnull final RegionManager regionManager) {
|
@Inject public ClassicPlotManager(@Nonnull final ClassicPlotWorld classicPlotWorld, @Nonnull final RegionManager regionManager) {
|
||||||
super(classicPlotWorld, regionManager);
|
super(classicPlotWorld, regionManager);
|
||||||
this.classicPlotWorld = classicPlotWorld;
|
this.classicPlotWorld = classicPlotWorld;
|
||||||
this.regionManager = regionManager;
|
this.regionManager = regionManager;
|
||||||
|
this.subscriberFactory = PlotSquared.platform().getInjector().getInstance(ProgressSubscriberFactory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean setComponent(@Nonnull PlotId plotId,
|
@Override public boolean setComponent(@Nonnull PlotId plotId,
|
||||||
@ -232,7 +234,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
queue = classicPlotWorld.getQueue();
|
queue = classicPlotWorld.getQueue();
|
||||||
enqueue = true;
|
enqueue = true;
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
queue.addProgressSubscriber(subscriberFactory.create(actor));
|
queue.addProgressSubscriber(subscriberFactory.createWithActor(actor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +313,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
queue = classicPlotWorld.getQueue();
|
queue = classicPlotWorld.getQueue();
|
||||||
enqueue = true;
|
enqueue = true;
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
queue.addProgressSubscriber(subscriberFactory.create(actor));
|
queue.addProgressSubscriber(subscriberFactory.createWithActor(actor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +383,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
enqueue = true;
|
enqueue = true;
|
||||||
queue = classicPlotWorld.getQueue();
|
queue = classicPlotWorld.getQueue();
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
queue.addProgressSubscriber(subscriberFactory.create(actor));
|
queue.addProgressSubscriber(subscriberFactory.createWithActor(actor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,19 +29,19 @@ import com.google.inject.assistedinject.Assisted;
|
|||||||
import com.plotsquared.core.configuration.caption.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.queue.subscriber.ProgressSubscriber;
|
import com.plotsquared.core.queue.subscriber.ProgressSubscriber;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public interface ProgressSubscriberFactory {
|
public interface ProgressSubscriberFactory {
|
||||||
|
|
||||||
@Nonnull ProgressSubscriber create(@Nonnull @Assisted("subscriber") PlotPlayer<?> actor);
|
@Nonnull ProgressSubscriber create();
|
||||||
|
|
||||||
@Nonnull ProgressSubscriber create(@Nonnull @Assisted("subscriber") PlotPlayer<?> actor,
|
@Nonnull ProgressSubscriber createWithActor(@Nullable @Assisted("subscriber") PlotPlayer<?> actor);
|
||||||
@Nonnull TaskManager taskManager,
|
|
||||||
|
@Nonnull ProgressSubscriber createFull(@Nullable @Assisted("subscriber") PlotPlayer<?> actor,
|
||||||
@Assisted("progressInterval") final long interval,
|
@Assisted("progressInterval") final long interval,
|
||||||
@Assisted("progressInterval") final long wait,
|
@Assisted("waitBeforeStarting") final long wait,
|
||||||
@Nullable @Assisted("caption") Caption caption);
|
@Nullable @Assisted("caption") Caption caption);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.plotsquared.core.inject.modules;
|
package com.plotsquared.core.inject.modules;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||||
import com.intellectualsites.services.ServicePipeline;
|
import com.intellectualsites.services.ServicePipeline;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
@ -34,7 +35,10 @@ import com.plotsquared.core.inject.annotations.ConfigFile;
|
|||||||
import com.plotsquared.core.inject.annotations.ImpromptuPipeline;
|
import com.plotsquared.core.inject.annotations.ImpromptuPipeline;
|
||||||
import com.plotsquared.core.inject.annotations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.inject.annotations.WorldFile;
|
import com.plotsquared.core.inject.annotations.WorldFile;
|
||||||
|
import com.plotsquared.core.inject.factory.ProgressSubscriberFactory;
|
||||||
import com.plotsquared.core.listener.PlotListener;
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
|
import com.plotsquared.core.queue.subscriber.DefaultProgressSubscriber;
|
||||||
|
import com.plotsquared.core.queue.subscriber.ProgressSubscriber;
|
||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.uuid.UUIDPipeline;
|
import com.plotsquared.core.uuid.UUIDPipeline;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
@ -78,10 +78,11 @@ public final class PlotModificationManager {
|
|||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotModificationManager.class.getSimpleName());
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + PlotModificationManager.class.getSimpleName());
|
||||||
|
|
||||||
private final Plot plot;
|
private final Plot plot;
|
||||||
@Inject private ProgressSubscriberFactory subscriberFactory;
|
private final ProgressSubscriberFactory subscriberFactory;
|
||||||
|
|
||||||
@Inject PlotModificationManager(@Nonnull final Plot plot) {
|
@Inject PlotModificationManager(@Nonnull final Plot plot) {
|
||||||
this.plot = plot;
|
this.plot = plot;
|
||||||
|
this.subscriberFactory = PlotSquared.platform().getInjector().getInstance(ProgressSubscriberFactory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -239,7 +240,7 @@ public final class PlotModificationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
queue.addProgressSubscriber(subscriberFactory.create(actor));
|
queue.addProgressSubscriber(subscriberFactory.createWithActor(actor));
|
||||||
}
|
}
|
||||||
if (queue.size() > 0) {
|
if (queue.size() > 0) {
|
||||||
queue.enqueue();
|
queue.enqueue();
|
||||||
@ -597,7 +598,7 @@ public final class PlotModificationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
queue.addProgressSubscriber(subscriberFactory.create(actor));
|
queue.addProgressSubscriber(subscriberFactory.createWithActor(actor));
|
||||||
}
|
}
|
||||||
if (queue.size() > 0) {
|
if (queue.size() > 0) {
|
||||||
queue.enqueue();
|
queue.enqueue();
|
||||||
|
@ -28,6 +28,8 @@ package com.plotsquared.core.queue.subscriber;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.util.concurrent.AtomicDouble;
|
import com.google.common.util.concurrent.AtomicDouble;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
import com.google.inject.assistedinject.AssistedInject;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.caption.Caption;
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
@ -55,10 +57,15 @@ public class DefaultProgressSubscriber implements ProgressSubscriber {
|
|||||||
@Nonnull private final TaskTime wait;
|
@Nonnull private final TaskTime wait;
|
||||||
@Nonnull private final PlotPlayer<?> actor;
|
@Nonnull private final PlotPlayer<?> actor;
|
||||||
@Nonnull private final Caption caption;
|
@Nonnull private final Caption caption;
|
||||||
@Inject @Nonnull private TaskManager taskManager;
|
|
||||||
private PlotSquaredTask task;
|
private PlotSquaredTask task;
|
||||||
|
|
||||||
@Inject public DefaultProgressSubscriber(@Nonnull final PlotPlayer<?> actor) {
|
@AssistedInject
|
||||||
|
public DefaultProgressSubscriber() {
|
||||||
|
throw new UnsupportedOperationException("DefaultProgressSubscriber cannot be used without an actor.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@AssistedInject
|
||||||
|
public DefaultProgressSubscriber(@Nullable @Assisted("subscriber") final PlotPlayer<?> actor) {
|
||||||
Preconditions.checkNotNull(actor,
|
Preconditions.checkNotNull(actor,
|
||||||
"Actor cannot be null when using DefaultProgressSubscriber! Make sure if attempting to use custom Subscribers it is correctly parsed to the queue!");
|
"Actor cannot be null when using DefaultProgressSubscriber! Make sure if attempting to use custom Subscribers it is correctly parsed to the queue!");
|
||||||
this.actor = actor;
|
this.actor = actor;
|
||||||
@ -67,17 +74,16 @@ public class DefaultProgressSubscriber implements ProgressSubscriber {
|
|||||||
this.caption = TranslatableCaption.of("working.progress");
|
this.caption = TranslatableCaption.of("working.progress");
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultProgressSubscriber(@Nonnull final PlotPlayer<?> actor,
|
@AssistedInject
|
||||||
@Nonnull final TaskManager taskManager,
|
public DefaultProgressSubscriber(@Nullable @Assisted("subscriber") final PlotPlayer<?> actor,
|
||||||
final long interval,
|
@Assisted("progressInterval") final long interval,
|
||||||
final long wait,
|
@Assisted("waitBeforeStarting") final long wait,
|
||||||
@Nullable final Caption caption) {
|
@Nullable @Assisted("caption") final Caption caption) {
|
||||||
Preconditions.checkNotNull(actor,
|
Preconditions.checkNotNull(actor,
|
||||||
"Actor cannot be null when using DefaultProgressSubscriber! Make sure if attempting to use custom Subscribers it is correctly parsed to the queue!");
|
"Actor cannot be null when using DefaultProgressSubscriber! Make sure if attempting to use custom Subscribers it is correctly parsed to the queue!");
|
||||||
this.actor = actor;
|
this.actor = actor;
|
||||||
this.interval = TaskTime.ms(interval);
|
this.interval = TaskTime.ms(interval);
|
||||||
this.wait = TaskTime.ms(wait);
|
this.wait = TaskTime.ms(wait);
|
||||||
this.taskManager = taskManager;
|
|
||||||
if (caption == null) {
|
if (caption == null) {
|
||||||
this.caption = TranslatableCaption.of("working.progress");
|
this.caption = TranslatableCaption.of("working.progress");
|
||||||
} else {
|
} else {
|
||||||
@ -92,7 +98,7 @@ public class DefaultProgressSubscriber implements ProgressSubscriber {
|
|||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
} else if (started.compareAndSet(false, true)) {
|
} else if (started.compareAndSet(false, true)) {
|
||||||
taskManager.taskLater(() -> task = taskManager.taskRepeat(() -> {
|
TaskManager.getPlatformImplementation().taskLater(() -> task = TaskManager.getPlatformImplementation().taskRepeat(() -> {
|
||||||
if (!started.get()) {
|
if (!started.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,12 @@ public abstract class RegionManager {
|
|||||||
public static RegionManager manager = null;
|
public static RegionManager manager = null;
|
||||||
private final WorldUtil worldUtil;
|
private final WorldUtil worldUtil;
|
||||||
private final GlobalBlockQueue blockQueue;
|
private final GlobalBlockQueue blockQueue;
|
||||||
@Inject private ProgressSubscriberFactory subscriberFactory;
|
private final ProgressSubscriberFactory subscriberFactory;
|
||||||
@Inject private TaskManager taskManager;
|
|
||||||
|
|
||||||
@Inject public RegionManager(@Nonnull WorldUtil worldUtil, @Nonnull GlobalBlockQueue blockQueue) {
|
@Inject public RegionManager(@Nonnull WorldUtil worldUtil, @Nonnull GlobalBlockQueue blockQueue, @Nonnull ProgressSubscriberFactory subscriberFactory) {
|
||||||
this.worldUtil = worldUtil;
|
this.worldUtil = worldUtil;
|
||||||
this.blockQueue = blockQueue;
|
this.blockQueue = blockQueue;
|
||||||
|
this.subscriberFactory = subscriberFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockVector2 getRegion(Location location) {
|
public static BlockVector2 getRegion(Location location) {
|
||||||
@ -129,7 +129,7 @@ public abstract class RegionManager {
|
|||||||
queue = area.getQueue();
|
queue = area.getQueue();
|
||||||
enqueue = true;
|
enqueue = true;
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
queue.addProgressSubscriber(subscriberFactory.create(actor));
|
queue.addProgressSubscriber(subscriberFactory.createWithActor(actor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (CuboidRegion region : regions) {
|
for (CuboidRegion region : regions) {
|
||||||
@ -188,14 +188,14 @@ public abstract class RegionManager {
|
|||||||
copyFromTo(pos1, pos2, relX, relZ, oldWorld, copyFrom, copyTo, false);
|
copyFromTo(pos1, pos2, relX, relZ, oldWorld, copyFrom, copyTo, false);
|
||||||
copyFrom.setCompleteTask(copyTo::enqueue);
|
copyFrom.setCompleteTask(copyTo::enqueue);
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
copyFrom.addProgressSubscriber(subscriberFactory.create(actor, taskManager, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
copyFrom.addProgressSubscriber(subscriberFactory.createFull(actor, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
||||||
StaticCaption.of("<prefix><gray>Current copy progress: </gray><gold><progress></gold><gray>%</gray>")));
|
StaticCaption.of("<prefix><gray>Current copy progress: </gray><gold><progress></gold><gray>%</gray>")));
|
||||||
}
|
}
|
||||||
copyFrom
|
copyFrom
|
||||||
.addReadChunks(new CuboidRegion(BlockVector3.at(pos1.getX(), 0, pos1.getZ()), BlockVector3.at(pos2.getX(), 0, pos2.getZ())).getChunks());
|
.addReadChunks(new CuboidRegion(BlockVector3.at(pos1.getX(), 0, pos1.getZ()), BlockVector3.at(pos2.getX(), 0, pos2.getZ())).getChunks());
|
||||||
copyTo.setCompleteTask(whenDone);
|
copyTo.setCompleteTask(whenDone);
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
copyTo.addProgressSubscriber(subscriberFactory.create(actor, taskManager, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
copyTo.addProgressSubscriber(subscriberFactory.createFull(actor, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
||||||
StaticCaption.of("<prefix><gray>Current paste progress: </gray><gold><progress></gold><gray>%</gray>")));
|
StaticCaption.of("<prefix><gray>Current paste progress: </gray><gold><progress></gold><gray>%</gray>")));
|
||||||
}
|
}
|
||||||
return copyFrom.enqueue();
|
return copyFrom.enqueue();
|
||||||
@ -246,22 +246,22 @@ public abstract class RegionManager {
|
|||||||
copyFromTo(pos1, pos2, relX, relZ, world1, fromQueue2, toQueue1, true);
|
copyFromTo(pos1, pos2, relX, relZ, world1, fromQueue2, toQueue1, true);
|
||||||
fromQueue1.setCompleteTask(fromQueue2::enqueue);
|
fromQueue1.setCompleteTask(fromQueue2::enqueue);
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
fromQueue1.addProgressSubscriber(subscriberFactory.create(actor, taskManager, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
fromQueue1.addProgressSubscriber(subscriberFactory.createFull(actor, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
||||||
StaticCaption.of("<prefix><gray>Current region 1 copy progress: </gray><gold><progress></gold><gray>%</gray>")));
|
StaticCaption.of("<prefix><gray>Current region 1 copy progress: </gray><gold><progress></gold><gray>%</gray>")));
|
||||||
}
|
}
|
||||||
fromQueue2.setCompleteTask(toQueue1::enqueue);
|
fromQueue2.setCompleteTask(toQueue1::enqueue);
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
fromQueue2.addProgressSubscriber(subscriberFactory.create(actor, taskManager, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
fromQueue2.addProgressSubscriber(subscriberFactory.createFull(actor, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
||||||
StaticCaption.of("<prefix><gray>Current region 2 copy progress: </gray><gold><progress></gold><gray>%</gray>")));
|
StaticCaption.of("<prefix><gray>Current region 2 copy progress: </gray><gold><progress></gold><gray>%</gray>")));
|
||||||
}
|
}
|
||||||
toQueue1.setCompleteTask(toQueue2::enqueue);
|
toQueue1.setCompleteTask(toQueue2::enqueue);
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
toQueue1.addProgressSubscriber(subscriberFactory.create(actor, taskManager, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
toQueue1.addProgressSubscriber(subscriberFactory.createFull(actor, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
||||||
StaticCaption.of("<prefix><gray>Current region 1 paste progress: </gray><gold><progress></gold><gray>%</gray>")));
|
StaticCaption.of("<prefix><gray>Current region 1 paste progress: </gray><gold><progress></gold><gray>%</gray>")));
|
||||||
}
|
}
|
||||||
toQueue2.setCompleteTask(whenDone);
|
toQueue2.setCompleteTask(whenDone);
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
toQueue2.addProgressSubscriber(subscriberFactory.create(actor, taskManager, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
toQueue2.addProgressSubscriber(subscriberFactory.createFull(actor, Settings.QUEUE.NOTIFY_INTERVAL, Settings.QUEUE.NOTIFY_WAIT,
|
||||||
StaticCaption.of("<prefix><gray>Current region 2 paste progress: </gray><gold><progress></gold><gray>%</gray>")));
|
StaticCaption.of("<prefix><gray>Current region 2 paste progress: </gray><gold><progress></gold><gray>%</gray>")));
|
||||||
}
|
}
|
||||||
fromQueue1.enqueue();
|
fromQueue1.enqueue();
|
||||||
|
@ -114,10 +114,11 @@ public abstract class SchematicHandler {
|
|||||||
public static SchematicHandler manager;
|
public static SchematicHandler manager;
|
||||||
private final WorldUtil worldUtil;
|
private final WorldUtil worldUtil;
|
||||||
private boolean exportAll = false;
|
private boolean exportAll = false;
|
||||||
@Inject private ProgressSubscriberFactory subscriberFactory;
|
private final ProgressSubscriberFactory subscriberFactory;
|
||||||
|
|
||||||
@Inject public SchematicHandler(@Nonnull final WorldUtil worldUtil) {
|
@Inject public SchematicHandler(@Nonnull final WorldUtil worldUtil, @Nonnull ProgressSubscriberFactory subscriberFactory) {
|
||||||
this.worldUtil = worldUtil;
|
this.worldUtil = worldUtil;
|
||||||
|
this.subscriberFactory = subscriberFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void upload(@Nullable UUID uuid,
|
public static void upload(@Nullable UUID uuid,
|
||||||
@ -353,7 +354,7 @@ public abstract class SchematicHandler {
|
|||||||
whenDone.value = true;
|
whenDone.value = true;
|
||||||
}
|
}
|
||||||
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
if (actor != null && Settings.QUEUE.NOTIFY_PROGRESS) {
|
||||||
queue.addProgressSubscriber(subscriberFactory.create(actor));
|
queue.addProgressSubscriber(subscriberFactory.createWithActor(actor));
|
||||||
}
|
}
|
||||||
queue.setCompleteTask(whenDone);
|
queue.setCompleteTask(whenDone);
|
||||||
queue.enqueue();
|
queue.enqueue();
|
||||||
|
Loading…
Reference in New Issue
Block a user