More DI progress

This commit is contained in:
Alexander Söderberg 2020-07-11 05:29:41 +02:00
parent c0f69f321d
commit 6f6cb4b630
16 changed files with 123 additions and 81 deletions

View File

@ -40,10 +40,12 @@ import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.PlotPlatform; import com.plotsquared.core.PlotPlatform;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.generator.HybridGen; import com.plotsquared.core.generator.HybridGen;
import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.inject.annotations.ConsoleActor; import com.plotsquared.core.inject.annotations.ConsoleActor;
import com.plotsquared.core.inject.annotations.DefaultGenerator; import com.plotsquared.core.inject.annotations.DefaultGenerator;
import com.plotsquared.core.plot.world.DefaultPlotAreaManager;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.QueueProvider; import com.plotsquared.core.queue.QueueProvider;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
@ -76,7 +78,6 @@ import org.jetbrains.annotations.NotNull;
@NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); @NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
WorldEditPlugin wePlugin = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")); WorldEditPlugin wePlugin = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
bind(Actor.class).annotatedWith(ConsoleActor.class).toInstance(wePlugin.wrapCommandSender(console)); bind(Actor.class).annotatedWith(ConsoleActor.class).toInstance(wePlugin.wrapCommandSender(console));
bind(HybridUtils.class).to(BukkitHybridUtils.class);
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);
@ -87,6 +88,11 @@ import org.jetbrains.annotations.NotNull;
bind(SchematicHandler.class).to(BukkitSchematicHandler.class); bind(SchematicHandler.class).to(BukkitSchematicHandler.class);
bind(PermHandler.class).to(BukkitPermHandler.class); bind(PermHandler.class).to(BukkitPermHandler.class);
bind(EconHandler.class).to(BukkitEconHandler.class); bind(EconHandler.class).to(BukkitEconHandler.class);
if (Settings.Enabled_Components.WORLDS) {
bind(PlotAreaManager.class).to(SinglePlotAreaManager.class);
} else {
bind(PlotAreaManager.class).to(DefaultPlotAreaManager.class);
}
} }
} }

View File

@ -137,7 +137,7 @@ import java.util.stream.Stream;
final Player player = OfflinePlayerUtil.loadPlayer(op); final Player player = OfflinePlayerUtil.loadPlayer(op);
player.loadData(); player.loadData();
return new BukkitPlayer(PlotSquared.get().getPlotAreaManager(), return new BukkitPlayer(PlotSquared.get().getPlotAreaManager(),
PlotSquared.get().getEventDispatcher(), player, true); PlotSquared.get().getEventDispatcher(), player, true, PlotSquared.platform().getEconHandler());
} }
/** /**

View File

@ -36,8 +36,10 @@ import com.plotsquared.core.location.World;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.queue.GlobalBlockQueue; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.ChatManager; import com.plotsquared.core.util.ChatManager;
import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.PlatformWorldManager; import com.plotsquared.core.util.PlatformWorldManager;
import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.logger.ILogger; import com.plotsquared.core.util.logger.ILogger;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -218,12 +220,30 @@ public interface PlotPlatform<P> extends ILogger {
} }
/** /**
* Get the hybrid utility class * Get the {@link HybridUtils} implementation for the platform
* *
* @return Hybrid utility class * @return Hybrid utils
*/ */
@NotNull default HybridUtils getHybridUtils() { @NotNull default HybridUtils getHybridUtils() {
return getInjector().getInstance(HybridUtils.class); return getInjector().getInstance(HybridUtils.class);
} }
/**
* Get the {@link SetupUtils} implementation for the platform
*
* @return Setup utils
*/
@NotNull default SetupUtils getSetupUtils() {
return getInjector().getInstance(SetupUtils.class);
}
/**
* Get the {@link EconHandler} implementation for the platform
*
* @return Econ handler
*/
@NotNull default EconHandler getEconHandler() {
return getInjector().getInstance(EconHandler.class);
}
} }

View File

