Replace getOwnerAbs() == null with hasOwner()

This commit is contained in:
Alexander Söderberg 2020-04-10 19:10:43 +02:00
parent 474795367e
commit 7962004215
2 changed files with 12 additions and 12 deletions

View file

@ -490,7 +490,7 @@ public class Plot {
* @return true if the player is added/trusted or is the owner * @return true if the player is added/trusted or is the owner
*/ */
public boolean isAdded(UUID uuid) { public boolean isAdded(UUID uuid) {
if (this.getOwnerAbs() == null || getDenied().contains(uuid)) { if (this.hasOwner() || getDenied().contains(uuid)) {
return false; return false;
} }
if (isOwner(uuid)) { if (isOwner(uuid)) {
@ -914,7 +914,7 @@ public class Plot {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
}; };
for (Plot current : plots) { for (Plot current : plots) {
if (isDelete || current.getOwnerAbs() == null) { if (isDelete || current.hasOwner()) {
manager.unClaimPlot(current, null); manager.unClaimPlot(current, null);
} else { } else {
manager.claimPlot(current); manager.claimPlot(current);
@ -1316,7 +1316,7 @@ public class Plot {
* @return false if the Plot has no owner, otherwise true. * @return false if the Plot has no owner, otherwise true.
*/ */
public boolean unclaim() { public boolean unclaim() {
if (this.getOwnerAbs() == null) { if (this.hasOwner()) {
return false; return false;
} }
for (Plot current : getConnectedPlots()) { for (Plot current : getConnectedPlots()) {
@ -1701,7 +1701,7 @@ public class Plot {
* Sets the plot sign if plot signs are enabled. * Sets the plot sign if plot signs are enabled.
*/ */
public void setSign() { public void setSign() {
if (this.getOwnerAbs() == null) { if (this.hasOwner()) {
this.setSign("unknown"); this.setSign("unknown");
return; return;
} }
@ -1895,7 +1895,7 @@ public class Plot {
* @return Future containing the result * @return Future containing the result
*/ */
public CompletableFuture<Boolean> swapData(Plot plot) { public CompletableFuture<Boolean> swapData(Plot plot) {
if (this.getOwnerAbs() == null) { if (this.hasOwner()) {
if (plot != null && plot.hasOwner()) { if (plot != null && plot.hasOwner()) {
plot.moveData(this, null); plot.moveData(this, null);
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
@ -1930,7 +1930,7 @@ public class Plot {
* @return * @return
*/ */
public boolean moveData(Plot plot, Runnable whenDone) { public boolean moveData(Plot plot, Runnable whenDone) {
if (this.getOwnerAbs() == null) { if (this.hasOwner()) {
PlotSquared.debug(plot + " is unowned (single)"); PlotSquared.debug(plot + " is unowned (single)");
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return false; return false;
@ -2483,7 +2483,7 @@ public class Plot {
*/ */
public boolean autoMerge(Direction dir, int max, UUID uuid, boolean removeRoads) { public boolean autoMerge(Direction dir, int max, UUID uuid, boolean removeRoads) {
//Ignore merging if there is no owner for the plot //Ignore merging if there is no owner for the plot
if (this.getOwnerAbs() == null) { if (this.hasOwner()) {
return false; return false;
} }
Set<Plot> connected = this.getConnectedPlots(); Set<Plot> connected = this.getConnectedPlots();
@ -2783,7 +2783,7 @@ public class Plot {
} }
Plot current; Plot current;
while ((current = frontier.poll()) != null) { while ((current = frontier.poll()) != null) {
if (current.getOwnerAbs() == null || current.settings == null) { if (current.hasOwner() || current.settings == null) {
// Invalid plot // Invalid plot
// merged onto unclaimed plot // merged onto unclaimed plot
PlotSquared.debug( PlotSquared.debug(
@ -3091,7 +3091,7 @@ public class Plot {
* @return true if the owner of the Plot is online * @return true if the owner of the Plot is online
*/ */
public boolean isOnline() { public boolean isOnline() {
if (this.getOwnerAbs() == null) { if (this.hasOwner()) {
return false; return false;
} }
if (!isMerged()) { if (!isMerged()) {
@ -3222,7 +3222,7 @@ public class Plot {
Location ob = this.getBottomAbs(); Location ob = this.getBottomAbs();
final int offsetX = db.getX() - ob.getX(); final int offsetX = db.getX() - ob.getX();
final int offsetZ = db.getZ() - ob.getZ(); final int offsetZ = db.getZ() - ob.getZ();
if (this.getOwnerAbs() == null) { if (this.hasOwner()) {
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTaskLater(whenDone, 1);
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
@ -3341,7 +3341,7 @@ public class Plot {
Location ob = this.getBottomAbs(); Location ob = this.getBottomAbs();
final int offsetX = db.getX() - ob.getX(); final int offsetX = db.getX() - ob.getX();
final int offsetZ = db.getZ() - ob.getZ(); final int offsetZ = db.getZ() - ob.getZ();
if (this.getOwnerAbs() == null) { if (this.hasOwner()) {
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTaskLater(whenDone, 1);
return false; return false;
} }

View file

@ -8,7 +8,7 @@ import java.util.UUID;
public class PlotHandler { public class PlotHandler {
public static boolean sameOwners(@NotNull final Plot plot1, @NotNull final Plot plot2) { public static boolean sameOwners(@NotNull final Plot plot1, @NotNull final Plot plot2) {
if (plot1.getOwnerAbs() == null || plot2.getOwnerAbs() == null) { if (plot1.hasOwner() || plot2.hasOwner()) {
return false; return false;
} }
final Set<UUID> owners = plot1.getOwners(); final Set<UUID> owners = plot1.getOwners();