Remove all direct access to Plot.owner

New methods were added for access to the absolute owner of a plot, and the documentation of the owner getters to clarify the purpose of the methods.
This commit is contained in:
Alexander Söderberg 2020-04-10 14:05:01 +02:00
parent 0d26111fa7
commit ce756411cf
14 changed files with 125 additions and 85 deletions

View File

@ -231,9 +231,9 @@ import java.util.UUID;
MainUtil.sendMessage(player, "&7 - Updating plot objects");
for (Plot plot : PlotSquared.get().getPlots()) {
UUID value = uCMap.get(plot.owner);
UUID value = uCMap.get(plot.getOwnerAbs());
if (value != null) {
plot.owner = value;
plot.setOwnerAbs(value);
}
plot.getTrusted().clear();
plot.getMembers().clear();
@ -250,9 +250,9 @@ import java.util.UUID;
if (!result) {
MainUtil.sendMessage(player, "&cConversion failed! Attempting recovery");
for (Plot plot : PlotSquared.get().getPlots()) {
UUID value = uCReverse.get(plot.owner);
UUID value = uCReverse.get(plot.getOwnerAbs());
if (value != null) {
plot.owner = value;
plot.setOwnerAbs(value);
}
}
DBFunc.createPlotsAndData(new ArrayList<>(PlotSquared.get().getPlots()),

View File

@ -347,8 +347,8 @@ import java.util.zip.ZipInputStream;
UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE);
forEachPlotRaw(plot -> {
if (plot.hasOwner() && plot.temp != -1) {
if (UUIDHandler.getName(plot.owner) == null) {
UUIDHandler.implementation.unknown.add(plot.owner);
if (UUIDHandler.getName(plot.getOwnerAbs()) == null) {
UUIDHandler.implementation.unknown.add(plot.getOwnerAbs());
}
}
});
@ -736,7 +736,7 @@ import java.util.zip.ZipInputStream;
} else {
list = new ArrayList<>(input);
}
list.sort(Comparator.comparingLong(a -> ExpireManager.IMP.getTimestamp(a.owner)));
list.sort(Comparator.comparingLong(a -> ExpireManager.IMP.getTimestamp(a.getOwnerAbs())));
return list;
}

View File

@ -138,7 +138,7 @@ public class Auto extends SubCommand {
return;
}
whenDone.value = plot;
plot.owner = player.getUUID();
plot.setOwnerAbs(player.getUUID());
DBFunc.createPlotSafe(plot, whenDone,
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
}

View File

@ -59,8 +59,8 @@ public class Buy extends Command {
confirm.run(this, () -> {
Captions.REMOVED_BALANCE.send(player, price);
EconHandler.manager
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.getOwnerAbs()), price);
PlotPlayer owner = UUIDHandler.getPlayer(plot.getOwnerAbs());
if (owner != null) {
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
}

View File

@ -97,7 +97,7 @@ public class Claim extends SubCommand {
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
return !sendMessage(player, Captions.BORDER);
}
plot.owner = player.getUUID();
plot.setOwnerAbs(player.getUUID());
final String finalSchematic = schematic;
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override public void run(Object value) {
@ -105,7 +105,7 @@ public class Claim extends SubCommand {
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
String.format("Failed to claim plot %s", plot.getId().toCommaSeparatedString()));
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
plot.owner = null;
plot.setOwnerAbs(null);
} else if (area.isAutoMerge()) {
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
@ -120,7 +120,7 @@ public class Claim extends SubCommand {
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
String.format("Failed to add plot %s to the database", plot.getId().toCommaSeparatedString()));
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
plot.owner = null;
plot.setOwnerAbs(null);
});
return true;
}

View File

