diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index c10a4f8a9..5dd04e506 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -2211,12 +2211,12 @@ import java.util.regex.Pattern; } break; } - case LEFT_CLICK_BLOCK: - Block block = event.getClickedBlock(); - location = BukkitUtil.getLocation(block.getLocation()); - eventType = PlayerBlockEventType.BREAK_BLOCK; - lazyItem = BukkitBlockUtil.supplyItem(block); - break; +// case LEFT_CLICK_BLOCK: +// Block block = event.getClickedBlock(); +// location = BukkitUtil.getLocation(block.getLocation()); +// eventType = PlayerBlockEventType.BREAK_BLOCK; +// lazyItem = BukkitBlockUtil.supplyItem(block); +// break; default: return; } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitBlockUtil.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitBlockUtil.java index bd86b5068..f35d4ea88 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitBlockUtil.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitBlockUtil.java @@ -10,7 +10,11 @@ import java.util.function.Supplier; public class BukkitBlockUtil { public static Supplier supplyItem(Block block) { - return () -> BukkitAdapter.asItemType(block.getType()); + return new Supplier() { + @Override public ItemType get() { + return BukkitAdapter.asItemType(block.getType()); + } + }; } public static Supplier supplyItem(Material type) { diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java index 0209058c5..4fb6f5db4 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitChunkManager.java @@ -40,9 +40,12 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import java.util.concurrent.CompletableFuture; +import static com.google.common.base.Preconditions.checkNotNull; + public class BukkitChunkManager extends ChunkManager { public static boolean isIn(CuboidRegion region, int x, int z) { @@ -111,7 +114,7 @@ public class BukkitChunkManager extends ChunkManager { @Override public Set getChunkChunks(String world) { Set chunks = super.getChunkChunks(world); - for (Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) { + for (Chunk chunk : Objects.requireNonNull(Bukkit.getWorld(world)).getLoadedChunks()) { BlockVector2 loc = BlockVector2.at(chunk.getX() >> 5, chunk.getZ() >> 5); chunks.add(loc); } @@ -269,6 +272,7 @@ public class BukkitChunkManager extends ChunkManager { } } final World worldObj = Bukkit.getWorld(world); + checkNotNull(worldObj, "Critical error during regeneration."); final BukkitWorld bukkitWorldObj = new BukkitWorld(worldObj); TaskManager.runTask(new Runnable() { @Override public void run() { @@ -398,7 +402,7 @@ public class BukkitChunkManager extends ChunkManager { return true; } - @Override public CompletableFuture loadChunk(String world, BlockVector2 chunkLoc, boolean force) { + @Override public CompletableFuture loadChunk(String world, BlockVector2 chunkLoc, boolean force) { return PaperLib.getChunkAtAsync(BukkitUtil.getWorld(world),chunkLoc.getX(), chunkLoc.getZ(), force); } @@ -440,8 +444,9 @@ public class BukkitChunkManager extends ChunkManager { CuboidRegion region2 = RegionUtil.createRegion(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ()); final World world1 = Bukkit.getWorld(bot1.getWorld()); - World world2 = Bukkit.getWorld(bot2.getWorld()); - + final World world2 = Bukkit.getWorld(bot2.getWorld()); + checkNotNull(world1,"Critical error during swap."); + checkNotNull(world2,"Critical error during swap."); int relX = bot2.getX() - bot1.getX(); int relZ = bot2.getZ() - bot1.getZ(); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitCommand.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitCommand.java index 190aa077a..cb927f190 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitCommand.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitCommand.java @@ -48,12 +48,12 @@ public class BukkitCommand implements CommandExecutor, TabCompleter { if (args.length == 0) { return Collections.singletonList("plots"); } - Collection objects = MainCommand.getInstance().tab(player, args, s.endsWith(" ")); + Collection objects = MainCommand.getInstance().tab(player, args, s.endsWith(" ")); if (objects == null) { return null; } List result = new ArrayList<>(); - for (Object o : objects) { + for (com.github.intellectualsites.plotsquared.commands.Command o : objects) { result.add(o.toString()); } return result.isEmpty() ? null : result; diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitInventoryUtil.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitInventoryUtil.java index 303b180e5..bb003833f 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitInventoryUtil.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitInventoryUtil.java @@ -96,6 +96,7 @@ public class BukkitInventoryUtil extends InventoryUtil { } if (meta.hasLore()) { List itemLore = meta.getLore(); + assert itemLore != null; lore = itemLore.toArray(new String[0]); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java index e08684da8..355dbc32a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java @@ -174,10 +174,16 @@ public class Auto extends SubCommand { if (Permissions.hasPermission(player, Captions.PERMISSION_AUTO_MEGA)) { try { String[] split = args[0].split(",|;"); - size_x = Integer.parseInt(split[0]); - size_z = Integer.parseInt(split[1]); + if (split[1] == null) { + MainUtil.sendMessage(player,"Correct use /plot auto [length,width]"); + size_x = 1; + size_z = 1; + } else { + size_x = Integer.parseInt(split[0]); + size_z = Integer.parseInt(split[1]); + } if (size_x < 1 || size_z < 1) { - MainUtil.sendMessage(player, "&cError: size<=0"); + MainUtil.sendMessage(player, "Error: size<=0"); } if (args.length > 1) { schematic = args[1];