Finalize DI stuff

This commit is contained in:
Alexander Söderberg 2020-07-14 18:49:40 +02:00
parent 25a58a5c46
commit 510ea56431
No known key found for this signature in database
GPG Key ID: C0207FF7EA146678
288 changed files with 1512 additions and 1320 deletions

View File

@ -101,13 +101,14 @@ shadowJar {
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT")) include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
include(dependency("com.google.inject:guice:4.2.3")) include(dependency("com.google.inject:guice:4.2.3"))
include(dependency("com.google.inject.extensions:guice-assistedinject:4.2.3")) include(dependency("com.google.inject.extensions:guice-assistedinject:4.2.3"))
include(dependency("javax.annotation:javax-annotation-api"))
} }
relocate('net.kyori.text', 'com.plotsquared.formatting.text') relocate('net.kyori.text', 'com.plotsquared.formatting.text')
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib") relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
relocate("org.bstats", "com.plotsquared.metrics") relocate("org.bstats", "com.plotsquared.metrics")
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid') relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
relocate('org.khelekore.prtree', 'com.plotsquared.prtree') relocate('org.khelekore.prtree', 'com.plotsquared.prtree')
relocate('com.google', 'com.plotsquared.google') relocate('com.google.inject', 'com.plotsquared.google')
archiveFileName = "${project.name}-${parent.version}.jar" archiveFileName = "${project.name}-${parent.version}.jar"
destinationDirectory = file "../target" destinationDirectory = file "../target"
} }

View File

@ -12,6 +12,12 @@
<version>20200518</version> <version>20200518</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.bstats</groupId> <groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId> <artifactId>bstats-bukkit</artifactId>

View File

