From b4c33aaa187fc851f4e8bbea19fcd181a50eb83e Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Wed, 14 Aug 2019 14:36:20 -0400 Subject: [PATCH] Midnight work Also fixes #2463 --- .../bukkit/listeners/PlayerEvents.java | 4 ++-- .../bukkit/object/BukkitPlayer.java | 3 +-- .../plotsquared/bukkit/util/BukkitUtil.java | 5 +++-- .../plotsquared/plot/commands/Set.java | 2 -- .../plotsquared/plot/database/SQLManager.java | 2 +- .../plot/generator/AugmentedUtils.java | 3 --- .../plot/generator/HybridPlotWorld.java | 2 +- .../plot/generator/HybridUtils.java | 2 +- .../plotsquared/plot/object/ConsolePlayer.java | 2 +- .../plotsquared/plot/object/PlotArea.java | 18 +++++++----------- .../plotsquared/plot/object/PlotId.java | 2 +- .../plotsquared/plot/object/PlotPlayer.java | 3 +-- .../plot/object/worlds/SinglePlot.java | 2 +- .../plot/object/worlds/SinglePlotArea.java | 10 +++++----- .../plotsquared/plot/util/MainUtil.java | 10 +++++----- 15 files changed, 30 insertions(+), 40 deletions(-) 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 c7c2edf5d..3ecc572db 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 @@ -931,10 +931,10 @@ import java.util.regex.Pattern; PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); Location location = plotPlayer.getLocation(); PlotArea area = location.getPlotArea(); - if (location.isPlotArea() || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) { + if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) { return; } - Plot plot = location.getPlot(); + Plot plot = area.getPlot(location); if (plot == null) { return; } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java index 7eae614f7..61862f899 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java @@ -25,7 +25,6 @@ import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.RegisteredListener; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; import java.util.Arrays; import java.util.Set; import java.util.UUID; @@ -56,7 +55,7 @@ public class BukkitPlayer extends PlotPlayer { super.populatePersistentMetaMap(); } - @Override public Location getLocation() { + @NotNull @Override public Location getLocation() { final Location location = super.getLocation(); return location == null ? BukkitUtil.getLocation(this.player) : location; } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java index 9996b99fc..0ba9c5700 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java @@ -28,8 +28,9 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; - +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -243,7 +244,7 @@ import java.util.Set; location.getBlockZ()); } - public static Location getLocationFull(@NonNull final Entity entity) { + @NotNull public static Location getLocationFull(@NonNull final Entity entity) { final org.bukkit.Location location = entity.getLocation(); return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java index 982e03ae1..082e80582 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Set.java @@ -10,7 +10,6 @@ import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.Plot; -import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; @@ -45,7 +44,6 @@ import java.util.stream.IntStream; } @Override public boolean set(PlotPlayer player, final Plot plot, String value) { - PlotArea plotArea = player.getLocation().getPlotArea(); PlotManager manager = player.getLocation().getPlotManager(); String[] components = manager.getPlotComponents(plot.getId()); boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(player.getUUID()); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java index 16991bf75..b3b20379f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java @@ -12,8 +12,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.google.common.base.Charsets; +import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; import java.sql.*; import java.text.ParseException; import java.text.SimpleDateFormat; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/AugmentedUtils.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/AugmentedUtils.java index fe0a614a2..2a85581ad 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/AugmentedUtils.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/AugmentedUtils.java @@ -47,9 +47,6 @@ public class AugmentedUtils { continue; } IndependentPlotGenerator generator = area.getGenerator(); - if (generator == null) { - continue; - } // Mask if (queue == null) { queue = GlobalBlockQueue.IMP.getNewQueue(world, false); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java index 101b6fcb3..2f8c7c823 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridPlotWorld.java @@ -44,7 +44,7 @@ public class HybridPlotWorld extends ClassicPlotWorld { super(worldName, id, generator, min, max); } - @Override + @NotNull @Override protected PlotManager createManager() { return new HybridPlotManager(this); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java index 135149279..46f02d6fb 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/HybridUtils.java @@ -140,7 +140,7 @@ public abstract class HybridUtils { } HybridUtils.UPDATE = true; Set regions = new HashSet<>(); - regions.add(ChunkManager.manager.getChunkChunk(plot.getCenter())); + regions.add(ChunkManager.getChunkChunk(plot.getCenter())); return scheduleRoadUpdate(plot.getArea(), regions, extend); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java index 253681c89..490a6e211 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java @@ -42,7 +42,7 @@ public class ConsolePlayer extends PlotPlayer { public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) { } - @Override public Location getLocation() { + @NotNull @Override public Location getLocation() { return this.getMeta("location"); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java index 9c7d88dd2..ff6668ea4 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotArea.java @@ -22,9 +22,8 @@ import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import org.jetbrains.annotations.NotNull; - -import javax.annotation.Nonnull; import org.jetbrains.annotations.Nullable; + import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; @@ -37,12 +36,12 @@ public abstract class PlotArea { public final String worldname; public final String id; - public final PlotManager manager; + @NotNull public final PlotManager manager; public final int worldhash; protected final ConcurrentHashMap plots = new ConcurrentHashMap<>(); private final PlotId min; private final PlotId max; - private final IndependentPlotGenerator generator; + @NotNull private final IndependentPlotGenerator generator; private final BlockBucket[][] blockBucketChunk; public int MAX_PLOT_MEMBERS = 128; public boolean AUTO_MERGE = false; @@ -102,7 +101,7 @@ public abstract class PlotArea { } } - protected abstract PlotManager createManager(); + @NotNull protected abstract PlotManager createManager(); public LocalBlockQueue getQueue(final boolean autoQueue) { return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue); @@ -117,10 +116,7 @@ public abstract class PlotArea { if (blockBucketChunk != null) { return blockBucketChunk; } - if (generator != null) { - return generator.generateBlockBucketChunk(this); - } - return null; + return generator.generateBlockBucketChunk(this); } /** @@ -178,7 +174,7 @@ public abstract class PlotArea { * * @return the {@link IndependentPlotGenerator} */ - public IndependentPlotGenerator getGenerator() { + @NotNull public IndependentPlotGenerator getGenerator() { return this.generator; } @@ -617,7 +613,7 @@ public abstract class PlotArea { return this.clusters != null ? this.clusters.get(id.x, id.y) : null; } - public PlotManager getPlotManager() { + @NotNull public PlotManager getPlotManager() { return this.manager; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotId.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotId.java index 6506a1d50..21e7dc777 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotId.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotId.java @@ -1,6 +1,6 @@ package com.github.intellectualsites.plotsquared.plot.object; -import javax.annotation.Nonnull; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class PlotId { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java index 04390adbe..f8e21255b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java @@ -16,7 +16,6 @@ import com.google.common.base.Preconditions; import lombok.NonNull; import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; import java.nio.ByteBuffer; import java.util.HashMap; import java.util.HashSet; @@ -307,7 +306,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { * * @return The location */ - public Location getLocation() { + @NotNull public Location getLocation() { Location location = getMeta("location"); if (location != null) { return location; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java index c216b4589..8c80e46a7 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlot.java @@ -4,8 +4,8 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.object.*; import com.google.common.collect.Sets; +import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; import java.util.Collection; import java.util.HashSet; import java.util.UUID; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java index 28a2e02dc..8f8ac96b1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/worlds/SinglePlotArea.java @@ -9,9 +9,9 @@ import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.util.SetupUtils; import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; - -import javax.annotation.Nonnull; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; + import java.io.File; import java.io.IOException; import java.nio.file.Files; @@ -26,7 +26,7 @@ public class SinglePlotArea extends GridPlotWorld { this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE); } - @Override + @NotNull @Override protected PlotManager createManager() { return new SinglePlotManager(this); } @@ -76,8 +76,8 @@ public class SinglePlotArea extends GridPlotWorld { new File(dataDest, file.getName()).toPath()); } } - } catch (IOException ignore) { - ignore.printStackTrace(); + } catch (IOException exception) { + exception.printStackTrace(); } } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java index 10e81c8db..1f42d6772 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java @@ -13,8 +13,8 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.stream.AbstractDelegateOutputStream; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; +import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; import java.io.*; import java.net.HttpURLConnection; import java.net.MalformedURLException; @@ -560,11 +560,11 @@ public class MainUtil { * Send a message to the player. * * @param player Player to receive message - * @param msg Message to send + * @param message Message to send * @return true Can be used in things such as commands (return PlayerFunctions.sendMessage(...)) */ - public static boolean sendMessage(PlotPlayer player, String msg) { - return sendMessage(player, msg, true); + public static boolean sendMessage(PlotPlayer player, String message) { + return sendMessage(player, message, true); } /** @@ -585,7 +585,7 @@ public class MainUtil { * @param prefix If the message should be prefixed with the configured prefix * @return */ - public static boolean sendMessage(CommandCaller player, String msg, boolean prefix) { + public static boolean sendMessage(CommandCaller player, @NotNull String msg, boolean prefix) { if (!msg.isEmpty()) { if (player == null) { String message = (prefix ? Captions.PREFIX.getTranslated() : "") + msg;