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 60c1351d0..888de164a 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 @@ -19,6 +19,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.RegisteredListener; +import javax.annotation.Nonnull; import java.util.Arrays; import java.util.Set; import java.util.UUID; @@ -53,7 +54,7 @@ public class BukkitPlayer extends PlotPlayer { return location == null ? BukkitUtil.getLocation(this.player) : location; } - @Override public UUID getUUID() { + @Nonnull @Override public UUID getUUID() { if (this.uuid == null) { this.uuid = UUIDHandler.getUUID(this); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java index ae4a1fa76..0eecd6539 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDB.java @@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; +import javax.annotation.Nonnull; import java.util.*; public interface AbstractDB { @@ -300,7 +301,7 @@ public interface AbstractDB { * * @param plot The Plot to get comments from */ - void getComments(Plot plot, String inbox, RunnableVal> whenDone); + void getComments(@Nonnull Plot plot, String inbox, RunnableVal> whenDone); void createPlotAndSettings(Plot plot, Runnable whenDone); 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 2995a448d..876a29121 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 @@ -13,6 +13,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.google.common.base.Charsets; +import javax.annotation.Nonnull; import java.sql.*; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -2168,7 +2169,7 @@ import java.util.concurrent.atomic.AtomicInteger; }); } - @Override public void getComments(final Plot plot, final String inbox, + @Override public void getComments(@Nonnull Plot plot, final String inbox, final RunnableVal> whenDone) { addPlotTask(plot, new UniqueStatement("getComments_" + plot) { @Override public void set(PreparedStatement statement) throws SQLException { 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 18a0ce7bc..6f386b3cb 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 @@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode; import com.github.intellectualsites.plotsquared.plot.util.PlotWeather; +import javax.annotation.Nonnull; import java.util.UUID; public class ConsolePlayer extends PlotPlayer { @@ -45,7 +46,7 @@ public class ConsolePlayer extends PlotPlayer { return getLocation(); } - @Override public UUID getUUID() { + @Nonnull @Override public UUID getUUID() { return DBFunc.EVERYONE; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index 23f561233..fd76d9c87 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -21,6 +21,7 @@ import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableSet; import com.sk89q.jnbt.CompoundTag; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.awt.geom.Area; import java.awt.geom.PathIterator; @@ -322,7 +323,7 @@ public class Plot { * @param uuid the player uuid * @return if the provided uuid is the owner of the plot */ - public boolean isOwner(UUID uuid) { + public boolean isOwner(@Nonnull UUID uuid) { if (uuid.equals(this.owner)) { return true; } @@ -339,6 +340,9 @@ public class Plot { /** * Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots). + *

+ * This method cannot be used to add or remove owners from a plot. + *

* * @return the plot owners */ @@ -752,8 +756,9 @@ public class Plot { public boolean setOwner(UUID owner, PlotPlayer initiator) { boolean result = EventUtil.manager .callOwnerChange(initiator, this, owner, hasOwner() ? this.owner : null, hasOwner()); - if (!result) + if (!result) { return false; + } if (!hasOwner()) { this.owner = owner; create(); @@ -948,8 +953,9 @@ public class Plot { * @param name name */ public void setSign(final String name) { - if (!isLoaded()) + if (!isLoaded()) { return; + } if (!PlotSquared.get().isMainThread(Thread.currentThread())) { TaskManager.runTask(() -> Plot.this.setSign(name)); return; @@ -1165,8 +1171,9 @@ public class Plot { Location bot = corners[1]; Location loc = new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()), MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ())); - if (!isLoaded()) + if (!isLoaded()) { return loc; + } int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), loc.getX(), loc.getZ()) : 62; if (area.ALLOW_SIGNS) { @@ -1201,8 +1208,9 @@ public class Plot { Location bot = this.getBottomAbs(); Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z, home.yaw, home.pitch); - if (!isLoaded()) + if (!isLoaded()) { return loc; + } if (!WorldUtil.IMP.getBlock(loc).isAir()) { loc.setY(Math.max( 1 + WorldUtil.IMP.getHighestBlock(this.getWorldName(), loc.getX(), loc.getZ()), @@ -1514,6 +1522,7 @@ public class Plot { } //TODO Better documentation needed. + /** * Return the top location for the plot. * @@ -1526,6 +1535,7 @@ public class Plot { } //TODO Better documentation needed. + /** * Return the bottom location for the plot. */ @@ -2616,7 +2626,6 @@ public class Plot { } /** - * * Do the plot entry tasks for each player in the plot
* - Usually called when the plot state changes (unclaimed/claimed/flag change etc) */ 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 c0d9ec726..b3df60558 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 @@ -14,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import lombok.NonNull; +import javax.annotation.Nonnull; import java.nio.ByteBuffer; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -326,7 +327,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { * * @return UUID */ - @Override public abstract UUID getUUID(); + @Override @Nonnull public abstract UUID getUUID(); public boolean canTeleport(Location loc) { Location current = getLocationFull(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/UUIDHandler.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/UUIDHandler.java index c2aebe971..6696edbd5 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/UUIDHandler.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/UUIDHandler.java @@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.object.StringWrapper; import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; import com.google.common.collect.BiMap; +import javax.annotation.Nonnull; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -82,10 +83,7 @@ public class UUIDHandler { implementation.add(toAdd); } - public static UUID getUUID(PlotPlayer player) { - if (implementation == null) { - return null; - } + @Nonnull public static UUID getUUID(PlotPlayer player) { return implementation.getUUID(player); } diff --git a/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDBTest.java b/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDBTest.java index 1ef04abba..1ef5c92ec 100644 --- a/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDBTest.java +++ b/Core/src/test/java/com/github/intellectualsites/plotsquared/plot/database/AbstractDBTest.java @@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; +import javax.annotation.Nonnull; import java.util.*; public class AbstractDBTest implements AbstractDB { @@ -148,8 +149,8 @@ public class AbstractDBTest implements AbstractDB { @Override public void setComment(Plot plot, PlotComment comment) { } - @Override - public void getComments(Plot plot, String inbox, RunnableVal> whenDone) { + @Override public void getComments(@Nonnull Plot plot, String inbox, + RunnableVal> whenDone) { } @Override public void createPlotAndSettings(Plot plot, Runnable whenDone) {