@ -61,6 +61,7 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.backup.BackupManager; import com.plotsquared.core.backup.BackupManager;
import com.plotsquared.core.command.WE_Anywhere; import com.plotsquared.core.command.WE_Anywhere;
import com.plotsquared.core.components.ComponentPresetManager; import com.plotsquared.core.components.ComponentPresetManager;
import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
import com.plotsquared.core.configuration.ChatFormatter; import com.plotsquared.core.configuration.ChatFormatter;
import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationNode;
@ -79,12 +80,14 @@ import com.plotsquared.core.inject.annotations.WorldFile;
import com.plotsquared.core.inject.modules.PlotSquaredModule; import com.plotsquared.core.inject.modules.PlotSquaredModule;
import com.plotsquared.core.listener.PlotListener; import com.plotsquared.core.listener.PlotListener;
import com.plotsquared.core.listener.WESubscriber; import com.plotsquared.core.listener.WESubscriber;
import com.plotsquared.core.player.ConsolePlayer;
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.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotAreaTerrainType; import com.plotsquared.core.plot.PlotAreaTerrainType;
import com.plotsquared.core.plot.PlotAreaType; import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotId; import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.comment.CommentManager;
import com.plotsquared.core.plot.message.PlainChatManager; import com.plotsquared.core.plot.message.PlainChatManager;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.plot.world.SinglePlotArea;
@ -111,7 +114,7 @@ import com.plotsquared.core.uuid.offline.OfflineModeUUIDService;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -129,8 +132,8 @@ import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -234,8 +237,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
// We create the injector after PlotSquared has been initialized, so that we have access // We create the injector after PlotSquared has been initialized, so that we have access
// to generated instances and settings // to generated instances and settings
this.injector = Guice.createInjector(Stage.PRODUCTION, new PlotSquaredModule(), this.injector = Guice.createInjector(Stage.PRODUCTION, new WorldManagerModule(), new PlotSquaredModule(),
new BukkitModule(this), new BackupModule(), new WorldManagerModule()); new BukkitModule(this), new BackupModule());
this.injector.injectMembers(this); this.injector.injectMembers(this);
if (PremiumVerification.isPremium() && Settings.Enabled_Components.UPDATE_NOTIFICATIONS) { if (PremiumVerification.isPremium() && Settings.Enabled_Components.UPDATE_NOTIFICATIONS) {
@ -253,6 +256,33 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
PlotSquared.log(Captions.PREFIX + "&6Couldn't verify purchase :("); PlotSquared.log(Captions.PREFIX + "&6Couldn't verify purchase :(");
} }
// Database
if (Settings.Enabled_Components.DATABASE) {
plotSquared.setupDatabase();
}
// Check if we need to convert old flag values, etc
if (!plotSquared.getConfigurationVersion().equalsIgnoreCase("v5")) {
// Perform upgrade
if (DBFunc.dbManager.convertFlags()) {
log(Captions.PREFIX.getTranslated() + "Flags were converted successfully!");
// Update the config version
try {
plotSquared.setConfigurationVersion("v5");
} catch (final Exception e) {
e.printStackTrace();
}
}
}
// Comments
CommentManager.registerDefaultInboxes();
plotSquared.startExpiryTasks();
// This is getting removed so I won't even bother migrating it
ChatManager.manager = this.initChatManager();
// Do stuff that was previously done in PlotSquared // Do stuff that was previously done in PlotSquared
// Kill entities // Kill entities
if (Settings.Enabled_Components.KILL_ROAD_MOBS if (Settings.Enabled_Components.KILL_ROAD_MOBS
@ -302,8 +332,14 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
// Economy // Economy
if (Settings.Enabled_Components.ECONOMY) { if (Settings.Enabled_Components.ECONOMY) {
TaskManager.runTask(() -> { TaskManager.runTask(() -> {
getInjector().getInstance(PermHandler.class).init(); final PermHandler permHandler = getInjector().getInstance(PermHandler.class);
getInjector().getInstance(EconHandler.class).init(); if (permHandler != null) {
permHandler.init();
}
final EconHandler econHandler = getInjector().getInstance(EconHandler.class);
if (econHandler != null) {
econHandler.init();
}
}); });
} }
@ -501,6 +537,10 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
getLogger().warning("Failed to clean up players: " + e.getMessage()); getLogger().warning("Failed to clean up players: " + e.getMessage());
} }
}, 100L, 100L); }, 100L, 100L);
PlotSquared.log(Captions.PREFIX + CaptionUtility
.format(ConsolePlayer.getConsole(), Captions.ENABLED.getTranslated(),
this.getPluginName()));
} }
private void unload() { private void unload() {
@ -582,8 +622,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
} }
} }
private void startUuidCaching(@NotNull final SQLiteUUIDService sqLiteUUIDService, private void startUuidCaching(@Nonnull final SQLiteUUIDService sqLiteUUIDService,
@NotNull final CacheUUIDService cacheUUIDService) { @Nonnull final CacheUUIDService cacheUUIDService) {
// Load all uuids into a big chunky boi queue // Load all uuids into a big chunky boi queue
final Queue<UUID> uuidQueue = new LinkedBlockingQueue<>(); final Queue<UUID> uuidQueue = new LinkedBlockingQueue<>();
PlotSquared.get().forEachPlotRaw(plot -> { PlotSquared.get().forEachPlotRaw(plot -> {
@ -658,7 +698,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
Bukkit.getScheduler().cancelTasks(this); Bukkit.getScheduler().cancelTasks(this);
} }
@Override public void log(@NonNull String message) { @Override public void log(@Nonnull String message) {
try { try {
message = Captions.color(message); message = Captions.color(message);
if (!Settings.Chat.CONSOLE_COLOR) { if (!Settings.Chat.CONSOLE_COLOR) {
@ -948,7 +988,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
} }
@Override @Nullable @Override @Nullable
public final ChunkGenerator getDefaultWorldGenerator(@NotNull final String worldName, public final ChunkGenerator getDefaultWorldGenerator(@Nonnull final String worldName,
final String id) { final String id) {
final IndependentPlotGenerator result; final IndependentPlotGenerator result;
if (id != null && id.equalsIgnoreCase("single")) { if (id != null && id.equalsIgnoreCase("single")) {
@ -962,7 +1002,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
return (ChunkGenerator) result.specify(worldName); return (ChunkGenerator) result.specify(worldName);
} }
@Override @Nullable public GeneratorWrapper<?> getGenerator(@NonNull final String world, @Override @Nullable public GeneratorWrapper<?> getGenerator(@Nonnull final String world,
@Nullable final String name) { @Nullable final String name) {
if (name == null) { if (name == null) {
return null; return null;
@ -1011,11 +1051,11 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
"WorldEdit")); "WorldEdit"));
} }
@Override public void unregister(@NonNull final PlotPlayer player) { @Override public void unregister(@Nonnull final PlotPlayer player) {
BukkitUtil.removePlayer(player.getUUID()); BukkitUtil.removePlayer(player.getUUID());
} }
@Override public void setGenerator(@NonNull final String worldName) { @Override public void setGenerator(@Nonnull final String worldName) {
World world = BukkitUtil.getWorld(worldName); World world = BukkitUtil.getWorld(worldName);
if (world == null) { if (world == null) {
// create world // create world
@ -1098,7 +1138,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
} }
@Override public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world, @Override public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world,
@NonNull final IndependentPlotGenerator generator) { @Nonnull final IndependentPlotGenerator generator) {
return new BukkitPlotGenerator(world, generator, this.plotAreaManager); return new BukkitPlotGenerator(world, generator, this.plotAreaManager);
} }
@ -1112,7 +1152,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
return names; return names;
} }
@Override @NotNull public com.plotsquared.core.location.World<?> getPlatformWorld(@NotNull final String worldName) { @Override public com.plotsquared.core.location.World<?> getPlatformWorld(@Nonnull final String worldName) {
return BukkitWorld.of(worldName); return BukkitWorld.of(worldName);
} }

View File

@ -26,11 +26,12 @@
package com.plotsquared.bukkit.entity; package com.plotsquared.bukkit.entity;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import javax.annotation.Nonnull;
@Getter @Getter
public abstract class EntityWrapper { public abstract class EntityWrapper {
@ -43,7 +44,7 @@ public abstract class EntityWrapper {
public double y; public double y;
public double z; public double z;
EntityWrapper(@NonNull final Entity entity) { EntityWrapper(@Nonnull final Entity entity) {
this.entity = entity; this.entity = entity;
this.type = entity.getType(); this.type = entity.getType();

View File

@ -25,17 +25,17 @@
*/ */
package com.plotsquared.bukkit.generator; package com.plotsquared.bukkit.generator;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.generator.IndependentPlotGenerator; import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.location.ChunkWrapper; import com.plotsquared.core.location.ChunkWrapper;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue; import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.queue.ScopedLocalBlockQueue; import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.Random; import java.util.Random;
@ -46,17 +46,18 @@ final class BlockStatePopulator extends BlockPopulator {
private LocalBlockQueue queue; private LocalBlockQueue queue;
public BlockStatePopulator(@NotNull final IndependentPlotGenerator plotGenerator, public BlockStatePopulator(@Nonnull final IndependentPlotGenerator plotGenerator,
@NotNull final PlotAreaManager plotAreaManager) { @Nonnull final PlotAreaManager plotAreaManager) {
this.plotGenerator = plotGenerator; this.plotGenerator = plotGenerator;
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
} }
@Override @Override
public void populate(@NotNull final World world, @NotNull final Random random, public void populate(@Nonnull final World world, @Nonnull final Random random,
@NotNull final Chunk source) { @Nonnull final Chunk source) {
if (this.queue == null) { if (this.queue == null) {
this.queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false); this.queue = PlotSquared.platform().getGlobalBlockQueue()
.getNewQueue(world.getName(), false);
} }
final PlotArea area = this.plotAreaManager.getPlotArea(world.getName(), null); final PlotArea area = this.plotAreaManager.getPlotArea(world.getName(), null);
if (area == null) { if (area == null) {

View File

@ -29,7 +29,7 @@ import com.plotsquared.core.generator.AugmentedUtils;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.Random; import java.util.Random;
@ -51,7 +51,7 @@ public class BukkitAugmentedGenerator extends BlockPopulator {
} }
@Override @Override
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk source) { public void populate(@Nonnull World world, @Nonnull Random random, @Nonnull Chunk source) {
AugmentedUtils.generate(source, world.getName(), source.getX(), source.getZ(), null); AugmentedUtils.generate(source, world.getName(), source.getX(), source.getZ(), null);
} }
} }

View File

@ -43,7 +43,7 @@ import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -64,9 +64,9 @@ public class BukkitPlotGenerator extends ChunkGenerator
@Getter private final String levelName; @Getter private final String levelName;
public BukkitPlotGenerator(@NotNull final String name, public BukkitPlotGenerator(@Nonnull final String name,
@NotNull final IndependentPlotGenerator generator, @Nonnull final IndependentPlotGenerator generator,
@NotNull final PlotAreaManager plotAreaManager) { @Nonnull final PlotAreaManager plotAreaManager) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.levelName = name; this.levelName = name;
this.plotGenerator = generator; this.plotGenerator = generator;
@ -77,7 +77,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
MainUtil.initCache(); MainUtil.initCache();
} }
public BukkitPlotGenerator(final String world, final ChunkGenerator cg, @NotNull final PlotAreaManager plotAreaManager) { public BukkitPlotGenerator(final String world, final ChunkGenerator cg, @Nonnull final PlotAreaManager plotAreaManager) {
if (cg instanceof BukkitPlotGenerator) { if (cg instanceof BukkitPlotGenerator) {
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName()
+ " is already a BukkitPlotGenerator!"); + " is already a BukkitPlotGenerator!");
@ -106,7 +106,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
return this.platformGenerator; return this.platformGenerator;
} }
@Override @NotNull public List<BlockPopulator> getDefaultPopulators(@NotNull World world) { @Override @Nonnull public List<BlockPopulator> getDefaultPopulators(@Nonnull World world) {
try { try {
if (!this.loaded) { if (!this.loaded) {
String name = world.getName(); String name = world.getName();
@ -150,9 +150,9 @@ public class BukkitPlotGenerator extends ChunkGenerator
return toAdd; return toAdd;
} }
@Override @NotNull @Override @Nonnull
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, public ChunkData generateChunkData(@Nonnull World world, @Nonnull Random random, int x, int z,
@NotNull BiomeGrid biome) { @Nonnull BiomeGrid biome) {
GenChunk result = new GenChunk(); GenChunk result = new GenChunk();
if (this.getPlotGenerator() instanceof SingleWorldGenerator) { if (this.getPlotGenerator() instanceof SingleWorldGenerator) {
@ -216,7 +216,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
ChunkManager.postProcessChunk(loc, result); ChunkManager.postProcessChunk(loc, result);
} }
@Override public boolean canSpawn(@NotNull final World world, final int x, final int z) { @Override public boolean canSpawn(@Nonnull final World world, final int x, final int z) {
return true; return true;
} }

View File

@ -38,7 +38,7 @@ import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Range; import org.jetbrains.annotations.Range;
import java.util.Random; import java.util.Random;
@ -74,21 +74,21 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() { ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
@Override @Override
public void setBiome(@Range(from = 0, to = 15) int x, public void setBiome(@Range(from = 0, to = 15) int x,
@Range(from = 0, to = 15) int z, @NotNull Biome biome) { @Range(from = 0, to = 15) int z, @Nonnull Biome biome) {
result.setBiome(x, z, BukkitAdapter.adapt(biome)); result.setBiome(x, z, BukkitAdapter.adapt(biome));
} }
//do not annotate with Override until we discontinue support for 1.4.4 //do not annotate with Override until we discontinue support for 1.4.4
public void setBiome(int x, int y, int z, @NotNull Biome biome) { public void setBiome(int x, int y, int z, @Nonnull Biome biome) {
result.setBiome(x, z, BukkitAdapter.adapt(biome)); result.setBiome(x, z, BukkitAdapter.adapt(biome));
} }
@Override @NotNull public Biome getBiome(int x, int z) { @Override @Nonnull public Biome getBiome(int x, int z) {
return Biome.FOREST; return Biome.FOREST;
} }
@Override public @NotNull Biome getBiome(int x, int y, int z) { @Override public @Nonnull Biome getBiome(int x, int y, int z) {
return Biome.FOREST; return Biome.FOREST;
} }
}; };

View File

@ -27,6 +27,7 @@ package com.plotsquared.bukkit.inject;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.assistedinject.FactoryModuleBuilder; import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.google.inject.util.Providers;
import com.plotsquared.bukkit.BukkitPlatform; import com.plotsquared.bukkit.BukkitPlatform;
import com.plotsquared.bukkit.player.BukkitPlayerManager; import com.plotsquared.bukkit.player.BukkitPlayerManager;
import com.plotsquared.bukkit.queue.BukkitLocalQueue; import com.plotsquared.bukkit.queue.BukkitLocalQueue;
@ -65,7 +66,7 @@ import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
@RequiredArgsConstructor public class BukkitModule extends AbstractModule { @RequiredArgsConstructor public class BukkitModule extends AbstractModule {
@ -77,7 +78,7 @@ import org.jetbrains.annotations.NotNull;
bind(PlotPlatform.class).toInstance(bukkitPlatform); bind(PlotPlatform.class).toInstance(bukkitPlatform);
bind(IndependentPlotGenerator.class).annotatedWith(DefaultGenerator.class).to(HybridGen.class); bind(IndependentPlotGenerator.class).annotatedWith(DefaultGenerator.class).to(HybridGen.class);
// Console actor // Console actor
@NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender(); @Nonnull 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(InventoryUtil.class).to(BukkitInventoryUtil.class); bind(InventoryUtil.class).to(BukkitInventoryUtil.class);
@ -88,8 +89,7 @@ import org.jetbrains.annotations.NotNull;
bind(ChunkManager.class).to(BukkitChunkManager.class); bind(ChunkManager.class).to(BukkitChunkManager.class);
bind(RegionManager.class).to(BukkitRegionManager.class); bind(RegionManager.class).to(BukkitRegionManager.class);
bind(SchematicHandler.class).to(BukkitSchematicHandler.class); bind(SchematicHandler.class).to(BukkitSchematicHandler.class);
bind(PermHandler.class).to(BukkitPermHandler.class); this.setupVault();
bind(EconHandler.class).to(BukkitEconHandler.class);
if (Settings.Enabled_Components.WORLDS) { if (Settings.Enabled_Components.WORLDS) {
bind(PlotAreaManager.class).to(SinglePlotAreaManager.class); bind(PlotAreaManager.class).to(SinglePlotAreaManager.class);
} else { } else {
@ -98,4 +98,25 @@ import org.jetbrains.annotations.NotNull;
install(new FactoryModuleBuilder().build(HybridPlotWorldFactory.class)); install(new FactoryModuleBuilder().build(HybridPlotWorldFactory.class));
} }
private void setupVault() {
if (Bukkit.getPluginManager().isPluginEnabled("Vault")) {
BukkitPermHandler bukkitPermHandler = null;
try {
bukkitPermHandler = new BukkitPermHandler();
bind(PermHandler.class).toInstance(bukkitPermHandler);
} catch (final Exception ignored) {
bind(PermHandler.class).toProvider(Providers.of(null));
}
try {
final BukkitEconHandler bukkitEconHandler = new BukkitEconHandler(bukkitPermHandler);
bind(EconHandler.class).toInstance(bukkitEconHandler);
} catch (final Exception ignored) {
bind(EconHandler.class).toProvider(Providers.of(null));
}
} else {
bind(PermHandler.class).toProvider(Providers.of(null));
bind(EconHandler.class).toProvider(Providers.of(null));
}
}
} }

View File

@ -26,21 +26,26 @@
package com.plotsquared.bukkit.inject; package com.plotsquared.bukkit.inject;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.plotsquared.bukkit.managers.BukkitWorldManager; import com.plotsquared.bukkit.managers.BukkitWorldManager;
import com.plotsquared.bukkit.managers.HyperverseWorldManager; import com.plotsquared.bukkit.managers.HyperverseWorldManager;
import com.plotsquared.bukkit.managers.MultiverseWorldManager; import com.plotsquared.bukkit.managers.MultiverseWorldManager;
import com.plotsquared.core.util.PlatformWorldManager; import com.plotsquared.core.util.PlatformWorldManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
public class WorldManagerModule extends AbstractModule { public class WorldManagerModule extends AbstractModule {
@Override protected void configure() { @Provides
@Singleton
PlatformWorldManager<World> provideWorldManager() {
if (Bukkit.getPluginManager().getPlugin("Hyperverse") != null) { if (Bukkit.getPluginManager().getPlugin("Hyperverse") != null) {
bind(PlatformWorldManager.class).to(HyperverseWorldManager.class); return new HyperverseWorldManager();
} else if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) { } else if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) {
bind(PlatformWorldManager.class).to(MultiverseWorldManager.class); return new MultiverseWorldManager();
} else { } else {
bind(PlatformWorldManager.class).to(BukkitWorldManager.class); return new BukkitWorldManager();
} }
} }

View File

@ -53,7 +53,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.ChunkUnloadEvent;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.HashSet; import java.util.HashSet;
@ -70,7 +70,7 @@ public class ChunkListener implements Listener {
private Chunk lastChunk; private Chunk lastChunk;
private boolean ignoreUnload = false; private boolean ignoreUnload = false;
@Inject public ChunkListener(@NotNull final PlotAreaManager plotAreaManager) { @Inject public ChunkListener(@Nonnull final PlotAreaManager plotAreaManager) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
if (Settings.Chunk_Processor.AUTO_TRIM) { if (Settings.Chunk_Processor.AUTO_TRIM) {
try { try {

View File

@ -53,7 +53,7 @@ import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.List; import java.util.List;
@ -65,7 +65,7 @@ public class EntitySpawnListener implements Listener {
private static String areaName = null; private static String areaName = null;
public static void testNether(final Entity entity) { public static void testNether(final Entity entity) {
@NotNull World world = entity.getWorld(); @Nonnull World world = entity.getWorld();
if (world.getEnvironment() != World.Environment.NETHER if (world.getEnvironment() != World.Environment.NETHER
&& world.getEnvironment() != World.Environment.THE_END) { && world.getEnvironment() != World.Environment.THE_END) {
return; return;
@ -74,7 +74,7 @@ public class EntitySpawnListener implements Listener {
} }
public static void testCreate(final Entity entity) { public static void testCreate(final Entity entity) {
@NotNull World world = entity.getWorld(); @Nonnull World world = entity.getWorld();
if (areaName == world.getName()) { if (areaName == world.getName()) {
} else { } else {
areaName = world.getName(); areaName = world.getName();
@ -87,7 +87,7 @@ public class EntitySpawnListener implements Listener {
} }
public static void test(Entity entity) { public static void test(Entity entity) {
@NotNull World world = entity.getWorld(); @Nonnull World world = entity.getWorld();
List<MetadataValue> meta = entity.getMetadata(KEY); List<MetadataValue> meta = entity.getMetadata(KEY);
if (meta.isEmpty()) { if (meta.isEmpty()) {
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world.getName())) { if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world.getName())) {
@ -167,7 +167,7 @@ public class EntitySpawnListener implements Listener {
} }
@EventHandler public void onChunkLoad(ChunkLoadEvent event) { @EventHandler public void onChunkLoad(ChunkLoadEvent event) {
@NotNull Chunk chunk = event.getChunk(); @Nonnull Chunk chunk = event.getChunk();
for (final Entity entity : chunk.getEntities()) { for (final Entity entity : chunk.getEntities()) {
testCreate(entity); testCreate(entity);
} }

View File

@ -59,7 +59,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -76,7 +76,7 @@ public class PaperListener implements Listener {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private Chunk lastChunk; private Chunk lastChunk;
@Inject public PaperListener(@NotNull final PlotAreaManager plotAreaManager) { @Inject public PaperListener(@Nonnull final PlotAreaManager plotAreaManager) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
} }

View File

@ -215,7 +215,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.projectiles.BlockProjectileSource; import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
@ -247,11 +247,11 @@ import java.util.regex.Pattern;
private PlayerMoveEvent moveTmp; private PlayerMoveEvent moveTmp;
private String internalVersion; private String internalVersion;
@Inject public PlayerEvents(@NotNull final PlotAreaManager plotAreaManager, @Inject public PlayerEvents(@Nonnull final PlotAreaManager plotAreaManager,
@NotNull final EventDispatcher eventDispatcher, @Nonnull final EventDispatcher eventDispatcher,
@NotNull final WorldEdit worldEdit, @Nonnull final WorldEdit worldEdit,
@NotNull final WorldUtil worldUtil) { @Nonnull final WorldUtil worldUtil) {
super(eventDispatcher, worldUtil); super(eventDispatcher);
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.worldEdit = worldEdit; this.worldEdit = worldEdit;

View File

@ -37,14 +37,14 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent; import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class WorldEvents implements Listener { public class WorldEvents implements Listener {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
@Inject public WorldEvents(@NotNull final PlotAreaManager plotAreaManager) { @Inject public WorldEvents(@Nonnull final PlotAreaManager plotAreaManager) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
} }

View File

@ -32,8 +32,8 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.WorldType; import org.bukkit.WorldType;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -51,7 +51,7 @@ import java.util.List;
} }
@Override @Nullable @Override @Nullable
public World handleWorldCreation(@NotNull String worldName, @Nullable String generator) { public World handleWorldCreation(@Nonnull String worldName, @Nullable String generator) {
this.setGenerator(worldName, generator); this.setGenerator(worldName, generator);
final WorldCreator wc = new WorldCreator(worldName); final WorldCreator wc = new WorldCreator(worldName);
wc.environment(World.Environment.NORMAL); wc.environment(World.Environment.NORMAL);

View File

@ -27,8 +27,8 @@ package com.plotsquared.bukkit.managers;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import org.bukkit.World; import org.bukkit.World;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import se.hyperver.hyperverse.Hyperverse; import se.hyperver.hyperverse.Hyperverse;
import se.hyperver.hyperverse.world.WorldConfiguration; import se.hyperver.hyperverse.world.WorldConfiguration;
import se.hyperver.hyperverse.world.WorldConfigurationBuilder; import se.hyperver.hyperverse.world.WorldConfigurationBuilder;
@ -42,7 +42,7 @@ import se.hyperver.hyperverse.world.WorldType;
@Singleton public class HyperverseWorldManager extends BukkitWorldManager { @Singleton public class HyperverseWorldManager extends BukkitWorldManager {
@Override @Nullable @Override @Nullable
public World handleWorldCreation(@NotNull String worldName, @Nullable String generator) { public World handleWorldCreation(@Nonnull String worldName, @Nullable String generator) {
// First let Bukkit register the world // First let Bukkit register the world
this.setGenerator(worldName, generator); this.setGenerator(worldName, generator);
// Create the world // Create the world

View File

@ -28,8 +28,8 @@ package com.plotsquared.bukkit.managers;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
/** /**
* Multiverse specific manager that informs Multiverse of * Multiverse specific manager that informs Multiverse of
@ -38,7 +38,7 @@ import org.jetbrains.annotations.Nullable;
@Singleton public class MultiverseWorldManager extends BukkitWorldManager { @Singleton public class MultiverseWorldManager extends BukkitWorldManager {
@Override @Nullable @Override @Nullable
public World handleWorldCreation(@NotNull final String worldName, @Nullable final String generator) { public World handleWorldCreation(@Nonnull final String worldName, @Nullable final String generator) {
// First let Bukkit register the world // First let Bukkit register the world
this.setGenerator(worldName, generator); this.setGenerator(worldName, generator);
// Then we send the console command // Then we send the console command

View File

@ -27,7 +27,7 @@ package com.plotsquared.bukkit.player;
import com.plotsquared.core.player.OfflinePlotPlayer; import com.plotsquared.core.player.OfflinePlotPlayer;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
@ -45,7 +45,7 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
this.player = player; this.player = player;
} }
@NotNull @Override public UUID getUUID() { @Nonnull @Override public UUID getUUID() {
return this.player.getUniqueId(); return this.player.getUniqueId();
} }

View File

@ -53,8 +53,8 @@ import org.bukkit.event.EventException;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.RegisteredListener; import org.bukkit.plugin.RegisteredListener;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Set; import java.util.Set;
@ -82,18 +82,18 @@ public class BukkitPlayer extends PlotPlayer<Player> {
* *
* @param player Bukkit player instance * @param player Bukkit player instance
*/ */
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher, public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher,
@NotNull final Player player, @Nullable final EconHandler econHandler) { @Nonnull final Player player, @Nullable final EconHandler econHandler) {
this(plotAreaManager, eventDispatcher, player, false, econHandler); this(plotAreaManager, eventDispatcher, player, false, econHandler);
} }
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher, public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher,
@NotNull final Player player, final boolean offline, @Nullable final EconHandler econHandler) { @Nonnull final Player player, final boolean offline, @Nullable final EconHandler econHandler) {
this(plotAreaManager, eventDispatcher, player, offline, true, econHandler); this(plotAreaManager, eventDispatcher, player, offline, true, econHandler);
} }
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final
EventDispatcher eventDispatcher, @NotNull final Player player, final boolean offline, EventDispatcher eventDispatcher, @Nonnull final Player player, final boolean offline,
final boolean realPlayer, @Nullable final EconHandler econHandler) { final boolean realPlayer, @Nullable final EconHandler econHandler) {
super(plotAreaManager, eventDispatcher, econHandler); super(plotAreaManager, eventDispatcher, econHandler);
this.player = player; this.player = player;
@ -112,12 +112,12 @@ public class BukkitPlayer extends PlotPlayer<Player> {
return this.player; return this.player;
} }
@NotNull @Override public Location getLocation() { @Nonnull @Override public Location getLocation() {
final Location location = super.getLocation(); final Location location = super.getLocation();
return location == null ? BukkitUtil.getLocation(this.player) : location; return location == null ? BukkitUtil.getLocation(this.player) : location;
} }
@NotNull @Override public UUID getUUID() { @Nonnull @Override public UUID getUUID() {
if (Settings.UUID.OFFLINE) { if (Settings.UUID.OFFLINE) {
if (Settings.UUID.FORCE_LOWERCASE) { if (Settings.UUID.FORCE_LOWERCASE) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + return UUID.nameUUIDFromBytes(("OfflinePlayer:" +
@ -134,7 +134,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
return this.player.getLastPlayed(); return this.player.getLastPlayed();
} }
@Override public boolean canTeleport(@NotNull final Location location) { @Override public boolean canTeleport(@Nonnull final Location location) {
final org.bukkit.Location to = BukkitUtil.getLocation(location); final org.bukkit.Location to = BukkitUtil.getLocation(location);
final org.bukkit.Location from = player.getLocation(); final org.bukkit.Location from = player.getLocation();
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to); PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
@ -152,7 +152,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
player.sendTitle(title, subtitle, fadeIn, stay, fadeOut); player.sendTitle(title, subtitle, fadeIn, stay, fadeOut);
} }
private void callEvent(@NotNull final Event event) { private void callEvent(@Nonnull final Event event) {
final RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners(); final RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
for (final RegisteredListener listener : listeners) { for (final RegisteredListener listener : listeners) {
if (listener.getPlugin().getName().equals(PlotSquared.platform().getPluginName())) { if (listener.getPlugin().getName().equals(PlotSquared.platform().getPluginName())) {
@ -248,7 +248,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
} }
@Override @Override
public void teleport(@NotNull final Location location, @NotNull final TeleportCause cause) { public void teleport(@Nonnull final Location location, @Nonnull final TeleportCause cause) {
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) { if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
return; return;
} }
@ -279,7 +279,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
return BukkitUtil.getLocationFull(this.player); return BukkitUtil.getLocationFull(this.player);
} }
@Override public void setWeather(@NotNull final PlotWeather weather) { @Override public void setWeather(@Nonnull final PlotWeather weather) {
switch (weather) { switch (weather) {
case CLEAR: case CLEAR:
this.player.setPlayerWeather(WeatherType.CLEAR); this.player.setPlayerWeather(WeatherType.CLEAR);
@ -294,7 +294,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
} }
} }
@NotNull @Override public com.sk89q.worldedit.world.gamemode.GameMode getGameMode() { @Override public com.sk89q.worldedit.world.gamemode.GameMode getGameMode() {
switch (this.player.getGameMode()) { switch (this.player.getGameMode()) {
case ADVENTURE: case ADVENTURE:
return ADVENTURE; return ADVENTURE;
@ -309,7 +309,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
} }
@Override @Override
public void setGameMode(@NotNull final com.sk89q.worldedit.world.gamemode.GameMode gameMode) { public void setGameMode(final com.sk89q.worldedit.world.gamemode.GameMode gameMode) {
if (ADVENTURE.equals(gameMode)) { if (ADVENTURE.equals(gameMode)) {
this.player.setGameMode(GameMode.ADVENTURE); this.player.setGameMode(GameMode.ADVENTURE);
} else if (CREATIVE.equals(gameMode)) { } else if (CREATIVE.equals(gameMode)) {
@ -337,7 +337,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
this.player.setAllowFlight(fly); this.player.setAllowFlight(fly);
} }
@Override public void playMusic(@NotNull final Location location, @NotNull final ItemType id) { @Override public void playMusic(@Nonnull final Location location, @Nonnull final ItemType id) {
if (id == ItemTypes.AIR) { if (id == ItemTypes.AIR) {
// Let's just stop all the discs because why not? // Let's just stop all the discs because why not?
for (final Sound sound : Arrays.stream(Sound.values()) for (final Sound sound : Arrays.stream(Sound.values())
@ -367,7 +367,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
} }
public PlayerTeleportEvent.TeleportCause getTeleportCause(@NotNull final TeleportCause cause) { public PlayerTeleportEvent.TeleportCause getTeleportCause(@Nonnull final TeleportCause cause) {
switch (cause) { switch (cause) {
case COMMAND: case COMMAND:
return PlayerTeleportEvent.TeleportCause.COMMAND; return PlayerTeleportEvent.TeleportCause.COMMAND;

View File

@ -28,13 +28,14 @@ package com.plotsquared.bukkit.player;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.PlayerManager; import com.plotsquared.core.util.PlayerManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
/** /**
@ -44,27 +45,31 @@ import java.util.UUID;
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler;
@Inject public BukkitPlayerManager(@NotNull final PlotAreaManager plotAreaManager, @Inject public BukkitPlayerManager(@Nonnull final PlotAreaManager plotAreaManager,
@NotNull final EventDispatcher eventDispatcher) { @Nonnull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler;
} }
@NotNull @Override public BukkitPlayer getPlayer(@NotNull final Player object) { @Nonnull @Override public BukkitPlayer getPlayer(@Nonnull final Player object) {
try { try {
return getPlayer(object.getUniqueId()); return getPlayer(object.getUniqueId());
} catch (final NoSuchPlayerException exception) { } catch (final NoSuchPlayerException exception) {
return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, object, object.isOnline(), false); return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, object,
object.isOnline(), false, this.econHandler);
} }
} }
@Override @NotNull public BukkitPlayer createPlayer(@NotNull final UUID uuid) { @Override @Nonnull public BukkitPlayer createPlayer(@Nonnull final UUID uuid) {
final Player player = Bukkit.getPlayer(uuid); final Player player = Bukkit.getPlayer(uuid);
if (player == null || !player.isOnline()) { if (player == null || !player.isOnline()) {
throw new NoSuchPlayerException(uuid); throw new NoSuchPlayerException(uuid);
} }
return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, player); return new BukkitPlayer(this.plotAreaManager, this.eventDispatcher, player, this.econHandler);
} }
@Nullable @Override public BukkitOfflinePlayer getOfflinePlayer(@Nullable final UUID uuid) { @Nullable @Override public BukkitOfflinePlayer getOfflinePlayer(@Nullable final UUID uuid) {
@ -74,7 +79,7 @@ import java.util.UUID;
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(uuid)); return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(uuid));
} }
@NotNull @Override public BukkitOfflinePlayer getOfflinePlayer(@NotNull final String username) { @Nonnull @Override public BukkitOfflinePlayer getOfflinePlayer(@Nonnull final String username) {
return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(username)); return new BukkitOfflinePlayer(Bukkit.getOfflinePlayer(username));
} }

View File

@ -31,7 +31,6 @@ import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.queue.BasicLocalBlockQueue; import com.plotsquared.core.queue.BasicLocalBlockQueue;
import com.plotsquared.core.util.BlockUtil; import com.plotsquared.core.util.BlockUtil;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -42,7 +41,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import lombok.NonNull;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Material; import org.bukkit.Material;
@ -51,6 +49,7 @@ import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Container; import org.bukkit.block.Container;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import javax.annotation.Nonnull;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -201,12 +200,12 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
return chunk; return chunk;
} }
private void setMaterial(@NonNull final BlockState plotBlock, @NonNull final Block block) { private void setMaterial(@Nonnull final BlockState plotBlock, @Nonnull final Block block) {
Material material = BukkitAdapter.adapt(plotBlock.getBlockType()); Material material = BukkitAdapter.adapt(plotBlock.getBlockType());
block.setType(material, false); block.setType(material, false);
} }
private boolean equals(@NonNull final BlockState plotBlock, @NonNull final Block block) { private boolean equals(@Nonnull final BlockState plotBlock, @Nonnull final Block block) {
return plotBlock.equals(BukkitBlockUtil.get(block)); return plotBlock.equals(BukkitBlockUtil.get(block));
} }

View File

@ -46,7 +46,7 @@ import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData; import org.bukkit.generator.ChunkGenerator.ChunkData;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.Arrays; import java.util.Arrays;
@ -135,7 +135,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
return false; return false;
} }
@Override public boolean setBlock(int x, int y, int z, @NotNull Pattern pattern) { @Override public boolean setBlock(int x, int y, int z, @Nonnull Pattern pattern) {
return setBlock(x, y, z, PatternUtil return setBlock(x, y, z, PatternUtil
.apply(Preconditions.checkNotNull(pattern, "Pattern may not be null"), x, y, z)); .apply(Preconditions.checkNotNull(pattern, "Pattern may not be null"), x, y, z));
} }

View File

@ -31,14 +31,14 @@ import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
/** /**
* Schematic Handler. * Schematic Handler.
*/ */
@Singleton public class BukkitSchematicHandler extends SchematicHandler { @Singleton public class BukkitSchematicHandler extends SchematicHandler {
@Inject public BukkitSchematicHandler(@NotNull final WorldUtil worldUtil) { @Inject public BukkitSchematicHandler(@Nonnull final WorldUtil worldUtil) {
super(worldUtil); super(worldUtil);
} }

View File

@ -28,7 +28,6 @@ package com.plotsquared.bukkit.util;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.listener.WEExtent; import com.plotsquared.core.listener.WEExtent;
import com.plotsquared.core.queue.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.entity.EntityCategories; import com.plotsquared.core.util.entity.EntityCategories;
@ -80,8 +79,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
BukkitWorld bukkitWorld1 = new BukkitWorld(world1); BukkitWorld bukkitWorld1 = new BukkitWorld(world1);
BukkitWorld bukkitWorld2 = new BukkitWorld(world2); BukkitWorld bukkitWorld2 = new BukkitWorld(world2);
LocalBlockQueue queue1 = GlobalBlockQueue.IMP.getNewQueue(worldName1, false); LocalBlockQueue queue1 = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName1, false);
LocalBlockQueue queue2 = GlobalBlockQueue.IMP.getNewQueue(worldName2, false); LocalBlockQueue queue2 = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName2, false);
for (int x = Math.max(r1.getMinimumPoint().getX(), sx); for (int x = Math.max(r1.getMinimumPoint().getX(), sx);
x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) { x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) {

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.util.PermHandler;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
@Singleton public class BukkitEconHandler extends EconHandler { @Singleton public class BukkitEconHandler extends EconHandler {

View File

@ -35,7 +35,6 @@ import com.plotsquared.core.location.PlotLoc;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue; import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.queue.ScopedLocalBlockQueue; import com.plotsquared.core.queue.ScopedLocalBlockQueue;
import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.ChunkManager;
@ -58,7 +57,7 @@ import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
@ -79,7 +78,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
@Singleton public class BukkitRegionManager extends RegionManager { @Singleton public class BukkitRegionManager extends RegionManager {
@Inject public BukkitRegionManager(@NotNull ChunkManager chunkManager) { @Inject public BukkitRegionManager(@Nonnull final ChunkManager chunkManager) {
super(chunkManager); super(chunkManager);
} }
@ -212,7 +211,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
assert oldWorld != null; assert oldWorld != null;
final String newWorldName = newWorld.getName(); final String newWorldName = newWorld.getName();
final ContentMap map = new ContentMap(); final ContentMap map = new ContentMap();
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(newWorldName, false); final LocalBlockQueue queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(newWorldName, false);
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override public void run(int[] value) { @Override public void run(int[] value) {
int bx = value[2]; int bx = value[2];
@ -243,7 +242,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
} }
} }
queue.enqueue(); queue.enqueue();
GlobalBlockQueue.IMP.addEmptyTask(() -> { PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(() -> {
//map.restoreBlocks(newWorld, 0, 0); //map.restoreBlocks(newWorld, 0, 0);
map.restoreEntities(newWorld, relX, relZ); map.restoreEntities(newWorld, relX, relZ);
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -291,8 +290,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
if (chunkObj == null) { if (chunkObj == null) {
return; return;
} }
final LocalBlockQueue queue = final LocalBlockQueue queue = PlotSquared.platform().getGlobalBlockQueue()
GlobalBlockQueue.IMP.getNewQueue(world, false); .getNewQueue(world, false);
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) { if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
AugmentedUtils.bypass(ignoreAugment, AugmentedUtils.bypass(ignoreAugment,
() -> queue.regenChunkSafe(chunk.getX(), chunk.getZ())); () -> queue.regenChunkSafe(chunk.getX(), chunk.getZ()));
@ -452,7 +451,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
BukkitChunkManager.swapChunk(world1, world2, chunk1, chunk2, region1, region2)); BukkitChunkManager.swapChunk(world1, world2, chunk1, chunk2, region1, region2));
} }
} }
GlobalBlockQueue.IMP.addEmptyTask(() -> { PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(() -> {
for (ContentMap map : maps) { for (ContentMap map : maps) {
map.restoreEntities(world1, 0, 0); map.restoreEntities(world1, 0, 0);
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTaskLater(whenDone, 1);
@ -467,12 +466,13 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
region.getMinimumPoint().getY(), region.getMinimumPoint().getZ() - extendBiome); region.getMinimumPoint().getY(), region.getMinimumPoint().getZ() - extendBiome);
Location pos2 = Location.at(world, region.getMaximumPoint().getX() + extendBiome, Location pos2 = Location.at(world, region.getMaximumPoint().getX() + extendBiome,
region.getMaximumPoint().getY(), region.getMaximumPoint().getZ() + extendBiome); region.getMaximumPoint().getY(), region.getMaximumPoint().getZ() + extendBiome);
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false); final LocalBlockQueue queue = PlotSquared.platform().getGlobalBlockQueue()
.getNewQueue(world, false);
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override public void run(int[] value) { @Override public void run(int[] value) {
BlockVector2 loc = BlockVector2.at(value[0], value[1]); BlockVector2 loc = BlockVector2.at(value[0], value[1]);
ChunkManager.manager.loadChunk(world, loc, false).thenRun(() -> { PlotSquared.platform().getChunkManager().loadChunk(world, loc, false).thenRun(() -> {
MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome); MainUtil.setBiome(world, value[2], value[3], value[4], value[5], biome);
queue.refreshChunk(value[0], value[1]); queue.refreshChunk(value[0], value[1]);
}); });

View File

@ -48,7 +48,7 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -62,9 +62,9 @@ import java.util.Objects;
private final YamlConfiguration worldConfiguration; private final YamlConfiguration worldConfiguration;
private final File worldFile; private final File worldFile;
@Inject public BukkitSetupUtils(@NotNull final PlotAreaManager plotAreaManager, @Inject public BukkitSetupUtils(@Nonnull final PlotAreaManager plotAreaManager,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
@WorldFile @NotNull final File worldFile) { @WorldFile @Nonnull final File worldFile) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;
this.worldFile = worldFile; this.worldFile = worldFile;

View File

@ -54,7 +54,7 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import lombok.NonNull;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Material; import org.bukkit.Material;
@ -96,8 +96,8 @@ import org.bukkit.entity.Snowman;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
import org.bukkit.entity.WaterMob; import org.bukkit.entity.WaterMob;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -119,7 +119,7 @@ import java.util.stream.Stream;
private static Player lastPlayer = null; private static Player lastPlayer = null;
private static BukkitPlayer lastPlotPlayer = null; private static BukkitPlayer lastPlotPlayer = null;
@Inject public BukkitUtil(@NotNull final RegionManager regionManager) { @Inject public BukkitUtil(@Nonnull final RegionManager regionManager) {
super(regionManager); super(regionManager);
} }
@ -130,7 +130,7 @@ import java.util.stream.Stream;
PlotSquared.platform().getPlayerManager().removePlayer(uuid); PlotSquared.platform().getPlayerManager().removePlayer(uuid);
} }
public static PlotPlayer<Player> getPlayer(@NonNull final OfflinePlayer op) { public static PlotPlayer<Player> getPlayer(@Nonnull final OfflinePlayer op) {
if (op.isOnline()) { if (op.isOnline()) {
return getPlayer(op.getPlayer()); return getPlayer(op.getPlayer());
} }
@ -275,7 +275,7 @@ import java.util.stream.Stream;
MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption); MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption);
} }
public static BukkitPlayer getPlayer(@NonNull final Player player) { public static BukkitPlayer getPlayer(@Nonnull final Player player) {
if (player == lastPlayer) { if (player == lastPlayer) {
return lastPlotPlayer; return lastPlotPlayer;
} }
@ -283,31 +283,31 @@ import java.util.stream.Stream;
return ((BukkitPlayerManager) playerManager).getPlayer(player); return ((BukkitPlayerManager) playerManager).getPlayer(player);
} }
public static Location getLocation(@NonNull final org.bukkit.Location location) { public static Location getLocation(final org.bukkit.Location location) {
return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()), return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ())); MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()));
} }
public static Location getLocationFull(@NonNull final org.bukkit.Location location) { public static Location getLocationFull(final org.bukkit.Location location) {
return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()), return Location.at(com.plotsquared.bukkit.util.BukkitWorld.of(location.getWorld()),
MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(), MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
location.getPitch()); location.getPitch());
} }
public static org.bukkit.Location getLocation(@NonNull final Location location) { public static org.bukkit.Location getLocation(@Nonnull final Location location) {
return new org.bukkit.Location((World) location.getWorld().getPlatformWorld(), location.getX(), return new org.bukkit.Location((World) location.getWorld().getPlatformWorld(), location.getX(),
location.getY(), location.getZ()); location.getY(), location.getZ());
} }
public static World getWorld(@NonNull final String string) { public static World getWorld(@Nonnull final String string) {
return Bukkit.getWorld(string); return Bukkit.getWorld(string);
} }
public static String getWorld(@NonNull final Entity entity) { public static String getWorld(@Nonnull final Entity entity) {
return entity.getWorld().getName(); return entity.getWorld().getName();
} }
public static List<Entity> getEntities(@NonNull final String worldName) { public static List<Entity> getEntities(@Nonnull final String worldName) {
World world = getWorld(worldName); World world = getWorld(worldName);
if (world != null) { if (world != null) {
return world.getEntities(); return world.getEntities();
@ -316,21 +316,21 @@ import java.util.stream.Stream;
} }
} }
public static Location getLocation(@NonNull final Entity entity) { public static Location getLocation(@Nonnull final Entity entity) {
final org.bukkit.Location location = entity.getLocation(); final org.bukkit.Location location = entity.getLocation();
String world = location.getWorld().getName(); String world = location.getWorld().getName();
return Location.at(world, location.getBlockX(), location.getBlockY(), return Location.at(world, location.getBlockX(), location.getBlockY(),
location.getBlockZ()); location.getBlockZ());
} }
@NotNull public static Location getLocationFull(@NonNull final Entity entity) { @Nonnull public static Location getLocationFull(@Nonnull final Entity entity) {
final org.bukkit.Location location = entity.getLocation(); final org.bukkit.Location location = entity.getLocation();
return Location.at(location.getWorld().getName(), MathMan.roundInt(location.getX()), return Location.at(location.getWorld().getName(), MathMan.roundInt(location.getX()),
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
location.getPitch()); location.getPitch());
} }
public static Material getMaterial(@NonNull final BlockState plotBlock) { public static Material getMaterial(@Nonnull final BlockState plotBlock) {
return BukkitAdapter.adapt(plotBlock.getBlockType()); return BukkitAdapter.adapt(plotBlock.getBlockType());
} }
@ -342,7 +342,7 @@ import java.util.stream.Stream;
return mat1 == mat2; return mat1 == mat2;
} }
@Override public boolean isWorld(@NonNull final String worldName) { @Override public boolean isWorld(@Nonnull final String worldName) {
return getWorld(worldName) != null; return getWorld(worldName) != null;
} }
@ -356,7 +356,7 @@ import java.util.stream.Stream;
} }
@Override @Override
public void getHighestBlock(@NonNull final String world, final int x, final int z, public void getHighestBlock(@Nonnull final String world, final int x, final int z,
final IntConsumer result) { final IntConsumer result) {
ensureLoaded(world, x, z, chunk -> { ensureLoaded(world, x, z, chunk -> {
final World bukkitWorld = getWorld(world); final World bukkitWorld = getWorld(world);
@ -406,7 +406,7 @@ import java.util.stream.Stream;
} }
@Override @Override
public void getSign(@NonNull final Location location, final Consumer<String[]> result) { public void getSign(@Nonnull final Location location, final Consumer<String[]> result) {
ensureLoaded(location, chunk -> { ensureLoaded(location, chunk -> {
final Block block = chunk.getWorld().getBlockAt(getLocation(location)); final Block block = chunk.getWorld().getBlockAt(getLocation(location));
if (block.getState() instanceof Sign) { if (block.getState() instanceof Sign) {
@ -416,7 +416,7 @@ import java.util.stream.Stream;
}); });
} }
@Override @Nullable public String[] getSignSynchronous(@NonNull final Location location) { @Override @Nullable public String[] getSignSynchronous(@Nonnull final Location location) {
Block block = getWorld(location.getWorldName()) Block block = getWorld(location.getWorldName())
.getBlockAt(location.getX(), location.getY(), location.getZ()); .getBlockAt(location.getX(), location.getY(), location.getZ());
return TaskManager.getImplementation().sync(new RunnableVal<String[]>() { return TaskManager.getImplementation().sync(new RunnableVal<String[]>() {
@ -429,20 +429,20 @@ import java.util.stream.Stream;
}); });
} }
@Override public Location getSpawn(@NonNull final String world) { @Override public Location getSpawn(@Nonnull final String world) {
final org.bukkit.Location temp = getWorld(world).getSpawnLocation(); final org.bukkit.Location temp = getWorld(world).getSpawnLocation();
return Location.at(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(), return Location.at(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(),
temp.getYaw(), temp.getPitch()); temp.getYaw(), temp.getPitch());
} }
@Override public void setSpawn(@NonNull final Location location) { @Override public void setSpawn(@Nonnull final Location location) {
final World world = getWorld(location.getWorldName()); final World world = getWorld(location.getWorldName());
if (world != null) { if (world != null) {
world.setSpawnLocation(location.getX(), location.getY(), location.getZ()); world.setSpawnLocation(location.getX(), location.getY(), location.getZ());
} }
} }
@Override public void saveWorld(@NonNull final String worldName) { @Override public void saveWorld(@Nonnull final String worldName) {
final World world = getWorld(worldName); final World world = getWorld(worldName);
if (world != null) { if (world != null) {
world.save(); world.save();
@ -450,8 +450,8 @@ import java.util.stream.Stream;
} }
@Override @SuppressWarnings("deprecation") @Override @SuppressWarnings("deprecation")
public void setSign(@NonNull final String worldName, final int x, final int y, final int z, public void setSign(@Nonnull final String worldName, final int x, final int y, final int z,
@NonNull final String[] lines) { @Nonnull final String[] lines) {
ensureLoaded(worldName, x, z, chunk -> { ensureLoaded(worldName, x, z, chunk -> {
final World world = getWorld(worldName); final World world = getWorld(worldName);
final Block block = world.getBlockAt(x, y, z); final Block block = world.getBlockAt(x, y, z);
@ -490,11 +490,11 @@ import java.util.stream.Stream;
}); });
} }
@Override public boolean isBlockSolid(@NonNull final BlockState block) { @Override public boolean isBlockSolid(@Nonnull final BlockState block) {
return block.getBlockType().getMaterial().isSolid(); return block.getBlockType().getMaterial().isSolid();
} }
@Override public String getClosestMatchingName(@NonNull final BlockState block) { @Override public String getClosestMatchingName(@Nonnull final BlockState block) {
try { try {
return getMaterial(block).name(); return getMaterial(block).name();
} catch (Exception ignored) { } catch (Exception ignored) {
@ -509,8 +509,8 @@ import java.util.stream.Stream;
} }
@Override @Override
public void setBiomes(@NonNull final String worldName, @NonNull final CuboidRegion region, public void setBiomes(@Nonnull final String worldName, @Nonnull final CuboidRegion region,
@NonNull final BiomeType biomeType) { @Nonnull final BiomeType biomeType) {
final World world = getWorld(worldName); final World world = getWorld(worldName);
if (world == null) { if (world == null) {
PlotSquared.log("An error occurred setting the biome because the world was null."); PlotSquared.log("An error occurred setting the biome because the world was null.");
@ -532,7 +532,7 @@ import java.util.stream.Stream;
} }
@Override @Override
public void getBlock(@NonNull final Location location, final Consumer<BlockState> result) { public void getBlock(@Nonnull final Location location, final Consumer<BlockState> result) {
ensureLoaded(location, chunk -> { ensureLoaded(location, chunk -> {
final World world = getWorld(location.getWorldName()); final World world = getWorld(location.getWorldName());
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ()); final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
@ -540,7 +540,7 @@ import java.util.stream.Stream;
}); });
} }
@Override public BlockState getBlockSynchronous(@NonNull final Location location) { @Override public BlockState getBlockSynchronous(@Nonnull final Location location) {
final World world = getWorld(location.getWorldName()); final World world = getWorld(location.getWorldName());
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ()); final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
return BukkitAdapter.asBlockType(block.getType()).getDefaultState(); return BukkitAdapter.asBlockType(block.getType()).getDefaultState();

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.location.World;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.Map; import java.util.Map;
@ -40,7 +40,7 @@ import java.util.Map;
private final org.bukkit.World world; private final org.bukkit.World world;
private BukkitWorld(@NotNull final org.bukkit.World world) { private BukkitWorld(final org.bukkit.World world) {
this.world = world; this.world = world;
} }
@ -50,7 +50,7 @@ import java.util.Map;
* @param worldName World name * @param worldName World name
* @return World instance * @return World instance
*/ */
@NotNull public static BukkitWorld of(@NotNull final String worldName) { @Nonnull public static BukkitWorld of(@Nonnull final String worldName) {
final org.bukkit.World bukkitWorld = Bukkit.getWorld(worldName); final org.bukkit.World bukkitWorld = Bukkit.getWorld(worldName);
if (bukkitWorld == null) { if (bukkitWorld == null) {
throw new IllegalArgumentException(String.format("There is no world with the name '%s'", worldName)); throw new IllegalArgumentException(String.format("There is no world with the name '%s'", worldName));
@ -64,7 +64,7 @@ import java.util.Map;
* @param world Bukkit world * @param world Bukkit world
* @return World instance * @return World instance
*/ */
@NotNull public static BukkitWorld of(@NotNull final org.bukkit.World world) { @Nonnull public static BukkitWorld of(final org.bukkit.World world) {
BukkitWorld bukkitWorld = worldMap.get(world.getName()); BukkitWorld bukkitWorld = worldMap.get(world.getName());
if (bukkitWorld != null && bukkitWorld.getPlatformWorld().equals(world)) { if (bukkitWorld != null && bukkitWorld.getPlatformWorld().equals(world)) {
return bukkitWorld; return bukkitWorld;
@ -74,11 +74,11 @@ import java.util.Map;
return bukkitWorld; return bukkitWorld;
} }
@NotNull @Override public org.bukkit.World getPlatformWorld() { @Override public org.bukkit.World getPlatformWorld() {
return this.world; return this.world;
} }
@Override @NotNull public String getName() { @Override @Nonnull public String getName() {
return this.world.getName(); return this.world.getName();
} }

View File

@ -38,7 +38,7 @@ import java.util.ArrayList;
public class SetGenCB { public class SetGenCB {
public static void setGenerator(World world) throws Exception { public static void setGenerator(World world) throws Exception {
SetupUtils.manager.updateGenerators(); PlotSquared.platform().getSetupUtils().updateGenerators();
PlotSquared.get().removePlotAreas(world.getName()); PlotSquared.get().removePlotAreas(world.getName());
ChunkGenerator gen = world.getGenerator(); ChunkGenerator gen = world.getGenerator();
if (gen == null) { if (gen == null) {

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.uuid.UUIDService;
import net.luckperms.api.model.user.UserManager; import net.luckperms.api.model.user.UserManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -54,7 +54,7 @@ public class BungeePermsUUIDService implements UUIDService {
} }
} }
@Override @NotNull public List<UUIDMapping> getNames(@NotNull final List<UUID> uuids) { @Override @Nonnull public List<UUIDMapping> getNames(@Nonnull final List<UUID> uuids) {
final List<UUIDMapping> mappings = new ArrayList<>(uuids.size()); final List<UUIDMapping> mappings = new ArrayList<>(uuids.size());
final UUIDPlayerDB uuiddb = BungeePerms.getInstance().getPermissionsManager().getUUIDPlayerDB(); final UUIDPlayerDB uuiddb = BungeePerms.getInstance().getPermissionsManager().getUUIDPlayerDB();
for (final UUID uuid : uuids) { for (final UUID uuid : uuids) {
@ -68,7 +68,7 @@ public class BungeePermsUUIDService implements UUIDService {
return mappings; return mappings;
} }
@Override @NotNull public List<UUIDMapping> getUUIDs(@NotNull final List<String> usernames) { @Override @Nonnull public List<UUIDMapping> getUUIDs(@Nonnull final List<String> usernames) {
final List<UUIDMapping> mappings = new ArrayList<>(usernames.size()); final List<UUIDMapping> mappings = new ArrayList<>(usernames.size());
final UUIDPlayerDB uuiddb = BungeePerms.getInstance().getPermissionsManager().getUUIDPlayerDB(); final UUIDPlayerDB uuiddb = BungeePerms.getInstance().getPermissionsManager().getUUIDPlayerDB();
for (final String username : usernames) { for (final String username : usernames) {

View File

@ -29,7 +29,7 @@ import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import com.plotsquared.core.uuid.UUIDService; import com.plotsquared.core.uuid.UUIDService;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -47,11 +47,11 @@ public class EssentialsUUIDService implements UUIDService {
this.essentials = Essentials.getPlugin(Essentials.class); this.essentials = Essentials.getPlugin(Essentials.class);
} }
@Override @NotNull public List<UUIDMapping> getNames(@NotNull final List<UUID> uuids) { @Override @Nonnull public List<UUIDMapping> getNames(@Nonnull final List<UUID> uuids) {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override @NotNull public List<UUIDMapping> getUUIDs(@NotNull final List<String> usernames) { @Override @Nonnull public List<UUIDMapping> getUUIDs(@Nonnull final List<String> usernames) {
final List<UUIDMapping> mappings = new ArrayList<>(usernames.size()); final List<UUIDMapping> mappings = new ArrayList<>(usernames.size());
for (final String username : usernames) { for (final String username : usernames) {
try { try {

View File

@ -31,7 +31,7 @@ import net.luckperms.api.LuckPerms;
import net.luckperms.api.model.user.UserManager; import net.luckperms.api.model.user.UserManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -53,7 +53,7 @@ public class LuckPermsUUIDService implements UUIDService {
} }
} }
@Override @NotNull public List<UUIDMapping> getNames(@NotNull final List<UUID> uuids) { @Override @Nonnull public List<UUIDMapping> getNames(@Nonnull final List<UUID> uuids) {
final List<UUIDMapping> mappings = new ArrayList<>(uuids.size()); final List<UUIDMapping> mappings = new ArrayList<>(uuids.size());
final UserManager userManager = this.luckPerms.getUserManager(); final UserManager userManager = this.luckPerms.getUserManager();
for (final UUID uuid : uuids) { for (final UUID uuid : uuids) {
@ -67,7 +67,7 @@ public class LuckPermsUUIDService implements UUIDService {
return mappings; return mappings;
} }
@Override @NotNull public List<UUIDMapping> getUUIDs(@NotNull final List<String> usernames) { @Override @Nonnull public List<UUIDMapping> getUUIDs(@Nonnull final List<String> usernames) {
final List<UUIDMapping> mappings = new ArrayList<>(usernames.size()); final List<UUIDMapping> mappings = new ArrayList<>(usernames.size());
final UserManager userManager = this.luckPerms.getUserManager(); final UserManager userManager = this.luckPerms.getUserManager();
for (final String username : usernames) { for (final String username : usernames) {

View File

@ -31,7 +31,7 @@ import com.plotsquared.core.uuid.UUIDMapping;
import com.plotsquared.core.uuid.UUIDService; import com.plotsquared.core.uuid.UUIDService;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -43,7 +43,7 @@ import java.util.UUID;
*/ */
public class OfflinePlayerUUIDService implements UUIDService { public class OfflinePlayerUUIDService implements UUIDService {
@Override @NotNull public List<UUIDMapping> getNames(@NotNull final List<UUID> uuids) { @Override @Nonnull public List<UUIDMapping> getNames(@Nonnull final List<UUID> uuids) {
if (Settings.UUID.FORCE_LOWERCASE || Bukkit.getWorlds().isEmpty()) { if (Settings.UUID.FORCE_LOWERCASE || Bukkit.getWorlds().isEmpty()) {
return Collections.emptyList(); // This is useless now return Collections.emptyList(); // This is useless now
} }
@ -61,7 +61,7 @@ public class OfflinePlayerUUIDService implements UUIDService {
return wrappers; return wrappers;
} }
@Override @NotNull public List<UUIDMapping> getUUIDs(@NotNull final List<String> usernames) { @Override @Nonnull public List<UUIDMapping> getUUIDs(@Nonnull final List<String> usernames) {
final List<UUIDMapping> wrappers = new ArrayList<>(usernames.size()); final List<UUIDMapping> wrappers = new ArrayList<>(usernames.size());
for (final String username : usernames) { for (final String username : usernames) {
if (Settings.UUID.OFFLINE) { if (Settings.UUID.OFFLINE) {

View File

@ -29,7 +29,7 @@ import com.destroystokyo.paper.profile.PlayerProfile;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import com.plotsquared.core.uuid.UUIDService; import com.plotsquared.core.uuid.UUIDService;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -40,7 +40,7 @@ import java.util.UUID;
*/ */
public class PaperUUIDService implements UUIDService { public class PaperUUIDService implements UUIDService {
@Override @NotNull public List<UUIDMapping> getNames(@NotNull final List<UUID> uuids) { @Override @Nonnull public List<UUIDMapping> getNames(@Nonnull final List<UUID> uuids) {
final List<UUIDMapping> mappings = new ArrayList<>(uuids.size()); final List<UUIDMapping> mappings = new ArrayList<>(uuids.size());
for (final UUID uuid : uuids) { for (final UUID uuid : uuids) {
final PlayerProfile playerProfile = Bukkit.createProfile(uuid); final PlayerProfile playerProfile = Bukkit.createProfile(uuid);
@ -51,7 +51,7 @@ public class PaperUUIDService implements UUIDService {
return mappings; return mappings;
} }
@Override @NotNull public List<UUIDMapping> getUUIDs(@NotNull final List<String> usernames) { @Override @Nonnull public List<UUIDMapping> getUUIDs(@Nonnull final List<String> usernames) {
final List<UUIDMapping> mappings = new ArrayList<>(usernames.size()); final List<UUIDMapping> mappings = new ArrayList<>(usernames.size());
for (final String username : usernames) { for (final String username : usernames) {
final PlayerProfile playerProfile = Bukkit.createProfile(username); final PlayerProfile playerProfile = Bukkit.createProfile(username);

View File

@ -30,7 +30,7 @@ import com.plotsquared.core.database.SQLite;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import com.plotsquared.core.uuid.UUIDService; import com.plotsquared.core.uuid.UUIDService;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -72,7 +72,7 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
} }
} }
@Override @NotNull public List<UUIDMapping> getNames(@NotNull final List<UUID> uuids) { @Override @Nonnull public List<UUIDMapping> getNames(@Nonnull final List<UUID> uuids) {
final List<UUIDMapping> mappings = new ArrayList<>(uuids.size()); final List<UUIDMapping> mappings = new ArrayList<>(uuids.size());
try (final PreparedStatement statement = getConnection() try (final PreparedStatement statement = getConnection()
.prepareStatement("SELECT `username` FROM `usercache` WHERE `uuid` = ?")) { .prepareStatement("SELECT `username` FROM `usercache` WHERE `uuid` = ?")) {
@ -90,7 +90,7 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
return mappings; return mappings;
} }
@Override @NotNull public List<UUIDMapping> getUUIDs(@NotNull List<String> usernames) { @Override @Nonnull public List<UUIDMapping> getUUIDs(@Nonnull List<String> usernames) {
final List<UUIDMapping> mappings = new ArrayList<>(usernames.size()); final List<UUIDMapping> mappings = new ArrayList<>(usernames.size());
try (final PreparedStatement statement = getConnection() try (final PreparedStatement statement = getConnection()
.prepareStatement("SELECT `uuid` FROM `usercache` WHERE `username` = ?")) { .prepareStatement("SELECT `uuid` FROM `usercache` WHERE `username` = ?")) {
@ -127,7 +127,7 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
* *
* @return All read mappings * @return All read mappings
*/ */
@NotNull public List<UUIDMapping> getAll() { @Nonnull public List<UUIDMapping> getAll() {
final List<UUIDMapping> mappings = new LinkedList<>(); final List<UUIDMapping> mappings = new LinkedList<>();
try (final PreparedStatement statement = getConnection().prepareStatement("SELECT * FROM `usercache`")) { try (final PreparedStatement statement = getConnection().prepareStatement("SELECT * FROM `usercache`")) {
try (final ResultSet resultSet = statement.executeQuery()) { try (final ResultSet resultSet = statement.executeQuery()) {

View File

@ -33,7 +33,7 @@ import com.plotsquared.core.uuid.UUIDService;
import com.sk89q.squirrelid.Profile; import com.sk89q.squirrelid.Profile;
import com.sk89q.squirrelid.resolver.HttpRepositoryService; import com.sk89q.squirrelid.resolver.HttpRepositoryService;
import com.sk89q.squirrelid.resolver.ProfileService; import com.sk89q.squirrelid.resolver.ProfileService;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -64,7 +64,7 @@ public class SquirrelIdUUIDService implements UUIDService {
this.rateLimiter = RateLimiter.create(rateLimit / 600.0D); this.rateLimiter = RateLimiter.create(rateLimit / 600.0D);
} }
@Override @NotNull public List<UUIDMapping> getNames(@NotNull final List<UUID> uuids) { @Override @Nonnull public List<UUIDMapping> getNames(@Nonnull final List<UUID> uuids) {
final List<UUIDMapping> results = new ArrayList<>(uuids.size()); final List<UUIDMapping> results = new ArrayList<>(uuids.size());
this.rateLimiter.acquire(uuids.size()); this.rateLimiter.acquire(uuids.size());
try { try {
@ -96,7 +96,7 @@ public class SquirrelIdUUIDService implements UUIDService {
return results; return results;
} }
@Override @NotNull public List<UUIDMapping> getUUIDs(@NotNull final List<String> usernames) { @Override @Nonnull public List<UUIDMapping> getUUIDs(@Nonnull final List<String> usernames) {
final List<UUIDMapping> results = new ArrayList<>(usernames.size()); final List<UUIDMapping> results = new ArrayList<>(usernames.size());
this.rateLimiter.acquire(usernames.size()); this.rateLimiter.acquire(usernames.size());
try { try {

View File

@ -16,10 +16,10 @@ dependencies {
annotationProcessor("org.projectlombok:lombok:1.18.8") annotationProcessor("org.projectlombok:lombok:1.18.8")
testAnnotationProcessor("org.projectlombok:lombok:1.18.8") testAnnotationProcessor("org.projectlombok:lombok:1.18.8")
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72") implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
implementation("org.jetbrains:annotations:19.0.0")
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT") implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
compile("com.google.inject:guice:4.2.3") compile("com.google.inject:guice:4.2.3")
compile("com.google.inject.extensions:guice-assistedinject:4.2.3") compile("com.google.inject.extensions:guice-assistedinject:4.2.3")
compile group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1'
} }
sourceCompatibility = 1.8 sourceCompatibility = 1.8

View File

@ -12,18 +12,36 @@
<version>20200518</version> <version>20200518</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
<version>4.2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.12</version> <version>1.18.12</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>19.0.0</version>
<scope>runtime</scope>
</dependency>
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId> <artifactId>worldedit-core</artifactId>
@ -98,18 +116,6 @@
<version>1.7.0-SNAPSHOT</version> <version>1.7.0-SNAPSHOT</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.3</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
<version>4.2.3</version>
<scope>runtime</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -36,14 +36,16 @@ 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.ChunkManager;
import com.plotsquared.core.util.EconHandler; 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.RegionManager;
import com.plotsquared.core.util.SetupUtils; 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 javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -153,7 +155,7 @@ public interface PlotPlatform<P> extends ILogger {
* *
* @return Default implementation generator * @return Default implementation generator
*/ */
@NotNull default IndependentPlotGenerator getDefaultGenerator() { @Nonnull default IndependentPlotGenerator getDefaultGenerator() {
return getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class)); return getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
} }
@ -164,7 +166,7 @@ public interface PlotPlatform<P> extends ILogger {
* *
* @return Backup manager * @return Backup manager
*/ */
@NotNull default BackupManager getBackupManager() { @Nonnull default BackupManager getBackupManager() {
return getInjector().getInstance(BackupManager.class); return getInjector().getInstance(BackupManager.class);
} }
@ -173,7 +175,7 @@ public interface PlotPlatform<P> extends ILogger {
* *
* @return World manager * @return World manager
*/ */
@NotNull default PlatformWorldManager<?> getWorldManager() { @Nonnull default PlatformWorldManager<?> getWorldManager() {
return getInjector().getInstance(PlatformWorldManager.class); return getInjector().getInstance(PlatformWorldManager.class);
} }
@ -182,7 +184,7 @@ public interface PlotPlatform<P> extends ILogger {
* *
* @return Player manager * @return Player manager
*/ */
@NotNull default PlayerManager<? extends PlotPlayer<P>, ? extends P> getPlayerManager() { @Nonnull default PlayerManager<? extends PlotPlayer<P>, ? extends P> getPlayerManager() {
return getInjector().getInstance(PlayerManager.class); return getInjector().getInstance(PlayerManager.class);
} }
@ -192,21 +194,21 @@ public interface PlotPlatform<P> extends ILogger {
* @param worldName World name * @param worldName World name
* @return Platform world wrapper * @return Platform world wrapper
*/ */
@NotNull World<?> getPlatformWorld(@NotNull final String worldName); @Nonnull World<?> getPlatformWorld(@Nonnull final String worldName);
/** /**
* Get the {@link com.google.inject.Injector} instance used by PlotSquared * Get the {@link com.google.inject.Injector} instance used by PlotSquared
* *
* @return Injector instance * @return Injector instance
*/ */
@NotNull Injector getInjector(); @Nonnull Injector getInjector();
/** /**
* Get the world utility implementation * Get the world utility implementation
* *
* @return World utility * @return World utility
*/ */
@NotNull default WorldUtil getWorldUtil() { @Nonnull default WorldUtil getWorldUtil() {
return getInjector().getInstance(WorldUtil.class); return getInjector().getInstance(WorldUtil.class);
} }
@ -215,7 +217,7 @@ public interface PlotPlatform<P> extends ILogger {
* *
* @return Global block queue implementation * @return Global block queue implementation
*/ */
@NotNull default GlobalBlockQueue getGlobalBlockQueue() { @Nonnull default GlobalBlockQueue getGlobalBlockQueue() {
return getInjector().getInstance(GlobalBlockQueue.class); return getInjector().getInstance(GlobalBlockQueue.class);
} }
@ -224,7 +226,7 @@ public interface PlotPlatform<P> extends ILogger {
* *
* @return Hybrid utils * @return Hybrid utils
*/ */
@NotNull default HybridUtils getHybridUtils() { @Nonnull default HybridUtils getHybridUtils() {
return getInjector().getInstance(HybridUtils.class); return getInjector().getInstance(HybridUtils.class);
} }
@ -233,17 +235,35 @@ public interface PlotPlatform<P> extends ILogger {
* *
* @return Setup utils * @return Setup utils
*/ */
@NotNull default SetupUtils getSetupUtils() { @Nonnull default SetupUtils getSetupUtils() {
return getInjector().getInstance(SetupUtils.class); return getInjector().getInstance(SetupUtils.class);
} }
/** /**
* Get the {@link EconHandler} implementation for the platform * Get the {@link EconHandler} implementation for the platform
* * *
* @return Econ handler * @return Econ handler
*/ */
@NotNull default EconHandler getEconHandler() { @Nullable default EconHandler getEconHandler() {
return getInjector().getInstance(EconHandler.class); return getInjector().getInstance(EconHandler.class);
} }
/**
* Get the {@link RegionManager} implementation for the platform
*
* @return Region manager
*/
@Nonnull default RegionManager getRegionManager() {
return getInjector().getInstance(RegionManager.class);
}
/**
* Get the {@link ChunkManager} implementation for the platform
*
* @return Region manager
*/
@Nonnull default ChunkManager getChunkManager() {
return getInjector().getInstance(ChunkManager.class);
}
} }

View File

@ -26,7 +26,6 @@
package com.plotsquared.core; package com.plotsquared.core;
import com.plotsquared.core.configuration.Caption; import com.plotsquared.core.configuration.Caption;
import com.plotsquared.core.configuration.CaptionUtility;
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.ConfigurationUtil; import com.plotsquared.core.configuration.ConfigurationUtil;
@ -47,7 +46,6 @@ import com.plotsquared.core.generator.IndependentPlotGenerator;
import com.plotsquared.core.inject.factory.HybridPlotWorldFactory; 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.plot.BlockBucket; import com.plotsquared.core.plot.BlockBucket;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
@ -56,13 +54,11 @@ import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.PlotCluster; import com.plotsquared.core.plot.PlotCluster;
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.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.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.plot.world.SinglePlotArea; import com.plotsquared.core.plot.world.SinglePlotArea;
import com.plotsquared.core.plot.world.SinglePlotAreaManager; import com.plotsquared.core.plot.world.SinglePlotAreaManager;
import com.plotsquared.core.util.ChatManager;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.LegacyConverter; import com.plotsquared.core.util.LegacyConverter;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
@ -77,9 +73,9 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -150,7 +146,6 @@ public class PlotSquared {
// Files and configuration // Files and configuration
@Getter private File jarFile = null; // This file @Getter private File jarFile = null; // This file
private File storageFile; private File storageFile;
@Getter private PlotAreaManager plotAreaManager;
@Getter private EventDispatcher eventDispatcher; @Getter private EventDispatcher eventDispatcher;
@Getter private PlotListener plotListener; @Getter private PlotListener plotListener;
@ -195,6 +190,7 @@ public class PlotSquared {
if (!setupConfigs()) { if (!setupConfigs()) {
return; return;
} }
this.translationFile = MainUtil.getFile(this.platform.getDirectory(), this.translationFile = MainUtil.getFile(this.platform.getDirectory(),
Settings.Paths.TRANSLATIONS + File.separator + this.platform.getPluginName() Settings.Paths.TRANSLATIONS + File.separator + this.platform.getPluginName()
+ ".use_THIS.yml"); + ".use_THIS.yml");
@ -207,29 +203,6 @@ public class PlotSquared {
// Create plot listener // Create plot listener
this.plotListener = new PlotListener(this.eventDispatcher); this.plotListener = new PlotListener(this.eventDispatcher);
// Database
if (Settings.Enabled_Components.DATABASE) {
setupDatabase();
}
// Check if we need to convert old flag values, etc
if (!getConfigurationVersion().equalsIgnoreCase("v5")) {
// Perform upgrade
if (DBFunc.dbManager.convertFlags()) {
log(Captions.PREFIX.getTranslated() + "Flags were converted successfully!");
// Update the config version
setConfigurationVersion("v5");
}
}
// Comments
CommentManager.registerDefaultInboxes();
startExpiryTasks();
// This is getting removed so I won't even bother migrating it
ChatManager.manager = this.platform.initChatManager();
// Copy files // Copy files
copyFile("addplots.js", Settings.Paths.SCRIPTS); copyFile("addplots.js", Settings.Paths.SCRIPTS);
copyFile("addsigns.js", Settings.Paths.SCRIPTS); copyFile("addsigns.js", Settings.Paths.SCRIPTS);
@ -253,10 +226,15 @@ public class PlotSquared {
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
}
PlotSquared.log(Captions.PREFIX + CaptionUtility /**
.format(ConsolePlayer.getConsole(), Captions.ENABLED.getTranslated(), * Get the platform specific {@link PlotAreaManager} instance
this.platform.getPluginName())); *
* @return Plot area manager
*/
@Nonnull public PlotAreaManager getPlotAreaManager() {
return this.platform.getInjector().getInstance(PlotAreaManager.class);
} }
/** /**
@ -273,7 +251,7 @@ public class PlotSquared {
* *
* @return Platform implementation * @return Platform implementation
*/ */
@NotNull public static PlotPlatform<?> platform() { @Nonnull public static PlotPlatform<?> platform() {
if (instance != null && instance.platform != null) { if (instance != null && instance.platform != null) {
return instance.platform; return instance.platform;
} }
@ -315,12 +293,12 @@ public class PlotSquared {
} }
} }
private void startExpiryTasks() { public void startExpiryTasks() {
if (Settings.Enabled_Components.PLOT_EXPIRY) { if (Settings.Enabled_Components.PLOT_EXPIRY) {
ExpireManager.IMP = new ExpireManager(this.eventDispatcher); ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
ExpireManager.IMP.runAutomatedTask(); ExpireManager.IMP.runAutomatedTask();
for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) { for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) {
ExpiryTask task = new ExpiryTask(settings, this.plotAreaManager); ExpiryTask task = new ExpiryTask(settings, this.getPlotAreaManager());
ExpireManager.IMP.addTask(task); ExpireManager.IMP.addTask(task);
} }
} }
@ -412,7 +390,7 @@ public class PlotSquared {
cluster.setArea(plotArea); cluster.setArea(plotArea);
} }
} }
plotAreaManager.addPlotArea(plotArea); getPlotAreaManager().addPlotArea(plotArea);
plotArea.setupBorder(); plotArea.setupBorder();
if (!Settings.Enabled_Components.PERSISTENT_ROAD_REGEN) { if (!Settings.Enabled_Components.PERSISTENT_ROAD_REGEN) {
return; return;
@ -459,11 +437,11 @@ public class PlotSquared {
* @param area the {@code PlotArea} to remove * @param area the {@code PlotArea} to remove
*/ */
public void removePlotArea(PlotArea area) { public void removePlotArea(PlotArea area) {
plotAreaManager.removePlotArea(area); getPlotAreaManager().removePlotArea(area);
setPlotsTmp(area); setPlotsTmp(area);
} }
public void removePlotAreas(@NotNull final String world) { public void removePlotAreas(@Nonnull final String world) {
for (final PlotArea area : this.getPlotAreaManager().getPlotAreasSet(world)) { for (final PlotArea area : this.getPlotAreaManager().getPlotAreasSet(world)) {
if (area.getWorldName().equals(world)) { if (area.getWorldName().equals(world)) {
removePlotArea(area); removePlotArea(area);
@ -486,7 +464,7 @@ public class PlotSquared {
this.clustersTmp.put(area.toString(), area.getClusters()); this.clustersTmp.put(area.toString(), area.getClusters());
} }
public Set<PlotCluster> getClusters(@NotNull final String world) { public Set<PlotCluster> getClusters(@Nonnull final String world) {
final Set<PlotCluster> set = new HashSet<>(); final Set<PlotCluster> set = new HashSet<>();
for (final PlotArea area : this.getPlotAreaManager().getPlotAreasSet(world)) { for (final PlotArea area : this.getPlotAreaManager().getPlotAreasSet(world)) {
set.addAll(area.getClusters()); set.addAll(area.getClusters());
@ -695,13 +673,13 @@ public class PlotSquared {
// group by world // group by world
// sort each // sort each
HashMap<PlotArea, Collection<Plot>> map = new HashMap<>(); HashMap<PlotArea, Collection<Plot>> map = new HashMap<>();
int totalSize = Arrays.stream(this.plotAreaManager.getAllPlotAreas()).mapToInt(PlotArea::getPlotCount).sum(); int totalSize = Arrays.stream(this.getPlotAreaManager().getAllPlotAreas()).mapToInt(PlotArea::getPlotCount).sum();
if (plots.size() == totalSize) { if (plots.size() == totalSize) {
for (PlotArea area : plotAreaManager.getAllPlotAreas()) { for (PlotArea area : getPlotAreaManager().getAllPlotAreas()) {
map.put(area, area.getPlots()); map.put(area, area.getPlots());
} }
} else { } else {
for (PlotArea area : plotAreaManager.getAllPlotAreas()) { for (PlotArea area : getPlotAreaManager().getAllPlotAreas()) {
map.put(area, new ArrayList<>(0)); map.put(area, new ArrayList<>(0));
} }
Collection<Plot> lastList = null; Collection<Plot> lastList = null;
@ -716,7 +694,7 @@ public class PlotSquared {
} }
} }
} }
List<PlotArea> areas = Arrays.asList(plotAreaManager.getAllPlotAreas()); List<PlotArea> areas = Arrays.asList(getPlotAreaManager().getAllPlotAreas());
areas.sort((a, b) -> { areas.sort((a, b) -> {
if (priorityArea != null) { if (priorityArea != null) {
if (a.equals(priorityArea)) { if (a.equals(priorityArea)) {
@ -749,7 +727,7 @@ public class PlotSquared {
return toReturn; return toReturn;
} }
public void setPlots(@NotNull final Map<String, HashMap<PlotId, Plot>> plots) { public void setPlots(@Nonnull final Map<String, HashMap<PlotId, Plot>> plots) {
if (this.plots_tmp == null) { if (this.plots_tmp == null) {
this.plots_tmp = new HashMap<>(); this.plots_tmp = new HashMap<>();
} }
@ -816,7 +794,7 @@ public class PlotSquared {
if (world.equals("CheckingPlotSquaredGenerator")) { if (world.equals("CheckingPlotSquaredGenerator")) {
return; return;
} }
this.plotAreaManager.addWorld(world); this.getPlotAreaManager().addWorld(world);
Set<String> worlds; Set<String> worlds;
if (this.worldConfiguration.contains("worlds")) { if (this.worldConfiguration.contains("worlds")) {
worlds = this.worldConfiguration.getConfigurationSection("worlds").getKeys(false); worlds = this.worldConfiguration.getConfigurationSection("worlds").getKeys(false);
@ -832,7 +810,7 @@ public class PlotSquared {
type = PlotAreaType.NORMAL; type = PlotAreaType.NORMAL;
} }
if (type == PlotAreaType.NORMAL) { if (type == PlotAreaType.NORMAL) {
if (plotAreaManager.getPlotAreas(world, null).length != 0) { if (getPlotAreaManager().getPlotAreas(world, null).length != 0) {
debug("World possibly already loaded: " + world); debug("World possibly already loaded: " + world);
return; return;
} }
@ -866,7 +844,7 @@ public class PlotSquared {
.log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + plotGenerator); .log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + plotGenerator);
PlotSquared.log(Captions.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName()); PlotSquared.log(Captions.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
PlotSquared.log( PlotSquared.log(
Captions.PREFIX + "&3 - plotAreaManager: &7" + plotManager.getClass().getName()); Captions.PREFIX + "&3 - getPlotAreaManager(): &7" + plotManager.getClass().getName());
if (!this.worldConfiguration.contains(path)) { if (!this.worldConfiguration.contains(path)) {
this.worldConfiguration.createSection(path); this.worldConfiguration.createSection(path);
worldSection = this.worldConfiguration.getConfigurationSection(path); worldSection = this.worldConfiguration.getConfigurationSection(path);
@ -887,7 +865,7 @@ public class PlotSquared {
} }
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas"); ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
if (areasSection == null) { if (areasSection == null) {
if (plotAreaManager.getPlotAreas(world, null).length != 0) { if (getPlotAreaManager().getPlotAreas(world, null).length != 0) {
debug("World possibly already loaded: " + world); debug("World possibly already loaded: " + world);
return; return;
} }
@ -954,7 +932,7 @@ public class PlotSquared {
PlotSquared PlotSquared
.log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + areaGen); .log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + areaGen);
PlotSquared.log(Captions.PREFIX + "&3 - plotworld: &7" + pa); PlotSquared.log(Captions.PREFIX + "&3 - plotworld: &7" + pa);
PlotSquared.log(Captions.PREFIX + "&3 - plotAreaManager: &7" + pa.getPlotManager()); PlotSquared.log(Captions.PREFIX + "&3 - getPlotAreaManager(): &7" + pa.getPlotManager());
areaGen.getPlotGenerator().initialize(pa); areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa); areaGen.augment(pa);
addPlotArea(pa); addPlotArea(pa);
@ -1314,8 +1292,8 @@ public class PlotSquared {
} }
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, this.eventDispatcher, this.plotListener, this.worldConfiguration); DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, this.eventDispatcher, this.plotListener, this.worldConfiguration);
this.plots_tmp = DBFunc.getPlots(); this.plots_tmp = DBFunc.getPlots();
if (plotAreaManager instanceof SinglePlotAreaManager) { if (getPlotAreaManager() instanceof SinglePlotAreaManager) {
SinglePlotArea area = ((SinglePlotAreaManager) plotAreaManager).getArea(); SinglePlotArea area = ((SinglePlotAreaManager) getPlotAreaManager()).getArea();
addPlotArea(area); addPlotArea(area);
ConfigurationSection section = worldConfiguration.getConfigurationSection("worlds.*"); ConfigurationSection section = worldConfiguration.getConfigurationSection("worlds.*");
if (section == null) { if (section == null) {
@ -1556,7 +1534,7 @@ public class PlotSquared {
} }
public void forEachPlotRaw(Consumer<Plot> consumer) { public void forEachPlotRaw(Consumer<Plot> consumer) {
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) { for (final PlotArea area : this.getPlotAreaManager().getAllPlotAreas()) {
area.getPlots().forEach(consumer); area.getPlots().forEach(consumer);
} }
if (this.plots_tmp != null) { if (this.plots_tmp != null) {
@ -1573,10 +1551,10 @@ public class PlotSquared {
* @param chunkCoordinates Chunk coordinates * @param chunkCoordinates Chunk coordinates
* @return True if the chunk uses non-standard generation, false if not * @return True if the chunk uses non-standard generation, false if not
*/ */
public boolean isNonStandardGeneration(@NotNull final String world, public boolean isNonStandardGeneration(@Nonnull final String world,
@NotNull final BlockVector2 chunkCoordinates) { @Nonnull final BlockVector2 chunkCoordinates) {
final Location location = Location.at(world, chunkCoordinates.getBlockX() << 4, 64, chunkCoordinates.getBlockZ() << 4); final Location location = Location.at(world, chunkCoordinates.getBlockX() << 4, 64, chunkCoordinates.getBlockZ() << 4);
final PlotArea area = plotAreaManager.getApplicablePlotArea(location); final PlotArea area = getPlotAreaManager().getApplicablePlotArea(location);
if (area == null) { if (area == null) {
return true; return true;
} }

View File

@ -28,7 +28,7 @@ package com.plotsquared.core.backup;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;

View File

@ -28,8 +28,8 @@ package com.plotsquared.core.backup;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
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 org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Objects; import java.util.Objects;
@ -45,7 +45,7 @@ public interface BackupManager {
* @param plot Plot to perform the automatic backup on * @param plot Plot to perform the automatic backup on
* @param whenDone Action that runs when the automatic backup has been completed * @param whenDone Action that runs when the automatic backup has been completed
*/ */
static void backup(@Nullable PlotPlayer player, @NotNull final Plot plot, @NotNull Runnable whenDone) { static void backup(@Nullable PlotPlayer player, @Nonnull final Plot plot, @Nonnull Runnable whenDone) {
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().automaticBackup(player, plot, whenDone); Objects.requireNonNull(PlotSquared.platform()).getBackupManager().automaticBackup(player, plot, whenDone);
} }
@ -56,7 +56,7 @@ public interface BackupManager {
* @param plot Plot to get the backup profile for * @param plot Plot to get the backup profile for
* @return Backup profile * @return Backup profile
*/ */
@NotNull BackupProfile getProfile(@NotNull final Plot plot); @Nonnull BackupProfile getProfile(@Nonnull final Plot plot);
/** /**
* This will perform an automatic backup of the plot iff the plot has an owner, * This will perform an automatic backup of the plot iff the plot has an owner,
@ -67,14 +67,14 @@ public interface BackupManager {
* @param plot Plot to perform the automatic backup on * @param plot Plot to perform the automatic backup on
* @param whenDone Action that runs when the automatic backup has been completed * @param whenDone Action that runs when the automatic backup has been completed
*/ */
void automaticBackup(@Nullable PlotPlayer player, @NotNull final Plot plot, @NotNull Runnable whenDone); void automaticBackup(@Nullable PlotPlayer player, @Nonnull final Plot plot, @Nonnull Runnable whenDone);
/** /**
* Get the directory in which backups are stored * Get the directory in which backups are stored
* *
* @return Backup directory path * @return Backup directory path
*/ */
@NotNull Path getBackupPath(); @Nonnull Path getBackupPath();
/** /**
* Get the maximum amount of backups that may be stored for * Get the maximum amount of backups that may be stored for

View File

@ -25,7 +25,7 @@
*/ */
package com.plotsquared.core.backup; package com.plotsquared.core.backup;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
@ -38,7 +38,7 @@ public interface BackupProfile {
* *
* @return Future that will be completed with available backups * @return Future that will be completed with available backups
*/ */
@NotNull CompletableFuture<List<Backup>> listBackups(); @Nonnull CompletableFuture<List<Backup>> listBackups();
/** /**
* Remove all backups stored for this profile * Remove all backups stored for this profile
@ -51,7 +51,7 @@ public interface BackupProfile {
* *
* @return Folder that contains the backups for this profile * @return Folder that contains the backups for this profile
*/ */
@NotNull Path getBackupDirectory(); @Nonnull Path getBackupDirectory();
/** /**
* Create a backup of the plot. If the profile is at the * Create a backup of the plot. If the profile is at the
@ -59,7 +59,7 @@ public interface BackupProfile {
* *
* @return Future that completes with the created backup. * @return Future that completes with the created backup.
*/ */
@NotNull CompletableFuture<Backup> createBackup(); @Nonnull CompletableFuture<Backup> createBackup();
/** /**
* Restore a backup * Restore a backup
@ -67,6 +67,6 @@ public interface BackupProfile {
* @param backup Backup to restore * @param backup Backup to restore
* @return Future that completes when the backup has finished * @return Future that completes when the backup has finished
*/ */
@NotNull CompletableFuture<Void> restoreBackup(@NotNull final Backup backup); @Nonnull CompletableFuture<Void> restoreBackup(@Nonnull final Backup backup);
} }

View File

@ -29,8 +29,8 @@ import com.google.inject.Singleton;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
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 org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Objects; import java.util.Objects;
@ -40,16 +40,16 @@ import java.util.Objects;
*/ */
@Singleton public class NullBackupManager implements BackupManager { @Singleton public class NullBackupManager implements BackupManager {
@Override @NotNull public BackupProfile getProfile(@NotNull Plot plot) { @Override @Nonnull public BackupProfile getProfile(@Nonnull Plot plot) {
return new NullBackupProfile(); return new NullBackupProfile();
} }
@Override public void automaticBackup(@Nullable PlotPlayer plotPlayer, @Override public void automaticBackup(@Nullable PlotPlayer plotPlayer,
@NotNull Plot plot, @NotNull Runnable whenDone) { @Nonnull Plot plot, @Nonnull Runnable whenDone) {
whenDone.run(); whenDone.run();
} }
@Override @NotNull public Path getBackupPath() { @Override @Nonnull public Path getBackupPath() {
return Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath(); return Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath();
} }

View File

@ -25,7 +25,7 @@
*/ */
package com.plotsquared.core.backup; package com.plotsquared.core.backup;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.nio.file.Path; import java.nio.file.Path;
@ -39,22 +39,22 @@ import java.util.concurrent.CompletableFuture;
*/ */
public class NullBackupProfile implements BackupProfile { public class NullBackupProfile implements BackupProfile {
@Override @NotNull public CompletableFuture<List<Backup>> listBackups() { @Override @Nonnull public CompletableFuture<List<Backup>> listBackups() {
return CompletableFuture.completedFuture(Collections.emptyList()); return CompletableFuture.completedFuture(Collections.emptyList());
} }
@Override public void destroy(){ @Override public void destroy(){
} }
@Override @NotNull public Path getBackupDirectory() { @Override @Nonnull public Path getBackupDirectory() {
return new File(".").toPath(); return new File(".").toPath();
} }
@Override @NotNull public CompletableFuture<Backup> createBackup() { @Override @Nonnull public CompletableFuture<Backup> createBackup() {
throw new UnsupportedOperationException("Cannot create backup of an unowned plot"); throw new UnsupportedOperationException("Cannot create backup of an unowned plot");
} }
@Override @NotNull public CompletableFuture<Void> restoreBackup(@NotNull final Backup backup) { @Override @Nonnull public CompletableFuture<Void> restoreBackup(@Nonnull final Backup backup) {
return CompletableFuture.completedFuture(null); return CompletableFuture.completedFuture(null);
} }

View File

@ -33,7 +33,7 @@ import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
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 javax.annotation.Nonnull;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
@ -59,8 +59,8 @@ public class PlayerBackupProfile implements BackupProfile {
private final BackupManager backupManager; private final BackupManager backupManager;
private final SchematicHandler schematicHandler; private final SchematicHandler schematicHandler;
@Inject public PlayerBackupProfile(@Assisted @NotNull final UUID owner, @Assisted @NotNull final Plot plot, @Inject public PlayerBackupProfile(@Assisted @Nonnull final UUID owner, @Assisted @Nonnull final Plot plot,
@NotNull final BackupManager backupManager, @NotNull final SchematicHandler schematicHandler) { @Nonnull final BackupManager backupManager, @Nonnull final SchematicHandler schematicHandler) {
this.owner = owner; this.owner = owner;
this.plot = plot; this.plot = plot;
this.backupManager = backupManager; this.backupManager = backupManager;
@ -70,12 +70,12 @@ public class PlayerBackupProfile implements BackupProfile {
private volatile List<Backup> backupCache; private volatile List<Backup> backupCache;
private final Object backupLock = new Object(); private final Object backupLock = new Object();
private static boolean isValidFile(@NotNull final Path path) { private static boolean isValidFile(@Nonnull final Path path) {
final String name = path.getFileName().toString(); final String name = path.getFileName().toString();
return name.endsWith(".schem") || name.endsWith(".schematic"); return name.endsWith(".schem") || name.endsWith(".schematic");
} }
@Override @NotNull public CompletableFuture<List<Backup>> listBackups() { @Override @Nonnull public CompletableFuture<List<Backup>> listBackups() {
synchronized (this.backupLock) { synchronized (this.backupLock) {
if (this.backupCache != null) { if (this.backupCache != null) {
return CompletableFuture.completedFuture(backupCache); return CompletableFuture.completedFuture(backupCache);
@ -121,12 +121,12 @@ public class PlayerBackupProfile implements BackupProfile {
}); });
} }
@NotNull public Path getBackupDirectory() { @Nonnull public Path getBackupDirectory() {
return resolve(resolve(resolve(backupManager.getBackupPath(), Objects.requireNonNull(plot.getArea().toString(), "plot area id")), return resolve(resolve(resolve(backupManager.getBackupPath(), Objects.requireNonNull(plot.getArea().toString(), "plot area id")),
Objects.requireNonNull(plot.getId().toDashSeparatedString(), "plot id")), Objects.requireNonNull(owner.toString(), "owner")); Objects.requireNonNull(plot.getId().toDashSeparatedString(), "plot id")), Objects.requireNonNull(owner.toString(), "owner"));
} }
private static Path resolve(@NotNull final Path parent, final String child) { private static Path resolve(@Nonnull final Path parent, final String child) {
Path path = parent; Path path = parent;
try { try {
if (!Files.exists(parent)) { if (!Files.exists(parent)) {
@ -142,7 +142,7 @@ public class PlayerBackupProfile implements BackupProfile {
return path; return path;
} }
@Override @NotNull public CompletableFuture<Backup> createBackup() { @Override @Nonnull public CompletableFuture<Backup> createBackup() {
final CompletableFuture<Backup> future = new CompletableFuture<>(); final CompletableFuture<Backup> future = new CompletableFuture<>();
this.listBackups().thenAcceptAsync(backups -> { this.listBackups().thenAcceptAsync(backups -> {
synchronized (this.backupLock) { synchronized (this.backupLock) {
@ -162,7 +162,7 @@ public class PlayerBackupProfile implements BackupProfile {
return future; return future;
} }
@Override @NotNull public CompletableFuture<Void> restoreBackup(@NotNull final Backup backup) { @Override @Nonnull public CompletableFuture<Void> restoreBackup(@Nonnull final Backup backup) {
final CompletableFuture<Void> future = new CompletableFuture<>(); final CompletableFuture<Void> future = new CompletableFuture<>();
if (backup.getFile() == null || !Files.exists(backup.getFile())) { if (backup.getFile() == null || !Files.exists(backup.getFile())) {
future.completeExceptionally(new IllegalArgumentException("The specific backup does not exist")); future.completeExceptionally(new IllegalArgumentException("The specific backup does not exist"));

View File

@ -39,8 +39,8 @@ import com.plotsquared.core.util.task.TaskManager;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -60,7 +60,7 @@ import java.util.concurrent.TimeUnit;
.expireAfterAccess(3, TimeUnit.MINUTES).build(); .expireAfterAccess(3, TimeUnit.MINUTES).build();
private final PlayerBackupProfileFactory playerBackupProfileFactory; private final PlayerBackupProfileFactory playerBackupProfileFactory;
@Inject public SimpleBackupManager(@NotNull final PlayerBackupProfileFactory playerBackupProfileFactory) throws Exception { @Inject public SimpleBackupManager(@Nonnull final PlayerBackupProfileFactory playerBackupProfileFactory) throws Exception {
this.playerBackupProfileFactory = playerBackupProfileFactory; this.playerBackupProfileFactory = playerBackupProfileFactory;
this.backupPath = Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath().resolve("backups"); this.backupPath = Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath().resolve("backups");
if (!Files.exists(backupPath)) { if (!Files.exists(backupPath)) {
@ -70,7 +70,7 @@ import java.util.concurrent.TimeUnit;
this.backupLimit = Settings.Backup.BACKUP_LIMIT; this.backupLimit = Settings.Backup.BACKUP_LIMIT;
} }
@Override @NotNull public BackupProfile getProfile(@NotNull final Plot plot) { @Override @Nonnull public BackupProfile getProfile(@Nonnull final Plot plot) {
if (plot.hasOwner() && !plot.isMerged()) { if (plot.hasOwner() && !plot.isMerged()) {
try { try {
return backupProfileCache.get(new PlotCacheKey(plot), () -> this.playerBackupProfileFactory.create(plot.getOwnerAbs(), plot)); return backupProfileCache.get(new PlotCacheKey(plot), () -> this.playerBackupProfileFactory.create(plot.getOwnerAbs(), plot));
@ -83,7 +83,7 @@ import java.util.concurrent.TimeUnit;
return new NullBackupProfile(); return new NullBackupProfile();
} }
@Override public void automaticBackup(@Nullable PlotPlayer player, @NotNull final Plot plot, @NotNull Runnable whenDone) { @Override public void automaticBackup(@Nullable PlotPlayer player, @Nonnull final Plot plot, @Nonnull Runnable whenDone) {
final BackupProfile profile; final BackupProfile profile;
if (!this.shouldAutomaticallyBackup() || (profile = getProfile(plot)) instanceof NullBackupProfile) { if (!this.shouldAutomaticallyBackup() || (profile = getProfile(plot)) instanceof NullBackupProfile) {
whenDone.run(); whenDone.run();

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.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -35,7 +36,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
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 javax.annotation.Nonnull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -54,7 +55,7 @@ public class Add extends Command {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
public Add(@NotNull final EventDispatcher eventDispatcher) { @Inject public Add(@Nonnull final EventDispatcher eventDispatcher) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
} }

View File

@ -71,7 +71,7 @@ import com.sk89q.worldedit.math.BlockVector2;
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 com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -100,13 +100,13 @@ public class Area extends SubCommand {
private final WorldUtil worldUtil; private final WorldUtil worldUtil;
private final RegionManager regionManager; private final RegionManager regionManager;
@Inject public Area(@NotNull final PlotAreaManager plotAreaManager, @Inject public Area(@Nonnull final PlotAreaManager plotAreaManager,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
@WorldFile @NotNull final File worldFile, @WorldFile @Nonnull final File worldFile,
@NotNull final HybridPlotWorldFactory hybridPlotWorldFactory, @Nonnull final HybridPlotWorldFactory hybridPlotWorldFactory,
@NotNull final SetupUtils setupUtils, @Nonnull final SetupUtils setupUtils,
@NotNull final WorldUtil worldUtil, @Nonnull final WorldUtil worldUtil,
@NotNull final RegionManager regionManager) { @Nonnull final RegionManager regionManager) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;
this.worldFile = worldFile; this.worldFile = worldFile;

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;
@ -49,8 +50,8 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.AutoClaimFinishTask; import com.plotsquared.core.util.task.AutoClaimFinishTask;
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 javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Set; import java.util.Set;
@ -66,10 +67,14 @@ public class Auto extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler;
public Auto(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) { @Inject public Auto(@Nonnull final PlotAreaManager plotAreaManager,
@Nonnull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler;
} }
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) { @Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
@ -147,7 +152,7 @@ public class Auto extends SubCommand {
player.setMeta(Auto.class.getName(), true); player.setMeta(Auto.class.getName(), true);
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() { autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
@Override public void run(final Plot plot) { @Override public void run(final Plot plot) {
TaskManager.IMP.sync(new AutoClaimFinishTask(player, plot, area, schematic, TaskManager.getImplementation().sync(new AutoClaimFinishTask(player, plot, area, schematic,
PlotSquared.get().getEventDispatcher())); PlotSquared.get().getEventDispatcher()));
} }
}); });
@ -169,10 +174,9 @@ public class Auto extends SubCommand {
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
PlotArea plotarea = player.getApplicablePlotArea(); PlotArea plotarea = player.getApplicablePlotArea();
if (plotarea == null) { if (plotarea == null) {
if (EconHandler.getEconHandler() != null) { if (this.econHandler != null) {
for (PlotArea area : this.plotAreaManager.getAllPlotAreas()) { for (PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
if (EconHandler.getEconHandler() if (this.econHandler.hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
.hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
if (plotarea != null) { if (plotarea != null) {
plotarea = null; plotarea = null;
break; break;
@ -265,18 +269,18 @@ public class Auto extends SubCommand {
return true; return true;
} }
} }
if (EconHandler.getEconHandler() != null && plotarea.useEconomy()) { if (this.econHandler != null && plotarea.useEconomy()) {
Expression<Double> costExp = plotarea.getPrices().get("claim"); Expression<Double> costExp = plotarea.getPrices().get("claim");
double cost = costExp.evaluate((double) (Settings.Limit.GLOBAL ? double cost = costExp.evaluate((double) (Settings.Limit.GLOBAL ?
player.getPlotCount() : player.getPlotCount() :
player.getPlotCount(plotarea.getWorldName()))); player.getPlotCount(plotarea.getWorldName())));
cost = (size_x * size_z) * cost; cost = (size_x * size_z) * cost;
if (cost > 0d) { if (cost > 0d) {
if (!force && EconHandler.getEconHandler().getMoney(player) < cost) { if (!force && this.econHandler.getMoney(player) < cost) {
sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost); sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
return true; return true;
} }
EconHandler.getEconHandler().withdrawMoney(player, cost); this.econHandler.withdrawMoney(player, cost);
sendMessage(player, Captions.REMOVED_BALANCE, cost + ""); sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
} }
} }

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
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 javax.annotation.Nonnull;
import java.nio.file.Files; import java.nio.file.Files;
import java.time.Instant; import java.time.Instant;
@ -64,7 +64,7 @@ public final class Backup extends Command {
private final BackupManager backupManager; private final BackupManager backupManager;
@Inject public Backup(@NotNull final BackupManager backupManager) { @Inject public Backup(@Nonnull final BackupManager backupManager) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.backupManager = backupManager; this.backupManager = backupManager;
} }

View File

@ -39,9 +39,9 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil; 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 javax.annotation.Nullable;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -56,7 +56,7 @@ public class Buy extends Command {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler; private final EconHandler econHandler;
@Inject public Buy(@NotNull final EventDispatcher eventDispatcher, @Inject public Buy(@Nonnull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) { @Nullable final EconHandler econHandler) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;

View File

@ -71,7 +71,7 @@ public class Caps extends SubCommand {
} }
private <T extends PlotFlag<Integer, T>> void sendFormatted(final Plot plot, private <T extends PlotFlag<Integer, T>> void sendFormatted(final Plot plot,
final PlotPlayer player, final Class<T> capFlag, final int[] countedEntities, final PlotPlayer<?> player, final Class<T> capFlag, final int[] countedEntities,
final String name, final int type) { final String name, final int type) {
final int current = countedEntities[type]; final int current = countedEntities[type];
final int max = plot.getFlag(capFlag); final int max = plot.getFlag(capFlag);

View File

@ -46,8 +46,8 @@ import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.Permissions; 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 javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
@CommandDeclaration(command = "claim", @CommandDeclaration(command = "claim",
aliases = "c", aliases = "c",
@ -61,7 +61,7 @@ public class Claim extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler; private final EconHandler econHandler;
@Inject public Claim(@NotNull final EventDispatcher eventDispatcher, @Inject public Claim(@Nonnull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) { @Nullable final EconHandler econHandler) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler; this.econHandler = econHandler;

View File

@ -42,7 +42,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.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 javax.annotation.Nonnull;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -61,8 +61,8 @@ public class Clear extends Command {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final GlobalBlockQueue blockQueue; private final GlobalBlockQueue blockQueue;
@Inject public Clear(@NotNull final EventDispatcher eventDispatcher, @Inject public Clear(@Nonnull final EventDispatcher eventDispatcher,
@NotNull final GlobalBlockQueue blockQueue) { @Nonnull final GlobalBlockQueue blockQueue) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.blockQueue = blockQueue; this.blockQueue = blockQueue;

View File

@ -36,7 +36,7 @@ import com.plotsquared.core.util.StringMan;
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 lombok.SneakyThrows; import lombok.SneakyThrows;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -582,7 +582,7 @@ public abstract class Command {
return object; return object;
} }
@SneakyThrows protected static void sneakyThrow(@NotNull final Throwable throwable) { @SneakyThrows protected static void sneakyThrow(@Nonnull final Throwable throwable) {
throw throwable; throw throwable;
} }

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.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
@ -34,7 +35,7 @@ import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -56,9 +57,12 @@ public class Condense extends SubCommand {
public static boolean TASK = false; public static boolean TASK = false;
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final WorldUtil worldUtil;
public Condense(@NotNull final PlotAreaManager plotAreaManager) { @Inject public Condense(@Nonnull final PlotAreaManager plotAreaManager,
@Nonnull final WorldUtil worldUtil) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldUtil = worldUtil;
} }
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
@ -67,7 +71,7 @@ public class Condense extends SubCommand {
return false; return false;
} }
PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]); PlotArea area = this.plotAreaManager.getPlotAreaByString(args[0]);
if (area == null || !WorldUtil.IMP.isWorld(area.getWorldName())) { if (area == null || !this.worldUtil.isWorld(area.getWorldName())) {
MainUtil.sendMessage(player, "INVALID AREA"); MainUtil.sendMessage(player, "INVALID AREA");
return false; return false;
} }

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.PlotFlagRemoveEvent; import com.plotsquared.core.events.PlotFlagRemoveEvent;
@ -36,7 +37,7 @@ import com.plotsquared.core.plot.flag.implementations.DoneFlag;
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.Permissions; import com.plotsquared.core.util.Permissions;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
@CommandDeclaration(command = "continue", @CommandDeclaration(command = "continue",
description = "Continue a plot that was previously marked as done", description = "Continue a plot that was previously marked as done",
@ -47,7 +48,7 @@ public class Continue extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
public Continue(@NotNull final EventDispatcher eventDispatcher) { @Inject public Continue(@Nonnull final EventDispatcher eventDispatcher) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
} }

View File

@ -33,7 +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; import javax.annotation.Nonnull;
@CommandDeclaration(command = "createroadschematic", @CommandDeclaration(command = "createroadschematic",
aliases = {"crs"}, aliases = {"crs"},
@ -46,7 +46,7 @@ public class CreateRoadSchematic extends SubCommand {
private final HybridUtils hybridUtils; private final HybridUtils hybridUtils;
@Inject public CreateRoadSchematic(@NotNull final HybridUtils hybridUtils) { @Inject public CreateRoadSchematic(@Nonnull final HybridUtils hybridUtils) {
this.hybridUtils = hybridUtils; this.hybridUtils = hybridUtils;
} }

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.configuration.file.YamlConfiguration; import com.plotsquared.core.configuration.file.YamlConfiguration;
@ -44,7 +45,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.query.PlotQuery; import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.sql.SQLException; import java.sql.SQLException;
@ -68,8 +69,10 @@ public class DatabaseCommand extends SubCommand {
private final PlotListener plotListener; private final PlotListener plotListener;
private final YamlConfiguration worldConfiguration; private final YamlConfiguration worldConfiguration;
public DatabaseCommand(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher, @Inject public DatabaseCommand(@Nonnull final PlotAreaManager plotAreaManager,
@NotNull final PlotListener plotListener, @WorldConfig @NotNull final YamlConfiguration worldConfiguration) { @Nonnull final EventDispatcher eventDispatcher,
@Nonnull final PlotListener plotListener,
@WorldConfig @Nonnull final YamlConfiguration worldConfiguration) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.plotListener = plotListener; this.plotListener = plotListener;

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.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -38,7 +39,7 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDMapping;
import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityType;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
@ -52,9 +53,12 @@ import java.util.Map;
public class Debug extends SubCommand { public class Debug extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final RegionManager regionManager;
public Debug(@NotNull final PlotAreaManager plotAreaManager) { @Inject public Debug(@Nonnull final PlotAreaManager plotAreaManager,
@Nonnull final RegionManager regionManager) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.regionManager = regionManager;
} }
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
@ -70,8 +74,7 @@ public class Debug extends SubCommand {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
MainUtil.sendMessage(player, "Fetching loaded chunks..."); MainUtil.sendMessage(player, "Fetching loaded chunks...");
TaskManager.runTaskAsync(() -> MainUtil.sendMessage(player, TaskManager.runTaskAsync(() -> MainUtil.sendMessage(player,
"Loaded chunks: " + RegionManager.manager "Loaded chunks: " + this.regionManager.getChunkChunks(player.getLocation().getWorldName()).size() + "(" + (
.getChunkChunks(player.getLocation().getWorldName()).size() + "(" + (
System.currentTimeMillis() - start) + "ms) using thread: " + Thread System.currentTimeMillis() - start) + "ms) using thread: " + Thread
.currentThread().getName())); .currentThread().getName()));
return true; return true;

View File

@ -26,6 +26,7 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.io.Files; import com.google.common.io.Files;
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;
@ -62,8 +63,8 @@ import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import javax.script.Bindings; import javax.script.Bindings;
import javax.script.ScriptContext; import javax.script.ScriptContext;
@ -90,35 +91,39 @@ public class DebugExec extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final WorldEdit worldEdit; private final WorldEdit worldEdit;
private final GlobalBlockQueue blockQueue;
private final SchematicHandler schematicHandler;
private final EconHandler econHandler;
private final ChunkManager chunkManager;
private final WorldUtil worldUtil;
private final SetupUtils setupUtils;
private final HybridUtils hybridUtils;
private ScriptEngine engine; private ScriptEngine engine;
private Bindings scope; private Bindings scope;
public DebugExec(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher, @Inject public DebugExec(@Nonnull final PlotAreaManager plotAreaManager,
@Nullable final WorldEdit worldEdit) { @Nonnull final EventDispatcher eventDispatcher,
@Nullable final WorldEdit worldEdit,
@Nonnull final GlobalBlockQueue blockQueue,
@Nonnull final SchematicHandler schematicHandler,
@Nullable final EconHandler econHandler,
@Nonnull final ChunkManager chunkManager,
@Nonnull final WorldUtil worldUtil,
@Nonnull final SetupUtils setupUtils,
@Nonnull final HybridUtils hybridUtils) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.worldEdit = worldEdit; this.worldEdit = worldEdit;
this.blockQueue = blockQueue;
this.schematicHandler = schematicHandler;
this.econHandler = econHandler;
this.chunkManager = chunkManager;
this.worldUtil = worldUtil;
this.setupUtils = setupUtils;
this.hybridUtils = hybridUtils;
init(); init();
/*
try {
if (PlotSquared.get() != null) {
File file = new File(PlotSquared.imp().getDirectory(),
Settings.Paths.SCRIPTS + File.separator + "start.js");
if (file.exists()) {
init();
String script = StringMan.join(Files.readLines(new File(new File(
PlotSquared.imp().getDirectory() + File.separator
+ Settings.Paths.SCRIPTS), "start.js"), StandardCharsets.UTF_8),
System.getProperty("line.separator"));
this.scope.put("THIS", this);
this.scope.put("PlotPlayer", ConsolePlayer.getConsole());
this.engine.eval(script, this.scope);
}
}
} catch (IOException | ScriptException ignored) {
ignored.printStackTrace();
}
*/
} }
public ScriptEngine getEngine() { public ScriptEngine getEngine() {
@ -167,21 +172,21 @@ public class DebugExec extends SubCommand {
// Instances // Instances
this.scope.put("PS", PlotSquared.get()); this.scope.put("PS", PlotSquared.get());
this.scope.put("GlobalBlockQueue", GlobalBlockQueue.IMP); this.scope.put("GlobalBlockQueue", this.blockQueue);
this.scope.put("ExpireManager", ExpireManager.IMP); this.scope.put("ExpireManager", ExpireManager.IMP);
if (this.worldEdit != null) { if (this.worldEdit != null) {
this.scope.put("WEManager", new WEManager()); this.scope.put("WEManager", new WEManager());
} }
this.scope.put("TaskManager", TaskManager.IMP); this.scope.put("TaskManager", TaskManager.getImplementation());
this.scope.put("ConsolePlayer", ConsolePlayer.getConsole()); this.scope.put("ConsolePlayer", ConsolePlayer.getConsole());
this.scope.put("SchematicHandler", SchematicHandler.manager); this.scope.put("SchematicHandler", this.schematicHandler);
this.scope.put("ChunkManager", ChunkManager.manager); this.scope.put("ChunkManager", this.chunkManager);
this.scope.put("BlockManager", WorldUtil.IMP); this.scope.put("BlockManager", this.worldUtil);
this.scope.put("SetupUtils", SetupUtils.manager); this.scope.put("SetupUtils", this.setupUtils);
this.scope.put("EventUtil", this.eventDispatcher); this.scope.put("EventUtil", this.eventDispatcher);
this.scope.put("EconHandler", EconHandler.getEconHandler()); this.scope.put("EconHandler", this.econHandler);
this.scope.put("DBFunc", DBFunc.dbManager); this.scope.put("DBFunc", DBFunc.dbManager);
this.scope.put("HybridUtils", HybridUtils.manager); this.scope.put("HybridUtils", this.hybridUtils);
this.scope.put("IMP", PlotSquared.platform()); this.scope.put("IMP", PlotSquared.platform());
this.scope.put("MainCommand", MainCommand.getInstance()); this.scope.put("MainCommand", MainCommand.getInstance());
@ -213,7 +218,7 @@ public class DebugExec extends SubCommand {
return true; return true;
} }
MainUtil.sendMessage(player, "$1Starting task..."); MainUtil.sendMessage(player, "$1Starting task...");
HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() { this.hybridUtils.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
@Override public void run(PlotAnalysis value) { @Override public void run(PlotAnalysis value) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"$1Done: $2Use $3/plot debugexec analyze$2 for more information"); "$1Done: $2Use $3/plot debugexec analyze$2 for more information");
@ -279,10 +284,9 @@ public class DebugExec extends SubCommand {
} }
boolean result; boolean result;
if (HybridUtils.regions != null) { if (HybridUtils.regions != null) {
result = HybridUtils.manager result = this.hybridUtils.scheduleRoadUpdate(area, HybridUtils.regions, 0, new HashSet<>());
.scheduleRoadUpdate(area, HybridUtils.regions, 0, new HashSet<>());
} else { } else {
result = HybridUtils.manager.scheduleRoadUpdate(area, 0); result = this.hybridUtils.scheduleRoadUpdate(area, 0);
} }
if (!result) { if (!result) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,

View File

@ -26,6 +26,7 @@
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
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.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -36,7 +37,7 @@ import com.plotsquared.core.plot.world.SinglePlotAreaManager;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
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 javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.util.UUID; import java.util.UUID;
@ -50,10 +51,13 @@ import java.util.concurrent.CompletableFuture;
public class DebugImportWorlds extends Command { public class DebugImportWorlds extends Command {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final WorldUtil worldUtil;
public DebugImportWorlds(@NotNull final PlotAreaManager plotAreaManager) { @Inject public DebugImportWorlds(@Nonnull final PlotAreaManager plotAreaManager,
@Nonnull final WorldUtil worldUtil) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldUtil = worldUtil;
} }
@Override @Override
@ -75,7 +79,7 @@ public class DebugImportWorlds extends Command {
} }
for (File folder : container.listFiles()) { for (File folder : container.listFiles()) {
String name = folder.getName(); String name = folder.getName();
if (!WorldUtil.IMP.isWorld(name) && PlotId.fromStringOrNull(name) == null) { if (!this.worldUtil.isWorld(name) && PlotId.fromStringOrNull(name) == null) {
UUID uuid; UUID uuid;
if (name.length() > 16) { if (name.length() > 16) {
uuid = UUID.fromString(name); uuid = UUID.fromString(name);

View File

@ -27,6 +27,7 @@ package com.plotsquared.core.command;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.inject.Inject;
import com.plotsquared.core.PlotSquared; import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.inject.annotations.ConfigFile; import com.plotsquared.core.inject.annotations.ConfigFile;
import com.plotsquared.core.inject.annotations.WorldFile; import com.plotsquared.core.inject.annotations.WorldFile;
@ -37,8 +38,8 @@ import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.PremiumVerification; import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.net.IncendoPaster; import com.plotsquared.core.util.net.IncendoPaster;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import lombok.NonNull;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
@ -65,13 +66,13 @@ public class DebugPaste extends SubCommand {
private final File configFile; private final File configFile;
private final File worldfile; private final File worldfile;
public DebugPaste(@ConfigFile @NotNull final File configFile, @Inject public DebugPaste(@ConfigFile @Nonnull final File configFile,
@WorldFile @NotNull final File worldFile) { @WorldFile @Nonnull final File worldFile) {
this.configFile = configFile; this.configFile = configFile;
this.worldfile = worldFile; this.worldfile = worldFile;
} }
private static String readFile(@NonNull final File file) throws IOException { private static String readFile(@Nonnull final File file) throws IOException {
final List<String> lines; final List<String> lines;
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) { try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
lines = reader.lines().collect(Collectors.toList()); lines = reader.lines().collect(Collectors.toList());

View File

@ -35,7 +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 javax.annotation.Nonnull;
import java.util.Arrays; import java.util.Arrays;
@ -51,7 +51,7 @@ public class DebugRoadRegen extends SubCommand {
private final HybridUtils hybridUtils; private final HybridUtils hybridUtils;
@Inject public DebugRoadRegen(@NotNull final HybridUtils hybridUtils) { @Inject public DebugRoadRegen(@Nonnull final HybridUtils hybridUtils) {
this.hybridUtils = hybridUtils; this.hybridUtils = hybridUtils;
} }

View File

@ -39,8 +39,8 @@ import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.MainUtil; 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 javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
@CommandDeclaration(command = "delete", @CommandDeclaration(command = "delete",
@ -56,7 +56,7 @@ public class Delete extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler; private final EconHandler econHandler;
@Inject public Delete(@NotNull final EventDispatcher eventDispatcher, @Inject public Delete(@Nonnull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) { @Nullable final EconHandler econHandler) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler; this.econHandler = econHandler;

View File

@ -39,7 +39,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.gamemode.GameModes;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -58,9 +58,9 @@ public class Deny extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final WorldUtil worldUtil; private final WorldUtil worldUtil;
@Inject public Deny(@NotNull final PlotAreaManager plotAreaManager, @Inject public Deny(@Nonnull final PlotAreaManager plotAreaManager,
@NotNull final EventDispatcher eventDispatcher, @Nonnull final EventDispatcher eventDispatcher,
@NotNull final WorldUtil worldUtil) { @Nonnull final WorldUtil worldUtil) {
super(Argument.PlayerName); super(Argument.PlayerName);
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;

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;
@ -34,7 +35,7 @@ import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.flag.implementations.DescriptionFlag; import com.plotsquared.core.plot.flag.implementations.DescriptionFlag;
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 org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
@CommandDeclaration(command = "setdescription", @CommandDeclaration(command = "setdescription",
permission = "plots.set.desc", permission = "plots.set.desc",
@ -47,7 +48,7 @@ public class Desc extends SetCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
public Desc(@NotNull final EventDispatcher eventDispatcher) { @Inject public Desc(@Nonnull final EventDispatcher eventDispatcher) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
} }

View File

@ -25,8 +25,9 @@
*/ */
package com.plotsquared.core.command; package com.plotsquared.core.command;
import com.google.inject.Inject;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
@CommandDeclaration(command = "dislike", @CommandDeclaration(command = "dislike",
permission = "plots.dislike", permission = "plots.dislike",
@ -38,7 +39,7 @@ public class Dislike extends SubCommand {
private final Like like; private final Like like;
public Dislike(@NotNull final Like like) { @Inject public Dislike(@Nonnull final Like like) {
this.like = like; this.like = like;
} }

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.PlotDoneEvent; import com.plotsquared.core.events.PlotDoneEvent;
@ -42,7 +43,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
@CommandDeclaration(command = "done", @CommandDeclaration(command = "done",
aliases = {"submit"}, aliases = {"submit"},
@ -53,9 +54,12 @@ import org.jetbrains.annotations.NotNull;
public class Done extends SubCommand { public class Done extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final HybridUtils hybridUtils;
public Done(@NotNull final EventDispatcher eventDispatcher) { @Inject public Done(@Nonnull final EventDispatcher eventDispatcher,
@Nonnull final HybridUtils hybridUtils) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.hybridUtils = hybridUtils;
} }
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
@ -90,7 +94,7 @@ public class Done extends SubCommand {
finish(plot, player, true); finish(plot, player, true);
plot.removeRunning(); plot.removeRunning();
} else { } else {
HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() { this.hybridUtils.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
@Override public void run(PlotAnalysis value) { @Override public void run(PlotAnalysis value) {
plot.removeRunning(); plot.removeRunning();
boolean result = boolean result =

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;
@ -38,7 +39,7 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.net.URL; import java.net.URL;
@ -52,9 +53,15 @@ import java.net.URL;
public class Download extends SubCommand { public class Download extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final SchematicHandler schematicHandler;
private final WorldUtil worldUtil;
public Download(@NotNull final PlotAreaManager plotAreaManager) { @Inject public Download(@Nonnull final PlotAreaManager plotAreaManager,
@Nonnull final SchematicHandler schematicHandler,
@Nonnull final WorldUtil worldUtil) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.schematicHandler = schematicHandler;
this.worldUtil = worldUtil;
} }
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
@ -91,10 +98,10 @@ public class Download extends SubCommand {
return false; return false;
} }
plot.addRunning(); plot.addRunning();
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() { this.schematicHandler.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
@Override public void run(CompoundTag value) { @Override public void run(CompoundTag value) {
plot.removeRunning(); plot.removeRunning();
SchematicHandler.manager.upload(value, null, null, new RunnableVal<URL>() { schematicHandler.upload(value, null, null, new RunnableVal<URL>() {
@Override public void run(URL url) { @Override public void run(URL url) {
if (url == null) { if (url == null) {
MainUtil.sendMessage(player, Captions.GENERATING_LINK_FAILED); MainUtil.sendMessage(player, Captions.GENERATING_LINK_FAILED);
@ -113,8 +120,8 @@ public class Download extends SubCommand {
} }
MainUtil.sendMessage(player, Captions.MCA_FILE_SIZE); MainUtil.sendMessage(player, Captions.MCA_FILE_SIZE);
plot.addRunning(); plot.addRunning();
WorldUtil.IMP.saveWorld(world); this.worldUtil.saveWorld(world);
WorldUtil.IMP.upload(plot, null, null, new RunnableVal<URL>() { this.worldUtil.upload(plot, null, null, new RunnableVal<URL>() {
@Override public void run(URL url) { @Override public void run(URL url) {
plot.removeRunning(); plot.removeRunning();
if (url == null) { if (url == null) {

View File

@ -50,8 +50,8 @@ import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.helpmenu.HelpMenu; import com.plotsquared.core.util.helpmenu.HelpMenu;
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 javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
@ -87,7 +87,7 @@ public final class FlagCommand extends Command {
} }
private static boolean checkPermValue(@Nonnull final PlotPlayer player, private static boolean checkPermValue(@Nonnull final PlotPlayer player,
@NotNull final PlotFlag<?, ?> flag, @NotNull String key, @NotNull String value) { @Nonnull final PlotFlag<?, ?> flag, @Nonnull String key, @Nonnull String value) {
key = key.toLowerCase(); key = key.toLowerCase();
value = value.toLowerCase(); value = value.toLowerCase();
String perm = CaptionUtility String perm = CaptionUtility
@ -152,7 +152,7 @@ public final class FlagCommand extends Command {
* *
* @return true if the player is allowed to modify the flags at their current location * @return true if the player is allowed to modify the flags at their current location
*/ */
private static boolean checkRequirements(@NotNull final PlotPlayer player) { private static boolean checkRequirements(@Nonnull final PlotPlayer player) {
final Location location = player.getLocation(); final Location location = player.getLocation();
final Plot plot = location.getPlotAbs(); final Plot plot = location.getPlotAbs();
if (plot == null) { if (plot == null) {
@ -180,8 +180,8 @@ public final class FlagCommand extends Command {
* @param arg String to extract flag from * @param arg String to extract flag from
* @return The flag, if found, else null * @return The flag, if found, else null
*/ */
@Nullable private static PlotFlag<?, ?> getFlag(@NotNull final PlotPlayer player, @Nullable private static PlotFlag<?, ?> getFlag(@Nonnull final PlotPlayer player,
@NotNull final String arg) { @Nonnull final String arg) {
if (arg != null && arg.length() > 0) { if (arg != null && arg.length() > 0) {
final PlotFlag<?, ?> flag = GlobalFlagContainer.getInstance().getFlagFromString(arg); final PlotFlag<?, ?> flag = GlobalFlagContainer.getInstance().getFlagFromString(arg);
if (flag instanceof InternalFlag || flag == null) { if (flag instanceof InternalFlag || flag == 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.events.TeleportCause; import com.plotsquared.core.events.TeleportCause;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -40,7 +41,7 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.query.SortingStrategy; import com.plotsquared.core.util.query.SortingStrategy;
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 javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -58,13 +59,13 @@ public class HomeCommand extends Command {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
public HomeCommand(@NotNull final PlotAreaManager plotAreaManager) { @Inject public HomeCommand(@Nonnull final PlotAreaManager plotAreaManager) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
} }
private void home(@NotNull final PlotPlayer<?> player, private void home(@Nonnull final PlotPlayer<?> player,
@NotNull final PlotQuery query, final int page, @Nonnull final PlotQuery query, final int page,
final RunnableVal3<Command, Runnable, Runnable> confirm, final RunnableVal3<Command, Runnable, Runnable> confirm,
final RunnableVal2<Command, CommandResult> whenDone) { final RunnableVal2<Command, CommandResult> whenDone) {
List<Plot> plots = query.asList(); List<Plot> plots = query.asList();
@ -86,7 +87,7 @@ public class HomeCommand extends Command {
}), () -> whenDone.run(HomeCommand.this, CommandResult.FAILURE)); }), () -> whenDone.run(HomeCommand.this, CommandResult.FAILURE));
} }
@NotNull private PlotQuery query(@NotNull final PlotPlayer<?> player) { @Nonnull private PlotQuery query(@Nonnull final PlotPlayer<?> player) {
// everything plots need to have in common here // everything plots need to have in common here
return PlotQuery.newQuery().ownedBy(player); return PlotQuery.newQuery().ownedBy(player);
} }

View File

@ -37,7 +37,7 @@ import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -58,8 +58,8 @@ public class Kick extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final WorldUtil worldUtil; private final WorldUtil worldUtil;
@Inject public Kick(@NotNull final PlotAreaManager plotAreaManager, @Inject public Kick(@Nonnull final PlotAreaManager plotAreaManager,
@NotNull final WorldUtil worldUtil) { @Nonnull final WorldUtil worldUtil) {
super(Argument.PlayerName); super(Argument.PlayerName);
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldUtil = worldUtil; this.worldUtil = worldUtil;

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.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
@ -32,7 +33,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil; 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 javax.annotation.Nonnull;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -47,7 +48,7 @@ public class Leave extends Command {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
public Leave(@NotNull final EventDispatcher eventDispatcher) { @Inject public Leave(@Nonnull final EventDispatcher eventDispatcher) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
} }

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;
@ -39,7 +40,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil; 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 javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -57,7 +58,7 @@ public class Like extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
public Like(@NotNull final EventDispatcher eventDispatcher) { @Inject public Like(@Nonnull final EventDispatcher eventDispatcher) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
} }

View File

@ -49,8 +49,8 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.query.SortingStrategy; 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 javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -76,7 +76,7 @@ public class ListCmd extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final EconHandler econHandler; private final EconHandler econHandler;
@Inject public ListCmd(@NotNull final PlotAreaManager plotAreaManager, @Inject public ListCmd(@Nonnull final PlotAreaManager plotAreaManager,
@Nullable final EconHandler econHandler) { @Nullable final EconHandler econHandler) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.econHandler = econHandler; this.econHandler = econHandler;

View File

@ -39,7 +39,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
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 javax.annotation.Nonnull;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
@ -57,8 +57,8 @@ public class Load extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final SchematicHandler schematicHandler; private final SchematicHandler schematicHandler;
@Inject public Load(@NotNull final PlotAreaManager plotAreaManager, @Inject public Load(@Nonnull final PlotAreaManager plotAreaManager,
@NotNull final SchematicHandler schematicHandler) { @Nonnull final SchematicHandler schematicHandler) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.schematicHandler = schematicHandler; this.schematicHandler = schematicHandler;
} }

View File

@ -29,23 +29,17 @@ 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;
import com.plotsquared.core.configuration.file.YamlConfiguration;
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;
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.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.world.PlotAreaManager;
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.Permissions; import com.plotsquared.core.util.Permissions;
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 com.sk89q.worldedit.WorldEdit;
import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -152,12 +146,13 @@ public class MainCommand extends Command {
// Referenced commands // Referenced commands
instance.toggle = injector.getInstance(Toggle.class); instance.toggle = injector.getInstance(Toggle.class);
instance.help = injector.getInstance(Help.class); instance.help = new Help(instance);
} }
return instance; return instance;
} }
public static boolean onCommand(final PlotPlayer<?> player, String... args) { public static boolean onCommand(final PlotPlayer<?> player, String... args) {
final EconHandler econHandler = PlotSquared.platform().getEconHandler();
if (args.length >= 1 && args[0].contains(":")) { if (args.length >= 1 && args[0].contains(":")) {
String[] split2 = args[0].split(":"); String[] split2 = args[0].split(":");
if (split2.length == 2) { if (split2.length == 2) {
@ -179,14 +174,14 @@ public class MainCommand extends Command {
public void run(final Command cmd, final Runnable success, final Runnable failure) { public void run(final Command cmd, final Runnable success, final Runnable failure) {
if (cmd.hasConfirmation(player)) { if (cmd.hasConfirmation(player)) {
CmdConfirm.addPending(player, cmd.getUsage(), () -> { CmdConfirm.addPending(player, cmd.getUsage(), () -> {
if (EconHandler.getEconHandler() != null) { if (econHandler != null) {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null) { if (area != null) {
Expression<Double> priceEval = Expression<Double> priceEval =
area.getPrices().get(cmd.getFullId()); area.getPrices().get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != null if (price != null
&& EconHandler.getEconHandler().getMoney(player) < price) { && econHandler.getMoney(player) < price) {
if (failure != null) { if (failure != null) {
failure.run(); failure.run();
} }
@ -200,12 +195,12 @@ public class MainCommand extends Command {
}); });
return; return;
} }
if (EconHandler.getEconHandler() != null) { if (econHandler != null) {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null) { if (area != null) {
Expression<Double> priceEval = area.getPrices().get(cmd.getFullId()); Expression<Double> priceEval = area.getPrices().get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d && EconHandler.getEconHandler().getMoney(player) < price) { if (price != 0d && econHandler.getMoney(player) < price) {
if (failure != null) { if (failure != null) {
failure.run(); failure.run();
} }
@ -267,14 +262,14 @@ public class MainCommand extends Command {
if ("f".equals(args[0].substring(1))) { if ("f".equals(args[0].substring(1))) {
confirm = new RunnableVal3<Command, Runnable, Runnable>() { confirm = new RunnableVal3<Command, Runnable, Runnable>() {
@Override public void run(Command cmd, Runnable success, Runnable failure) { @Override public void run(Command cmd, Runnable success, Runnable failure) {
if (EconHandler.getEconHandler() != null) { if (PlotSquared.platform().getEconHandler() != null) {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
if (area != null) { if (area != null) {
Expression<Double> priceEval = Expression<Double> priceEval =
area.getPrices().get(cmd.getFullId()); area.getPrices().get(cmd.getFullId());
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d; Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
if (price != 0d if (price != 0d
&& EconHandler.getEconHandler().getMoney(player) < price) { && PlotSquared.platform().getEconHandler().getMoney(player) < price) {
if (failure != null) { if (failure != null) {
failure.run(); failure.run();
} }

View File

@ -42,8 +42,8 @@ import com.plotsquared.core.util.Expression;
import com.plotsquared.core.util.MainUtil; 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 javax.annotation.Nonnull;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
@ -63,7 +63,7 @@ public class Merge extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final EconHandler econHandler; private final EconHandler econHandler;
@Inject public Merge(@NotNull final EventDispatcher eventDispatcher, @Inject public Merge(@Nonnull final EventDispatcher eventDispatcher,
@Nullable final EconHandler econHandler) { @Nullable final EconHandler econHandler) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.econHandler = econHandler; this.econHandler = econHandler;

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.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -35,7 +36,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.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 javax.annotation.Nonnull;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -49,7 +50,7 @@ public class Move extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
public Move(@NotNull final PlotAreaManager plotAreaManager) { @Inject public Move(@Nonnull final PlotAreaManager plotAreaManager) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
} }

View File

@ -39,7 +39,7 @@ 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.plotsquared.core.util.InventoryUtil;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import org.jetbrains.annotations.Nullable; import javax.annotation.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;

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;
@ -37,7 +38,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil; 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 javax.annotation.Nonnull;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -56,7 +57,7 @@ public class Owner extends SetCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
public Owner(@NotNull final EventDispatcher eventDispatcher) { @Inject public Owner(@Nonnull final EventDispatcher eventDispatcher) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
} }

View File

@ -40,7 +40,7 @@ import com.plotsquared.core.util.task.TaskManager;
public class PluginCmd extends SubCommand { public class PluginCmd extends SubCommand {
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
TaskManager.IMP.taskAsync(() -> { TaskManager.getImplementation().taskAsync(() -> {
MainUtil.sendMessage(player, String.format( MainUtil.sendMessage(player, String.format(
"$2>> $1&l" + PlotSquared.platform().getPluginName() + " $2($1Version$2: $1%s$2)", "$2>> $1&l" + PlotSquared.platform().getPluginName() + " $2($1Version$2: $1%s$2)",
PlotSquared.get().getVersion())); PlotSquared.get().getVersion()));

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;
@ -37,7 +38,7 @@ import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -58,7 +59,8 @@ public class Purge extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final PlotListener plotListener; private final PlotListener plotListener;
public Purge(@NotNull final PlotAreaManager plotAreaManager, @NotNull final PlotListener plotListener) { @Inject public Purge(@Nonnull final PlotAreaManager plotAreaManager,
@Nonnull final PlotListener plotListener) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.plotListener = plotListener; this.plotListener = plotListener;
} }

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;
@ -38,11 +39,12 @@ import com.plotsquared.core.plot.PlotItemStack;
import com.plotsquared.core.plot.Rating; import com.plotsquared.core.plot.Rating;
import com.plotsquared.core.plot.flag.implementations.DoneFlag; import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.util.EventDispatcher; import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.InventoryUtil;
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;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -59,9 +61,12 @@ import java.util.UUID;
public class Rate extends SubCommand { public class Rate extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
private final InventoryUtil inventoryUtil;
public Rate(@NotNull final EventDispatcher eventDispatcher) { @Inject public Rate(@Nonnull final EventDispatcher eventDispatcher,
@Nonnull final InventoryUtil inventoryUtil) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
this.inventoryUtil = inventoryUtil;
} }
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) { @Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
@ -143,7 +148,7 @@ public class Rate extends SubCommand {
final MutableInt index = new MutableInt(0); final MutableInt index = new MutableInt(0);
final MutableInt rating = new MutableInt(0); final MutableInt rating = new MutableInt(0);
String title = Settings.Ratings.CATEGORIES.get(0); String title = Settings.Ratings.CATEGORIES.get(0);
PlotInventory inventory = new PlotInventory(player, 1, title) { PlotInventory inventory = new PlotInventory(inventoryUtil, player, 1, title) {
@Override public boolean onClick(int i) { @Override public boolean onClick(int i) {
rating.add((i + 1) * Math.pow(10, index.getValue())); rating.add((i + 1) * Math.pow(10, index.getValue()));
index.increment(); index.increment();

View File

@ -34,7 +34,7 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager; import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
@CommandDeclaration(command = "regenallroads", @CommandDeclaration(command = "regenallroads",
description = "Regenerate all roads in the map using the set road schematic", description = "Regenerate all roads in the map using the set road schematic",
@ -48,8 +48,8 @@ public class RegenAllRoads extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final HybridUtils hybridUtils; private final HybridUtils hybridUtils;
@Inject public RegenAllRoads(@NotNull final PlotAreaManager plotAreaManager, @Inject public RegenAllRoads(@Nonnull final PlotAreaManager plotAreaManager,
@NotNull final HybridUtils hybridUtils) { @Nonnull final HybridUtils hybridUtils) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.hybridUtils = hybridUtils; this.hybridUtils = hybridUtils;
} }

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;
@ -36,7 +37,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotAreaType; import com.plotsquared.core.plot.PlotAreaType;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -54,9 +55,9 @@ public class Reload extends SubCommand {
private final YamlConfiguration worldConfiguration; private final YamlConfiguration worldConfiguration;
private final File worldFile; private final File worldFile;
public Reload(@NotNull final PlotAreaManager plotAreaManager, @Inject public Reload(@Nonnull final PlotAreaManager plotAreaManager,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
@WorldFile @NotNull final File worldFile) { @WorldFile @Nonnull final File worldFile) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;
this.worldFile = worldFile; this.worldFile = worldFile;

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.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.location.Location; import com.plotsquared.core.location.Location;
@ -34,7 +35,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -52,7 +53,7 @@ public class Remove extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
public Remove(@NotNull final EventDispatcher eventDispatcher) { @Inject public Remove(@Nonnull final EventDispatcher eventDispatcher) {
super(Argument.PlayerName); super(Argument.PlayerName);
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
} }

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.location.Location; import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -37,7 +38,7 @@ import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
@ -51,9 +52,12 @@ import java.util.UUID;
public class Save extends SubCommand { public class Save extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final SchematicHandler schematicHandler;
public Save(@NotNull final PlotAreaManager plotAreaManager) { @Inject public Save(@Nonnull final PlotAreaManager plotAreaManager,
@Nonnull 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) {
@ -79,7 +83,7 @@ public class Save extends SubCommand {
return false; return false;
} }
plot.addRunning(); plot.addRunning();
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() { this.schematicHandler.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
@Override public void run(final CompoundTag value) { @Override public void run(final CompoundTag value) {
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
String time = (System.currentTimeMillis() / 1000) + ""; String time = (System.currentTimeMillis() / 1000) + "";
@ -92,7 +96,7 @@ public class Save extends SubCommand {
.replaceAll("[^A-Za-z0-9]", ""); .replaceAll("[^A-Za-z0-9]", "");
final String file = time + '_' + world1 + '_' + id.x + '_' + id.y + '_' + size; final String file = time + '_' + world1 + '_' + id.x + '_' + id.y + '_' + size;
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() { schematicHandler.upload(value, uuid, file, new RunnableVal<URL>() {
@Override public void run(URL url) { @Override public void run(URL url) {
plot.removeRunning(); plot.removeRunning();
if (url == null) { if (url == null) {

View File

@ -42,7 +42,7 @@ import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.StringMan; import com.plotsquared.core.util.StringMan;
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 javax.annotation.Nonnull;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
@ -61,8 +61,8 @@ public class SchematicCmd extends SubCommand {
private final SchematicHandler schematicHandler; private final SchematicHandler schematicHandler;
private boolean running = false; private boolean running = false;
@Inject public SchematicCmd(@NotNull final PlotAreaManager plotAreaManager, @Inject public SchematicCmd(@Nonnull final PlotAreaManager plotAreaManager,
@NotNull final SchematicHandler schematicHandler) { @Nonnull final SchematicHandler schematicHandler) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.schematicHandler = schematicHandler; this.schematicHandler = schematicHandler;
} }

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.CaptionUtility; import com.plotsquared.core.configuration.CaptionUtility;
import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.configuration.Captions;
@ -44,6 +45,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -67,8 +69,13 @@ public class Set extends SubCommand {
public static final String[] aliases = new String[] {"b", "w", "wf", "a", "h"}; public static final String[] aliases = new String[] {"b", "w", "wf", "a", "h"};
private final SetCommand component; private final SetCommand component;
private final WorldUtil worldUtil;
private final GlobalBlockQueue blockQueue;
public Set() { @Inject public Set(@Nonnull final WorldUtil worldUtil,
@Nonnull final GlobalBlockQueue blockQueue) {
this.worldUtil = worldUtil;
this.blockQueue = blockQueue;
this.component = new SetCommand() { this.component = new SetCommand() {
@Override public String getId() { @Override public String getId() {
@ -91,7 +98,7 @@ public class Set extends SubCommand {
final List<String> forbiddenTypes = new ArrayList<>(Settings.General.INVALID_BLOCKS); final List<String> forbiddenTypes = new ArrayList<>(Settings.General.INVALID_BLOCKS);
if (Settings.Enabled_Components.CHUNK_PROCESSOR) { if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
forbiddenTypes.addAll(WorldUtil.IMP.getTileEntityTypes().stream().map( forbiddenTypes.addAll(worldUtil.getTileEntityTypes().stream().map(
BlockType::getName).collect(Collectors.toList())); BlockType::getName).collect(Collectors.toList()));
} }
@ -154,7 +161,7 @@ public class Set extends SubCommand {
current.setComponent(component, pattern); current.setComponent(component, pattern);
} }
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT); MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
GlobalBlockQueue.IMP.addEmptyTask(plot::removeRunning); blockQueue.addEmptyTask(plot::removeRunning);
}); });
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.generator.GeneratorWrapper; import com.plotsquared.core.generator.GeneratorWrapper;
@ -33,6 +34,7 @@ import com.plotsquared.core.setup.SetupProcess;
import com.plotsquared.core.setup.SetupStep; import com.plotsquared.core.setup.SetupStep;
import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -48,6 +50,12 @@ import java.util.Map.Entry;
category = CommandCategory.ADMINISTRATION) category = CommandCategory.ADMINISTRATION)
public class Setup extends SubCommand { public class Setup extends SubCommand {
private final SetupUtils setupUtils;
@Inject public Setup(@Nonnull final SetupUtils setupUtils) {
this.setupUtils = setupUtils;
}
public void displayGenerators(PlotPlayer<?> player) { public void displayGenerators(PlotPlayer<?> player) {
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
message.append("&6What generator do you want?"); message.append("&6What generator do you want?");
@ -72,7 +80,7 @@ public class Setup extends SubCommand {
} }
process = new SetupProcess(); process = new SetupProcess();
player.setMeta("setup", process); player.setMeta("setup", process);
SetupUtils.manager.updateGenerators(); this.setupUtils.updateGenerators();
SetupStep step = process.getCurrentStep(); SetupStep step = process.getCurrentStep();
step.announce(player); step.announce(player);
displayGenerators(player); displayGenerators(player);

View File

@ -48,7 +48,7 @@ import com.plotsquared.core.util.MainUtil;
import com.plotsquared.core.util.SetupUtils; import com.plotsquared.core.util.SetupUtils;
import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.WorldUtil;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -73,12 +73,12 @@ public class Template extends SubCommand {
private final GlobalBlockQueue globalBlockQueue; private final GlobalBlockQueue globalBlockQueue;
private final WorldUtil worldUtil; private final WorldUtil worldUtil;
@Inject public Template(@NotNull final PlotAreaManager plotAreaManager, @Inject public Template(@Nonnull final PlotAreaManager plotAreaManager,
@WorldConfig @NotNull final YamlConfiguration worldConfiguration, @WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
@WorldFile @NotNull final File worldFile, @WorldFile @Nonnull final File worldFile,
@NotNull final SetupUtils setupUtils, @Nonnull final SetupUtils setupUtils,
@NotNull final GlobalBlockQueue globalBlockQueue, @Nonnull final GlobalBlockQueue globalBlockQueue,
@NotNull final WorldUtil worldUtil) { @Nonnull final WorldUtil worldUtil) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldConfiguration = worldConfiguration; this.worldConfiguration = worldConfiguration;
this.worldFile = worldFile; this.worldFile = worldFile;

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.location.Location; import com.plotsquared.core.location.Location;
@ -44,7 +45,7 @@ import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -60,9 +61,18 @@ import java.util.Set;
public class Trim extends SubCommand { public class Trim extends SubCommand {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final WorldUtil worldUtil;
private final GlobalBlockQueue blockQueue;
private final RegionManager regionManager;
public Trim(@NotNull final PlotAreaManager plotAreaManager) { @Inject public Trim(@Nonnull final PlotAreaManager plotAreaManager,
@Nonnull final WorldUtil worldUtil,
@Nonnull final GlobalBlockQueue blockQueue,
@Nonnull final RegionManager regionManager) {
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
this.worldUtil = worldUtil;
this.blockQueue = blockQueue;
this.regionManager = regionManager;
} }
private static volatile boolean TASK = false; private static volatile boolean TASK = false;
@ -84,7 +94,7 @@ public class Trim extends SubCommand {
if (ExpireManager.IMP != null) { if (ExpireManager.IMP != null) {
plots.removeAll(ExpireManager.IMP.getPendingExpired()); plots.removeAll(ExpireManager.IMP.getPendingExpired());
} }
result.value1 = new HashSet<>(RegionManager.manager.getChunkChunks(world)); result.value1 = new HashSet<>(PlotSquared.platform().getRegionManager().getChunkChunks(world));
result.value2 = new HashSet<>(); result.value2 = new HashSet<>();
MainUtil.sendMessage(null, " - MCA #: " + result.value1.size()); MainUtil.sendMessage(null, " - MCA #: " + result.value1.size());
MainUtil.sendMessage(null, " - CHUNKS: " + (result.value1.size() * 1024) + " (max)"); MainUtil.sendMessage(null, " - CHUNKS: " + (result.value1.size() * 1024) + " (max)");
@ -116,7 +126,7 @@ public class Trim extends SubCommand {
return false; return false;
} }
final String world = args[0]; final String world = args[0];
if (!WorldUtil.IMP.isWorld(world) || !this.plotAreaManager.hasPlotArea(world)) { if (!this.worldUtil.isWorld(world) || !this.plotAreaManager.hasPlotArea(world)) {
MainUtil.sendMessage(player, Captions.NOT_VALID_WORLD); MainUtil.sendMessage(player, Captions.NOT_VALID_WORLD);
return false; return false;
} }
@ -174,8 +184,7 @@ public class Trim extends SubCommand {
} }
} }
} }
final LocalBlockQueue queue = final LocalBlockQueue queue = blockQueue.getNewQueue(world, false);
GlobalBlockQueue.IMP.getNewQueue(world, false);
TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() { TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
queue.regenChunk(value.getX(), value.getZ()); queue.regenChunk(value.getX(), value.getZ());
@ -189,7 +198,7 @@ public class Trim extends SubCommand {
player.sendMessage("Trim done!"); player.sendMessage("Trim done!");
}; };
} }
RegionManager.manager.deleteRegionFiles(world, viable, regenTask); regionManager.deleteRegionFiles(world, viable, regenTask);
} }
}); });

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.database.DBFunc; import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
@ -35,7 +36,7 @@ import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.TabCompletions; import com.plotsquared.core.util.TabCompletions;
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 javax.annotation.Nonnull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@ -54,7 +55,7 @@ public class Trust extends Command {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
public Trust(@NotNull final EventDispatcher eventDispatcher) { @Inject public Trust(@Nonnull final EventDispatcher eventDispatcher) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
} }

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.PlotUnlinkEvent; import com.plotsquared.core.events.PlotUnlinkEvent;
import com.plotsquared.core.events.Result; import com.plotsquared.core.events.Result;
@ -36,7 +37,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 com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull;
@CommandDeclaration(command = "unlink", @CommandDeclaration(command = "unlink",
aliases = {"u", "unmerge"}, aliases = {"u", "unmerge"},
@ -49,7 +50,7 @@ public class Unlink extends SubCommand {
private final EventDispatcher eventDispatcher; private final EventDispatcher eventDispatcher;
public Unlink(@NotNull final EventDispatcher eventDispatcher) { @Inject public Unlink(@Nonnull final EventDispatcher eventDispatcher) {
this.eventDispatcher = eventDispatcher; this.eventDispatcher = eventDispatcher;
} }

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.TeleportCause; import com.plotsquared.core.events.TeleportCause;
@ -41,7 +42,7 @@ import com.plotsquared.core.util.query.PlotQuery;
import com.plotsquared.core.util.query.SortingStrategy; import com.plotsquared.core.util.query.SortingStrategy;
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 javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -62,17 +63,17 @@ public class Visit extends Command {
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
public Visit(@NotNull final PlotAreaManager plotAreaManager) { @Inject public Visit(@Nonnull final PlotAreaManager plotAreaManager) {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
this.plotAreaManager = plotAreaManager; this.plotAreaManager = plotAreaManager;
} }
private void visit(@NotNull final PlotPlayer player, @NotNull final PlotQuery query, final PlotArea sortByArea, private void visit(@Nonnull final PlotPlayer player, @Nonnull final PlotQuery query, final PlotArea sortByArea,
final RunnableVal3<Command, Runnable, Runnable> confirm, final RunnableVal2<Command, CommandResult> whenDone) { final RunnableVal3<Command, Runnable, Runnable> confirm, final RunnableVal2<Command, CommandResult> whenDone) {
this.visit(player, query, sortByArea, confirm, whenDone, 1); this.visit(player, query, sortByArea, confirm, whenDone, 1);
} }
private void visit(@NotNull final PlotPlayer player, @NotNull final PlotQuery query, final PlotArea sortByArea, private void visit(@Nonnull final PlotPlayer player, @Nonnull final PlotQuery query, final PlotArea sortByArea,
final RunnableVal3<Command, Runnable, Runnable> confirm, final RunnableVal2<Command, CommandResult> whenDone, int page) { final RunnableVal3<Command, Runnable, Runnable> confirm, final RunnableVal2<Command, CommandResult> whenDone, int page) {
// We get the query once, // We get the query once,
// then we get it another time further on // then we get it another time further on

Some files were not shown because too many files have changed in this diff Show More