mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
CLeaning of code
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
parent
b7aeeb151d
commit
df47697ca6
@ -19,6 +19,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
|||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.plugin.RegisteredListener;
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -53,7 +54,7 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public UUID getUUID() {
|
@Nonnull @Override public UUID getUUID() {
|
||||||
if (this.uuid == null) {
|
if (this.uuid == null) {
|
||||||
this.uuid = UUIDHandler.getUUID(this);
|
this.uuid = UUIDHandler.getUUID(this);
|
||||||
}
|
}
|
||||||
|
@ -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.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public interface AbstractDB {
|
public interface AbstractDB {
|
||||||
@ -300,7 +301,7 @@ public interface AbstractDB {
|
|||||||
*
|
*
|
||||||
* @param plot The Plot to get comments from
|
* @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);
|
void createPlotAndSettings(Plot plot, Runnable whenDone);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
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) {
|
final RunnableVal<List<PlotComment>> whenDone) {
|
||||||
addPlotTask(plot, new UniqueStatement("getComments_" + plot) {
|
addPlotTask(plot, new UniqueStatement("getComments_" + plot) {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
|
@ -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.PlotGameMode;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ConsolePlayer extends PlotPlayer {
|
public class ConsolePlayer extends PlotPlayer {
|
||||||
@ -45,7 +46,7 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
return getLocation();
|
return getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public UUID getUUID() {
|
@Nonnull @Override public UUID getUUID() {
|
||||||
return DBFunc.EVERYONE;
|
return DBFunc.EVERYONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import com.google.common.collect.BiMap;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.PathIterator;
|
import java.awt.geom.PathIterator;
|
||||||
@ -322,7 +323,7 @@ public class Plot {
|
|||||||
* @param uuid the player uuid
|
* @param uuid the player uuid
|
||||||
* @return if the provided uuid is the owner of the plot
|
* @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)) {
|
if (uuid.equals(this.owner)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -339,6 +340,9 @@ public class Plot {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
|
* 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
|
* @return the plot owners
|
||||||
*/
|
*/
|
||||||
@ -752,8 +756,9 @@ public class Plot {
|
|||||||
public boolean setOwner(UUID owner, PlotPlayer initiator) {
|
public boolean setOwner(UUID owner, PlotPlayer initiator) {
|
||||||
boolean result = EventUtil.manager
|
boolean result = EventUtil.manager
|
||||||
.callOwnerChange(initiator, this, owner, hasOwner() ? this.owner : null, hasOwner());
|
.callOwnerChange(initiator, this, owner, hasOwner() ? this.owner : null, hasOwner());
|
||||||
if (!result)
|
if (!result) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if (!hasOwner()) {
|
if (!hasOwner()) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
create();
|
create();
|
||||||
@ -948,8 +953,9 @@ public class Plot {
|
|||||||
* @param name name
|
* @param name name
|
||||||
*/
|
*/
|
||||||
public void setSign(final String name) {
|
public void setSign(final String name) {
|
||||||
if (!isLoaded())
|
if (!isLoaded()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
||||||
TaskManager.runTask(() -> Plot.this.setSign(name));
|
TaskManager.runTask(() -> Plot.this.setSign(name));
|
||||||
return;
|
return;
|
||||||
@ -1165,8 +1171,9 @@ public class Plot {
|
|||||||
Location bot = corners[1];
|
Location bot = corners[1];
|
||||||
Location loc = new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
|
Location loc = new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
|
||||||
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||||
if (!isLoaded())
|
if (!isLoaded()) {
|
||||||
return loc;
|
return loc;
|
||||||
|
}
|
||||||
int y =
|
int y =
|
||||||
isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), loc.getX(), loc.getZ()) : 62;
|
isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), loc.getX(), loc.getZ()) : 62;
|
||||||
if (area.ALLOW_SIGNS) {
|
if (area.ALLOW_SIGNS) {
|
||||||
@ -1201,8 +1208,9 @@ public class Plot {
|
|||||||
Location bot = this.getBottomAbs();
|
Location bot = this.getBottomAbs();
|
||||||
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y,
|
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y,
|
||||||
bot.getZ() + home.z, home.yaw, home.pitch);
|
bot.getZ() + home.z, home.yaw, home.pitch);
|
||||||
if (!isLoaded())
|
if (!isLoaded()) {
|
||||||
return loc;
|
return loc;
|
||||||
|
}
|
||||||
if (!WorldUtil.IMP.getBlock(loc).isAir()) {
|
if (!WorldUtil.IMP.getBlock(loc).isAir()) {
|
||||||
loc.setY(Math.max(
|
loc.setY(Math.max(
|
||||||
1 + WorldUtil.IMP.getHighestBlock(this.getWorldName(), loc.getX(), loc.getZ()),
|
1 + WorldUtil.IMP.getHighestBlock(this.getWorldName(), loc.getX(), loc.getZ()),
|
||||||
@ -1514,6 +1522,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO Better documentation needed.
|
//TODO Better documentation needed.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the top location for the plot.
|
* Return the top location for the plot.
|
||||||
*
|
*
|
||||||
@ -1526,6 +1535,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO Better documentation needed.
|
//TODO Better documentation needed.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the bottom location for the plot.
|
* 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>
|
* Do the plot entry tasks for each player in the plot<br>
|
||||||
* - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
|
* - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -326,7 +327,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
*
|
*
|
||||||
* @return UUID
|
* @return UUID
|
||||||
*/
|
*/
|
||||||
@Override public abstract UUID getUUID();
|
@Override @Nonnull public abstract UUID getUUID();
|
||||||
|
|
||||||
public boolean canTeleport(Location loc) {
|
public boolean canTeleport(Location loc) {
|
||||||
Location current = getLocationFull();
|
Location current = getLocationFull();
|
||||||
|
@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -82,10 +83,7 @@ public class UUIDHandler {
|
|||||||
implementation.add(toAdd);
|
implementation.add(toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getUUID(PlotPlayer player) {
|
@Nonnull public static UUID getUUID(PlotPlayer player) {
|
||||||
if (implementation == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return implementation.getUUID(player);
|
return implementation.getUUID(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class AbstractDBTest implements AbstractDB {
|
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 setComment(Plot plot, PlotComment comment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public void getComments(@Nonnull Plot plot, String inbox,
|
||||||
public void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone) {
|
RunnableVal<List<PlotComment>> whenDone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void createPlotAndSettings(Plot plot, Runnable whenDone) {
|
@Override public void createPlotAndSettings(Plot plot, Runnable whenDone) {
|
||||||
|
Loading…
Reference in New Issue
Block a user