@ -49,7 +49,7 @@ public class Owner extends SetCommand {
uuid = null;
}
PlotChangeOwnerEvent event = PlotSquared.get().getEventDispatcher()
.callOwnerChange(player, plot, plot.hasOwner() ? plot.owner : null, uuid,
.callOwnerChange(player, plot, plot.hasOwner() ? plot.getOwnerAbs() : null, uuid,
plot.hasOwner());
if (event.getEventResult() == Result.DENY) {
sendMessage(player, Captions.EVENT_DENIED, "Owner change");

View File

@ -121,7 +121,7 @@ public class Purge extends SubCommand {
if (added != null && !plot.isAdded(added)) {
continue;
}
if (unknown && UUIDHandler.getName(plot.owner) != null) {
if (unknown && UUIDHandler.getName(plot.getOwnerAbs()) != null) {
continue;
}
toDelete.addAll(plot.getConnectedPlots());
@ -144,7 +144,7 @@ public class Purge extends SubCommand {
if (added != null && !plot.isAdded(added)) {
continue;
}
if (unknown && UUIDHandler.getName(plot.owner) != null) {
if (unknown && UUIDHandler.getName(plot.getOwnerAbs()) != null) {
continue;
}
toDelete.add(plot);

View File

@ -718,7 +718,7 @@ import java.util.concurrent.atomic.AtomicInteger;
stmt.setInt(i * 5 + 1, plot.getId().x);
stmt.setInt(i * 5 + 2, plot.getId().y);
try {
stmt.setString(i * 5 + 3, plot.owner.toString());
stmt.setString(i * 5 + 3, plot.getOwnerAbs().toString());
} catch (SQLException ignored) {
stmt.setString(i * 5 + 3, everyone.toString());
}
@ -732,7 +732,7 @@ import java.util.concurrent.atomic.AtomicInteger;
stmt.setInt(i * 6 + 2, plot.getId().x);
stmt.setInt(i * 6 + 3, plot.getId().y);
try {
stmt.setString(i * 6 + 4, plot.owner.toString());
stmt.setString(i * 6 + 4, plot.getOwnerAbs().toString());
} catch (SQLException ignored) {
stmt.setString(i * 6 + 4, everyone.toString());
}
@ -743,7 +743,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override public void setSQL(PreparedStatement stmt, Plot plot) throws SQLException {
stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.owner.toString());
stmt.setString(3, plot.getOwnerAbs().toString());
stmt.setString(4, plot.getArea().toString());
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
@ -982,7 +982,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setInt(1, plot.getId().x);
statement.setInt(2, plot.getId().y);
statement.setString(3, plot.owner.toString());
statement.setString(3, plot.getOwnerAbs().toString());
statement.setString(4, plot.getArea().toString());
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
statement.setString(6, plot.getArea().toString());
@ -1051,7 +1051,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setInt(1, plot.getId().x);
statement.setInt(2, plot.getId().y);
statement.setString(3, plot.owner.toString());
statement.setString(3, plot.getOwnerAbs().toString());
statement.setString(4, plot.getArea().toString());
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
}
@ -1356,7 +1356,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override public void delete(final Plot plot) {
PlotSquared.debug(
"Deleting plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
+ plot.owner + " Index: " + plot.temp);
+ plot.getOwnerAbs() + " Index: " + plot.temp);
deleteSettings(plot);
deleteDenied(plot);
deleteHelpers(plot);
@ -1384,7 +1384,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Override public void createPlotSettings(final int id, Plot plot) {
PlotSquared.debug(
"Creating plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
+ plot.owner + " Index: " + id);
+ plot.getOwnerAbs() + " Index: " + id);
addPlotTask(plot, new UniqueStatement("createPlotSettings") {
@Override public void set(PreparedStatement statement) throws SQLException {
statement.setInt(1, id);
@ -3002,10 +3002,10 @@ import java.util.concurrent.atomic.AtomicInteger;
continue;
}
// owner
if (!plot.owner.equals(dataPlot.owner)) {
if (!plot.getOwnerAbs().equals(dataPlot.getOwnerAbs())) {
PlotSquared
.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil.getName(plot.owner));
setOwner(plot, plot.owner);
.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil.getName(plot.getOwnerAbs()));
setOwner(plot, plot.getOwnerAbs());
}
// trusted
if (!plot.getTrusted().equals(dataPlot.getTrusted())) {

View File

@ -98,7 +98,7 @@ public class Plot {
*
* @deprecated
*/
@Deprecated public UUID owner;
private UUID owner;
/**
* Has the plot changed since the last save cycle?
@ -286,6 +286,34 @@ public class Plot {
return null;
}
/**
* Get the owner of this exact plot, as it is
* stored in the database.
*
* If the plot is a mega-plot, then the method returns
* the owner of this particular subplot.
*
* Unlike {@link #getOwner()} this method does not
* consider factors such as {@link com.github.intellectualsites.plotsquared.plot.flags.implementations.ServerPlotFlag}
* that could alter the de facto owner of the plot.
*
* @return The plot owner of this particular (sub-)plot
* as stored in the database, if one exists. Else, null.
*/
@Nullable public UUID getOwnerAbs() {
return this.owner;
}
/**
* Set the owner of this exact sub-plot. This does
* not update the database.
*
* @param owner The new owner of this particular sub-plot.
*/
public void setOwnerAbs(@Nullable final UUID owner) {
this.owner = owner;
}
public String getWorldName() {
return area.getWorldName();
}
@ -366,7 +394,7 @@ public class Plot {
* @return false if there is no owner
*/
public boolean hasOwner() {
return this.owner != null;
return this.getOwnerAbs() != null;
}
/**
@ -386,7 +414,10 @@ public class Plot {
return connected.stream().anyMatch(current -> uuid.equals(current.getOwner()));
}
public boolean isOwnerAbs(UUID uuid) {
public boolean isOwnerAbs(@Nullable final UUID uuid) {
if (uuid == null) {
return false;
}
return uuid.equals(this.getOwner());
}
@ -395,13 +426,16 @@ public class Plot {
* (Merged plots can have multiple owners)
* Direct access is Deprecated: use getOwners()
*
* @deprecated
* @deprecated A mega-plot may have multiple owners
* and this method only considers the
* owner of this particular sub-plot.
* @see #getOwnerAbs() getOwnerAbs() to get the owner as stored in the database
*/
@Deprecated public UUID getOwner() {
if (MainUtil.isServerOwned(this)) {
return DBFunc.SERVER;
}
return this.owner;
return this.getOwnerAbs();
}
/**
@ -411,20 +445,20 @@ public class Plot {
*/
public void setOwner(UUID owner) {
if (!hasOwner()) {
this.owner = owner;
this.setOwnerAbs(owner);
create();
return;
}
if (!isMerged()) {
if (!this.owner.equals(owner)) {
this.owner = owner;
if (!owner.equals(this.getOwnerAbs())) {
this.setOwnerAbs(owner);
DBFunc.setOwner(this, owner);
}
return;
}
for (Plot current : getConnectedPlots()) {
if (!owner.equals(current.owner)) {
current.owner = owner;
if (!owner.equals(current.getOwnerAbs())) {
current.setOwnerAbs(owner);
DBFunc.setOwner(current, owner);
}
}
@ -467,7 +501,7 @@ public class Plot {
* @return true if the player is added/trusted or is the owner
*/
public boolean isAdded(UUID uuid) {
if (this.owner == null || getDenied().contains(uuid)) {
if (this.getOwnerAbs() == null || getDenied().contains(uuid)) {
return false;
}
if (isOwner(uuid)) {
@ -832,20 +866,20 @@ public class Plot {
*/
public boolean setOwner(UUID owner, PlotPlayer initiator) {
if (!hasOwner()) {
this.owner = owner;
this.setOwnerAbs(owner);
create();
return true;
}
if (!isMerged()) {
if (!this.owner.equals(owner)) {
this.owner = owner;
if (!owner.equals(this.getOwnerAbs())) {
this.setOwnerAbs(owner);
DBFunc.setOwner(this, owner);
}
return true;
}
for (Plot current : getConnectedPlots()) {
if (!owner.equals(current.owner)) {
current.owner = owner;
for (final Plot current : getConnectedPlots()) {
if (!owner.equals(current.getOwnerAbs())) {
current.setOwnerAbs(owner);
DBFunc.setOwner(current, owner);
}
}
@ -891,7 +925,7 @@ public class Plot {
TaskManager.runTask(whenDone);
};
for (Plot current : plots) {
if (isDelete || current.owner == null) {
if (isDelete || current.getOwnerAbs() == null) {
manager.unClaimPlot(current, null);
} else {
manager.claimPlot(current);
@ -1023,7 +1057,7 @@ public class Plot {
if (createSign) {
GlobalBlockQueue.IMP.addEmptyTask(() -> {
for (Plot current : plots) {
current.setSign(MainUtil.getName(current.owner));
current.setSign(MainUtil.getName(current.getOwnerAbs()));
}
});
}
@ -1291,7 +1325,7 @@ public class Plot {
* @return false if the Plot has no owner, otherwise true.
*/
public boolean unclaim() {
if (this.owner == null) {
if (this.getOwnerAbs() == null) {
return false;
}
for (Plot current : getConnectedPlots()) {
@ -1301,7 +1335,7 @@ public class Plot {
}
getArea().removePlot(getId());
DBFunc.delete(current);
current.owner = null;
current.setOwnerAbs(null);
current.settings = null;
for (PlotPlayer pp : players) {
PlotListener.plotEntry(pp, current);
@ -1677,11 +1711,11 @@ public class Plot {
* Sets the plot sign if plot signs are enabled.
*/
public void setSign() {
if (this.owner == null) {
if (this.getOwnerAbs() == null) {
this.setSign("unknown");
return;
}
String name = UUIDHandler.getName(this.owner);
String name = UUIDHandler.getName(this.getOwnerAbs());
if (name == null) {
this.setSign("unknown");
} else {
@ -1771,7 +1805,7 @@ public class Plot {
* @return true if plot was created successfully
*/
public boolean create(@NotNull UUID uuid, final boolean notify) {
this.owner = uuid;
this.setOwnerAbs(uuid);
Plot existing = this.area.getOwnedPlotAbs(this.id);
if (existing != null) {
throw new IllegalStateException("Plot already exists!");
@ -1870,7 +1904,7 @@ public class Plot {
* @return Future containing the result
*/
public CompletableFuture<Boolean> swapData(Plot plot) {
if (this.owner == null) {
if (this.getOwnerAbs() == null) {
if (plot != null && plot.hasOwner()) {
plot.moveData(this, null);
return CompletableFuture.completedFuture(true);
@ -1905,7 +1939,7 @@ public class Plot {
* @return
*/
public boolean moveData(Plot plot, Runnable whenDone) {
if (this.owner == null) {
if (this.getOwnerAbs() == null) {
PlotSquared.debug(plot + " is unowned (single)");
TaskManager.runTask(whenDone);
return false;
@ -2159,7 +2193,7 @@ public class Plot {
} else {
TaskManager.runTaskAsync(() -> {
String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil
.getName(Plot.this.owner);
.getName(Plot.this.getOwnerAbs());
boolean result = SchematicHandler.manager.save(value,
Settings.Paths.SCHEMATICS + File.separator + name + ".schem");
if (whenDone != null) {
@ -2366,7 +2400,7 @@ public class Plot {
*/
public UUID guessOwner() {
if (this.hasOwner()) {
return this.owner;
return this.getOwnerAbs();
}
if (!this.area.allowSigns() || !Settings.Enabled_Components.GUESS_PLOT_OWNER) {
return null;
@ -2400,7 +2434,7 @@ public class Plot {
}
UUID owner = UUIDHandler.getUUID(name, null);
if (owner != null) {
this.owner = owner;
this.setOwnerAbs(owner);
break;
}
if (lines[i - 1].length() == 15) {
@ -2408,19 +2442,19 @@ public class Plot {
for (Entry<StringWrapper, UUID> entry : map.entrySet()) {
String key = entry.getKey().value;
if (key.length() > name.length() && key.startsWith(name)) {
this.owner = entry.getValue();
this.setOwnerAbs(entry.getValue());
break loop;
}
}
}
this.owner = UUID.nameUUIDFromBytes(
("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8));
this.setOwnerAbs(UUID.nameUUIDFromBytes(
("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)));
break;
}
if (this.hasOwner()) {
this.create();
}
return this.owner;
return this.getOwnerAbs();
} catch (IllegalArgumentException ignored) {
return null;
}
@ -2454,7 +2488,7 @@ public class Plot {
*/
public boolean autoMerge(Direction dir, int max, UUID uuid, boolean removeRoads) {
//Ignore merging if there is no owner for the plot
if (this.owner == null) {
if (this.getOwnerAbs() == null) {
return false;
}
Set<Plot> connected = this.getConnectedPlots();
@ -2689,7 +2723,7 @@ public class Plot {
if (!tmp.getMerged(Direction.SOUTH)) {
// invalid merge
PlotSquared.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(this.owner)) {
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.SOUTH, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
@ -2702,10 +2736,11 @@ public class Plot {
}
if (this.getMerged(Direction.EAST)) {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.EAST));
assert tmp != null;
if (!tmp.getMerged(Direction.WEST)) {
// invalid merge
PlotSquared.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(this.owner)) {
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.WEST, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
@ -2718,10 +2753,11 @@ public class Plot {
}
if (this.getMerged(Direction.SOUTH)) {
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.SOUTH));
assert tmp != null;
if (!tmp.getMerged(Direction.NORTH)) {
// invalid merge
PlotSquared.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(this.owner)) {
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.NORTH, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
@ -2737,7 +2773,7 @@ public class Plot {
if (!tmp.getMerged(Direction.EAST)) {
// invalid merge
PlotSquared.debug("Fixing invalid merge: " + this);
if (tmp.isOwnerAbs(this.owner)) {
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
tmp.getSettings().setMerged(Direction.EAST, true);
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
} else {
@ -2750,11 +2786,11 @@ public class Plot {
}
Plot current;
while ((current = frontier.poll()) != null) {
if (current.owner == null || current.settings == null) {
if (current.getOwnerAbs() == null || current.settings == null) {
// Invalid plot
// merged onto unclaimed plot
PlotSquared
.debug("Ignoring invalid merged plot: " + current + " | " + current.owner);
.debug("Ignoring invalid merged plot: " + current + " | " + current.getOwnerAbs());
continue;
}
tmpSet.add(current);
@ -3054,14 +3090,14 @@ public class Plot {
* @return true if the owner of the Plot is online
*/
public boolean isOnline() {
if (this.owner == null) {
if (this.getOwnerAbs() == null) {
return false;
}
if (!isMerged()) {
return UUIDHandler.getPlayer(this.owner) != null;
return UUIDHandler.getPlayer(this.getOwnerAbs()) != null;
}
for (Plot current : getConnectedPlots()) {
if (current.hasOwner() && UUIDHandler.getPlayer(current.owner) != null) {
for (final Plot current : getConnectedPlots()) {
if (current.hasOwner() && UUIDHandler.getPlayer(current.getOwnerAbs()) != null) {
return true;
}
}
@ -3183,7 +3219,7 @@ public class Plot {
Location ob = this.getBottomAbs();
final int offsetX = db.getX() - ob.getX();
final int offsetZ = db.getZ() - ob.getZ();
if (this.owner == null) {
if (this.getOwnerAbs() == null) {
TaskManager.runTaskLater(whenDone, 1);
return CompletableFuture.completedFuture(false);
}
@ -3301,7 +3337,7 @@ public class Plot {
Location ob = this.getBottomAbs();
final int offsetX = db.getX() - ob.getX();
final int offsetZ = db.getZ() - ob.getZ();
if (this.owner == null) {
if (this.getOwnerAbs() == null) {
TaskManager.runTaskLater(whenDone, 1);
return false;
}

View File

@ -503,7 +503,7 @@ public abstract class PlotArea {
}
final HashSet<Plot> myPlots = new HashSet<>();
forEachPlotAbs(value -> {
if (uuid.equals(value.owner)) {
if (uuid.equals(value.getOwnerAbs())) {
myPlots.add(value);
}
});

View File

@ -1,11 +1,14 @@
package com.github.intellectualsites.plotsquared.plot.object;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
import java.util.UUID;
public class PlotHandler {
public static boolean sameOwners(final Plot plot1, final Plot plot2) {
if (plot1.owner == null || plot2.owner == null) {
public static boolean sameOwners(@NotNull final Plot plot1, @NotNull final Plot plot2) {
if (plot1.getOwnerAbs() == null || plot2.getOwnerAbs() == null) {
return false;
}
final Set<UUID> owners = plot1.getOwners();
@ -16,4 +19,5 @@ public class PlotHandler {
}
return false;
}
}

View File

@ -171,7 +171,7 @@ public class SinglePlotArea extends GridPlotWorld {
PlotSettings s = p.getSettings();
final FlagContainer oldContainer = p.getFlagContainer();
p = new SinglePlot(p.getId(), p.owner, p.getTrusted(), p.getMembers(), p.getDenied(),
p = new SinglePlot(p.getId(), p.getOwnerAbs(), p.getTrusted(), p.getMembers(), p.getDenied(),
s.getAlias(), s.getPosition(), null, this, s.getMerged(), p.getTimestamp(), p.temp);
p.getFlagContainer().addAll(oldContainer);

View File

@ -61,7 +61,7 @@ public class UUIDHandler {
final HashSet<UUID> uuids = new HashSet<>();
PlotSquared.get().forEachPlotRaw(plot -> {
if (plot.hasOwner()) {
uuids.add(plot.owner);
uuids.add(plot.getOwnerAbs());
uuids.addAll(plot.getTrusted());
uuids.addAll(plot.getMembers());
uuids.addAll(plot.getDenied());
@ -107,8 +107,8 @@ public class UUIDHandler {
return implementation.getName(uuid);
}
public static PlotPlayer getPlayer(UUID uuid) {
if (implementation == null) {
@Nullable public static PlotPlayer getPlayer(@Nullable final UUID uuid) {
if (implementation == null || uuid == null) {
return null;
}
return check(implementation.getPlayer(uuid));

View File

@ -130,8 +130,8 @@ public abstract class UUIDHandlerImplementation {
UUIDHandlerImplementation.this.unknown.remove(offline);
Set<Plot> plots = PlotSquared.get().getPlotsAbs(offline);
if (!plots.isEmpty()) {
for (Plot plot : plots) {
plot.owner = uuid;
for (final Plot plot : plots) {
plot.setOwnerAbs(uuid);
}
DBFunc.replaceUUID(offline, uuid);
PlotSquared.debug("&cDetected invalid UUID stored for: " + name.value);
@ -152,8 +152,8 @@ public abstract class UUIDHandlerImplementation {
UUIDHandlerImplementation.this.unknown.remove(offlineUpper);
Set<Plot> plots = PlotSquared.get().getPlotsAbs(offlineUpper);
if (!plots.isEmpty()) {
for (Plot plot : plots) {
plot.owner = uuid;
for (final Plot plot : plots) {
plot.setOwnerAbs(uuid);
}
replace(offlineUpper, uuid, name.value);
}
@ -166,8 +166,8 @@ public abstract class UUIDHandlerImplementation {
if (!existing.equals(uuid)) {
Set<Plot> plots = PlotSquared.get().getPlots(existing);
if (!plots.isEmpty()) {
for (Plot plot : plots) {
plot.owner = uuid;
for (final Plot plot : plots) {
plot.setOwnerAbs(uuid);
}
replace(existing, uuid, name.value);
}