Finalize DI stuff

This commit is contained in:
Alexander Söderberg
2020-07-14 18:49:40 +02:00
parent 25a58a5c46
commit 510ea56431
288 changed files with 1512 additions and 1320 deletions

View File

@ -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++) {

View File

@ -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 {

View File

@ -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]);
});

View File

@ -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;

View File

@ -54,7 +54,7 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.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();

View File

@ -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();
}

View File

@ -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) {