CLeaning of code

Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
matt 2019-02-19 19:00:37 -05:00
parent b7aeeb151d
commit df47697ca6
8 changed files with 30 additions and 17 deletions

View File

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

View File

@ -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<List<PlotComment>> whenDone);
void getComments(@Nonnull Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone);
void createPlotAndSettings(Plot plot, Runnable whenDone);

View File

@ -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<List<PlotComment>> whenDone) {
addPlotTask(plot, new UniqueStatement("getComments_" + plot) {
@Override public void set(PreparedStatement statement) throws SQLException {

View File

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

View File

@ -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).
* <p>
* This method cannot be used to add or remove owners from a plot.
* </p>
*
* @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<br>
* - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
*/

View File

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

View File

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

View File

@ -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<List<PlotComment>> whenDone) {
@Override public void getComments(@Nonnull Plot plot, String inbox,
RunnableVal<List<PlotComment>> whenDone) {
}
@Override public void createPlotAndSettings(Plot plot, Runnable whenDone) {