Guice progress

This commit is contained in:
Alexander Söderberg 2020-07-11 17:19:19 +02:00
parent 6f6cb4b630
commit 916675fb08
No known key found for this signature in database
GPG Key ID: C0207FF7EA146678
29 changed files with 427 additions and 237 deletions

View File

@ -26,6 +26,7 @@
package com.plotsquared.bukkit.inject; package com.plotsquared.bukkit.inject;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.assistedinject.FactoryModuleBuilder;
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.BukkitLocalQueue;
@ -43,6 +44,7 @@ import com.plotsquared.core.generator.HybridGen;
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.inject.factory.HybridPlotWorldFactory;
import com.plotsquared.core.plot.world.DefaultPlotAreaManager; import com.plotsquared.core.plot.world.DefaultPlotAreaManager;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotAreaManager; import com.plotsquared.core.plot.world.SinglePlotAreaManager;
@ -93,6 +95,7 @@ import org.jetbrains.annotations.NotNull;
} else { } else {
bind(PlotAreaManager.class).to(DefaultPlotAreaManager.class); bind(PlotAreaManager.class).to(DefaultPlotAreaManager.class);
} }
install(new FactoryModuleBuilder().build(HybridPlotWorldFactory.class));
} }
} }

View File

@ -44,6 +44,7 @@ import com.plotsquared.core.generator.GeneratorWrapper;
import com.plotsquared.core.generator.HybridPlotWorld; import com.plotsquared.core.generator.HybridPlotWorld;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.inject.factory.HybridPlotWorldFactory;
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.player.ConsolePlayer; import com.plotsquared.core.player.ConsolePlayer;
@ -58,7 +59,6 @@ import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.plot.comment.CommentManager; import com.plotsquared.core.plot.comment.CommentManager;
import com.plotsquared.core.plot.expiration.ExpireManager; import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.expiration.ExpiryTask; import com.plotsquared.core.plot.expiration.ExpiryTask;
import com.plotsquared.core.plot.world.DefaultPlotAreaManager;
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;
@ -1097,8 +1097,9 @@ public class PlotSquared {
split = combinedArgs; split = combinedArgs;
} }
HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator, final HybridPlotWorldFactory hybridPlotWorldFactory = this.platform.getInjector().getInstance(HybridPlotWorldFactory.class);
null, null, this.eventDispatcher, this.plotListener, this.worldConfiguration); final HybridPlotWorld plotWorld = hybridPlotWorldFactory.create(world, null, generator, null, null);
for (String element : split) { for (String element : split) {
String[] pair = element.split("="); String[] pair = element.split("=");
if (pair.length != 2) { if (pair.length != 2) {
@ -1162,8 +1163,8 @@ public class PlotSquared {
try { try {
ConfigurationSection section = ConfigurationSection section =
this.worldConfiguration.getConfigurationSection("worlds." + world); this.worldConfiguration.getConfigurationSection("worlds." + world);
plotworld.saveConfiguration(section); plotWorld.saveConfiguration(section);
plotworld.loadDefaultConfiguration(section); plotWorld.loadDefaultConfiguration(section);
this.worldConfiguration.save(this.worldsFile); this.worldConfiguration.save(this.worldsFile);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
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.inject.annotations.WorldFile; import com.plotsquared.core.inject.annotations.WorldFile;
@ -35,7 +36,7 @@ import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.generator.AugmentedUtils; import com.plotsquared.core.generator.AugmentedUtils;
import com.plotsquared.core.generator.HybridPlotWorld; import com.plotsquared.core.generator.HybridPlotWorld;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.inject.factory.HybridPlotWorldFactory;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.ConsolePlayer; import com.plotsquared.core.player.ConsolePlayer;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -46,7 +47,6 @@ import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.message.PlotMessage; import com.plotsquared.core.plot.message.PlotMessage;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.setup.PlotAreaBuilder; import com.plotsquared.core.setup.PlotAreaBuilder;
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.Permissions; import com.plotsquared.core.util.Permissions;
@ -93,21 +93,27 @@ import java.util.Set;
public class Area extends SubCommand { public class Area extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final EventDispatcher eventDispatcher;
private final PlotListener plotListener;
private final YamlConfiguration worldConfiguration; private final YamlConfiguration worldConfiguration;
private final File worldFile; private final File worldFile;
private final HybridPlotWorldFactory hybridPlotWorldFactory;
private final SetupUtils setupUtils;
private final WorldUtil worldUtil;
private final RegionManager regionManager;
public Area(@NotNull final PlotAreaManager plotAreaManager, @Inject public Area(@NotNull final PlotAreaManager plotAreaManager,
@NotNull final EventDispatcher eventDispatcher, @WorldConfig @NotNull final YamlConfiguration worldConfiguration,
@NotNull final PlotListener plotListener, @WorldFile @NotNull final File worldFile,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration, @NotNull final HybridPlotWorldFactory hybridPlotWorldFactory,
@WorldFile @NotNull final File worldFile) { @NotNull final SetupUtils setupUtils,
@NotNull final WorldUtil worldUtil,
@NotNull final RegionManager regionManager) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.eventDispatcher = eventDispatcher;
this.plotListener = plotListener;
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;
this.worldFile = worldFile; this.worldFile = worldFile;
this.hybridPlotWorldFactory = hybridPlotWorldFactory;
this.setupUtils = setupUtils;
this.worldUtil = worldUtil;
this.regionManager = regionManager;
} }
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
@ -164,9 +170,8 @@ public class Area extends SubCommand {
BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ())); BlockVector3.at(playerSelectionMax.getX(), 255, playerSelectionMax.getZ()));
// There's only one plot in the area... // There's only one plot in the area...
final PlotId plotId = new PlotId(1, 1); final PlotId plotId = new PlotId(1, 1);
final HybridPlotWorld hybridPlotWorld = new HybridPlotWorld(player.getLocation().getWorldName(), args[1], final HybridPlotWorld hybridPlotWorld = this.hybridPlotWorldFactory.create(player.getLocation().getWorldName(), args[1],
Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId, Objects.requireNonNull(PlotSquared.platform()).getDefaultGenerator(), plotId, plotId);
this.eventDispatcher, this.plotListener, this.worldConfiguration);
// Plot size is the same as the region width // Plot size is the same as the region width
hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth(); hybridPlotWorld.PLOT_WIDTH = hybridPlotWorld.SIZE = (short) selectedRegion.getWidth();
// We use a schematic generator // We use a schematic generator
@ -231,8 +236,8 @@ public class Area extends SubCommand {
if (offsetZ != 0) { if (offsetZ != 0) {
this.worldConfiguration.set(path + ".road.offset.z", offsetZ); this.worldConfiguration.set(path + ".road.offset.z", offsetZ);
} }
final String world = SetupUtils.manager.setupWorld(singleBuilder); final String world = this.setupUtils.setupWorld(singleBuilder);
if (WorldUtil.IMP.isWorld(world)) { if (this.worldUtil.isWorld(world)) {
PlotSquared.get().loadWorld(world, null); PlotSquared.get().loadWorld(world, null);
MainUtil.sendMessage(player, Captions.SINGLE_AREA_CREATED); MainUtil.sendMessage(player, Captions.SINGLE_AREA_CREATED);
} else { } else {
@ -322,14 +327,14 @@ public class Area extends SubCommand {
if (offsetZ != 0) { if (offsetZ != 0) {
this.worldConfiguration.set(path + ".road.offset.z", offsetZ); this.worldConfiguration.set(path + ".road.offset.z", offsetZ);
} }
final String world = SetupUtils.manager.setupWorld(builder); final String world = this.setupUtils.setupWorld(builder);
if (WorldUtil.IMP.isWorld(world)) { if (this.worldUtil.isWorld(world)) {
PlotSquared.get().loadWorld(world, null); PlotSquared.get().loadWorld(world, null);
Captions.SETUP_FINISHED.send(player); Captions.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world), player.teleport(this.worldUtil.getSpawn(world),
TeleportCause.COMMAND); TeleportCause.COMMAND);
if (area.getTerrain() != PlotAreaTerrainType.ALL) { if (area.getTerrain() != PlotAreaTerrainType.ALL) {
RegionManager.largeRegionTask(world, region, this.regionManager.largeRegionTask(world, region,
new RunnableVal<BlockVector2>() { new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
AugmentedUtils AugmentedUtils
@ -360,11 +365,10 @@ public class Area extends SubCommand {
} else { } else {
id = null; id = null;
} }
PlotAreaBuilder builder = new PlotAreaBuilder(); PlotAreaBuilder builder = PlotAreaBuilder.newBuilder();
builder.worldName(split[0]); builder.worldName(split[0]);
final HybridPlotWorld pa = new HybridPlotWorld(builder.worldName(), id, final HybridPlotWorld pa = this.hybridPlotWorldFactory.create(builder.worldName(),
PlotSquared.platform().getDefaultGenerator(), null, null, this.eventDispatcher, id, PlotSquared.platform().getDefaultGenerator(), null, null);
this.plotListener, this.worldConfiguration);
PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id); PlotArea other = this.plotAreaManager.getPlotArea(pa.getWorldName(), id);
if (other != null && Objects.equals(pa.getId(), other.getId())) { if (other != null && Objects.equals(pa.getId(), other.getId())) {
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString()); Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
@ -440,7 +444,7 @@ public class Area extends SubCommand {
} }
} }
if (pa.getType() != PlotAreaType.PARTIAL) { if (pa.getType() != PlotAreaType.PARTIAL) {
if (WorldUtil.IMP.isWorld(pa.getWorldName())) { if (this.worldUtil.isWorld(pa.getWorldName())) {
Captions.SETUP_WORLD_TAKEN.send(player, pa.getWorldName()); Captions.SETUP_WORLD_TAKEN.send(player, pa.getWorldName());
return false; return false;
} }
@ -454,10 +458,10 @@ public class Area extends SubCommand {
pa.loadConfiguration(section); pa.loadConfiguration(section);
builder.plotManager(PlotSquared.platform().getPluginName()); builder.plotManager(PlotSquared.platform().getPluginName());
builder.generatorName(PlotSquared.platform().getPluginName()); builder.generatorName(PlotSquared.platform().getPluginName());
String world = SetupUtils.manager.setupWorld(builder); String world = this.setupUtils.setupWorld(builder);
if (WorldUtil.IMP.isWorld(world)) { if (this.worldUtil.isWorld(world)) {
Captions.SETUP_FINISHED.send(player); Captions.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world), player.teleport(this.worldUtil.getSpawn(world),
TeleportCause.COMMAND); TeleportCause.COMMAND);
} else { } else {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
@ -483,16 +487,16 @@ public class Area extends SubCommand {
+ " create [world[:id]] [<modifier>=<value>]..."); + " create [world[:id]] [<modifier>=<value>]...");
return false; return false;
} }
if (WorldUtil.IMP.isWorld(pa.getWorldName())) { if (this.worldUtil.isWorld(pa.getWorldName())) {
if (!player.getLocation().getWorldName().equals(pa.getWorldName())) { if (!player.getLocation().getWorldName().equals(pa.getWorldName())) {
player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()), player.teleport(this.worldUtil.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND); TeleportCause.COMMAND);
} }
} else { } else {
builder.terrainType(PlotAreaTerrainType.NONE); builder.terrainType(PlotAreaTerrainType.NONE);
builder.plotAreaType(PlotAreaType.NORMAL); builder.plotAreaType(PlotAreaType.NORMAL);
SetupUtils.manager.setupWorld(builder); this.setupUtils.setupWorld(builder);
player.teleport(WorldUtil.IMP.getSpawn(pa.getWorldName()), player.teleport(this.worldUtil.getSpawn(pa.getWorldName()),
TeleportCause.COMMAND); TeleportCause.COMMAND);
} }
player.setMeta("area_create_area", pa); player.setMeta("area_create_area", pa);
@ -636,7 +640,7 @@ public class Area extends SubCommand {
"$4Stop the server and delete: " + area.getWorldName() + "/region"); "$4Stop the server and delete: " + area.getWorldName() + "/region");
return false; return false;
} }
RegionManager.largeRegionTask(area.getWorldName(), area.getRegion(), this.regionManager.largeRegionTask(area.getWorldName(), area.getRegion(),
new RunnableVal<BlockVector2>() { new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
AugmentedUtils AugmentedUtils
@ -666,7 +670,7 @@ public class Area extends SubCommand {
} }
Location center; Location center;
if (area.getType() != PlotAreaType.PARTIAL) { if (area.getType() != PlotAreaType.PARTIAL) {
center = WorldUtil.IMP.getSpawn(area.getWorldName()); center = this.worldUtil.getSpawn(area.getWorldName());
player.teleport(center, TeleportCause.COMMAND); player.teleport(center, TeleportCause.COMMAND);
} else { } else {
CuboidRegion region = area.getRegion(); CuboidRegion region = area.getRegion();
@ -674,8 +678,7 @@ public class Area extends SubCommand {
+ (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2, + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
0, region.getMinimumPoint().getZ() 0, region.getMinimumPoint().getZ()
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2); + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
WorldUtil.IMP this.worldUtil.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y ->
.getHighestBlock(area.getWorldName(), center.getX(), center.getZ(), y ->
player.teleport(center.withY(1 + y), TeleportCause.COMMAND)); player.teleport(center.withY(1 + y), TeleportCause.COMMAND));
} }
return true; return true;

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
@ -39,6 +40,7 @@ import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -52,10 +54,13 @@ import java.util.concurrent.CompletableFuture;
public class Buy extends Command { public class Buy extends Command {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler;
public Buy(@NotNull final EventDispatcher eventDispatcher) {
@Inject public Buy(@NotNull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler;
} }
@Override @Override
@ -63,7 +68,7 @@ public class Buy extends Command {
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) { final RunnableVal2<Command, CommandResult> whenDone) {
check(EconHandler.getEconHandler(), Captions.ECON_DISABLED); check(this.econHandler, Captions.ECON_DISABLED);
final Plot plot; final Plot plot;
if (args.length != 0) { if (args.length != 0) {
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage()); checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
@ -87,7 +92,7 @@ public class Buy extends Command {
confirm.run(this, () -> { confirm.run(this, () -> {
Captions.REMOVED_BALANCE.send(player, price); Captions.REMOVED_BALANCE.send(player, price);
EconHandler.getEconHandler().depositMoney(PlotSquared.platform().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price); this.econHandler.depositMoney(PlotSquared.platform().getPlayerManager().getOfflinePlayer(plot.getOwnerAbs()), price);
PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs()); PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs());
if (owner != null) { if (owner != null) {

View File

@ -26,6 +26,7 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
@ -46,6 +47,7 @@ import com.plotsquared.core.util.Permissions;
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;
import org.jetbrains.annotations.Nullable;
@CommandDeclaration(command = "claim", @CommandDeclaration(command = "claim",
aliases = "c", aliases = "c",
@ -57,9 +59,12 @@ import org.jetbrains.annotations.NotNull;
public class Claim extends SubCommand { public class Claim extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler;
public Claim(@NotNull final EventDispatcher eventDispatcher) { @Inject public Claim(@NotNull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler;
} }
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
@ -112,14 +117,14 @@ public class Claim extends SubCommand {
} }
} }
} }
if ((EconHandler.getEconHandler() != null) && area.useEconomy() && !force) { if ((this.econHandler != null) && area.useEconomy() && !force) {
Expression<Double> costExr = area.getPrices().get("claim"); Expression<Double> costExr = area.getPrices().get("claim");
double cost = costExr.evaluate((double) currentPlots); double cost = costExr.evaluate((double) currentPlots);
if (cost > 0d) { if (cost > 0d) {
if (EconHandler.getEconHandler().getMoney(player) < cost) { if (this.econHandler.getMoney(player) < cost) {
return sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost); return sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
} }
EconHandler.getEconHandler().withdrawMoney(player, cost); this.econHandler.withdrawMoney(player, cost);
sendMessage(player, Captions.REMOVED_BALANCE, cost + ""); sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
} }
} }
@ -137,7 +142,7 @@ public class Claim extends SubCommand {
} }
plot.setOwnerAbs(player.getUUID()); plot.setOwnerAbs(player.getUUID());
final String finalSchematic = schematic; final String finalSchematic = schematic;
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() { DBFunc.createPlotSafe(plot, () -> TaskManager.getImplementation().sync(new RunnableVal<Object>() {
@Override public void run(Object value) { @Override public void run(Object value) {
if (!plot.claim(player, true, finalSchematic, false)) { if (!plot.claim(player, true, finalSchematic, false)) {
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.backup.BackupManager; import com.plotsquared.core.backup.BackupManager;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
@ -58,10 +59,13 @@ import static com.plotsquared.core.command.SubCommand.sendMessage;
public class Clear extends Command { public class Clear extends Command {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final GlobalBlockQueue blockQueue;
public Clear(@NotNull final EventDispatcher eventDispatcher) {
@Inject public Clear(@NotNull final EventDispatcher eventDispatcher,
@NotNull final GlobalBlockQueue blockQueue) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.blockQueue = blockQueue;
} }
@Override @Override
@ -87,7 +91,7 @@ public class Clear extends Command {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
boolean result = plot.clear(true, false, () -> { boolean result = plot.clear(true, false, () -> {
plot.unlink(); plot.unlink();
GlobalBlockQueue.IMP.addEmptyTask(() -> { this.blockQueue.addEmptyTask(() -> {
plot.removeRunning(); plot.removeRunning();
// If the state changes, then mark it as no longer done // If the state changes, then mark it as no longer done
if (DoneFlag.isDone(plot)) { if (DoneFlag.isDone(plot)) {

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.generator.HybridPlotWorld; import com.plotsquared.core.generator.HybridPlotWorld;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
@ -32,6 +33,7 @@ import com.plotsquared.core.location.Location;
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.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import org.jetbrains.annotations.NotNull;
@CommandDeclaration(command = "createroadschematic", @CommandDeclaration(command = "createroadschematic",
aliases = {"crs"}, aliases = {"crs"},
@ -42,6 +44,12 @@ import com.plotsquared.core.util.MainUtil;
usage = "/plot createroadschematic") usage = "/plot createroadschematic")
public class CreateRoadSchematic extends SubCommand { public class CreateRoadSchematic extends SubCommand {
private final HybridUtils hybridUtils;
@Inject public CreateRoadSchematic(@NotNull final HybridUtils hybridUtils) {
this.hybridUtils = hybridUtils;
}
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();
Plot plot = location.getPlotAbs(); Plot plot = location.getPlotAbs();
@ -51,7 +59,7 @@ public class CreateRoadSchematic extends SubCommand {
if (!(location.getPlotArea() instanceof HybridPlotWorld)) { if (!(location.getPlotArea() instanceof HybridPlotWorld)) {
return sendMessage(player, Captions.NOT_IN_PLOT_WORLD); return sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
} }
HybridUtils.manager.setupRoadSchematic(plot); this.hybridUtils.setupRoadSchematic(plot);
MainUtil.sendMessage(player, Captions.SCHEMATIC_ROAD_CREATED); MainUtil.sendMessage(player, Captions.SCHEMATIC_ROAD_CREATED);
return true; return true;
} }

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.generator.HybridPlotManager; import com.plotsquared.core.generator.HybridPlotManager;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
@ -34,6 +35,7 @@ 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.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays; import java.util.Arrays;
@ -44,8 +46,15 @@ import java.util.Arrays;
category = CommandCategory.DEBUG, category = CommandCategory.DEBUG,
permission = "plots.debugroadregen") permission = "plots.debugroadregen")
public class DebugRoadRegen extends SubCommand { public class DebugRoadRegen extends SubCommand {
public static final String USAGE = "/plot debugroadregen <plot|region [height]>"; public static final String USAGE = "/plot debugroadregen <plot|region [height]>";
private final HybridUtils hybridUtils;
@Inject public DebugRoadRegen(@NotNull final HybridUtils hybridUtils) {
this.hybridUtils = hybridUtils;
}
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
if (args.length < 1) { if (args.length < 1) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE); MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE);
@ -117,7 +126,7 @@ public class DebugRoadRegen extends SubCommand {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads"); MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
boolean result = HybridUtils.manager.scheduleSingleRegionRoadUpdate(plot, height); boolean result = this.hybridUtils.scheduleSingleRegionRoadUpdate(plot, height);
if (!result) { if (!result) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&cCannot schedule mass schematic update! (Is one already in progress?)"); "&cCannot schedule mass schematic update! (Is one already in progress?)");

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
@ -39,6 +40,7 @@ import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandDeclaration(command = "delete", @CommandDeclaration(command = "delete",
@ -52,9 +54,12 @@ import org.jetbrains.annotations.NotNull;
public class Delete extends SubCommand { public class Delete extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler;
public Delete(@NotNull final EventDispatcher eventDispatcher) {
@Inject public Delete(@NotNull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler;
} }
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
@ -89,11 +94,11 @@ public class Delete extends SubCommand {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
boolean result = plot.deletePlot(() -> { boolean result = plot.deletePlot(() -> {
plot.removeRunning(); plot.removeRunning();
if ((EconHandler.getEconHandler() != null) && plotArea.useEconomy()) { if ((this.econHandler != null) && plotArea.useEconomy()) {
Expression<Double> valueExr = plotArea.getPrices().get("sell"); Expression<Double> valueExr = plotArea.getPrices().get("sell");
double value = plots.size() * valueExr.evaluate((double) currentPlots); double value = plots.size() * valueExr.evaluate((double) currentPlots);
if (value > 0d) { if (value > 0d) {
EconHandler.getEconHandler().depositMoney(player, value); this.econHandler.depositMoney(player, value);
sendMessage(player, Captions.ADDED_BALANCE, String.valueOf(value)); sendMessage(player, Captions.ADDED_BALANCE, String.valueOf(value));
} }
} }

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
@ -55,11 +56,15 @@ public class Deny extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final WorldUtil worldUtil;
public Deny(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) { @Inject public Deny(@NotNull final PlotAreaManager plotAreaManager,
@NotNull final EventDispatcher eventDispatcher,
@NotNull final WorldUtil worldUtil) {
super(Argument.PlayerName); super(Argument.PlayerName);
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.worldUtil = worldUtil;
} }
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
@ -141,10 +146,10 @@ public class Deny extends SubCommand {
player.stopSpectating(); player.stopSpectating();
} }
Location location = player.getLocation(); Location location = player.getLocation();
Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName()); Location spawn = this.worldUtil.getSpawn(location.getWorldName());
MainUtil.sendMessage(player, Captions.YOU_GOT_DENIED); MainUtil.sendMessage(player, Captions.YOU_GOT_DENIED);
if (plot.equals(spawn.getPlot())) { if (plot.equals(spawn.getPlot())) {
Location newSpawn = WorldUtil.IMP.getSpawn(this.plotAreaManager.getAllWorlds()[0]); Location newSpawn = this.worldUtil.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
if (plot.equals(newSpawn.getPlot())) { if (plot.equals(newSpawn.getPlot())) {
// Kick from server if you can't be teleported to spawn // Kick from server if you can't be teleported to spawn
player.kick(Captions.YOU_GOT_DENIED.getTranslated()); player.kick(Captions.YOU_GOT_DENIED.getTranslated());

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.database.DBFunc;
@ -55,10 +56,13 @@ import java.util.concurrent.TimeoutException;
public class Kick extends SubCommand { public class Kick extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final WorldUtil worldUtil;
public Kick(@NotNull final PlotAreaManager plotAreaManager) { @Inject public Kick(@NotNull final PlotAreaManager plotAreaManager,
@NotNull final WorldUtil worldUtil) {
super(Argument.PlayerName); super(Argument.PlayerName);
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldUtil = worldUtil;
} }
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
@ -110,10 +114,10 @@ public class Kick extends SubCommand {
Captions.CANNOT_KICK_PLAYER.send(player, player2.getName()); Captions.CANNOT_KICK_PLAYER.send(player, player2.getName());
return; return;
} }
Location spawn = WorldUtil.IMP.getSpawn(location.getWorldName()); Location spawn = this.worldUtil.getSpawn(location.getWorldName());
Captions.YOU_GOT_KICKED.send(player2); Captions.YOU_GOT_KICKED.send(player2);
if (plot.equals(spawn.getPlot())) { if (plot.equals(spawn.getPlot())) {
Location newSpawn = WorldUtil.IMP.getSpawn(this.plotAreaManager.getAllWorlds()[0]); Location newSpawn = this.worldUtil.getSpawn(this.plotAreaManager.getAllWorlds()[0]);
if (plot.equals(newSpawn.getPlot())) { if (plot.equals(newSpawn.getPlot())) {
// Kick from server if you can't be teleported to spawn // Kick from server if you can't be teleported to spawn
player2.kick(Captions.YOU_GOT_KICKED.getTranslated()); player2.kick(Captions.YOU_GOT_KICKED.getTranslated());

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
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,6 +50,7 @@ import com.plotsquared.core.util.query.SortingStrategy;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -72,14 +74,17 @@ import java.util.stream.Collectors;
public class ListCmd extends SubCommand { public class ListCmd extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final EconHandler econHandler;
public ListCmd(@NotNull final PlotAreaManager plotAreaManager) { @Inject public ListCmd(@NotNull final PlotAreaManager plotAreaManager,
@Nullable final EconHandler econHandler) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.econHandler = econHandler;
} }
private String[] getArgumentList(PlotPlayer player) { private String[] getArgumentList(PlotPlayer player) {
List<String> args = new ArrayList<>(); List<String> args = new ArrayList<>();
if (EconHandler.getEconHandler() != null && Permissions if (this.econHandler != null && Permissions
.hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) { .hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) {
args.add("forsale"); args.add("forsale");
} }
@ -272,7 +277,7 @@ public class ListCmd extends SubCommand {
Captions.PERMISSION_LIST_FOR_SALE); Captions.PERMISSION_LIST_FOR_SALE);
return false; return false;
} }
if (EconHandler.getEconHandler() == null) { if (this.econHandler == null) {
break; break;
} }
plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getFlag(PriceFlag.class) > 0)); plotConsumer.accept(PlotQuery.newQuery().allPlots().thatPasses(plot -> plot.getFlag(PriceFlag.class) > 0));
@ -412,7 +417,7 @@ public class ListCmd extends SubCommand {
@Override public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) { @Override public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
final List<String> completions = new LinkedList<>(); final List<String> completions = new LinkedList<>();
if (EconHandler.getEconHandler() != null && Permissions if (this.econHandler != null && Permissions
.hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) { .hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) {
completions.add("forsale"); completions.add("forsale");
} }

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -54,9 +55,12 @@ import java.util.List;
public class Load extends SubCommand { public class Load extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final SchematicHandler schematicHandler;
public Load(@NotNull final PlotAreaManager plotAreaManager) { @Inject public Load(@NotNull final PlotAreaManager plotAreaManager,
@NotNull final SchematicHandler schematicHandler) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.schematicHandler = schematicHandler;
} }
@Override public boolean onCommand(final PlotPlayer<?> player, final String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
@ -110,7 +114,7 @@ public class Load extends SubCommand {
plot.addRunning(); plot.addRunning();
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT); MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
Schematic taskSchematic = SchematicHandler.manager.getSchematic(url); Schematic taskSchematic = this.schematicHandler.getSchematic(url);
if (taskSchematic == null) { if (taskSchematic == null) {
plot.removeRunning(); plot.removeRunning();
sendMessage(player, Captions.SCHEMATIC_INVALID, sendMessage(player, Captions.SCHEMATIC_INVALID,
@ -118,8 +122,7 @@ public class Load extends SubCommand {
return; return;
} }
PlotArea area = plot.getArea(); PlotArea area = plot.getArea();
SchematicHandler.manager this.schematicHandler.paste(taskSchematic, plot, 0, area.getMinBuildHeight(), 0, false,
.paste(taskSchematic, plot, 0, area.getMinBuildHeight(), 0, false,
new RunnableVal<Boolean>() { new RunnableVal<Boolean>() {
@Override public void run(Boolean value) { @Override public void run(Boolean value) {
plot.removeRunning(); plot.removeRunning();
@ -144,7 +147,7 @@ public class Load extends SubCommand {
if (schematics == null) { if (schematics == null) {
plot.addRunning(); plot.addRunning();
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
List<String> schematics1 = SchematicHandler.manager.getSaves(player.getUUID()); List<String> schematics1 = this.schematicHandler.getSaves(player.getUUID());
plot.removeRunning(); plot.removeRunning();
if ((schematics1 == null) || schematics1.isEmpty()) { if ((schematics1 == null) || schematics1.isEmpty()) {
MainUtil.sendMessage(player, Captions.LOAD_FAILED); MainUtil.sendMessage(player, Captions.LOAD_FAILED);

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Injector;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
@ -46,6 +47,8 @@ import com.sk89q.worldedit.WorldEdit;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
@ -68,92 +71,88 @@ public class MainCommand extends Command {
if (instance == null) { if (instance == null) {
instance = new MainCommand(); instance = new MainCommand();
final PlotAreaManager plotAreaManager = PlotSquared.get().getPlotAreaManager(); private final Injector injector = PlotSquared.platform().getInjector();
final EventDispatcher eventDispatcher = PlotSquared.get().getEventDispatcher(); final List<Class<? extends Command>> commands = new LinkedList<>();
final PlotListener plotListener = PlotSquared.get().getPlotListener(); commands.add(Caps.class);
final YamlConfiguration worldconfiguration = PlotSquared.get().getWorldConfiguration(); commands.add(Buy.class);
final File worldFile = PlotSquared.get().getWorldsFile(); commands.add(Save.class);
final WorldEdit worldEdit = PlotSquared.get().getWorldedit(); commands.add(Load.class);
commands.add(Confirm.class);
new Caps(); commands.add(Template.class);
new Buy(eventDispatcher); commands.add(Download.class);
new Save(plotAreaManager); commands.add(Setup.class);
new Load(plotAreaManager); commands.add(Area.class);
new Confirm(); commands.add(DebugSaveTest.class);
new Template(plotAreaManager, worldconfiguration, worldFile); commands.add(DebugLoadTest.class);
new Download(plotAreaManager); commands.add(CreateRoadSchematic.class);
new Template(plotAreaManager, worldconfiguration, worldFile); commands.add(DebugAllowUnsafe.class);
new Setup(); commands.add(RegenAllRoads.class);
new Area(plotAreaManager, eventDispatcher, plotListener, worldconfiguration, worldFile); commands.add(Claim.class);
new DebugSaveTest(); commands.add(Auto.class);
new DebugLoadTest(); commands.add(HomeCommand.class);
new CreateRoadSchematic(); commands.add(Visit.class);
new DebugAllowUnsafe(); commands.add(Set.class);
new RegenAllRoads(plotAreaManager); commands.add(Clear.class);
new Claim(eventDispatcher); commands.add(Delete.class);
new Auto(plotAreaManager, eventDispatcher); commands.add(Trust.class);
new HomeCommand(plotAreaManager); commands.add(Add.class);
new Visit(plotAreaManager); commands.add(Leave.class);
new Set(); commands.add(Deny.class);
new Clear(eventDispatcher); commands.add(Remove.class);
new Delete(eventDispatcher); commands.add(Info.class);
new Trust(eventDispatcher); commands.add(Near.class);
new Add(eventDispatcher); commands.add(ListCmd.class);
new Leave(eventDispatcher); commands.add(Debug.class);
new Deny(plotAreaManager, eventDispatcher); commands.add(SchematicCmd.class);
new Remove(eventDispatcher); commands.add(PluginCmd.class);
new Info(); commands.add(Purge.class);
new Near(); commands.add(Reload.class);
new ListCmd(plotAreaManager); commands.add(Relight.class);
new Debug(plotAreaManager); commands.add(Merge.class);
new SchematicCmd(plotAreaManager); commands.add(DebugPaste.class);
new PluginCmd(); commands.add(Unlink.class);
new Purge(plotAreaManager, plotListener); commands.add(Kick.class);
new Reload(plotAreaManager, worldconfiguration, worldFile); commands.add(Inbox.class);
new Relight(); commands.add(Comment.class);
new Merge(eventDispatcher); commands.add(DatabaseCommand.class);
new DebugPaste(PlotSquared.get().getConfigFile(), PlotSquared.get().getWorldsFile()); commands.add(Swap.class);
new Unlink(eventDispatcher); commands.add(Music.class);
new Kick(plotAreaManager); commands.add(DebugRoadRegen.class);
new Inbox(); commands.add(DebugExec.class);
new Comment(); commands.add(FlagCommand.class);
new DatabaseCommand(plotAreaManager, eventDispatcher, plotListener, worldconfiguration); commands.add(Target.class);
new Swap(); commands.add(Move.class);
new Music(); commands.add(Condense.class);
new DebugRoadRegen(); commands.add(Copy.class);
new Trust(eventDispatcher); commands.add(Chat.class);
new DebugExec(plotAreaManager, eventDispatcher, worldEdit); commands.add(Trim.class);
new FlagCommand(); commands.add(Done.class);
new Target(); commands.add(Continue.class);
new Move(plotAreaManager); commands.add(Middle.class);
new Condense(plotAreaManager); commands.add(Grant.class);
new Copy(); commands.add(Owner.class);
new Chat(); commands.add(Desc.class);
new Trim(plotAreaManager); commands.add(Biome.class);
new Done(eventDispatcher); commands.add(Alias.class);
new Continue(eventDispatcher); commands.add(SetHome.class);
new Middle(); commands.add(Cluster.class);
new Grant(); commands.add(DebugImportWorlds.class);
// Set commands commands.add(Backup.class);
new Owner(eventDispatcher);
new Desc(eventDispatcher);
new Biome();
new Alias();
new SetHome();
new Cluster();
new DebugImportWorlds(plotAreaManager);
new Backup();
if (Settings.Ratings.USE_LIKES) { if (Settings.Ratings.USE_LIKES) {
final Like like = new Like(eventDispatcher); commands.add(Like.class);
new Dislike(like); commands.add(Dislike.class);
} else { } else {
new Rate(eventDispatcher); commands.add(Rate.class);
}
for (final Class<? extends Command> command : commands) {
injector.getInstance(command);
} }
// Referenced commands // Referenced commands
instance.toggle = new Toggle(); instance.toggle = injector.getInstance(Toggle.class);
instance.help = new Help(instance); instance.help = injector.getInstance(Help.class);
} }
return instance; return instance;
} }

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
@ -42,6 +43,7 @@ import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID; import java.util.UUID;
@ -59,9 +61,12 @@ public class Merge extends SubCommand {
public static final String[] aliases = new String[] {"n", "e", "s", "w"}; public static final String[] aliases = new String[] {"n", "e", "s", "w"};
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler;
public Merge(@NotNull final EventDispatcher eventDispatcher) {
@Inject public Merge(@NotNull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler;
} }
public static String direction(float yaw) { public static String direction(float yaw) {
@ -164,8 +169,8 @@ public class Merge extends SubCommand {
return true; return true;
} }
if (plot.autoMerge(Direction.ALL, maxSize, uuid, terrain)) { if (plot.autoMerge(Direction.ALL, maxSize, uuid, terrain)) {
if (EconHandler.getEconHandler() != null && plotArea.useEconomy() && price > 0d) { if (this.econHandler != null && plotArea.useEconomy() && price > 0d) {
EconHandler.getEconHandler().withdrawMoney(player, price); this.econHandler.withdrawMoney(player, price);
sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price)); sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price));
} }
MainUtil.sendMessage(player, Captions.SUCCESS_MERGE); MainUtil.sendMessage(player, Captions.SUCCESS_MERGE);
@ -182,8 +187,8 @@ public class Merge extends SubCommand {
uuid = plot.getOwnerAbs(); uuid = plot.getOwnerAbs();
} }
} }
if (!force && EconHandler.getEconHandler() != null && plotArea.useEconomy() && price > 0d if (!force && this.econHandler != null && plotArea.useEconomy() && price > 0d
&& EconHandler.getEconHandler().getMoney(player) < price) { && this.econHandler.getMoney(player) < price) {
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price)); sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
return false; return false;
} }
@ -200,8 +205,8 @@ public class Merge extends SubCommand {
return true; return true;
} }
if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) { if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
if (EconHandler.getEconHandler() != null && plotArea.useEconomy() && price > 0d) { if (this.econHandler != null && plotArea.useEconomy() && price > 0d) {
EconHandler.getEconHandler().withdrawMoney(player, price); this.econHandler.withdrawMoney(player, price);
sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price)); sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price));
} }
MainUtil.sendMessage(player, Captions.SUCCESS_MERGE); MainUtil.sendMessage(player, Captions.SUCCESS_MERGE);
@ -234,12 +239,12 @@ public class Merge extends SubCommand {
sendMessage(accepter, Captions.MERGE_NOT_VALID); sendMessage(accepter, Captions.MERGE_NOT_VALID);
return; return;
} }
if (EconHandler.getEconHandler() != null && plotArea.useEconomy() && price > 0d) { if (this.econHandler != null && plotArea.useEconomy() && price > 0d) {
if (!force && EconHandler.getEconHandler().getMoney(player) < price) { if (!force && this.econHandler.getMoney(player) < price) {
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price)); sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
return; return;
} }
EconHandler.getEconHandler().withdrawMoney(player, price); this.econHandler.withdrawMoney(player, price);
sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price)); sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price));
} }
MainUtil.sendMessage(player, Captions.SUCCESS_MERGE); MainUtil.sendMessage(player, Captions.SUCCESS_MERGE);

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.events.PlotFlagAddEvent; import com.plotsquared.core.events.PlotFlagAddEvent;
import com.plotsquared.core.events.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
@ -36,7 +37,9 @@ import com.plotsquared.core.plot.PlotInventory;
import com.plotsquared.core.plot.PlotItemStack; import com.plotsquared.core.plot.PlotItemStack;
import com.plotsquared.core.plot.flag.PlotFlag; import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.MusicFlag; import com.plotsquared.core.plot.flag.implementations.MusicFlag;
import com.plotsquared.core.util.InventoryUtil;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -55,6 +58,12 @@ public class Music extends SubCommand {
"music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal", "music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal",
"music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait"); "music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait");
private final InventoryUtil inventoryUtil;
@Inject public Music(@Nullable final InventoryUtil inventoryUtil) {
this.inventoryUtil = inventoryUtil;
}
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
@ -65,7 +74,7 @@ public class Music extends SubCommand {
sendMessage(player, Captions.NO_PLOT_PERMS); sendMessage(player, Captions.NO_PLOT_PERMS);
return true; return true;
} }
PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") { PlotInventory inv = new PlotInventory(this.inventoryUtil, player, 2, "Plot Jukebox") {
@Override public boolean onClick(int index) { @Override public boolean onClick(int index) {
PlotItemStack item = getItem(index); PlotItemStack item = getItem(index);
if (item == null) { if (item == null) {

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.generator.HybridPlotManager; import com.plotsquared.core.generator.HybridPlotManager;
import com.plotsquared.core.generator.HybridUtils; import com.plotsquared.core.generator.HybridUtils;
@ -45,9 +46,12 @@ import org.jetbrains.annotations.NotNull;
public class RegenAllRoads extends SubCommand { public class RegenAllRoads extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final HybridUtils hybridUtils;
public RegenAllRoads(@NotNull final PlotAreaManager plotAreaManager) { @Inject public RegenAllRoads(@NotNull final PlotAreaManager plotAreaManager,
@NotNull final HybridUtils hybridUtils) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.hybridUtils = hybridUtils;
} }
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
@ -84,7 +88,7 @@ public class RegenAllRoads extends SubCommand {
"&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); "&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
//MainUtil.sendMessage(player, "&6Potential chunks to update: &7" + (chunks.size() * 1024)); //MainUtil.sendMessage(player, "&6Potential chunks to update: &7" + (chunks.size() * 1024));
//MainUtil.sendMessage(player, "&6Estimated time: &7" + chunks.size() + " seconds"); //MainUtil.sendMessage(player, "&6Estimated time: &7" + chunks.size() + " seconds");
boolean result = HybridUtils.manager.scheduleRoadUpdate(area, height); boolean result = this.hybridUtils.scheduleRoadUpdate(area, height);
if (!result) { if (!result) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&cCannot schedule mass schematic update! (Is one already in progress?)"); "&cCannot schedule mass schematic update! (Is one already in progress?)");

View File

@ -26,6 +26,7 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.inject.Inject;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
@ -57,10 +58,13 @@ import java.util.UUID;
public class SchematicCmd extends SubCommand { public class SchematicCmd extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final SchematicHandler schematicHandler;
private boolean running = false; private boolean running = false;
public SchematicCmd(@NotNull final PlotAreaManager plotAreaManager) { @Inject public SchematicCmd(@NotNull final PlotAreaManager plotAreaManager,
@NotNull final SchematicHandler schematicHandler) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.schematicHandler = schematicHandler;
} }
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
@ -111,7 +115,7 @@ public class SchematicCmd extends SubCommand {
UUID uuid = UUID.fromString(location.substring(4)); UUID uuid = UUID.fromString(location.substring(4));
URL base = new URL(Settings.Web.URL); URL base = new URL(Settings.Web.URL);
URL url = new URL(base, "uploads/" + uuid + ".schematic"); URL url = new URL(base, "uploads/" + uuid + ".schematic");
schematic = SchematicHandler.manager.getSchematic(url); schematic = this.schematicHandler.getSchematic(url);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
sendMessage(player, Captions.SCHEMATIC_INVALID, sendMessage(player, Captions.SCHEMATIC_INVALID,
@ -121,7 +125,7 @@ public class SchematicCmd extends SubCommand {
} }
} else { } else {
try { try {
schematic = SchematicHandler.manager.getSchematic(location); schematic = this.schematicHandler.getSchematic(location);
} catch (SchematicHandler.UnsupportedFormatException e) { } catch (SchematicHandler.UnsupportedFormatException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -132,8 +136,7 @@ public class SchematicCmd extends SubCommand {
"non-existent or not in gzip format"); "non-existent or not in gzip format");
return; return;
} }
SchematicHandler.manager this.schematicHandler.paste(schematic, plot, 0, 1, 0, false, new RunnableVal<Boolean>() {
.paste(schematic, plot, 0, 1, 0, false, new RunnableVal<Boolean>() {
@Override public void run(Boolean value) { @Override public void run(Boolean value) {
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
if (value) { if (value) {
@ -166,7 +169,7 @@ public class SchematicCmd extends SubCommand {
MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_WORLD); MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_WORLD);
return false; return false;
} }
boolean result = SchematicHandler.manager.exportAll(plots, null, null, boolean result = this.schematicHandler.exportAll(plots, null, null,
() -> MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_FINISHED)); () -> MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_FINISHED));
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.TASK_IN_PROCESS); MainUtil.sendMessage(player, Captions.TASK_IN_PROCESS);
@ -204,7 +207,7 @@ public class SchematicCmd extends SubCommand {
return false; return false;
} }
ArrayList<Plot> plots = Lists.newArrayList(plot); ArrayList<Plot> plots = Lists.newArrayList(plot);
boolean result = SchematicHandler.manager.exportAll(plots, null, null, () -> { boolean result = this.schematicHandler.exportAll(plots, null, null, () -> {
MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_SINGLE_FINISHED); MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_SINGLE_FINISHED);
SchematicCmd.this.running = false; SchematicCmd.this.running = false;
}); });
@ -221,8 +224,7 @@ public class SchematicCmd extends SubCommand {
Captions.PERMISSION_SCHEMATIC_LIST); Captions.PERMISSION_SCHEMATIC_LIST);
return false; return false;
} }
final String string = final String string = StringMan.join(this.schematicHandler.getSchematicNames(), "$2, $1");
StringMan.join(SchematicHandler.manager.getSchematicNames(), "$2, $1");
Captions.SCHEMATIC_LIST.send(player, string); Captions.SCHEMATIC_LIST.send(player, string);
} }
break; break;

View File

@ -25,6 +25,7 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
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.inject.annotations.WorldFile; import com.plotsquared.core.inject.annotations.WorldFile;
@ -68,13 +69,22 @@ public class Template extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final YamlConfiguration worldConfiguration; private final YamlConfiguration worldConfiguration;
private final File worldFile; private final File worldFile;
private final SetupUtils setupUtils;
private final GlobalBlockQueue globalBlockQueue;
private final WorldUtil worldUtil;
public Template(@NotNull final PlotAreaManager plotAreaManager, @Inject public Template(@NotNull final PlotAreaManager plotAreaManager,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration, @WorldConfig @NotNull final YamlConfiguration worldConfiguration,
@WorldFile @NotNull final File worldFile) { @WorldFile @NotNull final File worldFile,
@NotNull final SetupUtils setupUtils,
@NotNull final GlobalBlockQueue globalBlockQueue,
@NotNull final WorldUtil worldUtil) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;
this.worldFile = worldFile; this.worldFile = worldFile;
this.setupUtils = setupUtils;
this.globalBlockQueue = globalBlockQueue;
this.worldUtil = worldUtil;
} }
public static boolean extractAllFiles(String world, String template) { public static boolean extractAllFiles(String world, String template) {
@ -123,7 +133,7 @@ public class Template extends SubCommand {
public static byte[] getBytes(PlotArea plotArea) { public static byte[] getBytes(PlotArea plotArea) {
ConfigurationSection section = PlotSquared.get().getWorldConfiguration().getConfigurationSection("worlds." + plotArea.getWorldName()); ConfigurationSection section = PlotSquared.get().getWorldConfiguration().getConfigurationSection("worlds." + plotArea.getWorldName());
YamlConfiguration config = new YamlConfiguration(); YamlConfiguration config = new YamlConfiguration();
String generator = SetupUtils.manager.getGenerator(plotArea); String generator = PlotSquared.platform().getSetupUtils().getGenerator(plotArea);
if (generator != null) { if (generator != null) {
config.set("generator.plugin", generator); config.set("generator.plugin", generator);
} }
@ -197,7 +207,7 @@ public class Template extends SubCommand {
String manager = String manager =
worldConfig.getString("generator.plugin", PlotSquared.platform().getPluginName()); worldConfig.getString("generator.plugin", PlotSquared.platform().getPluginName());
String generator = worldConfig.getString("generator.init", manager); String generator = worldConfig.getString("generator.init", manager);
PlotAreaBuilder builder = new PlotAreaBuilder() PlotAreaBuilder builder = PlotAreaBuilder.newBuilder()
.plotAreaType(MainUtil.getType(worldConfig)) .plotAreaType(MainUtil.getType(worldConfig))
.terrainType(MainUtil.getTerrain(worldConfig)) .terrainType(MainUtil.getTerrain(worldConfig))
.plotManager(manager) .plotManager(manager)
@ -205,10 +215,10 @@ public class Template extends SubCommand {
.settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null)) .settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null))
.worldName(world); .worldName(world);
SetupUtils.manager.setupWorld(builder); this.setupUtils.setupWorld(builder);
GlobalBlockQueue.IMP.addEmptyTask(() -> { this.globalBlockQueue.addEmptyTask(() -> {
MainUtil.sendMessage(player, "Done!"); MainUtil.sendMessage(player, "Done!");
player.teleport(WorldUtil.IMP.getSpawn(world), TeleportCause.COMMAND); player.teleport(this.worldUtil.getSpawn(world), TeleportCause.COMMAND);
}); });
return true; return true;
} }

View File

@ -25,15 +25,15 @@
*/ */
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
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.listener.PlotListener; import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.plot.BlockBucket; import com.plotsquared.core.plot.BlockBucket;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.EconHandler;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -63,10 +63,10 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
@NotNull final IndependentPlotGenerator generator, @NotNull final IndependentPlotGenerator generator,
@NotNull final PlotId min, @NotNull final PlotId min,
@NotNull final PlotId max, @NotNull final PlotId max,
@NotNull final EventDispatcher eventDispatcher, @WorldConfig @NotNull final YamlConfiguration worldConfiguration,
@NotNull final PlotListener plotListener, @NotNull final GlobalBlockQueue blockQueue,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) { @Nullable final EconHandler econHandler) {
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration); super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler);
} }
/** /**

View File

@ -25,14 +25,12 @@
*/ */
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.inject.annotations.WorldConfig;
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.GlobalBlockQueue; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -41,10 +39,9 @@ public abstract class GridPlotWorld extends PlotArea {
public short SIZE; public short SIZE;
public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator, public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final PlotId min, PlotId max, @WorldConfig @NotNull final YamlConfiguration worldConfiguration,
PlotListener plotListener, @WorldConfig @NotNull final YamlConfiguration worldConfiguration,
@NotNull final GlobalBlockQueue blockQueue, @NotNull final GlobalBlockQueue blockQueue,
@Nullable final EconHandler econHandler) { @Nullable final EconHandler econHandler) {
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration, blockQueue, econHandler); super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler);
} }
} }

View File

@ -28,15 +28,12 @@ package com.plotsquared.core.generator;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.inject.factory.HybridPlotWorldFactory;
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.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.queue.ScopedLocalBlockQueue; import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import com.plotsquared.core.util.EventDispatcher;
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;
@ -45,16 +42,10 @@ import org.jetbrains.annotations.NotNull;
public class HybridGen extends IndependentPlotGenerator { public class HybridGen extends IndependentPlotGenerator {
private final EventDispatcher eventDispatcher; private final HybridPlotWorldFactory hybridPlotWorldFactory;
private final PlotListener plotListener;
private final YamlConfiguration worldConfiguration;
@Inject public HybridGen(@NotNull final EventDispatcher eventDispatcher, @Inject public HybridGen(@NotNull final HybridPlotWorldFactory hybridPlotWorldFactory) {
@NotNull final PlotListener plotListener, this.hybridPlotWorldFactory = hybridPlotWorldFactory;
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
this.eventDispatcher = eventDispatcher;
this.plotListener = plotListener;
this.worldConfiguration = worldConfiguration;
} }
@Override public String getName() { @Override public String getName() {
@ -238,8 +229,7 @@ public class HybridGen extends IndependentPlotGenerator {
} }
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) { @Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
return new HybridPlotWorld(world, id, this, min, max, this.eventDispatcher, return this.hybridPlotWorldFactory.create(world, id, this, min, max);
this.plotListener, this.worldConfiguration);
} }
@Override public void initialize(PlotArea area) { @Override public void initialize(PlotArea area) {

View File

@ -27,19 +27,19 @@ package com.plotsquared.core.generator;
import com.google.inject.assistedinject.Assisted; 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.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.inject.annotations.WorldConfig;
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.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.plot.schematic.Schematic; import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.EconHandler;
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.RegionManager;
@ -58,6 +58,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import lombok.Getter; import lombok.Getter;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
import java.io.File; import java.io.File;
@ -87,12 +88,12 @@ public class HybridPlotWorld extends ClassicPlotWorld {
@Assisted @NotNull final IndependentPlotGenerator generator, @Assisted @NotNull final IndependentPlotGenerator generator,
@Assisted final PlotId min, @Assisted final PlotId min,
@Assisted final PlotId max, @Assisted final PlotId max,
@NotNull final EventDispatcher eventDispatcher,
@NotNull final PlotListener plotListener,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration, @WorldConfig @NotNull final YamlConfiguration worldConfiguration,
@NotNull final RegionManager regionManager, @NotNull final RegionManager regionManager,
@NotNull final SchematicHandler schematicHandler) { @NotNull final SchematicHandler schematicHandler,
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration); @NotNull final GlobalBlockQueue blockQueue,
@Nullable final EconHandler econHandler) {
super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler);
this.regionManager = regionManager; this.regionManager = regionManager;
this.schematicHandler = schematicHandler; this.schematicHandler = schematicHandler;
} }

View File

@ -26,13 +26,14 @@
package com.plotsquared.core.generator; package com.plotsquared.core.generator;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationSection;
import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.util.EconHandler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class SquarePlotWorld extends GridPlotWorld { public abstract class SquarePlotWorld extends GridPlotWorld {
@ -41,10 +42,15 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
public int ROAD_OFFSET_X = 0; public int ROAD_OFFSET_X = 0;
public int ROAD_OFFSET_Z = 0; public int ROAD_OFFSET_Z = 0;
public SquarePlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator, public SquarePlotWorld(final String worldName,
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final @Nullable final String id,
PlotListener plotListener, @WorldConfig @NotNull final YamlConfiguration worldConfiguration) { @NotNull final IndependentPlotGenerator generator,
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration); @Nullable final PlotId min,
@Nullable final PlotId max,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
@NotNull final GlobalBlockQueue blockQueue,
@Nullable final EconHandler econHandler) {
super(worldName, id, generator, min, max, worldConfiguration, blockQueue, econHandler);
} }
@Override public void loadConfiguration(ConfigurationSection config) { @Override public void loadConfiguration(ConfigurationSection config) {

View File

@ -1,3 +1,28 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2020 IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.inject.annotations; package com.plotsquared.core.inject.annotations;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;

View File

@ -1,3 +1,28 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2020 IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.inject.annotations; package com.plotsquared.core.inject.annotations;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;

View File

@ -0,0 +1,39 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2020 IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.inject.factory;
import com.plotsquared.core.generator.HybridPlotWorld;
import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.plot.PlotId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface HybridPlotWorldFactory {
@NotNull HybridPlotWorld create(@NotNull String worldName, @Nullable String id,
@NotNull IndependentPlotGenerator plotGenerator, @Nullable PlotId min, @Nullable PlotId max);
}

View File

@ -1,3 +1,28 @@
/*
* _____ _ _ _____ _
* | __ \| | | | / ____| | |
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
* | |
* |_|
* PlotSquared plot management system for Minecraft
* Copyright (C) 2020 IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.plotsquared.core.inject.factory; package com.plotsquared.core.inject.factory;
import com.plotsquared.core.backup.PlayerBackupProfile; import com.plotsquared.core.backup.PlayerBackupProfile;
@ -8,6 +33,6 @@ import java.util.UUID;
public interface PlayerBackupProfileFactory { public interface PlayerBackupProfileFactory {
PlayerBackupProfile create(@NotNull UUID uuid, @NotNull Plot plot); @NotNull PlayerBackupProfile create(@NotNull UUID uuid, @NotNull Plot plot);
} }

View File

@ -28,7 +28,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.PlotSquared;
import com.plotsquared.core.inject.annotations.WorldConfig;
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;
@ -39,7 +38,7 @@ import com.plotsquared.core.configuration.Settings;
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.IndependentPlotGenerator; import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.inject.annotations.WorldConfig;
import com.plotsquared.core.location.Direction; import com.plotsquared.core.location.Direction;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.location.PlotLoc; import com.plotsquared.core.location.PlotLoc;
@ -52,7 +51,6 @@ 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.LocalBlockQueue;
import com.plotsquared.core.util.EconHandler; import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Expression; import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
@ -137,16 +135,13 @@ public abstract class PlotArea {
@Getter private final FlagContainer roadFlagContainer = @Getter private final FlagContainer roadFlagContainer =
new FlagContainer(GlobalFlagContainer.getInstance()); new FlagContainer(GlobalFlagContainer.getInstance());
private final EventDispatcher eventDispatcher;
private final PlotListener plotListener;
private final YamlConfiguration worldConfiguration; private final YamlConfiguration worldConfiguration;
private final GlobalBlockQueue globalBlockQueue; private final GlobalBlockQueue globalBlockQueue;
private final EconHandler econHandler; private final EconHandler econHandler;
public PlotArea(@NotNull final String worldName, @Nullable final String id, public PlotArea(@NotNull final String worldName, @Nullable final String id,
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min, @NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
@Nullable final PlotId max, @NotNull final EventDispatcher eventDispatcher, @Nullable final PlotId max,
@NotNull final PlotListener plotListener,
@WorldConfig @Nullable final YamlConfiguration worldConfiguration, @WorldConfig @Nullable final YamlConfiguration worldConfiguration,
@NotNull final GlobalBlockQueue blockQueue, @NotNull final GlobalBlockQueue blockQueue,
@Nullable final EconHandler econHandler) { @Nullable final EconHandler econHandler) {
@ -167,8 +162,6 @@ public abstract class PlotArea {
this.max = max; this.max = max;
} }
this.worldHash = worldName.hashCode(); this.worldHash = worldName.hashCode();
this.eventDispatcher = eventDispatcher;
this.plotListener = plotListener;
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;
this.econHandler = econHandler; this.econHandler = econHandler;
} }