@ -207,13 +207,6 @@ public class PlotSquared {
// Create plot listener // Create plot listener
this.plotListener = new PlotListener(this.eventDispatcher); this.plotListener = new PlotListener(this.eventDispatcher);
// Setup plotAreaManager
if (Settings.Enabled_Components.WORLDS) {
this.plotAreaManager = new SinglePlotAreaManager(this.eventDispatcher, this.plotListener, this.worldConfiguration);
} else {
this.plotAreaManager = new DefaultPlotAreaManager();
}
// Database // Database
if (Settings.Enabled_Components.DATABASE) { if (Settings.Enabled_Components.DATABASE) {
setupDatabase(); setupDatabase();

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
@ -32,7 +33,6 @@ 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.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue; import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.BlockUtil; import com.plotsquared.core.util.BlockUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
@ -40,6 +40,7 @@ import com.plotsquared.core.util.RegionManager;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -50,10 +51,13 @@ import java.util.Optional;
public class ClassicPlotManager extends SquarePlotManager { public class ClassicPlotManager extends SquarePlotManager {
private final ClassicPlotWorld classicPlotWorld; private final ClassicPlotWorld classicPlotWorld;
private final RegionManager regionManager;
public ClassicPlotManager(ClassicPlotWorld classicPlotWorld) { public ClassicPlotManager(@NotNull final ClassicPlotWorld classicPlotWorld,
super(classicPlotWorld); @NotNull final RegionManager regionManager) {
super(classicPlotWorld, regionManager);
this.classicPlotWorld = classicPlotWorld; this.classicPlotWorld = classicPlotWorld;
this.regionManager = regionManager;
} }
@Override public boolean setComponent(PlotId plotId, String component, Pattern blocks) { @Override public boolean setComponent(PlotId plotId, String component, Pattern blocks) {
@ -88,13 +92,13 @@ public class ClassicPlotManager extends SquarePlotManager {
.equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) { .equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) {
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK.toPattern()); setWall(plot.getId(), classicPlotWorld.WALL_BLOCK.toPattern());
} }
return GlobalBlockQueue.IMP.addEmptyTask(whenDone); return PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(whenDone);
} }
public boolean setFloor(PlotId plotId, Pattern blocks) { public boolean setFloor(PlotId plotId, Pattern blocks) {
Plot plot = classicPlotWorld.getPlotAbs(plotId); Plot plot = classicPlotWorld.getPlotAbs(plotId);
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
return RegionManager.manager.setCuboids(classicPlotWorld, plot.getRegions(), blocks, return this.regionManager.setCuboids(classicPlotWorld, plot.getRegions(), blocks,
classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.PLOT_HEIGHT); classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.PLOT_HEIGHT);
} }
return false; return false;
@ -103,8 +107,7 @@ public class ClassicPlotManager extends SquarePlotManager {
public boolean setAll(PlotId plotId, Pattern blocks) { public boolean setAll(PlotId plotId, Pattern blocks) {
Plot plot = classicPlotWorld.getPlotAbs(plotId); Plot plot = classicPlotWorld.getPlotAbs(plotId);
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
return RegionManager.manager return this.regionManager.setCuboids(classicPlotWorld, plot.getRegions(), blocks, 1, getWorldHeight());
.setCuboids(classicPlotWorld, plot.getRegions(), blocks, 1, getWorldHeight());
} }
return false; return false;
} }
@ -112,7 +115,7 @@ public class ClassicPlotManager extends SquarePlotManager {
public boolean setAir(PlotId plotId, Pattern blocks) { public boolean setAir(PlotId plotId, Pattern blocks) {
Plot plot = classicPlotWorld.getPlotAbs(plotId); Plot plot = classicPlotWorld.getPlotAbs(plotId);
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
return RegionManager.manager.setCuboids(classicPlotWorld, plot.getRegions(), blocks, return this.regionManager.setCuboids(classicPlotWorld, plot.getRegions(), blocks,
classicPlotWorld.PLOT_HEIGHT + 1, getWorldHeight()); classicPlotWorld.PLOT_HEIGHT + 1, getWorldHeight());
} }
return false; return false;
@ -121,7 +124,7 @@ public class ClassicPlotManager extends SquarePlotManager {
public boolean setMain(PlotId plotId, Pattern blocks) { public boolean setMain(PlotId plotId, Pattern blocks) {
Plot plot = classicPlotWorld.getPlotAbs(plotId); Plot plot = classicPlotWorld.getPlotAbs(plotId);
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
return RegionManager.manager.setCuboids(classicPlotWorld, plot.getRegions(), blocks, 1, return this.regionManager.setCuboids(classicPlotWorld, plot.getRegions(), blocks, 1,
classicPlotWorld.PLOT_HEIGHT - 1); classicPlotWorld.PLOT_HEIGHT - 1);
} }
return false; return false;

View File

@ -50,8 +50,8 @@ public class HybridGen extends IndependentPlotGenerator {
private final YamlConfiguration worldConfiguration; private final YamlConfiguration worldConfiguration;
@Inject public HybridGen(@NotNull final EventDispatcher eventDispatcher, @Inject public HybridGen(@NotNull final EventDispatcher eventDispatcher,
@NotNull final PlotListener plotListener, @NotNull final PlotListener plotListener,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) { @WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.plotListener = plotListener; this.plotListener = plotListener;
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;

View File

@ -34,7 +34,6 @@ 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.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue; import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
import com.plotsquared.core.util.FileBytes; import com.plotsquared.core.util.FileBytes;
@ -48,6 +47,7 @@ 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 org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -59,10 +59,13 @@ public class HybridPlotManager extends ClassicPlotManager {
public static boolean REGENERATIVE_CLEAR = true; public static boolean REGENERATIVE_CLEAR = true;
@Getter private final HybridPlotWorld hybridPlotWorld; @Getter private final HybridPlotWorld hybridPlotWorld;
private final RegionManager regionManager;
public HybridPlotManager(HybridPlotWorld hybridPlotWorld) { public HybridPlotManager(@NotNull final HybridPlotWorld hybridPlotWorld,
super(hybridPlotWorld); @NotNull final RegionManager regionManager) {
super(hybridPlotWorld, regionManager);
this.hybridPlotWorld = hybridPlotWorld; this.hybridPlotWorld = hybridPlotWorld;
this.regionManager = regionManager;
} }
@Override public void exportTemplate() throws IOException { @Override public void exportTemplate() throws IOException {
@ -199,9 +202,9 @@ public class HybridPlotManager extends ClassicPlotManager {
* </p> * </p>
*/ */
@Override public boolean clearPlot(Plot plot, final Runnable whenDone) { @Override public boolean clearPlot(Plot plot, final Runnable whenDone) {
if (RegionManager.manager.notifyClear(this)) { if (this.regionManager.notifyClear(this)) {
//If this returns false, the clear didn't work //If this returns false, the clear didn't work
if (RegionManager.manager.handleClear(plot, whenDone, this)) { if (this.regionManager.handleClear(plot, whenDone, this)) {
return true; return true;
} }
} }
@ -256,7 +259,7 @@ public class HybridPlotManager extends ClassicPlotManager {
}, () -> { }, () -> {
queue.enqueue(); queue.enqueue();
// And notify whatever called this when plot clearing is done // And notify whatever called this when plot clearing is done
GlobalBlockQueue.IMP.addEmptyTask(whenDone); PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(whenDone);
}, 10); }, 10);
return true; return true;
} }

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
import com.google.inject.assistedinject.Assisted;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
@ -41,6 +42,7 @@ import com.plotsquared.core.plot.schematic.Schematic;
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;
import com.plotsquared.core.util.RegionManager;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.CompoundTagBuilder; import com.sk89q.jnbt.CompoundTagBuilder;
@ -57,6 +59,7 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import lombok.Getter; import lombok.Getter;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.inject.Inject;
import java.io.File; import java.io.File;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashMap; import java.util.HashMap;
@ -76,15 +79,22 @@ public class HybridPlotWorld extends ClassicPlotWorld {
private Location SIGN_LOCATION; private Location SIGN_LOCATION;
@Getter private File root = null; @Getter private File root = null;
public HybridPlotWorld(final String worldName, private final RegionManager regionManager;
final String id, private final SchematicHandler schematicHandler;
@NotNull final IndependentPlotGenerator generator,
final PlotId min, @Inject public HybridPlotWorld(@Assisted final String worldName,
final PlotId max, @Assisted final String id,
@NotNull final EventDispatcher eventDispatcher, @Assisted @NotNull final IndependentPlotGenerator generator,
@NotNull final PlotListener plotListener, @Assisted final PlotId min,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) { @Assisted final PlotId max,
@NotNull final EventDispatcher eventDispatcher,
@NotNull final PlotListener plotListener,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
@NotNull final RegionManager regionManager,
@NotNull final SchematicHandler schematicHandler) {
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration); super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration);
this.regionManager = regionManager;
this.schematicHandler = schematicHandler;
} }
public static byte wrap(byte data, int start) { public static byte wrap(byte data, int start) {
@ -135,7 +145,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
} }
@NotNull @Override protected PlotManager createManager() { @NotNull @Override protected PlotManager createManager() {
return new HybridPlotManager(this); return new HybridPlotManager(this, this.regionManager);
} }
public Location getSignLocation(@NotNull Plot plot) { public Location getSignLocation(@NotNull Plot plot) {
@ -223,9 +233,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
File schematic3File = new File(root, "plot.schem"); File schematic3File = new File(root, "plot.schem");
if (!schematic3File.exists()) if (!schematic3File.exists())
schematic3File = new File(root, "plot.schematic"); schematic3File = new File(root, "plot.schematic");
Schematic schematic1 = SchematicHandler.manager.getSchematic(schematic1File); Schematic schematic1 = this.schematicHandler.getSchematic(schematic1File);
Schematic schematic2 = SchematicHandler.manager.getSchematic(schematic2File); Schematic schematic2 = this.schematicHandler.getSchematic(schematic2File);
Schematic schematic3 = SchematicHandler.manager.getSchematic(schematic3File); Schematic schematic3 = this.schematicHandler.getSchematic(schematic3File);
int shift = this.ROAD_WIDTH / 2; int shift = this.ROAD_WIDTH / 2;
int oddshift = (this.ROAD_WIDTH & 1) == 0 ? 0 : 1; int oddshift = (this.ROAD_WIDTH & 1) == 0 ? 0 : 1;

View File

@ -34,6 +34,7 @@ import com.plotsquared.core.plot.PlotId;
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.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
@ -45,10 +46,12 @@ import java.util.Set;
public abstract class SquarePlotManager extends GridPlotManager { public abstract class SquarePlotManager extends GridPlotManager {
private final SquarePlotWorld squarePlotWorld; private final SquarePlotWorld squarePlotWorld;
private final RegionManager regionManager;
public SquarePlotManager(SquarePlotWorld squarePlotWorld) { public SquarePlotManager(@NotNull final SquarePlotWorld squarePlotWorld, @NotNull final RegionManager regionManager) {
super(squarePlotWorld); super(squarePlotWorld);
this.squarePlotWorld = squarePlotWorld; this.squarePlotWorld = squarePlotWorld;
this.regionManager = regionManager;
} }
@Override public boolean clearPlot(final Plot plot, final Runnable whenDone) { @Override public boolean clearPlot(final Plot plot, final Runnable whenDone) {
@ -64,7 +67,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
iterator.remove(); iterator.remove();
final Location pos1 = Location.at(plot.getWorldName(), region.getMinimumPoint()); final Location pos1 = Location.at(plot.getWorldName(), region.getMinimumPoint());
final Location pos2 = Location.at(plot.getWorldName(), region.getMaximumPoint()); final Location pos2 = Location.at(plot.getWorldName(), region.getMaximumPoint());
RegionManager.manager.regenerateRegion(pos1, pos2, false, this); regionManager.regenerateRegion(pos1, pos2, false, this);
} }
}; };
run.run(); run.run();

View File

@ -34,7 +34,6 @@ 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.listener.PlotListener; import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.plot.world.PlotAreaManager;
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;
@ -48,7 +47,6 @@ public class PlotSquaredModule extends AbstractModule {
bind(YamlConfiguration.class).annotatedWith(WorldConfig.class).toInstance(plotSquared.getWorldConfiguration()); bind(YamlConfiguration.class).annotatedWith(WorldConfig.class).toInstance(plotSquared.getWorldConfiguration());
bind(File.class).annotatedWith(WorldFile.class).toInstance(plotSquared.getWorldsFile()); bind(File.class).annotatedWith(WorldFile.class).toInstance(plotSquared.getWorldsFile());
bind(File.class).annotatedWith(ConfigFile.class).toInstance(plotSquared.getConfigFile()); bind(File.class).annotatedWith(ConfigFile.class).toInstance(plotSquared.getConfigFile());
bind(PlotAreaManager.class).toInstance(plotSquared.getPlotAreaManager());
bind(PlotListener.class).toInstance(plotSquared.getPlotListener()); bind(PlotListener.class).toInstance(plotSquared.getPlotListener());
bind(UUIDPipeline.class).annotatedWith(ImpromptuPipeline.class).toInstance(plotSquared.getImpromptuUUIDPipeline()); bind(UUIDPipeline.class).annotatedWith(ImpromptuPipeline.class).toInstance(plotSquared.getImpromptuUUIDPipeline());
bind(UUIDPipeline.class).annotatedWith(BackgroundPipeline.class).toInstance(plotSquared.getBackgroundUUIDPipeline()); bind(UUIDPipeline.class).annotatedWith(BackgroundPipeline.class).toInstance(plotSquared.getBackgroundUUIDPipeline());

View File

@ -31,7 +31,6 @@ import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.PlotUnlinkEvent; import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.player.OfflinePlotPlayer; import com.plotsquared.core.player.OfflinePlotPlayer;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
@ -325,7 +324,7 @@ public class ExpireManager {
} }
for (ExpiryTask expiryTask : expired) { for (ExpiryTask expiryTask : expired) {
if (!expiryTask.needsAnalysis()) { if (!expiryTask.needsAnalysis()) {
expiredTask.run(newPlot, () -> TaskManager.IMP.taskLaterAsync(task, 1), expiredTask.run(newPlot, () -> TaskManager.getImplementation().taskLaterAsync(task, 1),
expiryTask.requiresConfirmation()); expiryTask.requiresConfirmation());
return; return;
} }
@ -336,7 +335,7 @@ public class ExpireManager {
passesComplexity(changed, expired, new RunnableVal<Boolean>() { passesComplexity(changed, expired, new RunnableVal<Boolean>() {
@Override public void run(Boolean confirmation) { @Override public void run(Boolean confirmation) {
expiredTask.run(newPlot, expiredTask.run(newPlot,
() -> TaskManager.IMP.taskLaterAsync(task, 1), () -> TaskManager.getImplementation().taskLaterAsync(task, 1),
confirmation); confirmation);
} }
}, () -> { }, () -> {
@ -354,7 +353,7 @@ public class ExpireManager {
} }
}; };
final Runnable doAnalysis = final Runnable doAnalysis =
() -> HybridUtils.manager.analyzePlot(newPlot, handleAnalysis); () -> PlotSquared.platform().getHybridUtils().analyzePlot(newPlot, handleAnalysis);
PlotAnalysis analysis = newPlot.getComplexity(null); PlotAnalysis analysis = newPlot.getComplexity(null);
if (analysis != null) { if (analysis != null) {
@ -362,7 +361,7 @@ public class ExpireManager {
@Override public void run(Boolean value) { @Override public void run(Boolean value) {
doAnalysis.run(); doAnalysis.run();
} }
}, () -> TaskManager.IMP.taskLaterAsync(task, 1)); }, () -> TaskManager.getImplementation().taskLaterAsync(task, 1));
} else { } else {
doAnalysis.run(); doAnalysis.run();
} }

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.plot.world; package com.plotsquared.core.plot.world;
import com.google.inject.Singleton;
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.PlotAreaType; import com.plotsquared.core.plot.PlotAreaType;
@ -41,7 +42,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
public class DefaultPlotAreaManager implements PlotAreaManager { @Singleton public class DefaultPlotAreaManager implements PlotAreaManager {
final PlotArea[] noPlotAreas = new PlotArea[0]; final PlotArea[] noPlotAreas = new PlotArea[0];
private final Map<String, PlotWorld> plotWorlds = new HashMap<>(); private final Map<String, PlotWorld> plotWorlds = new HashMap<>();

View File

@ -25,14 +25,12 @@
*/ */
package com.plotsquared.core.plot.world; package com.plotsquared.core.plot.world;
import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.location.BlockLoc; import com.plotsquared.core.location.BlockLoc;
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.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.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.util.EventDispatcher;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -45,21 +43,20 @@ import java.util.UUID;
import java.util.function.Consumer; import java.util.function.Consumer;
public class SinglePlot extends Plot { public class SinglePlot extends Plot {
private Set<CuboidRegion> regions = Collections.singleton( private Set<CuboidRegion> regions = Collections.singleton(
new CuboidRegion(BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE), new CuboidRegion(BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE))); BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)));
public SinglePlot(PlotArea area, PlotId id, @NotNull final EventDispatcher eventDispatcher, @NotNull final public SinglePlot(@NotNull final PlotArea area, @NotNull final PlotId id) {
PlotListener plotListener) { super(area, id);
super(area, id, eventDispatcher, plotListener);
} }
public SinglePlot(PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members, public SinglePlot(PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members,
HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?, ?>> flags, HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?, ?>> flags,
PlotArea area, boolean[] merged, long timestamp, int temp, PlotArea area, boolean[] merged, long timestamp, int temp) {
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
super(id, owner, trusted, members, denied, alias, position, flags, area, merged, timestamp, super(id, owner, trusted, members, denied, alias, position, flags, area, merged, timestamp,
temp, eventDispatcher, plotListener); temp);
} }
@Override public String getWorldName() { @Override public String getWorldName() {

View File

@ -26,13 +26,13 @@
package com.plotsquared.core.plot.world; package com.plotsquared.core.plot.world;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.ConfigurationUtil; import com.plotsquared.core.configuration.ConfigurationUtil;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.generator.GridPlotWorld; import com.plotsquared.core.generator.GridPlotWorld;
import com.plotsquared.core.generator.SingleWorldGenerator; import com.plotsquared.core.generator.SingleWorldGenerator;
import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.location.PlotLoc; import com.plotsquared.core.location.PlotLoc;
@ -42,11 +42,11 @@ import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.plot.PlotSettings; import com.plotsquared.core.plot.PlotSettings;
import com.plotsquared.core.plot.flag.FlagContainer; import com.plotsquared.core.plot.flag.FlagContainer;
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.EconHandler;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.WorldUtil;
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 org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -66,8 +66,11 @@ public class SinglePlotArea extends GridPlotWorld {
public SinglePlotArea(@NotNull final PlotAreaManager plotAreaManager, public SinglePlotArea(@NotNull final PlotAreaManager plotAreaManager,
@NotNull final EventDispatcher eventDispatcher, @NotNull final EventDispatcher eventDispatcher,
@NotNull final PlotListener plotListener, @NotNull final PlotListener plotListener,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) { @WorldConfig @NotNull final YamlConfiguration worldConfiguration,
super("*", null, new SingleWorldGenerator(plotAreaManager), null, null, eventDispatcher, plotListener, worldConfiguration); @NotNull final GlobalBlockQueue globalBlockQueue,
@NotNull final EconHandler econHandler) {
super("*", null, new SingleWorldGenerator(plotAreaManager), null, null,
eventDispatcher, plotListener, worldConfiguration, globalBlockQueue, econHandler);
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.plotListener = plotListener; this.plotListener = plotListener;
this.setAllowSigns(false); this.setAllowSigns(false);
@ -88,10 +91,10 @@ public class SinglePlotArea extends GridPlotWorld {
public void loadWorld(final PlotId id) { public void loadWorld(final PlotId id) {
String worldName = id.getX() + "." + id.getY(); String worldName = id.getX() + "." + id.getY();
if (WorldUtil.IMP.isWorld(worldName)) { if (PlotSquared.platform().getWorldUtil().isWorld(worldName)) {
return; return;
} }
PlotAreaBuilder builder = new PlotAreaBuilder() PlotAreaBuilder builder = PlotAreaBuilder.newBuilder()
.plotManager("PlotSquared:single") .plotManager("PlotSquared:single")
.generatorName("PlotSquared:single") .generatorName("PlotSquared:single")
.plotAreaType(getType()) .plotAreaType(getType())
@ -138,14 +141,13 @@ public class SinglePlotArea extends GridPlotWorld {
} }
} }
TaskManager.IMP.sync(new RunnableVal<Object>() { TaskManager.getImplementation().sync(new RunnableVal<Object>() {
@Override public void run(Object value) { @Override public void run(Object value) {
String worldName = id.getX() + "." + id.getY(); String worldName = id.getX() + "." + id.getY();
if (WorldUtil.IMP.isWorld(worldName)) { if (PlotSquared.platform().getWorldUtil().isWorld(worldName)) {
return; return;
} }
PlotSquared.platform().getSetupUtils().setupWorld(builder);
SetupUtils.manager.setupWorld(builder);
} }
}); });
// String worldName = plot.getWorldName(); // String worldName = plot.getWorldName();

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.plot.world; package com.plotsquared.core.plot.world;
import com.google.inject.Singleton;
import com.plotsquared.core.inject.annotations.WorldConfig; import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.collection.ArrayUtil; import com.plotsquared.core.collection.ArrayUtil;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
@ -32,22 +33,29 @@ import com.plotsquared.core.generator.SingleWorldGenerator;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.listener.PlotListener;
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.queue.GlobalBlockQueue;
import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class SinglePlotAreaManager extends DefaultPlotAreaManager { import javax.inject.Inject;
@Singleton public class SinglePlotAreaManager extends DefaultPlotAreaManager {
private final SinglePlotArea[] array; private final SinglePlotArea[] array;
private SinglePlotArea area; private SinglePlotArea area;
private PlotArea[] all; private PlotArea[] all;
public SinglePlotAreaManager(@NotNull final EventDispatcher eventDispatcher, @Inject public SinglePlotAreaManager(@NotNull final EventDispatcher eventDispatcher,
@NotNull final PlotListener plotListener, @NotNull final PlotListener plotListener,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) { @WorldConfig @NotNull final YamlConfiguration worldConfiguration,
this.area = new SinglePlotArea(this, eventDispatcher, plotListener, worldConfiguration); @NotNull final GlobalBlockQueue blockQueue,
@NotNull final EconHandler econHandler) {
this.area = new SinglePlotArea(this, eventDispatcher, plotListener,
worldConfiguration, blockQueue, econHandler);
this.array = new SinglePlotArea[] {area}; this.array = new SinglePlotArea[] {area};
this.all = new PlotArea[] {area}; this.all = new PlotArea[] {area};
SetupUtils.generators.put("PlotSquared:single", SetupUtils.generators.put("PlotSquared:single",

View File

@ -32,7 +32,6 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.SetupUtils;
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;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -41,7 +40,8 @@ import java.io.File;
import java.util.List; import java.util.List;
public class SinglePlotManager extends PlotManager { public class SinglePlotManager extends PlotManager {
public SinglePlotManager(PlotArea plotArea) {
public SinglePlotManager(@NotNull final PlotArea plotArea) {
super(plotArea); super(plotArea);
} }
@ -62,10 +62,9 @@ public class SinglePlotManager extends PlotManager {
} }
@Override public boolean clearPlot(Plot plot, final Runnable whenDone) { @Override public boolean clearPlot(Plot plot, final Runnable whenDone) {
SetupUtils.manager.unload(plot.getWorldName(), false); PlotSquared.platform().getSetupUtils().unload(plot.getWorldName(), false);
final File worldFolder = final File worldFolder = new File(PlotSquared.platform().getWorldContainer(), plot.getWorldName());
new File(PlotSquared.platform().getWorldContainer(), plot.getWorldName()); TaskManager.getImplementation().taskAsync(() -> {
TaskManager.IMP.taskAsync(() -> {
MainUtil.deleteDirectory(worldFolder); MainUtil.deleteDirectory(worldFolder);
if (whenDone != null) { if (whenDone != null) {
whenDone.run(); whenDone.run();