mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Finalize DI stuff
This commit is contained in:
parent
25a58a5c46
commit
510ea56431
@ -101,13 +101,14 @@ shadowJar {
|
||||
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
|
||||
include(dependency("com.google.inject:guice: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("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
|
||||
relocate("org.bstats", "com.plotsquared.metrics")
|
||||
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
|
||||
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"
|
||||
destinationDirectory = file "../target"
|
||||
}
|
||||
|
@ -12,6 +12,12 @@
|
||||
<version>20200518</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
|
@ -61,6 +61,7 @@ import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.backup.BackupManager;
|
||||
import com.plotsquared.core.command.WE_Anywhere;
|
||||
import com.plotsquared.core.components.ComponentPresetManager;
|
||||
import com.plotsquared.core.configuration.CaptionUtility;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.ChatFormatter;
|
||||
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.listener.PlotListener;
|
||||
import com.plotsquared.core.listener.WESubscriber;
|
||||
import com.plotsquared.core.player.ConsolePlayer;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotAreaTerrainType;
|
||||
import com.plotsquared.core.plot.PlotAreaType;
|
||||
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.world.PlotAreaManager;
|
||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||
@ -111,7 +114,7 @@ import com.plotsquared.core.uuid.offline.OfflineModeUUIDService;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -129,8 +132,8 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
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
|
||||
// to generated instances and settings
|
||||
this.injector = Guice.createInjector(Stage.PRODUCTION, new PlotSquaredModule(),
|
||||
new BukkitModule(this), new BackupModule(), new WorldManagerModule());
|
||||
this.injector = Guice.createInjector(Stage.PRODUCTION, new WorldManagerModule(), new PlotSquaredModule(),
|
||||
new BukkitModule(this), new BackupModule());
|
||||
this.injector.injectMembers(this);
|
||||
|
||||
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 :(");
|
||||
}
|
||||
|
||||
// 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
|
||||
// Kill entities
|
||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS
|
||||
@ -302,8 +332,14 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
// Economy
|
||||
if (Settings.Enabled_Components.ECONOMY) {
|
||||
TaskManager.runTask(() -> {
|
||||
getInjector().getInstance(PermHandler.class).init();
|
||||
getInjector().getInstance(EconHandler.class).init();
|
||||
final PermHandler permHandler = getInjector().getInstance(PermHandler.class);
|
||||
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());
|
||||
}
|
||||
}, 100L, 100L);
|
||||
|
||||
PlotSquared.log(Captions.PREFIX + CaptionUtility
|
||||
.format(ConsolePlayer.getConsole(), Captions.ENABLED.getTranslated(),
|
||||
this.getPluginName()));
|
||||
}
|
||||
|
||||
private void unload() {
|
||||
@ -582,8 +622,8 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
}
|
||||
}
|
||||
|
||||
private void startUuidCaching(@NotNull final SQLiteUUIDService sqLiteUUIDService,
|
||||
@NotNull final CacheUUIDService cacheUUIDService) {
|
||||
private void startUuidCaching(@Nonnull final SQLiteUUIDService sqLiteUUIDService,
|
||||
@Nonnull final CacheUUIDService cacheUUIDService) {
|
||||
// Load all uuids into a big chunky boi queue
|
||||
final Queue<UUID> uuidQueue = new LinkedBlockingQueue<>();
|
||||
PlotSquared.get().forEachPlotRaw(plot -> {
|
||||
@ -658,7 +698,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
@Override public void log(@NonNull String message) {
|
||||
@Override public void log(@Nonnull String message) {
|
||||
try {
|
||||
message = Captions.color(message);
|
||||
if (!Settings.Chat.CONSOLE_COLOR) {
|
||||
@ -948,7 +988,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
}
|
||||
|
||||
@Override @Nullable
|
||||
public final ChunkGenerator getDefaultWorldGenerator(@NotNull final String worldName,
|
||||
public final ChunkGenerator getDefaultWorldGenerator(@Nonnull final String worldName,
|
||||
final String id) {
|
||||
final IndependentPlotGenerator result;
|
||||
if (id != null && id.equalsIgnoreCase("single")) {
|
||||
@ -962,7 +1002,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
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) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
@ -1011,11 +1051,11 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
"WorldEdit"));
|
||||
}
|
||||
|
||||
@Override public void unregister(@NonNull final PlotPlayer player) {
|
||||
@Override public void unregister(@Nonnull final PlotPlayer player) {
|
||||
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);
|
||||
if (world == null) {
|
||||
// create world
|
||||
@ -1098,7 +1138,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
}
|
||||
|
||||
@Override public GeneratorWrapper<?> wrapPlotGenerator(@Nullable final String world,
|
||||
@NonNull final IndependentPlotGenerator generator) {
|
||||
@Nonnull final IndependentPlotGenerator generator) {
|
||||
return new BukkitPlotGenerator(world, generator, this.plotAreaManager);
|
||||
}
|
||||
|
||||
@ -1112,7 +1152,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,12 @@
|
||||
package com.plotsquared.bukkit.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@Getter
|
||||
public abstract class EntityWrapper {
|
||||
@ -43,7 +44,7 @@ public abstract class EntityWrapper {
|
||||
public double y;
|
||||
public double z;
|
||||
|
||||
EntityWrapper(@NonNull final Entity entity) {
|
||||
EntityWrapper(@Nonnull final Entity entity) {
|
||||
this.entity = entity;
|
||||
this.type = entity.getType();
|
||||
|
||||
|
@ -25,17 +25,17 @@
|
||||
*/
|
||||
package com.plotsquared.bukkit.generator;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||
import com.plotsquared.core.location.ChunkWrapper;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -46,17 +46,18 @@ final class BlockStatePopulator extends BlockPopulator {
|
||||
|
||||
private LocalBlockQueue queue;
|
||||
|
||||
public BlockStatePopulator(@NotNull final IndependentPlotGenerator plotGenerator,
|
||||
@NotNull final PlotAreaManager plotAreaManager) {
|
||||
public BlockStatePopulator(@Nonnull final IndependentPlotGenerator plotGenerator,
|
||||
@Nonnull final PlotAreaManager plotAreaManager) {
|
||||
this.plotGenerator = plotGenerator;
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(@NotNull final World world, @NotNull final Random random,
|
||||
@NotNull final Chunk source) {
|
||||
public void populate(@Nonnull final World world, @Nonnull final Random random,
|
||||
@Nonnull final Chunk source) {
|
||||
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);
|
||||
if (area == null) {
|
||||
|
@ -29,7 +29,7 @@ import com.plotsquared.core.generator.AugmentedUtils;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -51,7 +51,7 @@ public class BukkitAugmentedGenerator extends BlockPopulator {
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -64,9 +64,9 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
|
||||
@Getter private final String levelName;
|
||||
|
||||
public BukkitPlotGenerator(@NotNull final String name,
|
||||
@NotNull final IndependentPlotGenerator generator,
|
||||
@NotNull final PlotAreaManager plotAreaManager) {
|
||||
public BukkitPlotGenerator(@Nonnull final String name,
|
||||
@Nonnull final IndependentPlotGenerator generator,
|
||||
@Nonnull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.levelName = name;
|
||||
this.plotGenerator = generator;
|
||||
@ -77,7 +77,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
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) {
|
||||
throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName()
|
||||
+ " is already a BukkitPlotGenerator!");
|
||||
@ -106,7 +106,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
return this.platformGenerator;
|
||||
}
|
||||
|
||||
@Override @NotNull public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
||||
@Override @Nonnull public List<BlockPopulator> getDefaultPopulators(@Nonnull World world) {
|
||||
try {
|
||||
if (!this.loaded) {
|
||||
String name = world.getName();
|
||||
@ -150,9 +150,9 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
return toAdd;
|
||||
}
|
||||
|
||||
@Override @NotNull
|
||||
public ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z,
|
||||
@NotNull BiomeGrid biome) {
|
||||
@Override @Nonnull
|
||||
public ChunkData generateChunkData(@Nonnull World world, @Nonnull Random random, int x, int z,
|
||||
@Nonnull BiomeGrid biome) {
|
||||
|
||||
GenChunk result = new GenChunk();
|
||||
if (this.getPlotGenerator() instanceof SingleWorldGenerator) {
|
||||
@ -216,7 +216,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.jetbrains.annotations.Range;
|
||||
|
||||
import java.util.Random;
|
||||
@ -74,21 +74,21 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
|
||||
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
|
||||
@Override
|
||||
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));
|
||||
}
|
||||
|
||||
//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));
|
||||
|
||||
}
|
||||
|
||||
@Override @NotNull public Biome getBiome(int x, int z) {
|
||||
@Override @Nonnull public Biome getBiome(int x, int z) {
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
@ -27,6 +27,7 @@ package com.plotsquared.bukkit.inject;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
import com.google.inject.util.Providers;
|
||||
import com.plotsquared.bukkit.BukkitPlatform;
|
||||
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
||||
import com.plotsquared.bukkit.queue.BukkitLocalQueue;
|
||||
@ -65,7 +66,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@RequiredArgsConstructor public class BukkitModule extends AbstractModule {
|
||||
|
||||
@ -77,7 +78,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
bind(PlotPlatform.class).toInstance(bukkitPlatform);
|
||||
bind(IndependentPlotGenerator.class).annotatedWith(DefaultGenerator.class).to(HybridGen.class);
|
||||
// Console actor
|
||||
@NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||
@Nonnull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||
WorldEditPlugin wePlugin = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
||||
bind(Actor.class).annotatedWith(ConsoleActor.class).toInstance(wePlugin.wrapCommandSender(console));
|
||||
bind(InventoryUtil.class).to(BukkitInventoryUtil.class);
|
||||
@ -88,8 +89,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
bind(ChunkManager.class).to(BukkitChunkManager.class);
|
||||
bind(RegionManager.class).to(BukkitRegionManager.class);
|
||||
bind(SchematicHandler.class).to(BukkitSchematicHandler.class);
|
||||
bind(PermHandler.class).to(BukkitPermHandler.class);
|
||||
bind(EconHandler.class).to(BukkitEconHandler.class);
|
||||
this.setupVault();
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
bind(PlotAreaManager.class).to(SinglePlotAreaManager.class);
|
||||
} else {
|
||||
@ -98,4 +98,25 @@ import org.jetbrains.annotations.NotNull;
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,21 +26,26 @@
|
||||
package com.plotsquared.bukkit.inject;
|
||||
|
||||
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.HyperverseWorldManager;
|
||||
import com.plotsquared.bukkit.managers.MultiverseWorldManager;
|
||||
import com.plotsquared.core.util.PlatformWorldManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class WorldManagerModule extends AbstractModule {
|
||||
|
||||
@Override protected void configure() {
|
||||
@Provides
|
||||
@Singleton
|
||||
PlatformWorldManager<World> provideWorldManager() {
|
||||
if (Bukkit.getPluginManager().getPlugin("Hyperverse") != null) {
|
||||
bind(PlatformWorldManager.class).to(HyperverseWorldManager.class);
|
||||
return new HyperverseWorldManager();
|
||||
} else if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) {
|
||||
bind(PlatformWorldManager.class).to(MultiverseWorldManager.class);
|
||||
return new MultiverseWorldManager();
|
||||
} else {
|
||||
bind(PlatformWorldManager.class).to(BukkitWorldManager.class);
|
||||
return new BukkitWorldManager();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
@ -70,7 +70,7 @@ public class ChunkListener implements Listener {
|
||||
private Chunk lastChunk;
|
||||
private boolean ignoreUnload = false;
|
||||
|
||||
@Inject public ChunkListener(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
@Inject public ChunkListener(@Nonnull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
||||
try {
|
||||
|
@ -53,7 +53,7 @@ import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -65,7 +65,7 @@ public class EntitySpawnListener implements Listener {
|
||||
private static String areaName = null;
|
||||
|
||||
public static void testNether(final Entity entity) {
|
||||
@NotNull World world = entity.getWorld();
|
||||
@Nonnull World world = entity.getWorld();
|
||||
if (world.getEnvironment() != World.Environment.NETHER
|
||||
&& world.getEnvironment() != World.Environment.THE_END) {
|
||||
return;
|
||||
@ -74,7 +74,7 @@ public class EntitySpawnListener implements Listener {
|
||||
}
|
||||
|
||||
public static void testCreate(final Entity entity) {
|
||||
@NotNull World world = entity.getWorld();
|
||||
@Nonnull World world = entity.getWorld();
|
||||
if (areaName == world.getName()) {
|
||||
} else {
|
||||
areaName = world.getName();
|
||||
@ -87,7 +87,7 @@ public class EntitySpawnListener implements Listener {
|
||||
}
|
||||
|
||||
public static void test(Entity entity) {
|
||||
@NotNull World world = entity.getWorld();
|
||||
@Nonnull World world = entity.getWorld();
|
||||
List<MetadataValue> meta = entity.getMetadata(KEY);
|
||||
if (meta.isEmpty()) {
|
||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world.getName())) {
|
||||
@ -167,7 +167,7 @@ public class EntitySpawnListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler public void onChunkLoad(ChunkLoadEvent event) {
|
||||
@NotNull Chunk chunk = event.getChunk();
|
||||
@Nonnull Chunk chunk = event.getChunk();
|
||||
for (final Entity entity : chunk.getEntities()) {
|
||||
testCreate(entity);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -76,7 +76,7 @@ public class PaperListener implements Listener {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private Chunk lastChunk;
|
||||
|
||||
@Inject public PaperListener(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
@Inject public PaperListener(@Nonnull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@ -247,11 +247,11 @@ import java.util.regex.Pattern;
|
||||
private PlayerMoveEvent moveTmp;
|
||||
private String internalVersion;
|
||||
|
||||
@Inject public PlayerEvents(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final WorldEdit worldEdit,
|
||||
@NotNull final WorldUtil worldUtil) {
|
||||
super(eventDispatcher, worldUtil);
|
||||
@Inject public PlayerEvents(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nonnull final WorldEdit worldEdit,
|
||||
@Nonnull final WorldUtil worldUtil) {
|
||||
super(eventDispatcher);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.worldEdit = worldEdit;
|
||||
|
@ -37,14 +37,14 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class WorldEvents implements Listener {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
@Inject public WorldEvents(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
@Inject public WorldEvents(@Nonnull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -51,7 +51,7 @@ import java.util.List;
|
||||
}
|
||||
|
||||
@Override @Nullable
|
||||
public World handleWorldCreation(@NotNull String worldName, @Nullable String generator) {
|
||||
public World handleWorldCreation(@Nonnull String worldName, @Nullable String generator) {
|
||||
this.setGenerator(worldName, generator);
|
||||
final WorldCreator wc = new WorldCreator(worldName);
|
||||
wc.environment(World.Environment.NORMAL);
|
||||
|
@ -27,8 +27,8 @@ package com.plotsquared.bukkit.managers;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import se.hyperver.hyperverse.Hyperverse;
|
||||
import se.hyperver.hyperverse.world.WorldConfiguration;
|
||||
import se.hyperver.hyperverse.world.WorldConfigurationBuilder;
|
||||
@ -42,7 +42,7 @@ import se.hyperver.hyperverse.world.WorldType;
|
||||
@Singleton public class HyperverseWorldManager extends BukkitWorldManager {
|
||||
|
||||
@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
|
||||
this.setGenerator(worldName, generator);
|
||||
// Create the world
|
||||
|
@ -28,8 +28,8 @@ package com.plotsquared.bukkit.managers;
|
||||
import com.google.inject.Singleton;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Multiverse specific manager that informs Multiverse of
|
||||
@ -38,7 +38,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
@Singleton public class MultiverseWorldManager extends BukkitWorldManager {
|
||||
|
||||
@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
|
||||
this.setGenerator(worldName, generator);
|
||||
// Then we send the console command
|
||||
|
@ -27,7 +27,7 @@ package com.plotsquared.bukkit.player;
|
||||
|
||||
import com.plotsquared.core.player.OfflinePlotPlayer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -45,7 +45,7 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@NotNull @Override public UUID getUUID() {
|
||||
@Nonnull @Override public UUID getUUID() {
|
||||
return this.player.getUniqueId();
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,8 @@ import org.bukkit.event.EventException;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
@ -82,18 +82,18 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
*
|
||||
* @param player Bukkit player instance
|
||||
*/
|
||||
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final Player player, @Nullable final EconHandler econHandler) {
|
||||
public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nonnull final Player player, @Nullable final EconHandler econHandler) {
|
||||
this(plotAreaManager, eventDispatcher, player, false, econHandler);
|
||||
}
|
||||
|
||||
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final Player player, final boolean offline, @Nullable final EconHandler econHandler) {
|
||||
public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nonnull final Player player, final boolean offline, @Nullable final EconHandler econHandler) {
|
||||
this(plotAreaManager, eventDispatcher, player, offline, true, econHandler);
|
||||
}
|
||||
|
||||
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final
|
||||
EventDispatcher eventDispatcher, @NotNull final Player player, final boolean offline,
|
||||
public BukkitPlayer(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final
|
||||
EventDispatcher eventDispatcher, @Nonnull final Player player, final boolean offline,
|
||||
final boolean realPlayer, @Nullable final EconHandler econHandler) {
|
||||
super(plotAreaManager, eventDispatcher, econHandler);
|
||||
this.player = player;
|
||||
@ -112,12 +112,12 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@NotNull @Override public Location getLocation() {
|
||||
@Nonnull @Override public Location getLocation() {
|
||||
final Location location = super.getLocation();
|
||||
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.FORCE_LOWERCASE) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" +
|
||||
@ -134,7 +134,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
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 from = player.getLocation();
|
||||
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
|
||||
@ -152,7 +152,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
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();
|
||||
for (final RegisteredListener listener : listeners) {
|
||||
if (listener.getPlugin().getName().equals(PlotSquared.platform().getPluginName())) {
|
||||
@ -248,7 +248,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
}
|
||||
|
||||
@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) {
|
||||
return;
|
||||
}
|
||||
@ -279,7 +279,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
return BukkitUtil.getLocationFull(this.player);
|
||||
}
|
||||
|
||||
@Override public void setWeather(@NotNull final PlotWeather weather) {
|
||||
@Override public void setWeather(@Nonnull final PlotWeather weather) {
|
||||
switch (weather) {
|
||||
case 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()) {
|
||||
case ADVENTURE:
|
||||
return ADVENTURE;
|
||||
@ -309,7 +309,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
}
|
||||
|
||||
@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)) {
|
||||
this.player.setGameMode(GameMode.ADVENTURE);
|
||||
} else if (CREATIVE.equals(gameMode)) {
|
||||
@ -337,7 +337,7 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
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) {
|
||||
// Let's just stop all the discs because why not?
|
||||
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) {
|
||||
case COMMAND:
|
||||
return PlayerTeleportEvent.TeleportCause.COMMAND;
|
||||
|
@ -28,13 +28,14 @@ package com.plotsquared.bukkit.player;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.EventDispatcher;
|
||||
import com.plotsquared.core.util.PlayerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -44,27 +45,31 @@ import java.util.UUID;
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final EconHandler econHandler;
|
||||
|
||||
@Inject public BukkitPlayerManager(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public BukkitPlayerManager(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nullable final EconHandler econHandler) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
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 {
|
||||
return getPlayer(object.getUniqueId());
|
||||
} 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);
|
||||
if (player == null || !player.isOnline()) {
|
||||
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) {
|
||||
@ -74,7 +79,7 @@ import java.util.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));
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@ import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.queue.BasicLocalBlockQueue;
|
||||
import com.plotsquared.core.util.BlockUtil;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
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.BlockState;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
@ -51,6 +49,7 @@ import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Consumer;
|
||||
@ -201,12 +200,12 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue {
|
||||
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());
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -135,7 +135,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
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
|
||||
.apply(Preconditions.checkNotNull(pattern, "Pattern may not be null"), x, y, z));
|
||||
}
|
||||
|
@ -31,14 +31,14 @@ import com.plotsquared.core.queue.LocalBlockQueue;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Schematic Handler.
|
||||
*/
|
||||
@Singleton public class BukkitSchematicHandler extends SchematicHandler {
|
||||
|
||||
@Inject public BukkitSchematicHandler(@NotNull final WorldUtil worldUtil) {
|
||||
@Inject public BukkitSchematicHandler(@Nonnull final WorldUtil worldUtil) {
|
||||
super(worldUtil);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ package com.plotsquared.bukkit.util;
|
||||
import com.google.inject.Singleton;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.listener.WEExtent;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||
import com.plotsquared.core.util.ChunkManager;
|
||||
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 bukkitWorld2 = new BukkitWorld(world2);
|
||||
|
||||
LocalBlockQueue queue1 = GlobalBlockQueue.IMP.getNewQueue(worldName1, false);
|
||||
LocalBlockQueue queue2 = GlobalBlockQueue.IMP.getNewQueue(worldName2, false);
|
||||
LocalBlockQueue queue1 = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName1, false);
|
||||
LocalBlockQueue queue2 = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName2, false);
|
||||
|
||||
for (int x = Math.max(r1.getMinimumPoint().getX(), sx);
|
||||
x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) {
|
||||
|
@ -36,7 +36,7 @@ import com.plotsquared.core.util.PermHandler;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Singleton public class BukkitEconHandler extends EconHandler {
|
||||
|
||||
|
@ -35,7 +35,6 @@ import com.plotsquared.core.location.PlotLoc;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||
import com.plotsquared.core.util.ChunkManager;
|
||||
@ -58,7 +57,7 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
@ -79,7 +78,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||
|
||||
@Singleton public class BukkitRegionManager extends RegionManager {
|
||||
|
||||
@Inject public BukkitRegionManager(@NotNull ChunkManager chunkManager) {
|
||||
@Inject public BukkitRegionManager(@Nonnull final ChunkManager chunkManager) {
|
||||
super(chunkManager);
|
||||
}
|
||||
|
||||
@ -212,7 +211,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||
assert oldWorld != null;
|
||||
final String newWorldName = newWorld.getName();
|
||||
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[]>() {
|
||||
@Override public void run(int[] value) {
|
||||
int bx = value[2];
|
||||
@ -243,7 +242,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||
}
|
||||
}
|
||||
queue.enqueue();
|
||||
GlobalBlockQueue.IMP.addEmptyTask(() -> {
|
||||
PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(() -> {
|
||||
//map.restoreBlocks(newWorld, 0, 0);
|
||||
map.restoreEntities(newWorld, relX, relZ);
|
||||
TaskManager.runTask(whenDone);
|
||||
@ -291,8 +290,8 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||
if (chunkObj == null) {
|
||||
return;
|
||||
}
|
||||
final LocalBlockQueue queue =
|
||||
GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||
final LocalBlockQueue queue = PlotSquared.platform().getGlobalBlockQueue()
|
||||
.getNewQueue(world, false);
|
||||
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
|
||||
AugmentedUtils.bypass(ignoreAugment,
|
||||
() -> 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));
|
||||
}
|
||||
}
|
||||
GlobalBlockQueue.IMP.addEmptyTask(() -> {
|
||||
PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(() -> {
|
||||
for (ContentMap map : maps) {
|
||||
map.restoreEntities(world1, 0, 0);
|
||||
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);
|
||||
Location pos2 = Location.at(world, region.getMaximumPoint().getX() + 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[]>() {
|
||||
@Override public void run(int[] value) {
|
||||
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);
|
||||
queue.refreshChunk(value[0], value[1]);
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -62,9 +62,9 @@ import java.util.Objects;
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
private final File worldFile;
|
||||
|
||||
@Inject public BukkitSetupUtils(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @NotNull final File worldFile) {
|
||||
@Inject public BukkitSetupUtils(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @Nonnull final File worldFile) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
this.worldFile = worldFile;
|
||||
|
@ -54,7 +54,7 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.NonNull;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
@ -96,8 +96,8 @@ import org.bukkit.entity.Snowman;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.entity.WaterMob;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -119,7 +119,7 @@ import java.util.stream.Stream;
|
||||
private static Player lastPlayer = null;
|
||||
private static BukkitPlayer lastPlotPlayer = null;
|
||||
|
||||
@Inject public BukkitUtil(@NotNull final RegionManager regionManager) {
|
||||
@Inject public BukkitUtil(@Nonnull final RegionManager regionManager) {
|
||||
super(regionManager);
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ import java.util.stream.Stream;
|
||||
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()) {
|
||||
return getPlayer(op.getPlayer());
|
||||
}
|
||||
@ -275,7 +275,7 @@ import java.util.stream.Stream;
|
||||
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) {
|
||||
return lastPlotPlayer;
|
||||
}
|
||||
@ -283,31 +283,31 @@ import java.util.stream.Stream;
|
||||
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()),
|
||||
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()),
|
||||
MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
|
||||
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(),
|
||||
location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
public static World getWorld(@NonNull final String string) {
|
||||
public static World getWorld(@Nonnull final String 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();
|
||||
}
|
||||
|
||||
public static List<Entity> getEntities(@NonNull final String worldName) {
|
||||
public static List<Entity> getEntities(@Nonnull final String worldName) {
|
||||
World world = getWorld(worldName);
|
||||
if (world != null) {
|
||||
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();
|
||||
String world = location.getWorld().getName();
|
||||
return Location.at(world, location.getBlockX(), location.getBlockY(),
|
||||
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();
|
||||
return Location.at(location.getWorld().getName(), MathMan.roundInt(location.getX()),
|
||||
MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
|
||||
location.getPitch());
|
||||
}
|
||||
|
||||
public static Material getMaterial(@NonNull final BlockState plotBlock) {
|
||||
public static Material getMaterial(@Nonnull final BlockState plotBlock) {
|
||||
return BukkitAdapter.adapt(plotBlock.getBlockType());
|
||||
}
|
||||
|
||||
@ -342,7 +342,7 @@ import java.util.stream.Stream;
|
||||
return mat1 == mat2;
|
||||
}
|
||||
|
||||
@Override public boolean isWorld(@NonNull final String worldName) {
|
||||
@Override public boolean isWorld(@Nonnull final String worldName) {
|
||||
return getWorld(worldName) != null;
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ import java.util.stream.Stream;
|
||||
}
|
||||
|
||||
@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) {
|
||||
ensureLoaded(world, x, z, chunk -> {
|
||||
final World bukkitWorld = getWorld(world);
|
||||
@ -406,7 +406,7 @@ import java.util.stream.Stream;
|
||||
}
|
||||
|
||||
@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 -> {
|
||||
final Block block = chunk.getWorld().getBlockAt(getLocation(location));
|
||||
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())
|
||||
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||
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();
|
||||
return Location.at(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(),
|
||||
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());
|
||||
if (world != null) {
|
||||
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);
|
||||
if (world != null) {
|
||||
world.save();
|
||||
@ -450,8 +450,8 @@ import java.util.stream.Stream;
|
||||
}
|
||||
|
||||
@Override @SuppressWarnings("deprecation")
|
||||
public void setSign(@NonNull final String worldName, final int x, final int y, final int z,
|
||||
@NonNull final String[] lines) {
|
||||
public void setSign(@Nonnull final String worldName, final int x, final int y, final int z,
|
||||
@Nonnull final String[] lines) {
|
||||
ensureLoaded(worldName, x, z, chunk -> {
|
||||
final World world = getWorld(worldName);
|
||||
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();
|
||||
}
|
||||
|
||||
@Override public String getClosestMatchingName(@NonNull final BlockState block) {
|
||||
@Override public String getClosestMatchingName(@Nonnull final BlockState block) {
|
||||
try {
|
||||
return getMaterial(block).name();
|
||||
} catch (Exception ignored) {
|
||||
@ -509,8 +509,8 @@ import java.util.stream.Stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiomes(@NonNull final String worldName, @NonNull final CuboidRegion region,
|
||||
@NonNull final BiomeType biomeType) {
|
||||
public void setBiomes(@Nonnull final String worldName, @Nonnull final CuboidRegion region,
|
||||
@Nonnull final BiomeType biomeType) {
|
||||
final World world = getWorld(worldName);
|
||||
if (world == null) {
|
||||
PlotSquared.log("An error occurred setting the biome because the world was null.");
|
||||
@ -532,7 +532,7 @@ import java.util.stream.Stream;
|
||||
}
|
||||
|
||||
@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 -> {
|
||||
final World world = getWorld(location.getWorldName());
|
||||
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 Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||
return BukkitAdapter.asBlockType(block.getType()).getDefaultState();
|
||||
|
@ -30,7 +30,7 @@ import com.plotsquared.core.location.World;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -40,7 +40,7 @@ import java.util.Map;
|
||||
|
||||
private final org.bukkit.World world;
|
||||
|
||||
private BukkitWorld(@NotNull final org.bukkit.World world) {
|
||||
private BukkitWorld(final org.bukkit.World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ import java.util.Map;
|
||||
* @param worldName World name
|
||||
* @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);
|
||||
if (bukkitWorld == null) {
|
||||
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
|
||||
* @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());
|
||||
if (bukkitWorld != null && bukkitWorld.getPlatformWorld().equals(world)) {
|
||||
return bukkitWorld;
|
||||
@ -74,11 +74,11 @@ import java.util.Map;
|
||||
return bukkitWorld;
|
||||
}
|
||||
|
||||
@NotNull @Override public org.bukkit.World getPlatformWorld() {
|
||||
@Override public org.bukkit.World getPlatformWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override @NotNull public String getName() {
|
||||
@Override @Nonnull public String getName() {
|
||||
return this.world.getName();
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ import java.util.ArrayList;
|
||||
public class SetGenCB {
|
||||
|
||||
public static void setGenerator(World world) throws Exception {
|
||||
SetupUtils.manager.updateGenerators();
|
||||
PlotSquared.platform().getSetupUtils().updateGenerators();
|
||||
PlotSquared.get().removePlotAreas(world.getName());
|
||||
ChunkGenerator gen = world.getGenerator();
|
||||
if (gen == null) {
|
||||
|
@ -30,7 +30,7 @@ import com.plotsquared.core.uuid.UUIDService;
|
||||
import net.luckperms.api.model.user.UserManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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 UUIDPlayerDB uuiddb = BungeePerms.getInstance().getPermissionsManager().getUUIDPlayerDB();
|
||||
for (final UUID uuid : uuids) {
|
||||
@ -68,7 +68,7 @@ public class BungeePermsUUIDService implements UUIDService {
|
||||
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 UUIDPlayerDB uuiddb = BungeePerms.getInstance().getPermissionsManager().getUUIDPlayerDB();
|
||||
for (final String username : usernames) {
|
||||
|
@ -29,7 +29,7 @@ import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import com.plotsquared.core.uuid.UUIDService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -47,11 +47,11 @@ public class EssentialsUUIDService implements UUIDService {
|
||||
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();
|
||||
}
|
||||
|
||||
@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());
|
||||
for (final String username : usernames) {
|
||||
try {
|
||||
|
@ -31,7 +31,7 @@ import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.model.user.UserManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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 UserManager userManager = this.luckPerms.getUserManager();
|
||||
for (final UUID uuid : uuids) {
|
||||
@ -67,7 +67,7 @@ public class LuckPermsUUIDService implements UUIDService {
|
||||
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 UserManager userManager = this.luckPerms.getUserManager();
|
||||
for (final String username : usernames) {
|
||||
|
@ -31,7 +31,7 @@ import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import com.plotsquared.core.uuid.UUIDService;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -43,7 +43,7 @@ import java.util.UUID;
|
||||
*/
|
||||
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()) {
|
||||
return Collections.emptyList(); // This is useless now
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class OfflinePlayerUUIDService implements UUIDService {
|
||||
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());
|
||||
for (final String username : usernames) {
|
||||
if (Settings.UUID.OFFLINE) {
|
||||
|
@ -29,7 +29,7 @@ import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import com.plotsquared.core.uuid.UUIDService;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -40,7 +40,7 @@ import java.util.UUID;
|
||||
*/
|
||||
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());
|
||||
for (final UUID uuid : uuids) {
|
||||
final PlayerProfile playerProfile = Bukkit.createProfile(uuid);
|
||||
@ -51,7 +51,7 @@ public class PaperUUIDService implements UUIDService {
|
||||
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());
|
||||
for (final String username : usernames) {
|
||||
final PlayerProfile playerProfile = Bukkit.createProfile(username);
|
||||
|
@ -30,7 +30,7 @@ import com.plotsquared.core.database.SQLite;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import com.plotsquared.core.uuid.UUIDService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.sql.Connection;
|
||||
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());
|
||||
try (final PreparedStatement statement = getConnection()
|
||||
.prepareStatement("SELECT `username` FROM `usercache` WHERE `uuid` = ?")) {
|
||||
@ -90,7 +90,7 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
|
||||
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());
|
||||
try (final PreparedStatement statement = getConnection()
|
||||
.prepareStatement("SELECT `uuid` FROM `usercache` WHERE `username` = ?")) {
|
||||
@ -127,7 +127,7 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping
|
||||
*
|
||||
* @return All read mappings
|
||||
*/
|
||||
@NotNull public List<UUIDMapping> getAll() {
|
||||
@Nonnull public List<UUIDMapping> getAll() {
|
||||
final List<UUIDMapping> mappings = new LinkedList<>();
|
||||
try (final PreparedStatement statement = getConnection().prepareStatement("SELECT * FROM `usercache`")) {
|
||||
try (final ResultSet resultSet = statement.executeQuery()) {
|
||||
|
@ -33,7 +33,7 @@ import com.plotsquared.core.uuid.UUIDService;
|
||||
import com.sk89q.squirrelid.Profile;
|
||||
import com.sk89q.squirrelid.resolver.HttpRepositoryService;
|
||||
import com.sk89q.squirrelid.resolver.ProfileService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@ -64,7 +64,7 @@ public class SquirrelIdUUIDService implements UUIDService {
|
||||
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());
|
||||
this.rateLimiter.acquire(uuids.size());
|
||||
try {
|
||||
@ -96,7 +96,7 @@ public class SquirrelIdUUIDService implements UUIDService {
|
||||
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());
|
||||
this.rateLimiter.acquire(usernames.size());
|
||||
try {
|
||||
|
@ -16,10 +16,10 @@ dependencies {
|
||||
annotationProcessor("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:annotations:19.0.0")
|
||||
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
|
||||
compile("com.google.inject:guice: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
|
||||
|
42
Core/pom.xml
42
Core/pom.xml
@ -12,18 +12,36 @@
|
||||
<version>20200518</version>
|
||||
<scope>compile</scope>
|
||||
</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>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>19.0.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-core</artifactId>
|
||||
@ -98,18 +116,6 @@
|
||||
<version>1.7.0-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</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>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@ -36,14 +36,16 @@ import com.plotsquared.core.location.World;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||
import com.plotsquared.core.util.ChatManager;
|
||||
import com.plotsquared.core.util.ChunkManager;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.PlatformWorldManager;
|
||||
import com.plotsquared.core.util.PlayerManager;
|
||||
import com.plotsquared.core.util.RegionManager;
|
||||
import com.plotsquared.core.util.SetupUtils;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.plotsquared.core.util.logger.ILogger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@ -153,7 +155,7 @@ public interface PlotPlatform<P> extends ILogger {
|
||||
*
|
||||
* @return Default implementation generator
|
||||
*/
|
||||
@NotNull default IndependentPlotGenerator getDefaultGenerator() {
|
||||
@Nonnull default IndependentPlotGenerator getDefaultGenerator() {
|
||||
return getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
|
||||
}
|
||||
|
||||
@ -164,7 +166,7 @@ public interface PlotPlatform<P> extends ILogger {
|
||||
*
|
||||
* @return Backup manager
|
||||
*/
|
||||
@NotNull default BackupManager getBackupManager() {
|
||||
@Nonnull default BackupManager getBackupManager() {
|
||||
return getInjector().getInstance(BackupManager.class);
|
||||
}
|
||||
|
||||
@ -173,7 +175,7 @@ public interface PlotPlatform<P> extends ILogger {
|
||||
*
|
||||
* @return World manager
|
||||
*/
|
||||
@NotNull default PlatformWorldManager<?> getWorldManager() {
|
||||
@Nonnull default PlatformWorldManager<?> getWorldManager() {
|
||||
return getInjector().getInstance(PlatformWorldManager.class);
|
||||
}
|
||||
|
||||
@ -182,7 +184,7 @@ public interface PlotPlatform<P> extends ILogger {
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -192,21 +194,21 @@ public interface PlotPlatform<P> extends ILogger {
|
||||
* @param worldName World name
|
||||
* @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
|
||||
*
|
||||
* @return Injector instance
|
||||
*/
|
||||
@NotNull Injector getInjector();
|
||||
@Nonnull Injector getInjector();
|
||||
|
||||
/**
|
||||
* Get the world utility implementation
|
||||
*
|
||||
* @return World utility
|
||||
*/
|
||||
@NotNull default WorldUtil getWorldUtil() {
|
||||
@Nonnull default WorldUtil getWorldUtil() {
|
||||
return getInjector().getInstance(WorldUtil.class);
|
||||
}
|
||||
|
||||
@ -215,7 +217,7 @@ public interface PlotPlatform<P> extends ILogger {
|
||||
*
|
||||
* @return Global block queue implementation
|
||||
*/
|
||||
@NotNull default GlobalBlockQueue getGlobalBlockQueue() {
|
||||
@Nonnull default GlobalBlockQueue getGlobalBlockQueue() {
|
||||
return getInjector().getInstance(GlobalBlockQueue.class);
|
||||
}
|
||||
|
||||
@ -224,7 +226,7 @@ public interface PlotPlatform<P> extends ILogger {
|
||||
*
|
||||
* @return Hybrid utils
|
||||
*/
|
||||
@NotNull default HybridUtils getHybridUtils() {
|
||||
@Nonnull default HybridUtils getHybridUtils() {
|
||||
return getInjector().getInstance(HybridUtils.class);
|
||||
}
|
||||
|
||||
@ -233,17 +235,35 @@ public interface PlotPlatform<P> extends ILogger {
|
||||
*
|
||||
* @return Setup utils
|
||||
*/
|
||||
@NotNull default SetupUtils getSetupUtils() {
|
||||
@Nonnull default SetupUtils getSetupUtils() {
|
||||
return getInjector().getInstance(SetupUtils.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link EconHandler} implementation for the platform
|
||||
*
|
||||
* *
|
||||
* @return Econ handler
|
||||
*/
|
||||
@NotNull default EconHandler getEconHandler() {
|
||||
@Nullable default EconHandler getEconHandler() {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
package com.plotsquared.core;
|
||||
|
||||
import com.plotsquared.core.configuration.Caption;
|
||||
import com.plotsquared.core.configuration.CaptionUtility;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||
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.listener.PlotListener;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.ConsolePlayer;
|
||||
import com.plotsquared.core.plot.BlockBucket;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
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.PlotId;
|
||||
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.ExpiryTask;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||
import com.plotsquared.core.util.ChatManager;
|
||||
import com.plotsquared.core.util.EventDispatcher;
|
||||
import com.plotsquared.core.util.LegacyConverter;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
@ -77,9 +73,9 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -150,7 +146,6 @@ public class PlotSquared {
|
||||
// Files and configuration
|
||||
@Getter private File jarFile = null; // This file
|
||||
private File storageFile;
|
||||
@Getter private PlotAreaManager plotAreaManager;
|
||||
@Getter private EventDispatcher eventDispatcher;
|
||||
@Getter private PlotListener plotListener;
|
||||
|
||||
@ -195,6 +190,7 @@ public class PlotSquared {
|
||||
if (!setupConfigs()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.translationFile = MainUtil.getFile(this.platform.getDirectory(),
|
||||
Settings.Paths.TRANSLATIONS + File.separator + this.platform.getPluginName()
|
||||
+ ".use_THIS.yml");
|
||||
@ -207,29 +203,6 @@ public class PlotSquared {
|
||||
// Create plot listener
|
||||
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
|
||||
copyFile("addplots.js", Settings.Paths.SCRIPTS);
|
||||
copyFile("addsigns.js", Settings.Paths.SCRIPTS);
|
||||
@ -253,10 +226,15 @@ public class PlotSquared {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
PlotSquared.log(Captions.PREFIX + CaptionUtility
|
||||
.format(ConsolePlayer.getConsole(), Captions.ENABLED.getTranslated(),
|
||||
this.platform.getPluginName()));
|
||||
/**
|
||||
* Get the platform specific {@link PlotAreaManager} instance
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@NotNull public static PlotPlatform<?> platform() {
|
||||
@Nonnull public static PlotPlatform<?> platform() {
|
||||
if (instance != null && instance.platform != null) {
|
||||
return instance.platform;
|
||||
}
|
||||
@ -315,12 +293,12 @@ public class PlotSquared {
|
||||
}
|
||||
}
|
||||
|
||||
private void startExpiryTasks() {
|
||||
public void startExpiryTasks() {
|
||||
if (Settings.Enabled_Components.PLOT_EXPIRY) {
|
||||
ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
|
||||
ExpireManager.IMP.runAutomatedTask();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -412,7 +390,7 @@ public class PlotSquared {
|
||||
cluster.setArea(plotArea);
|
||||
}
|
||||
}
|
||||
plotAreaManager.addPlotArea(plotArea);
|
||||
getPlotAreaManager().addPlotArea(plotArea);
|
||||
plotArea.setupBorder();
|
||||
if (!Settings.Enabled_Components.PERSISTENT_ROAD_REGEN) {
|
||||
return;
|
||||
@ -459,11 +437,11 @@ public class PlotSquared {
|
||||
* @param area the {@code PlotArea} to remove
|
||||
*/
|
||||
public void removePlotArea(PlotArea area) {
|
||||
plotAreaManager.removePlotArea(area);
|
||||
getPlotAreaManager().removePlotArea(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)) {
|
||||
if (area.getWorldName().equals(world)) {
|
||||
removePlotArea(area);
|
||||
@ -486,7 +464,7 @@ public class PlotSquared {
|
||||
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<>();
|
||||
for (final PlotArea area : this.getPlotAreaManager().getPlotAreasSet(world)) {
|
||||
set.addAll(area.getClusters());
|
||||
@ -695,13 +673,13 @@ public class PlotSquared {
|
||||
// group by world
|
||||
// sort each
|
||||
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) {
|
||||
for (PlotArea area : plotAreaManager.getAllPlotAreas()) {
|
||||
for (PlotArea area : getPlotAreaManager().getAllPlotAreas()) {
|
||||
map.put(area, area.getPlots());
|
||||
}
|
||||
} else {
|
||||
for (PlotArea area : plotAreaManager.getAllPlotAreas()) {
|
||||
for (PlotArea area : getPlotAreaManager().getAllPlotAreas()) {
|
||||
map.put(area, new ArrayList<>(0));
|
||||
}
|
||||
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) -> {
|
||||
if (priorityArea != null) {
|
||||
if (a.equals(priorityArea)) {
|
||||
@ -749,7 +727,7 @@ public class PlotSquared {
|
||||
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) {
|
||||
this.plots_tmp = new HashMap<>();
|
||||
}
|
||||
@ -816,7 +794,7 @@ public class PlotSquared {
|
||||
if (world.equals("CheckingPlotSquaredGenerator")) {
|
||||
return;
|
||||
}
|
||||
this.plotAreaManager.addWorld(world);
|
||||
this.getPlotAreaManager().addWorld(world);
|
||||
Set<String> worlds;
|
||||
if (this.worldConfiguration.contains("worlds")) {
|
||||
worlds = this.worldConfiguration.getConfigurationSection("worlds").getKeys(false);
|
||||
@ -832,7 +810,7 @@ public class PlotSquared {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
@ -866,7 +844,7 @@ public class PlotSquared {
|
||||
.log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + plotGenerator);
|
||||
PlotSquared.log(Captions.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
||||
PlotSquared.log(
|
||||
Captions.PREFIX + "&3 - plotAreaManager: &7" + plotManager.getClass().getName());
|
||||
Captions.PREFIX + "&3 - getPlotAreaManager(): &7" + plotManager.getClass().getName());
|
||||
if (!this.worldConfiguration.contains(path)) {
|
||||
this.worldConfiguration.createSection(path);
|
||||
worldSection = this.worldConfiguration.getConfigurationSection(path);
|
||||
@ -887,7 +865,7 @@ public class PlotSquared {
|
||||
}
|
||||
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
|
||||
if (areasSection == null) {
|
||||
if (plotAreaManager.getPlotAreas(world, null).length != 0) {
|
||||
if (getPlotAreaManager().getPlotAreas(world, null).length != 0) {
|
||||
debug("World possibly already loaded: " + world);
|
||||
return;
|
||||
}
|
||||
@ -954,7 +932,7 @@ public class PlotSquared {
|
||||
PlotSquared
|
||||
.log(Captions.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + areaGen);
|
||||
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.augment(pa);
|
||||
addPlotArea(pa);
|
||||
@ -1314,8 +1292,8 @@ public class PlotSquared {
|
||||
}
|
||||
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, this.eventDispatcher, this.plotListener, this.worldConfiguration);
|
||||
this.plots_tmp = DBFunc.getPlots();
|
||||
if (plotAreaManager instanceof SinglePlotAreaManager) {
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) plotAreaManager).getArea();
|
||||
if (getPlotAreaManager() instanceof SinglePlotAreaManager) {
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) getPlotAreaManager()).getArea();
|
||||
addPlotArea(area);
|
||||
ConfigurationSection section = worldConfiguration.getConfigurationSection("worlds.*");
|
||||
if (section == null) {
|
||||
@ -1556,7 +1534,7 @@ public class PlotSquared {
|
||||
}
|
||||
|
||||
public void forEachPlotRaw(Consumer<Plot> consumer) {
|
||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||
for (final PlotArea area : this.getPlotAreaManager().getAllPlotAreas()) {
|
||||
area.getPlots().forEach(consumer);
|
||||
}
|
||||
if (this.plots_tmp != null) {
|
||||
@ -1573,10 +1551,10 @@ public class PlotSquared {
|
||||
* @param chunkCoordinates Chunk coordinates
|
||||
* @return True if the chunk uses non-standard generation, false if not
|
||||
*/
|
||||
public boolean isNonStandardGeneration(@NotNull final String world,
|
||||
@NotNull final BlockVector2 chunkCoordinates) {
|
||||
public boolean isNonStandardGeneration(@Nonnull final String world,
|
||||
@Nonnull final BlockVector2 chunkCoordinates) {
|
||||
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) {
|
||||
return true;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ package com.plotsquared.core.backup;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
@ -28,8 +28,8 @@ package com.plotsquared.core.backup;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
@ -45,7 +45,7 @@ public interface BackupManager {
|
||||
* @param plot Plot to perform the automatic backup on
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ public interface BackupManager {
|
||||
* @param plot Plot to get the backup profile for
|
||||
* @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,
|
||||
@ -67,14 +67,14 @@ public interface BackupManager {
|
||||
* @param plot Plot to perform the automatic backup on
|
||||
* @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
|
||||
*
|
||||
* @return Backup directory path
|
||||
*/
|
||||
@NotNull Path getBackupPath();
|
||||
@Nonnull Path getBackupPath();
|
||||
|
||||
/**
|
||||
* Get the maximum amount of backups that may be stored for
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.backup;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
@ -38,7 +38,7 @@ public interface BackupProfile {
|
||||
*
|
||||
* @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
|
||||
@ -51,7 +51,7 @@ public interface BackupProfile {
|
||||
*
|
||||
* @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
|
||||
@ -59,7 +59,7 @@ public interface BackupProfile {
|
||||
*
|
||||
* @return Future that completes with the created backup.
|
||||
*/
|
||||
@NotNull CompletableFuture<Backup> createBackup();
|
||||
@Nonnull CompletableFuture<Backup> createBackup();
|
||||
|
||||
/**
|
||||
* Restore a backup
|
||||
@ -67,6 +67,6 @@ public interface BackupProfile {
|
||||
* @param backup Backup to restore
|
||||
* @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);
|
||||
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ import com.google.inject.Singleton;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
@ -40,16 +40,16 @@ import java.util.Objects;
|
||||
*/
|
||||
@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();
|
||||
}
|
||||
|
||||
@Override public void automaticBackup(@Nullable PlotPlayer plotPlayer,
|
||||
@NotNull Plot plot, @NotNull Runnable whenDone) {
|
||||
@Nonnull Plot plot, @Nonnull Runnable whenDone) {
|
||||
whenDone.run();
|
||||
}
|
||||
|
||||
@Override @NotNull public Path getBackupPath() {
|
||||
@Override @Nonnull public Path getBackupPath() {
|
||||
return Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath();
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.backup;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
@ -39,22 +39,22 @@ import java.util.concurrent.CompletableFuture;
|
||||
*/
|
||||
public class NullBackupProfile implements BackupProfile {
|
||||
|
||||
@Override @NotNull public CompletableFuture<List<Backup>> listBackups() {
|
||||
@Override @Nonnull public CompletableFuture<List<Backup>> listBackups() {
|
||||
return CompletableFuture.completedFuture(Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override public void destroy(){
|
||||
}
|
||||
|
||||
@Override @NotNull public Path getBackupDirectory() {
|
||||
@Override @Nonnull public Path getBackupDirectory() {
|
||||
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");
|
||||
}
|
||||
|
||||
@Override @NotNull public CompletableFuture<Void> restoreBackup(@NotNull final Backup backup) {
|
||||
@Override @Nonnull public CompletableFuture<Void> restoreBackup(@Nonnull final Backup backup) {
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ import com.plotsquared.core.plot.schematic.Schematic;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@ -59,8 +59,8 @@ public class PlayerBackupProfile implements BackupProfile {
|
||||
private final BackupManager backupManager;
|
||||
private final SchematicHandler schematicHandler;
|
||||
|
||||
@Inject public PlayerBackupProfile(@Assisted @NotNull final UUID owner, @Assisted @NotNull final Plot plot,
|
||||
@NotNull final BackupManager backupManager, @NotNull final SchematicHandler schematicHandler) {
|
||||
@Inject public PlayerBackupProfile(@Assisted @Nonnull final UUID owner, @Assisted @Nonnull final Plot plot,
|
||||
@Nonnull final BackupManager backupManager, @Nonnull final SchematicHandler schematicHandler) {
|
||||
this.owner = owner;
|
||||
this.plot = plot;
|
||||
this.backupManager = backupManager;
|
||||
@ -70,12 +70,12 @@ public class PlayerBackupProfile implements BackupProfile {
|
||||
private volatile List<Backup> backupCache;
|
||||
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();
|
||||
return name.endsWith(".schem") || name.endsWith(".schematic");
|
||||
}
|
||||
|
||||
@Override @NotNull public CompletableFuture<List<Backup>> listBackups() {
|
||||
@Override @Nonnull public CompletableFuture<List<Backup>> listBackups() {
|
||||
synchronized (this.backupLock) {
|
||||
if (this.backupCache != null) {
|
||||
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")),
|
||||
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;
|
||||
try {
|
||||
if (!Files.exists(parent)) {
|
||||
@ -142,7 +142,7 @@ public class PlayerBackupProfile implements BackupProfile {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override @NotNull public CompletableFuture<Backup> createBackup() {
|
||||
@Override @Nonnull public CompletableFuture<Backup> createBackup() {
|
||||
final CompletableFuture<Backup> future = new CompletableFuture<>();
|
||||
this.listBackups().thenAcceptAsync(backups -> {
|
||||
synchronized (this.backupLock) {
|
||||
@ -162,7 +162,7 @@ public class PlayerBackupProfile implements BackupProfile {
|
||||
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<>();
|
||||
if (backup.getFile() == null || !Files.exists(backup.getFile())) {
|
||||
future.completeExceptionally(new IllegalArgumentException("The specific backup does not exist"));
|
||||
|
@ -39,8 +39,8 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -60,7 +60,7 @@ import java.util.concurrent.TimeUnit;
|
||||
.expireAfterAccess(3, TimeUnit.MINUTES).build();
|
||||
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.backupPath = Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath().resolve("backups");
|
||||
if (!Files.exists(backupPath)) {
|
||||
@ -70,7 +70,7 @@ import java.util.concurrent.TimeUnit;
|
||||
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()) {
|
||||
try {
|
||||
return backupProfileCache.get(new PlotCacheKey(plot), () -> this.playerBackupProfileFactory.create(plot.getOwnerAbs(), plot));
|
||||
@ -83,7 +83,7 @@ import java.util.concurrent.TimeUnit;
|
||||
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;
|
||||
if (!this.shouldAutomaticallyBackup() || (profile = getProfile(plot)) instanceof NullBackupProfile) {
|
||||
whenDone.run();
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.database.DBFunc;
|
||||
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.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -54,7 +55,7 @@ public class Add extends Command {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public Add(@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public Add(@Nonnull final EventDispatcher eventDispatcher) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -100,13 +100,13 @@ public class Area extends SubCommand {
|
||||
private final WorldUtil worldUtil;
|
||||
private final RegionManager regionManager;
|
||||
|
||||
@Inject public Area(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @NotNull final File worldFile,
|
||||
@NotNull final HybridPlotWorldFactory hybridPlotWorldFactory,
|
||||
@NotNull final SetupUtils setupUtils,
|
||||
@NotNull final WorldUtil worldUtil,
|
||||
@NotNull final RegionManager regionManager) {
|
||||
@Inject public Area(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @Nonnull final File worldFile,
|
||||
@Nonnull final HybridPlotWorldFactory hybridPlotWorldFactory,
|
||||
@Nonnull final SetupUtils setupUtils,
|
||||
@Nonnull final WorldUtil worldUtil,
|
||||
@Nonnull final RegionManager regionManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
this.worldFile = worldFile;
|
||||
|
@ -26,6 +26,7 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.CaptionUtility;
|
||||
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.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
@ -66,10 +67,14 @@ public class Auto extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
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.eventDispatcher = eventDispatcher;
|
||||
this.econHandler = econHandler;
|
||||
}
|
||||
|
||||
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
|
||||
@ -147,7 +152,7 @@ public class Auto extends SubCommand {
|
||||
player.setMeta(Auto.class.getName(), true);
|
||||
autoClaimFromDatabase(player, area, start, new RunnableVal<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()));
|
||||
}
|
||||
});
|
||||
@ -169,10 +174,9 @@ public class Auto extends SubCommand {
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
PlotArea plotarea = player.getApplicablePlotArea();
|
||||
if (plotarea == null) {
|
||||
if (EconHandler.getEconHandler() != null) {
|
||||
if (this.econHandler != null) {
|
||||
for (PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||
if (EconHandler.getEconHandler()
|
||||
.hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
|
||||
if (this.econHandler.hasPermission(area.getWorldName(), player.getName(), "plots.auto")) {
|
||||
if (plotarea != null) {
|
||||
plotarea = null;
|
||||
break;
|
||||
@ -265,18 +269,18 @@ public class Auto extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (EconHandler.getEconHandler() != null && plotarea.useEconomy()) {
|
||||
if (this.econHandler != null && plotarea.useEconomy()) {
|
||||
Expression<Double> costExp = plotarea.getPrices().get("claim");
|
||||
double cost = costExp.evaluate((double) (Settings.Limit.GLOBAL ?
|
||||
player.getPlotCount() :
|
||||
player.getPlotCount(plotarea.getWorldName())));
|
||||
cost = (size_x * size_z) * cost;
|
||||
if (cost > 0d) {
|
||||
if (!force && EconHandler.getEconHandler().getMoney(player) < cost) {
|
||||
if (!force && this.econHandler.getMoney(player) < cost) {
|
||||
sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
return true;
|
||||
}
|
||||
EconHandler.getEconHandler().withdrawMoney(player, cost);
|
||||
this.econHandler.withdrawMoney(player, cost);
|
||||
sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.time.Instant;
|
||||
@ -64,7 +64,7 @@ public final class Backup extends Command {
|
||||
|
||||
private final BackupManager backupManager;
|
||||
|
||||
@Inject public Backup(@NotNull final BackupManager backupManager) {
|
||||
@Inject public Backup(@Nonnull final BackupManager backupManager) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.backupManager = backupManager;
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ import com.plotsquared.core.util.EventDispatcher;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -56,7 +56,7 @@ public class Buy extends Command {
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final EconHandler econHandler;
|
||||
|
||||
@Inject public Buy(@NotNull final EventDispatcher eventDispatcher,
|
||||
@Inject public Buy(@Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nullable final EconHandler econHandler) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
|
@ -71,7 +71,7 @@ public class Caps extends SubCommand {
|
||||
}
|
||||
|
||||
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 int current = countedEntities[type];
|
||||
final int max = plot.getFlag(capFlag);
|
||||
|
@ -46,8 +46,8 @@ import com.plotsquared.core.util.Expression;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@CommandDeclaration(command = "claim",
|
||||
aliases = "c",
|
||||
@ -61,7 +61,7 @@ public class Claim extends SubCommand {
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final EconHandler econHandler;
|
||||
|
||||
@Inject public Claim(@NotNull final EventDispatcher eventDispatcher,
|
||||
@Inject public Claim(@Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nullable final EconHandler econHandler) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.econHandler = econHandler;
|
||||
|
@ -42,7 +42,7 @@ import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -61,8 +61,8 @@ public class Clear extends Command {
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final GlobalBlockQueue blockQueue;
|
||||
|
||||
@Inject public Clear(@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final GlobalBlockQueue blockQueue) {
|
||||
@Inject public Clear(@Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nonnull final GlobalBlockQueue blockQueue) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.blockQueue = blockQueue;
|
||||
|
@ -36,7 +36,7 @@ import com.plotsquared.core.util.StringMan;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import lombok.SneakyThrows;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -582,7 +582,7 @@ public abstract class Command {
|
||||
return object;
|
||||
}
|
||||
|
||||
@SneakyThrows protected static void sneakyThrow(@NotNull final Throwable throwable) {
|
||||
@SneakyThrows protected static void sneakyThrow(@Nonnull final Throwable throwable) {
|
||||
throw throwable;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
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.WorldUtil;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -56,9 +57,12 @@ public class Condense extends SubCommand {
|
||||
public static boolean TASK = false;
|
||||
|
||||
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.worldUtil = worldUtil;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
@ -67,7 +71,7 @@ public class Condense extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
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.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@CommandDeclaration(command = "continue",
|
||||
description = "Continue a plot that was previously marked as done",
|
||||
@ -47,7 +48,7 @@ public class Continue extends SubCommand {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public Continue(@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public Continue(@Nonnull final EventDispatcher eventDispatcher) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@CommandDeclaration(command = "createroadschematic",
|
||||
aliases = {"crs"},
|
||||
@ -46,7 +46,7 @@ public class CreateRoadSchematic extends SubCommand {
|
||||
|
||||
private final HybridUtils hybridUtils;
|
||||
|
||||
@Inject public CreateRoadSchematic(@NotNull final HybridUtils hybridUtils) {
|
||||
@Inject public CreateRoadSchematic(@Nonnull final HybridUtils hybridUtils) {
|
||||
this.hybridUtils = hybridUtils;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||
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.query.PlotQuery;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
@ -68,8 +69,10 @@ public class DatabaseCommand extends SubCommand {
|
||||
private final PlotListener plotListener;
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
|
||||
public DatabaseCommand(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final PlotListener plotListener, @WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||
@Inject public DatabaseCommand(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nonnull final PlotListener plotListener,
|
||||
@WorldConfig @Nonnull final YamlConfiguration worldConfiguration) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.plotListener = plotListener;
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.uuid.UUIDMapping;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
@ -52,9 +53,12 @@ import java.util.Map;
|
||||
public class Debug extends SubCommand {
|
||||
|
||||
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.regionManager = regionManager;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
@ -70,8 +74,7 @@ public class Debug extends SubCommand {
|
||||
final long start = System.currentTimeMillis();
|
||||
MainUtil.sendMessage(player, "Fetching loaded chunks...");
|
||||
TaskManager.runTaskAsync(() -> MainUtil.sendMessage(player,
|
||||
"Loaded chunks: " + RegionManager.manager
|
||||
.getChunkChunks(player.getLocation().getWorldName()).size() + "(" + (
|
||||
"Loaded chunks: " + this.regionManager.getChunkChunks(player.getLocation().getWorldName()).size() + "(" + (
|
||||
System.currentTimeMillis() - start) + "ms) using thread: " + Thread
|
||||
.currentThread().getName()));
|
||||
return true;
|
||||
|
@ -26,6 +26,7 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
@ -90,35 +91,39 @@ public class DebugExec extends SubCommand {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
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 Bindings scope;
|
||||
|
||||
public DebugExec(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||
@Nullable final WorldEdit worldEdit) {
|
||||
@Inject public DebugExec(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@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.eventDispatcher = eventDispatcher;
|
||||
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();
|
||||
/*
|
||||
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() {
|
||||
@ -167,21 +172,21 @@ public class DebugExec extends SubCommand {
|
||||
|
||||
// Instances
|
||||
this.scope.put("PS", PlotSquared.get());
|
||||
this.scope.put("GlobalBlockQueue", GlobalBlockQueue.IMP);
|
||||
this.scope.put("GlobalBlockQueue", this.blockQueue);
|
||||
this.scope.put("ExpireManager", ExpireManager.IMP);
|
||||
if (this.worldEdit != null) {
|
||||
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("SchematicHandler", SchematicHandler.manager);
|
||||
this.scope.put("ChunkManager", ChunkManager.manager);
|
||||
this.scope.put("BlockManager", WorldUtil.IMP);
|
||||
this.scope.put("SetupUtils", SetupUtils.manager);
|
||||
this.scope.put("SchematicHandler", this.schematicHandler);
|
||||
this.scope.put("ChunkManager", this.chunkManager);
|
||||
this.scope.put("BlockManager", this.worldUtil);
|
||||
this.scope.put("SetupUtils", this.setupUtils);
|
||||
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("HybridUtils", HybridUtils.manager);
|
||||
this.scope.put("HybridUtils", this.hybridUtils);
|
||||
this.scope.put("IMP", PlotSquared.platform());
|
||||
this.scope.put("MainCommand", MainCommand.getInstance());
|
||||
|
||||
@ -213,7 +218,7 @@ public class DebugExec extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
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) {
|
||||
MainUtil.sendMessage(player,
|
||||
"$1Done: $2Use $3/plot debugexec analyze$2 for more information");
|
||||
@ -279,10 +284,9 @@ public class DebugExec extends SubCommand {
|
||||
}
|
||||
boolean result;
|
||||
if (HybridUtils.regions != null) {
|
||||
result = HybridUtils.manager
|
||||
.scheduleRoadUpdate(area, HybridUtils.regions, 0, new HashSet<>());
|
||||
result = this.hybridUtils.scheduleRoadUpdate(area, HybridUtils.regions, 0, new HashSet<>());
|
||||
} else {
|
||||
result = HybridUtils.manager.scheduleRoadUpdate(area, 0);
|
||||
result = this.hybridUtils.scheduleRoadUpdate(area, 0);
|
||||
}
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player,
|
||||
|
@ -26,6 +26,7 @@
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
@ -50,10 +51,13 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class DebugImportWorlds extends Command {
|
||||
|
||||
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);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.worldUtil = worldUtil;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,7 +79,7 @@ public class DebugImportWorlds extends Command {
|
||||
}
|
||||
for (File folder : container.listFiles()) {
|
||||
String name = folder.getName();
|
||||
if (!WorldUtil.IMP.isWorld(name) && PlotId.fromStringOrNull(name) == null) {
|
||||
if (!this.worldUtil.isWorld(name) && PlotId.fromStringOrNull(name) == null) {
|
||||
UUID uuid;
|
||||
if (name.length() > 16) {
|
||||
uuid = UUID.fromString(name);
|
||||
|
@ -27,6 +27,7 @@ package com.plotsquared.core.command;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.inject.annotations.ConfigFile;
|
||||
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.net.IncendoPaster;
|
||||
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.File;
|
||||
@ -65,13 +66,13 @@ public class DebugPaste extends SubCommand {
|
||||
private final File configFile;
|
||||
private final File worldfile;
|
||||
|
||||
public DebugPaste(@ConfigFile @NotNull final File configFile,
|
||||
@WorldFile @NotNull final File worldFile) {
|
||||
@Inject public DebugPaste(@ConfigFile @Nonnull final File configFile,
|
||||
@WorldFile @Nonnull final File worldFile) {
|
||||
this.configFile = configFile;
|
||||
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;
|
||||
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
lines = reader.lines().collect(Collectors.toList());
|
||||
|
@ -35,7 +35,7 @@ import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -51,7 +51,7 @@ public class DebugRoadRegen extends SubCommand {
|
||||
|
||||
private final HybridUtils hybridUtils;
|
||||
|
||||
@Inject public DebugRoadRegen(@NotNull final HybridUtils hybridUtils) {
|
||||
@Inject public DebugRoadRegen(@Nonnull final HybridUtils hybridUtils) {
|
||||
this.hybridUtils = hybridUtils;
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ import com.plotsquared.core.util.Expression;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
@CommandDeclaration(command = "delete",
|
||||
@ -56,7 +56,7 @@ public class Delete extends SubCommand {
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final EconHandler econHandler;
|
||||
|
||||
@Inject public Delete(@NotNull final EventDispatcher eventDispatcher,
|
||||
@Inject public Delete(@Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nullable final EconHandler econHandler) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.econHandler = econHandler;
|
||||
|
@ -39,7 +39,7 @@ import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.TabCompletions;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -58,9 +58,9 @@ public class Deny extends SubCommand {
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final WorldUtil worldUtil;
|
||||
|
||||
@Inject public Deny(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final EventDispatcher eventDispatcher,
|
||||
@NotNull final WorldUtil worldUtil) {
|
||||
@Inject public Deny(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nonnull final WorldUtil worldUtil) {
|
||||
super(Argument.PlayerName);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.events.PlotFlagAddEvent;
|
||||
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.util.EventDispatcher;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@CommandDeclaration(command = "setdescription",
|
||||
permission = "plots.set.desc",
|
||||
@ -47,7 +48,7 @@ public class Desc extends SetCommand {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public Desc(@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public Desc(@Nonnull final EventDispatcher eventDispatcher) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,9 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@CommandDeclaration(command = "dislike",
|
||||
permission = "plots.dislike",
|
||||
@ -38,7 +39,7 @@ public class Dislike extends SubCommand {
|
||||
|
||||
private final Like like;
|
||||
|
||||
public Dislike(@NotNull final Like like) {
|
||||
@Inject public Dislike(@Nonnull final Like like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
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.Permissions;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@CommandDeclaration(command = "done",
|
||||
aliases = {"submit"},
|
||||
@ -53,9 +54,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class Done extends SubCommand {
|
||||
|
||||
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.hybridUtils = hybridUtils;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
@ -90,7 +94,7 @@ public class Done extends SubCommand {
|
||||
finish(plot, player, true);
|
||||
plot.removeRunning();
|
||||
} else {
|
||||
HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
|
||||
this.hybridUtils.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
|
||||
@Override public void run(PlotAnalysis value) {
|
||||
plot.removeRunning();
|
||||
boolean result =
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
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.task.RunnableVal;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
@ -52,9 +53,15 @@ import java.net.URL;
|
||||
public class Download extends SubCommand {
|
||||
|
||||
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.schematicHandler = schematicHandler;
|
||||
this.worldUtil = worldUtil;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
@ -91,10 +98,10 @@ public class Download extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||
this.schematicHandler.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||
@Override public void run(CompoundTag value) {
|
||||
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) {
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_LINK_FAILED);
|
||||
@ -113,8 +120,8 @@ public class Download extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(player, Captions.MCA_FILE_SIZE);
|
||||
plot.addRunning();
|
||||
WorldUtil.IMP.saveWorld(world);
|
||||
WorldUtil.IMP.upload(plot, null, null, new RunnableVal<URL>() {
|
||||
this.worldUtil.saveWorld(world);
|
||||
this.worldUtil.upload(plot, null, null, new RunnableVal<URL>() {
|
||||
@Override public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
|
@ -50,8 +50,8 @@ import com.plotsquared.core.util.StringMan;
|
||||
import com.plotsquared.core.util.helpmenu.HelpMenu;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@ -87,7 +87,7 @@ public final class FlagCommand extends Command {
|
||||
}
|
||||
|
||||
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();
|
||||
value = value.toLowerCase();
|
||||
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
|
||||
*/
|
||||
private static boolean checkRequirements(@NotNull final PlotPlayer player) {
|
||||
private static boolean checkRequirements(@Nonnull final PlotPlayer player) {
|
||||
final Location location = player.getLocation();
|
||||
final Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
@ -180,8 +180,8 @@ public final class FlagCommand extends Command {
|
||||
* @param arg String to extract flag from
|
||||
* @return The flag, if found, else null
|
||||
*/
|
||||
@Nullable private static PlotFlag<?, ?> getFlag(@NotNull final PlotPlayer player,
|
||||
@NotNull final String arg) {
|
||||
@Nullable private static PlotFlag<?, ?> getFlag(@Nonnull final PlotPlayer player,
|
||||
@Nonnull final String arg) {
|
||||
if (arg != null && arg.length() > 0) {
|
||||
final PlotFlag<?, ?> flag = GlobalFlagContainer.getInstance().getFlagFromString(arg);
|
||||
if (flag instanceof InternalFlag || flag == null) {
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.events.TeleportCause;
|
||||
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.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -58,13 +59,13 @@ public class HomeCommand extends Command {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public HomeCommand(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
@Inject public HomeCommand(@Nonnull final PlotAreaManager plotAreaManager) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
private void home(@NotNull final PlotPlayer<?> player,
|
||||
@NotNull final PlotQuery query, final int page,
|
||||
private void home(@Nonnull final PlotPlayer<?> player,
|
||||
@Nonnull final PlotQuery query, final int page,
|
||||
final RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
final RunnableVal2<Command, CommandResult> whenDone) {
|
||||
List<Plot> plots = query.asList();
|
||||
@ -86,7 +87,7 @@ public class HomeCommand extends Command {
|
||||
}), () -> 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
|
||||
return PlotQuery.newQuery().ownedBy(player);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.TabCompletions;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -58,8 +58,8 @@ public class Kick extends SubCommand {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final WorldUtil worldUtil;
|
||||
|
||||
@Inject public Kick(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final WorldUtil worldUtil) {
|
||||
@Inject public Kick(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@Nonnull final WorldUtil worldUtil) {
|
||||
super(Argument.PlayerName);
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.worldUtil = worldUtil;
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
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.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -47,7 +48,7 @@ public class Leave extends Command {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public Leave(@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public Leave(@Nonnull final EventDispatcher eventDispatcher) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.Permissions;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -57,7 +58,7 @@ public class Like extends SubCommand {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public Like(@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public Like(@Nonnull final EventDispatcher eventDispatcher) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ import com.plotsquared.core.util.query.PlotQuery;
|
||||
import com.plotsquared.core.util.query.SortingStrategy;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -76,7 +76,7 @@ public class ListCmd extends SubCommand {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final EconHandler econHandler;
|
||||
|
||||
@Inject public ListCmd(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@Inject public ListCmd(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@Nullable final EconHandler econHandler) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.econHandler = econHandler;
|
||||
|
@ -39,7 +39,7 @@ import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
@ -57,8 +57,8 @@ public class Load extends SubCommand {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final SchematicHandler schematicHandler;
|
||||
|
||||
@Inject public Load(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final SchematicHandler schematicHandler) {
|
||||
@Inject public Load(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@Nonnull final SchematicHandler schematicHandler) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.schematicHandler = schematicHandler;
|
||||
}
|
||||
|
@ -29,23 +29,17 @@ import com.google.inject.Injector;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.player.ConsolePlayer;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.EconHandler;
|
||||
import com.plotsquared.core.util.EventDispatcher;
|
||||
import com.plotsquared.core.util.Expression;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -152,12 +146,13 @@ public class MainCommand extends Command {
|
||||
|
||||
// Referenced commands
|
||||
instance.toggle = injector.getInstance(Toggle.class);
|
||||
instance.help = injector.getInstance(Help.class);
|
||||
instance.help = new Help(instance);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean onCommand(final PlotPlayer<?> player, String... args) {
|
||||
final EconHandler econHandler = PlotSquared.platform().getEconHandler();
|
||||
if (args.length >= 1 && args[0].contains(":")) {
|
||||
String[] split2 = args[0].split(":");
|
||||
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) {
|
||||
if (cmd.hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, cmd.getUsage(), () -> {
|
||||
if (EconHandler.getEconHandler() != null) {
|
||||
if (econHandler != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Expression<Double> priceEval =
|
||||
area.getPrices().get(cmd.getFullId());
|
||||
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||
if (price != null
|
||||
&& EconHandler.getEconHandler().getMoney(player) < price) {
|
||||
&& econHandler.getMoney(player) < price) {
|
||||
if (failure != null) {
|
||||
failure.run();
|
||||
}
|
||||
@ -200,12 +195,12 @@ public class MainCommand extends Command {
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (EconHandler.getEconHandler() != null) {
|
||||
if (econHandler != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Expression<Double> priceEval = area.getPrices().get(cmd.getFullId());
|
||||
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) {
|
||||
failure.run();
|
||||
}
|
||||
@ -267,14 +262,14 @@ public class MainCommand extends Command {
|
||||
if ("f".equals(args[0].substring(1))) {
|
||||
confirm = new RunnableVal3<Command, Runnable, Runnable>() {
|
||||
@Override public void run(Command cmd, Runnable success, Runnable failure) {
|
||||
if (EconHandler.getEconHandler() != null) {
|
||||
if (PlotSquared.platform().getEconHandler() != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Expression<Double> priceEval =
|
||||
area.getPrices().get(cmd.getFullId());
|
||||
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||
if (price != 0d
|
||||
&& EconHandler.getEconHandler().getMoney(player) < price) {
|
||||
&& PlotSquared.platform().getEconHandler().getMoney(player) < price) {
|
||||
if (failure != null) {
|
||||
failure.run();
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ import com.plotsquared.core.util.Expression;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -63,7 +63,7 @@ public class Merge extends SubCommand {
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final EconHandler econHandler;
|
||||
|
||||
@Inject public Merge(@NotNull final EventDispatcher eventDispatcher,
|
||||
@Inject public Merge(@Nonnull final EventDispatcher eventDispatcher,
|
||||
@Nullable final EconHandler econHandler) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.econHandler = econHandler;
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.location.Location;
|
||||
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.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@ -49,7 +50,7 @@ public class Move extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Move(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
@Inject public Move(@Nonnull final PlotAreaManager plotAreaManager) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.MusicFlag;
|
||||
import com.plotsquared.core.util.InventoryUtil;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.Permissions;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -56,7 +57,7 @@ public class Owner extends SetCommand {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public Owner(@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public Owner(@Nonnull final EventDispatcher eventDispatcher) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ import com.plotsquared.core.util.task.TaskManager;
|
||||
public class PluginCmd extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, String[] args) {
|
||||
TaskManager.IMP.taskAsync(() -> {
|
||||
TaskManager.getImplementation().taskAsync(() -> {
|
||||
MainUtil.sendMessage(player, String.format(
|
||||
"$2>> $1&l" + PlotSquared.platform().getPluginName() + " $2($1Version$2: $1%s$2)",
|
||||
PlotSquared.get().getVersion()));
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.util.StringMan;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -58,7 +59,8 @@ public class Purge extends SubCommand {
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
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.plotListener = plotListener;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.flag.implementations.DoneFlag;
|
||||
import com.plotsquared.core.util.EventDispatcher;
|
||||
import com.plotsquared.core.util.InventoryUtil;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.MathMan;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -59,9 +61,12 @@ import java.util.UUID;
|
||||
public class Rate extends SubCommand {
|
||||
|
||||
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.inventoryUtil = inventoryUtil;
|
||||
}
|
||||
|
||||
@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 rating = new MutableInt(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) {
|
||||
rating.add((i + 1) * Math.pow(10, index.getValue()));
|
||||
index.increment();
|
||||
|
@ -34,7 +34,7 @@ import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.plot.PlotManager;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@CommandDeclaration(command = "regenallroads",
|
||||
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 HybridUtils hybridUtils;
|
||||
|
||||
@Inject public RegenAllRoads(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final HybridUtils hybridUtils) {
|
||||
@Inject public RegenAllRoads(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@Nonnull final HybridUtils hybridUtils) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.hybridUtils = hybridUtils;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||
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.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -54,9 +55,9 @@ public class Reload extends SubCommand {
|
||||
private final YamlConfiguration worldConfiguration;
|
||||
private final File worldFile;
|
||||
|
||||
public Reload(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @NotNull final File worldFile) {
|
||||
@Inject public Reload(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @Nonnull final File worldFile) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
this.worldFile = worldFile;
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.database.DBFunc;
|
||||
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.Permissions;
|
||||
import com.plotsquared.core.util.TabCompletions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -52,7 +53,7 @@ public class Remove extends SubCommand {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public Remove(@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public Remove(@Nonnull final EventDispatcher eventDispatcher) {
|
||||
super(Argument.PlayerName);
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.location.Location;
|
||||
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.TaskManager;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
@ -51,9 +52,12 @@ import java.util.UUID;
|
||||
public class Save extends SubCommand {
|
||||
|
||||
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.schematicHandler = schematicHandler;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
|
||||
@ -79,7 +83,7 @@ public class Save extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||
this.schematicHandler.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||
@Override public void run(final CompoundTag value) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
String time = (System.currentTimeMillis() / 1000) + "";
|
||||
@ -92,7 +96,7 @@ public class Save extends SubCommand {
|
||||
.replaceAll("[^A-Za-z0-9]", "");
|
||||
final String file = time + '_' + world1 + '_' + id.x + '_' + id.y + '_' + size;
|
||||
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) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
|
@ -42,7 +42,7 @@ import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.StringMan;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@ -61,8 +61,8 @@ public class SchematicCmd extends SubCommand {
|
||||
private final SchematicHandler schematicHandler;
|
||||
private boolean running = false;
|
||||
|
||||
@Inject public SchematicCmd(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@NotNull final SchematicHandler schematicHandler) {
|
||||
@Inject public SchematicCmd(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@Nonnull final SchematicHandler schematicHandler) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.schematicHandler = schematicHandler;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.backup.BackupManager;
|
||||
import com.plotsquared.core.configuration.CaptionUtility;
|
||||
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.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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"};
|
||||
|
||||
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() {
|
||||
|
||||
@Override public String getId() {
|
||||
@ -91,7 +98,7 @@ public class Set extends SubCommand {
|
||||
final List<String> forbiddenTypes = new ArrayList<>(Settings.General.INVALID_BLOCKS);
|
||||
|
||||
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
||||
forbiddenTypes.addAll(WorldUtil.IMP.getTileEntityTypes().stream().map(
|
||||
forbiddenTypes.addAll(worldUtil.getTileEntityTypes().stream().map(
|
||||
BlockType::getName).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@ -154,7 +161,7 @@ public class Set extends SubCommand {
|
||||
current.setComponent(component, pattern);
|
||||
}
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
||||
GlobalBlockQueue.IMP.addEmptyTask(plot::removeRunning);
|
||||
blockQueue.addEmptyTask(plot::removeRunning);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.util.MainUtil;
|
||||
import com.plotsquared.core.util.SetupUtils;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -48,6 +50,12 @@ import java.util.Map.Entry;
|
||||
category = CommandCategory.ADMINISTRATION)
|
||||
public class Setup extends SubCommand {
|
||||
|
||||
private final SetupUtils setupUtils;
|
||||
|
||||
@Inject public Setup(@Nonnull final SetupUtils setupUtils) {
|
||||
this.setupUtils = setupUtils;
|
||||
}
|
||||
|
||||
public void displayGenerators(PlotPlayer<?> player) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append("&6What generator do you want?");
|
||||
@ -72,7 +80,7 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
process = new SetupProcess();
|
||||
player.setMeta("setup", process);
|
||||
SetupUtils.manager.updateGenerators();
|
||||
this.setupUtils.updateGenerators();
|
||||
SetupStep step = process.getCurrentStep();
|
||||
step.announce(player);
|
||||
displayGenerators(player);
|
||||
|
@ -48,7 +48,7 @@ import com.plotsquared.core.util.MainUtil;
|
||||
import com.plotsquared.core.util.SetupUtils;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -73,12 +73,12 @@ public class Template extends SubCommand {
|
||||
private final GlobalBlockQueue globalBlockQueue;
|
||||
private final WorldUtil worldUtil;
|
||||
|
||||
@Inject public Template(@NotNull final PlotAreaManager plotAreaManager,
|
||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @NotNull final File worldFile,
|
||||
@NotNull final SetupUtils setupUtils,
|
||||
@NotNull final GlobalBlockQueue globalBlockQueue,
|
||||
@NotNull final WorldUtil worldUtil) {
|
||||
@Inject public Template(@Nonnull final PlotAreaManager plotAreaManager,
|
||||
@WorldConfig @Nonnull final YamlConfiguration worldConfiguration,
|
||||
@WorldFile @Nonnull final File worldFile,
|
||||
@Nonnull final SetupUtils setupUtils,
|
||||
@Nonnull final GlobalBlockQueue globalBlockQueue,
|
||||
@Nonnull final WorldUtil worldUtil) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.worldConfiguration = worldConfiguration;
|
||||
this.worldFile = worldFile;
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -60,9 +61,18 @@ import java.util.Set;
|
||||
public class Trim extends SubCommand {
|
||||
|
||||
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.worldUtil = worldUtil;
|
||||
this.blockQueue = blockQueue;
|
||||
this.regionManager = regionManager;
|
||||
}
|
||||
|
||||
private static volatile boolean TASK = false;
|
||||
@ -84,7 +94,7 @@ public class Trim extends SubCommand {
|
||||
if (ExpireManager.IMP != null) {
|
||||
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<>();
|
||||
MainUtil.sendMessage(null, " - MCA #: " + result.value1.size());
|
||||
MainUtil.sendMessage(null, " - CHUNKS: " + (result.value1.size() * 1024) + " (max)");
|
||||
@ -116,7 +126,7 @@ public class Trim extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
@ -174,8 +184,7 @@ public class Trim extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
final LocalBlockQueue queue =
|
||||
GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||
final LocalBlockQueue queue = blockQueue.getNewQueue(world, false);
|
||||
TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() {
|
||||
@Override public void run(BlockVector2 value) {
|
||||
queue.regenChunk(value.getX(), value.getZ());
|
||||
@ -189,7 +198,7 @@ public class Trim extends SubCommand {
|
||||
player.sendMessage("Trim done!");
|
||||
};
|
||||
}
|
||||
RegionManager.manager.deleteRegionFiles(world, viable, regenTask);
|
||||
regionManager.deleteRegionFiles(world, viable, regenTask);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.database.DBFunc;
|
||||
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.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -54,7 +55,7 @@ public class Trust extends Command {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public Trust(@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public Trust(@Nonnull final EventDispatcher eventDispatcher) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.events.PlotUnlinkEvent;
|
||||
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.StringMan;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@CommandDeclaration(command = "unlink",
|
||||
aliases = {"u", "unmerge"},
|
||||
@ -49,7 +50,7 @@ public class Unlink extends SubCommand {
|
||||
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public Unlink(@NotNull final EventDispatcher eventDispatcher) {
|
||||
@Inject public Unlink(@Nonnull final EventDispatcher eventDispatcher) {
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
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.task.RunnableVal2;
|
||||
import com.plotsquared.core.util.task.RunnableVal3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -62,17 +63,17 @@ public class Visit extends Command {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
|
||||
public Visit(@NotNull final PlotAreaManager plotAreaManager) {
|
||||
@Inject public Visit(@Nonnull final PlotAreaManager plotAreaManager) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
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) {
|
||||
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) {
|
||||
// We get the query once,
|
||||
// then we get it another time further on
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user