mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Merge pull request #2754 from IntellectualSites/features/v5/owners
Remove all direct access to Plot.owner
This commit is contained in:
commit
f9ea99fa1d
@ -256,9 +256,9 @@ import java.util.UUID;
|
|||||||
MainUtil.sendMessage(player, "&7 - Updating plot objects");
|
MainUtil.sendMessage(player, "&7 - Updating plot objects");
|
||||||
|
|
||||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||||
UUID value = uCMap.get(plot.owner);
|
UUID value = uCMap.get(plot.getOwnerAbs());
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
plot.owner = value;
|
plot.setOwnerAbs(value);
|
||||||
}
|
}
|
||||||
plot.getTrusted().clear();
|
plot.getTrusted().clear();
|
||||||
plot.getMembers().clear();
|
plot.getMembers().clear();
|
||||||
@ -275,9 +275,9 @@ import java.util.UUID;
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
MainUtil.sendMessage(player, "&cConversion failed! Attempting recovery");
|
MainUtil.sendMessage(player, "&cConversion failed! Attempting recovery");
|
||||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||||
UUID value = uCReverse.get(plot.owner);
|
UUID value = uCReverse.get(plot.getOwnerAbs());
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
plot.owner = value;
|
plot.setOwnerAbs(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBFunc.createPlotsAndData(new ArrayList<>(PlotSquared.get().getPlots()),
|
DBFunc.createPlotsAndData(new ArrayList<>(PlotSquared.get().getPlots()),
|
||||||
|
@ -372,8 +372,8 @@ import java.util.zip.ZipInputStream;
|
|||||||
UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE);
|
UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE);
|
||||||
forEachPlotRaw(plot -> {
|
forEachPlotRaw(plot -> {
|
||||||
if (plot.hasOwner() && plot.temp != -1) {
|
if (plot.hasOwner() && plot.temp != -1) {
|
||||||
if (UUIDHandler.getName(plot.owner) == null) {
|
if (UUIDHandler.getName(plot.getOwnerAbs()) == null) {
|
||||||
UUIDHandler.implementation.unknown.add(plot.owner);
|
UUIDHandler.implementation.unknown.add(plot.getOwnerAbs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -761,7 +761,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
} else {
|
} else {
|
||||||
list = new ArrayList<>(input);
|
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;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ public class Auto extends SubCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
whenDone.value = plot;
|
whenDone.value = plot;
|
||||||
plot.owner = player.getUUID();
|
plot.setOwnerAbs(player.getUUID());
|
||||||
DBFunc.createPlotSafe(plot, whenDone,
|
DBFunc.createPlotSafe(plot, whenDone,
|
||||||
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
|
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,8 @@ public class Buy extends Command {
|
|||||||
confirm.run(this, () -> {
|
confirm.run(this, () -> {
|
||||||
Captions.REMOVED_BALANCE.send(player, price);
|
Captions.REMOVED_BALANCE.send(player, price);
|
||||||
EconHandler.manager
|
EconHandler.manager
|
||||||
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
|
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.getOwnerAbs()), price);
|
||||||
PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
PlotPlayer owner = UUIDHandler.getPlayer(plot.getOwnerAbs());
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class Claim extends SubCommand {
|
|||||||
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
|
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border && !force) {
|
||||||
return !sendMessage(player, Captions.BORDER);
|
return !sendMessage(player, Captions.BORDER);
|
||||||
}
|
}
|
||||||
plot.owner = player.getUUID();
|
plot.setOwnerAbs(player.getUUID());
|
||||||
final String finalSchematic = schematic;
|
final String finalSchematic = schematic;
|
||||||
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
|
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||||
@Override public void run(Object value) {
|
@Override public void run(Object value) {
|
||||||
@ -130,7 +130,7 @@ public class Claim extends SubCommand {
|
|||||||
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
|
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
|
||||||
String.format("Failed to claim plot %s", plot.getId().toCommaSeparatedString()));
|
String.format("Failed to claim plot %s", plot.getId().toCommaSeparatedString()));
|
||||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||||
plot.owner = null;
|
plot.setOwnerAbs(null);
|
||||||
} else if (area.isAutoMerge()) {
|
} else if (area.isAutoMerge()) {
|
||||||
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
|
PlotMergeEvent event = PlotSquared.get().getEventDispatcher()
|
||||||
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
.callMerge(plot, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
@ -145,7 +145,7 @@ public class Claim extends SubCommand {
|
|||||||
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
|
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
|
||||||
String.format("Failed to add plot %s to the database", plot.getId().toCommaSeparatedString()));
|
String.format("Failed to add plot %s to the database", plot.getId().toCommaSeparatedString()));
|
||||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||||
plot.owner = null;
|
plot.setOwnerAbs(null);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class Owner extends SetCommand {
|
|||||||
uuid = null;
|
uuid = null;
|
||||||
}
|
}
|
||||||
PlotChangeOwnerEvent event = PlotSquared.get().getEventDispatcher()
|
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());
|
plot.hasOwner());
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Owner change");
|
sendMessage(player, Captions.EVENT_DENIED, "Owner change");
|
||||||
|
@ -146,7 +146,7 @@ public class Purge extends SubCommand {
|
|||||||
if (added != null && !plot.isAdded(added)) {
|
if (added != null && !plot.isAdded(added)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (unknown && UUIDHandler.getName(plot.owner) != null) {
|
if (unknown && UUIDHandler.getName(plot.getOwnerAbs()) != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
toDelete.addAll(plot.getConnectedPlots());
|
toDelete.addAll(plot.getConnectedPlots());
|
||||||
@ -169,7 +169,7 @@ public class Purge extends SubCommand {
|
|||||||
if (added != null && !plot.isAdded(added)) {
|
if (added != null && !plot.isAdded(added)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (unknown && UUIDHandler.getName(plot.owner) != null) {
|
if (unknown && UUIDHandler.getName(plot.getOwnerAbs()) != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
toDelete.add(plot);
|
toDelete.add(plot);
|
||||||
|
@ -743,7 +743,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
stmt.setInt(i * 5 + 1, plot.getId().x);
|
stmt.setInt(i * 5 + 1, plot.getId().x);
|
||||||
stmt.setInt(i * 5 + 2, plot.getId().y);
|
stmt.setInt(i * 5 + 2, plot.getId().y);
|
||||||
try {
|
try {
|
||||||
stmt.setString(i * 5 + 3, plot.owner.toString());
|
stmt.setString(i * 5 + 3, plot.getOwnerAbs().toString());
|
||||||
} catch (SQLException ignored) {
|
} catch (SQLException ignored) {
|
||||||
stmt.setString(i * 5 + 3, everyone.toString());
|
stmt.setString(i * 5 + 3, everyone.toString());
|
||||||
}
|
}
|
||||||
@ -757,7 +757,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
stmt.setInt(i * 6 + 2, plot.getId().x);
|
stmt.setInt(i * 6 + 2, plot.getId().x);
|
||||||
stmt.setInt(i * 6 + 3, plot.getId().y);
|
stmt.setInt(i * 6 + 3, plot.getId().y);
|
||||||
try {
|
try {
|
||||||
stmt.setString(i * 6 + 4, plot.owner.toString());
|
stmt.setString(i * 6 + 4, plot.getOwnerAbs().toString());
|
||||||
} catch (SQLException ignored) {
|
} catch (SQLException ignored) {
|
||||||
stmt.setString(i * 6 + 4, everyone.toString());
|
stmt.setString(i * 6 + 4, everyone.toString());
|
||||||
}
|
}
|
||||||
@ -768,7 +768,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void setSQL(PreparedStatement stmt, Plot plot) throws SQLException {
|
@Override public void setSQL(PreparedStatement stmt, Plot plot) throws SQLException {
|
||||||
stmt.setInt(1, plot.getId().x);
|
stmt.setInt(1, plot.getId().x);
|
||||||
stmt.setInt(2, plot.getId().y);
|
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.setString(4, plot.getArea().toString());
|
||||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||||
|
|
||||||
@ -1007,7 +1007,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setInt(1, plot.getId().x);
|
statement.setInt(1, plot.getId().x);
|
||||||
statement.setInt(2, plot.getId().y);
|
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.setString(4, plot.getArea().toString());
|
||||||
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||||
statement.setString(6, plot.getArea().toString());
|
statement.setString(6, plot.getArea().toString());
|
||||||
@ -1076,7 +1076,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setInt(1, plot.getId().x);
|
statement.setInt(1, plot.getId().x);
|
||||||
statement.setInt(2, plot.getId().y);
|
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.setString(4, plot.getArea().toString());
|
||||||
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
statement.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||||
}
|
}
|
||||||
@ -1381,7 +1381,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void delete(final Plot plot) {
|
@Override public void delete(final Plot plot) {
|
||||||
PlotSquared.debug(
|
PlotSquared.debug(
|
||||||
"Deleting plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
|
"Deleting plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
|
||||||
+ plot.owner + " Index: " + plot.temp);
|
+ plot.getOwnerAbs() + " Index: " + plot.temp);
|
||||||
deleteSettings(plot);
|
deleteSettings(plot);
|
||||||
deleteDenied(plot);
|
deleteDenied(plot);
|
||||||
deleteHelpers(plot);
|
deleteHelpers(plot);
|
||||||
@ -1409,7 +1409,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
@Override public void createPlotSettings(final int id, Plot plot) {
|
@Override public void createPlotSettings(final int id, Plot plot) {
|
||||||
PlotSquared.debug(
|
PlotSquared.debug(
|
||||||
"Creating plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
|
"Creating plot... Id: " + plot.getId() + " World: " + plot.getWorldName() + " Owner: "
|
||||||
+ plot.owner + " Index: " + id);
|
+ plot.getOwnerAbs() + " Index: " + id);
|
||||||
addPlotTask(plot, new UniqueStatement("createPlotSettings") {
|
addPlotTask(plot, new UniqueStatement("createPlotSettings") {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
statement.setInt(1, id);
|
statement.setInt(1, id);
|
||||||
@ -3027,10 +3027,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// owner
|
// owner
|
||||||
if (!plot.owner.equals(dataPlot.owner)) {
|
if (!plot.getOwnerAbs().equals(dataPlot.getOwnerAbs())) {
|
||||||
PlotSquared
|
PlotSquared
|
||||||
.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil.getName(plot.owner));
|
.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil.getName(plot.getOwnerAbs()));
|
||||||
setOwner(plot, plot.owner);
|
setOwner(plot, plot.getOwnerAbs());
|
||||||
}
|
}
|
||||||
// trusted
|
// trusted
|
||||||
if (!plot.getTrusted().equals(dataPlot.getTrusted())) {
|
if (!plot.getTrusted().equals(dataPlot.getTrusted())) {
|
||||||
|
@ -115,16 +115,10 @@ public class Plot {
|
|||||||
private static Set<CuboidRegion> regions_cache;
|
private static Set<CuboidRegion> regions_cache;
|
||||||
|
|
||||||
@NotNull private final PlotId id;
|
@NotNull private final PlotId id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plot owner
|
* Plot flag container
|
||||||
* (Merged plots can have multiple owners)
|
|
||||||
* Direct access is Deprecated: use getOwners()
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
*/
|
||||||
@Deprecated public UUID owner;
|
@Getter private final FlagContainer flagContainer = new FlagContainer(null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has the plot changed since the last save cycle?
|
* Has the plot changed since the last save cycle?
|
||||||
*/
|
*/
|
||||||
@ -138,55 +132,50 @@ public class Plot {
|
|||||||
* @deprecated magical
|
* @deprecated magical
|
||||||
*/
|
*/
|
||||||
@Deprecated public int temp;
|
@Deprecated public int temp;
|
||||||
|
/**
|
||||||
|
* plot owner
|
||||||
|
* (Merged plots can have multiple owners)
|
||||||
|
* Direct access is Deprecated: use getOwners()
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
private UUID owner;
|
||||||
/**
|
/**
|
||||||
* Plot creation timestamp (not accurate if the plot was created before this was implemented)<br>
|
* Plot creation timestamp (not accurate if the plot was created before this was implemented)<br>
|
||||||
* - Milliseconds since the epoch<br>
|
* - Milliseconds since the epoch<br>
|
||||||
*/
|
*/
|
||||||
private long timestamp;
|
private long timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of trusted (with plot permissions).
|
* List of trusted (with plot permissions).
|
||||||
*/
|
*/
|
||||||
private HashSet<UUID> trusted;
|
private HashSet<UUID> trusted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of members users (with plot permissions).
|
* List of members users (with plot permissions).
|
||||||
*/
|
*/
|
||||||
private HashSet<UUID> members;
|
private HashSet<UUID> members;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of denied players.
|
* List of denied players.
|
||||||
*/
|
*/
|
||||||
private HashSet<UUID> denied;
|
private HashSet<UUID> denied;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* External settings class.
|
* External settings class.
|
||||||
* - Please favor the methods over direct access to this class<br>
|
* - Please favor the methods over direct access to this class<br>
|
||||||
* - The methods are more likely to be left unchanged from version changes<br>
|
* - The methods are more likely to be left unchanged from version changes<br>
|
||||||
*/
|
*/
|
||||||
private PlotSettings settings;
|
private PlotSettings settings;
|
||||||
|
|
||||||
private PlotArea area;
|
private PlotArea area;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session only plot metadata (session is until the server stops)<br>
|
* Session only plot metadata (session is until the server stops)<br>
|
||||||
* <br>
|
* <br>
|
||||||
* For persistent metadata use the flag system
|
* For persistent metadata use the flag system
|
||||||
*/
|
*/
|
||||||
private ConcurrentHashMap<String, Object> meta;
|
private ConcurrentHashMap<String, Object> meta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cached origin plot.
|
* The cached origin plot.
|
||||||
* - The origin plot is used for plot grouping and relational data
|
* - The origin plot is used for plot grouping and relational data
|
||||||
*/
|
*/
|
||||||
private Plot origin;
|
private Plot origin;
|
||||||
|
|
||||||
/**
|
|
||||||
* Plot flag container
|
|
||||||
*/
|
|
||||||
@Getter private final FlagContainer flagContainer = new FlagContainer(null);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for a new plot.
|
* Constructor for a new plot.
|
||||||
* (Only changes after plot.create() will be properly set in the database)
|
* (Only changes after plot.create() will be properly set in the database)
|
||||||
@ -311,6 +300,34 @@ public class Plot {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the owner of this exact plot, as it is
|
||||||
|
* stored in the database.
|
||||||
|
* <p>
|
||||||
|
* If the plot is a mega-plot, then the method returns
|
||||||
|
* the owner of this particular subplot.
|
||||||
|
* <p>
|
||||||
|
* 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() {
|
public String getWorldName() {
|
||||||
return area.getWorldName();
|
return area.getWorldName();
|
||||||
}
|
}
|
||||||
@ -391,7 +408,7 @@ public class Plot {
|
|||||||
* @return false if there is no owner
|
* @return false if there is no owner
|
||||||
*/
|
*/
|
||||||
public boolean hasOwner() {
|
public boolean hasOwner() {
|
||||||
return this.owner != null;
|
return this.getOwnerAbs() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -411,22 +428,25 @@ public class Plot {
|
|||||||
return connected.stream().anyMatch(current -> uuid.equals(current.getOwner()));
|
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());
|
return uuid.equals(this.getOwner());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plot owner
|
* Get the plot owner of this particular sub-plot.
|
||||||
* (Merged plots can have multiple owners)
|
* (Merged plots can have multiple owners)
|
||||||
* Direct access is Deprecated: use getOwners()
|
* Direct access is discouraged: use getOwners()
|
||||||
*
|
*
|
||||||
* @deprecated
|
* @see #getOwnerAbs() getOwnerAbs() to get the owner as stored in the database
|
||||||
*/
|
*/
|
||||||
@Deprecated public UUID getOwner() {
|
public UUID getOwner() {
|
||||||
if (MainUtil.isServerOwned(this)) {
|
if (MainUtil.isServerOwned(this)) {
|
||||||
return DBFunc.SERVER;
|
return DBFunc.SERVER;
|
||||||
}
|
}
|
||||||
return this.owner;
|
return this.getOwnerAbs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -436,20 +456,20 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public void setOwner(UUID owner) {
|
public void setOwner(UUID owner) {
|
||||||
if (!hasOwner()) {
|
if (!hasOwner()) {
|
||||||
this.owner = owner;
|
this.setOwnerAbs(owner);
|
||||||
create();
|
create();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isMerged()) {
|
if (!isMerged()) {
|
||||||
if (!this.owner.equals(owner)) {
|
if (!owner.equals(this.getOwnerAbs())) {
|
||||||
this.owner = owner;
|
this.setOwnerAbs(owner);
|
||||||
DBFunc.setOwner(this, owner);
|
DBFunc.setOwner(this, owner);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Plot current : getConnectedPlots()) {
|
for (Plot current : getConnectedPlots()) {
|
||||||
if (!owner.equals(current.owner)) {
|
if (!owner.equals(current.getOwnerAbs())) {
|
||||||
current.owner = owner;
|
current.setOwnerAbs(owner);
|
||||||
DBFunc.setOwner(current, owner);
|
DBFunc.setOwner(current, owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,7 +512,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.owner == null || getDenied().contains(uuid)) {
|
if (!this.hasOwner() || getDenied().contains(uuid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isOwner(uuid)) {
|
if (isOwner(uuid)) {
|
||||||
@ -857,20 +877,20 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public boolean setOwner(UUID owner, PlotPlayer initiator) {
|
public boolean setOwner(UUID owner, PlotPlayer initiator) {
|
||||||
if (!hasOwner()) {
|
if (!hasOwner()) {
|
||||||
this.owner = owner;
|
this.setOwnerAbs(owner);
|
||||||
create();
|
create();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!isMerged()) {
|
if (!isMerged()) {
|
||||||
if (!this.owner.equals(owner)) {
|
if (!owner.equals(this.getOwnerAbs())) {
|
||||||
this.owner = owner;
|
this.setOwnerAbs(owner);
|
||||||
DBFunc.setOwner(this, owner);
|
DBFunc.setOwner(this, owner);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (Plot current : getConnectedPlots()) {
|
for (final Plot current : getConnectedPlots()) {
|
||||||
if (!owner.equals(current.owner)) {
|
if (!owner.equals(current.getOwnerAbs())) {
|
||||||
current.owner = owner;
|
current.setOwnerAbs(owner);
|
||||||
DBFunc.setOwner(current, owner);
|
DBFunc.setOwner(current, owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -916,7 +936,7 @@ public class Plot {
|
|||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
};
|
};
|
||||||
for (Plot current : plots) {
|
for (Plot current : plots) {
|
||||||
if (isDelete || current.owner == null) {
|
if (isDelete || !current.hasOwner()) {
|
||||||
manager.unClaimPlot(current, null);
|
manager.unClaimPlot(current, null);
|
||||||
} else {
|
} else {
|
||||||
manager.claimPlot(current);
|
manager.claimPlot(current);
|
||||||
@ -1048,7 +1068,7 @@ public class Plot {
|
|||||||
if (createSign) {
|
if (createSign) {
|
||||||
GlobalBlockQueue.IMP.addEmptyTask(() -> {
|
GlobalBlockQueue.IMP.addEmptyTask(() -> {
|
||||||
for (Plot current : plots) {
|
for (Plot current : plots) {
|
||||||
current.setSign(MainUtil.getName(current.owner));
|
current.setSign(MainUtil.getName(current.getOwnerAbs()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1079,7 +1099,9 @@ public class Plot {
|
|||||||
"%plr%", name),
|
"%plr%", name),
|
||||||
Captions.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll(
|
Captions.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll(
|
||||||
"%plr%", name)};
|
"%plr%", name)};
|
||||||
WorldUtil.IMP.setSign(this.getWorldName(), location.getX(), location.getY(), location.getZ(), lines);
|
WorldUtil.IMP
|
||||||
|
.setSign(this.getWorldName(), location.getX(), location.getY(), location.getZ(),
|
||||||
|
lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1316,7 +1338,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.owner == null) {
|
if (!this.hasOwner()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (Plot current : getConnectedPlots()) {
|
for (Plot current : getConnectedPlots()) {
|
||||||
@ -1326,7 +1348,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
getArea().removePlot(getId());
|
getArea().removePlot(getId());
|
||||||
DBFunc.delete(current);
|
DBFunc.delete(current);
|
||||||
current.owner = null;
|
current.setOwnerAbs(null);
|
||||||
current.settings = null;
|
current.settings = null;
|
||||||
for (PlotPlayer pp : players) {
|
for (PlotPlayer pp : players) {
|
||||||
PlotListener.plotEntry(pp, current);
|
PlotListener.plotEntry(pp, current);
|
||||||
@ -1359,7 +1381,7 @@ public class Plot {
|
|||||||
WorldUtil.IMP.getHighestBlock(getWorldName(), location.getX(), location.getZ(), y -> {
|
WorldUtil.IMP.getHighestBlock(getWorldName(), location.getX(), location.getZ(), y -> {
|
||||||
int height = y;
|
int height = y;
|
||||||
if (area.allowSigns()) {
|
if (area.allowSigns()) {
|
||||||
height = Math.max(y, getManager().getSignLoc(this).getY());
|
height = Math.max(y, getManager().getSignLoc(this).getY());
|
||||||
}
|
}
|
||||||
location.setY(1 + height);
|
location.setY(1 + height);
|
||||||
result.accept(location);
|
result.accept(location);
|
||||||
@ -1369,8 +1391,7 @@ public class Plot {
|
|||||||
/**
|
/**
|
||||||
* @deprecated May cause synchronous chunk loads
|
* @deprecated May cause synchronous chunk loads
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated public Location getCenterSynchronous() {
|
||||||
public Location getCenterSynchronous() {
|
|
||||||
Location[] corners = getCorners();
|
Location[] corners = getCorners();
|
||||||
Location top = corners[0];
|
Location top = corners[0];
|
||||||
Location bot = corners[1];
|
Location bot = corners[1];
|
||||||
@ -1380,7 +1401,8 @@ public class Plot {
|
|||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
int y = WorldUtil.IMP.getHighestBlockSynchronous(getWorldName(), location.getX(), location.getZ());
|
int y = WorldUtil.IMP
|
||||||
|
.getHighestBlockSynchronous(getWorldName(), location.getX(), location.getZ());
|
||||||
if (area.allowSigns()) {
|
if (area.allowSigns()) {
|
||||||
y = Math.max(y, getManager().getSignLoc(this).getY());
|
y = Math.max(y, getManager().getSignLoc(this).getY());
|
||||||
}
|
}
|
||||||
@ -1391,8 +1413,7 @@ public class Plot {
|
|||||||
/**
|
/**
|
||||||
* @deprecated May cause synchronous chunk loads
|
* @deprecated May cause synchronous chunk loads
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated public Location getSideSynchronous() {
|
||||||
public Location getSideSynchronous() {
|
|
||||||
CuboidRegion largest = getLargestRegion();
|
CuboidRegion largest = getLargestRegion();
|
||||||
int x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1)
|
int x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1)
|
||||||
+ largest.getMinimumPoint().getX();
|
+ largest.getMinimumPoint().getX();
|
||||||
@ -1431,8 +1452,7 @@ public class Plot {
|
|||||||
/**
|
/**
|
||||||
* @deprecated May cause synchronous chunk loading
|
* @deprecated May cause synchronous chunk loading
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated public Location getHomeSynchronous() {
|
||||||
public Location getHomeSynchronous() {
|
|
||||||
BlockLoc home = this.getPosition();
|
BlockLoc home = this.getPosition();
|
||||||
if (home == null || home.getX() == 0 && home.getZ() == 0) {
|
if (home == null || home.getX() == 0 && home.getZ() == 0) {
|
||||||
return this.getDefaultHomeSynchronous(true);
|
return this.getDefaultHomeSynchronous(true);
|
||||||
@ -1446,8 +1466,8 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (!WorldUtil.IMP.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
|
if (!WorldUtil.IMP.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
|
||||||
location.setY(Math.max(1 + WorldUtil.IMP
|
location.setY(Math.max(1 + WorldUtil.IMP
|
||||||
.getHighestBlockSynchronous(this.getWorldName(), location.getX(), location.getZ()),
|
.getHighestBlockSynchronous(this.getWorldName(), location.getX(),
|
||||||
bottom.getY()));
|
location.getZ()), bottom.getY()));
|
||||||
}
|
}
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
@ -1472,11 +1492,11 @@ public class Plot {
|
|||||||
WorldUtil.IMP.getBlock(location, block -> {
|
WorldUtil.IMP.getBlock(location, block -> {
|
||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
WorldUtil.IMP
|
WorldUtil.IMP
|
||||||
.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(), y -> {
|
.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
|
||||||
location.setY(Math.max(1 + y,
|
y -> {
|
||||||
bottom.getY()));
|
location.setY(Math.max(1 + y, bottom.getY()));
|
||||||
result.accept(location);
|
result.accept(location);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
result.accept(location);
|
result.accept(location);
|
||||||
}
|
}
|
||||||
@ -1515,8 +1535,7 @@ public class Plot {
|
|||||||
/**
|
/**
|
||||||
* @deprecated May cause synchronous chunk loads
|
* @deprecated May cause synchronous chunk loads
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated public Location getDefaultHomeSynchronous(final boolean member) {
|
||||||
public Location getDefaultHomeSynchronous(final boolean member) {
|
|
||||||
Plot plot = this.getBasePlot(false);
|
Plot plot = this.getBasePlot(false);
|
||||||
PlotLoc loc = member ? area.getDefaultHome() : area.getNonmemberHome();
|
PlotLoc loc = member ? area.getDefaultHome() : area.getNonmemberHome();
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
@ -1536,7 +1555,9 @@ public class Plot {
|
|||||||
z = bot.getZ() + loc.getZ();
|
z = bot.getZ() + loc.getZ();
|
||||||
}
|
}
|
||||||
int y = loc.getY() < 1 ?
|
int y = loc.getY() < 1 ?
|
||||||
(isLoaded() ? WorldUtil.IMP.getHighestBlockSynchronous(plot.getWorldName(), x, z) + 1 : 63) :
|
(isLoaded() ?
|
||||||
|
WorldUtil.IMP.getHighestBlockSynchronous(plot.getWorldName(), x, z) + 1 :
|
||||||
|
63) :
|
||||||
loc.getY();
|
loc.getY();
|
||||||
return new Location(plot.getWorldName(), x, y, z);
|
return new Location(plot.getWorldName(), x, y, z);
|
||||||
}
|
}
|
||||||
@ -1565,8 +1586,8 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (loc.getY() < 1) {
|
if (loc.getY() < 1) {
|
||||||
if (isLoaded()) {
|
if (isLoaded()) {
|
||||||
WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z, y ->
|
WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z,
|
||||||
result.accept(new Location(plot.getWorldName(), x, y + 1, z)));
|
y -> result.accept(new Location(plot.getWorldName(), x, y + 1, z)));
|
||||||
} else {
|
} else {
|
||||||
result.accept(new Location(plot.getWorldName(), x, 63, z));
|
result.accept(new Location(plot.getWorldName(), x, 63, z));
|
||||||
}
|
}
|
||||||
@ -1702,11 +1723,11 @@ 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.owner == null) {
|
if (!this.hasOwner()) {
|
||||||
this.setSign("unknown");
|
this.setSign("unknown");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String name = UUIDHandler.getName(this.owner);
|
String name = UUIDHandler.getName(this.getOwnerAbs());
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
this.setSign("unknown");
|
this.setSign("unknown");
|
||||||
} else {
|
} else {
|
||||||
@ -1728,8 +1749,8 @@ public class Plot {
|
|||||||
|
|
||||||
public boolean claim(final PlotPlayer player, boolean teleport, String schematic) {
|
public boolean claim(final PlotPlayer player, boolean teleport, String schematic) {
|
||||||
if (!canClaim(player)) {
|
if (!canClaim(player)) {
|
||||||
PlotSquared.debug(Captions.PREFIX.getTranslated() +
|
PlotSquared.debug(Captions.PREFIX.getTranslated() + String
|
||||||
String.format("Player %s attempted to claim plot %s, but was not allowed",
|
.format("Player %s attempted to claim plot %s, but was not allowed",
|
||||||
player.getName(), this.getId().toCommaSeparatedString()));
|
player.getName(), this.getId().toCommaSeparatedString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1741,9 +1762,9 @@ public class Plot {
|
|||||||
|
|
||||||
if (updateDB) {
|
if (updateDB) {
|
||||||
if (!create(player.getUUID(), true)) {
|
if (!create(player.getUUID(), true)) {
|
||||||
PlotSquared.debug(Captions.PREFIX.getTranslated() +
|
PlotSquared.debug(Captions.PREFIX.getTranslated() + String.format(
|
||||||
String.format("Player %s attempted to claim plot %s, but the database failed to update",
|
"Player %s attempted to claim plot %s, but the database failed to update",
|
||||||
player.getName(), this.getId().toCommaSeparatedString()));
|
player.getName(), this.getId().toCommaSeparatedString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1752,7 +1773,8 @@ public class Plot {
|
|||||||
setSign(player.getName());
|
setSign(player.getName());
|
||||||
MainUtil.sendMessage(player, Captions.CLAIMED);
|
MainUtil.sendMessage(player, Captions.CLAIMED);
|
||||||
if (teleport && Settings.Teleport.ON_CLAIM) {
|
if (teleport && Settings.Teleport.ON_CLAIM) {
|
||||||
teleportPlayer(player, TeleportCause.COMMAND, result -> {});
|
teleportPlayer(player, TeleportCause.COMMAND, result -> {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
PlotArea plotworld = getArea();
|
PlotArea plotworld = getArea();
|
||||||
if (plotworld.isSchematicOnClaim()) {
|
if (plotworld.isSchematicOnClaim()) {
|
||||||
@ -1796,7 +1818,7 @@ public class Plot {
|
|||||||
* @return true if plot was created successfully
|
* @return true if plot was created successfully
|
||||||
*/
|
*/
|
||||||
public boolean create(@NotNull UUID uuid, final boolean notify) {
|
public boolean create(@NotNull UUID uuid, final boolean notify) {
|
||||||
this.owner = uuid;
|
this.setOwnerAbs(uuid);
|
||||||
Plot existing = this.area.getOwnedPlotAbs(this.id);
|
Plot existing = this.area.getOwnedPlotAbs(this.id);
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
throw new IllegalStateException("Plot already exists!");
|
throw new IllegalStateException("Plot already exists!");
|
||||||
@ -1829,9 +1851,9 @@ public class Plot {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() +
|
PlotSquared.get().getLogger().log(Captions.PREFIX.getTranslated() + String
|
||||||
String.format("Failed to add plot %s to plot area %s", this.getId().toCommaSeparatedString(),
|
.format("Failed to add plot %s to plot area %s", this.getId().toCommaSeparatedString(),
|
||||||
this.area.toString()));
|
this.area.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1853,17 +1875,17 @@ public class Plot {
|
|||||||
* @return the name of the biome
|
* @return the name of the biome
|
||||||
*/
|
*/
|
||||||
public void getBiome(Consumer<BiomeType> result) {
|
public void getBiome(Consumer<BiomeType> result) {
|
||||||
this.getCenter(location ->
|
this.getCenter(location -> WorldUtil.IMP
|
||||||
WorldUtil.IMP.getBiome(location.getWorld(), location.getX(), location.getZ(), result));
|
.getBiome(location.getWorld(), location.getX(), location.getZ(), result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated May cause synchronous chunk loads
|
* @deprecated May cause synchronous chunk loads
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated public BiomeType getBiomeSynchronous() {
|
||||||
public BiomeType getBiomeSynchronous() {
|
|
||||||
final Location location = this.getCenterSynchronous();
|
final Location location = this.getCenterSynchronous();
|
||||||
return WorldUtil.IMP.getBiomeSynchronous(location.getWorld(), location.getX(), location.getZ());
|
return WorldUtil.IMP
|
||||||
|
.getBiomeSynchronous(location.getWorld(), location.getX(), location.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Better documentation needed.
|
//TODO Better documentation needed.
|
||||||
@ -1891,11 +1913,11 @@ public class Plot {
|
|||||||
/**
|
/**
|
||||||
* Swaps the settings for two plots.
|
* Swaps the settings for two plots.
|
||||||
*
|
*
|
||||||
* @param plot the plot to swap data with
|
* @param plot the plot to swap data with
|
||||||
* @return Future containing the result
|
* @return Future containing the result
|
||||||
*/
|
*/
|
||||||
public CompletableFuture<Boolean> swapData(Plot plot) {
|
public CompletableFuture<Boolean> swapData(Plot plot) {
|
||||||
if (this.owner == 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 +1952,7 @@ public class Plot {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean moveData(Plot plot, Runnable whenDone) {
|
public boolean moveData(Plot plot, Runnable whenDone) {
|
||||||
if (this.owner == 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;
|
||||||
@ -2011,14 +2033,16 @@ public class Plot {
|
|||||||
* - Used when a plot is merged<br>
|
* - Used when a plot is merged<br>
|
||||||
*/
|
*/
|
||||||
public void removeRoadEast() {
|
public void removeRoadEast() {
|
||||||
if (this.area.getType() != PlotAreaType.NORMAL && this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
if (this.area.getType() != PlotAreaType.NORMAL
|
||||||
|
&& this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
||||||
Plot other = this.getRelative(Direction.EAST);
|
Plot other = this.getRelative(Direction.EAST);
|
||||||
Location bot = other.getBottomAbs();
|
Location bot = other.getBottomAbs();
|
||||||
Location top = this.getTopAbs();
|
Location top = this.getTopAbs();
|
||||||
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
|
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
|
||||||
Location pos2 = new Location(this.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ());
|
Location pos2 = new Location(this.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ());
|
||||||
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
||||||
} else if (this.area.getTerrain() != PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
} else if (this.area.getTerrain()
|
||||||
|
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
||||||
this.area.getPlotManager().removeRoadEast(this);
|
this.area.getPlotManager().removeRoadEast(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2184,7 +2208,7 @@ public class Plot {
|
|||||||
} else {
|
} else {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil
|
String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil
|
||||||
.getName(Plot.this.owner);
|
.getName(Plot.this.getOwnerAbs());
|
||||||
boolean result = SchematicHandler.manager.save(value,
|
boolean result = SchematicHandler.manager.save(value,
|
||||||
Settings.Paths.SCHEMATICS + File.separator + name + ".schem");
|
Settings.Paths.SCHEMATICS + File.separator + name + ".schem");
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
@ -2391,7 +2415,7 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public UUID guessOwner() {
|
public UUID guessOwner() {
|
||||||
if (this.hasOwner()) {
|
if (this.hasOwner()) {
|
||||||
return this.owner;
|
return this.getOwnerAbs();
|
||||||
}
|
}
|
||||||
if (!this.area.allowSigns() || !Settings.Enabled_Components.GUESS_PLOT_OWNER) {
|
if (!this.area.allowSigns() || !Settings.Enabled_Components.GUESS_PLOT_OWNER) {
|
||||||
return null;
|
return null;
|
||||||
@ -2425,7 +2449,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
UUID owner = UUIDHandler.getUUID(name, null);
|
UUID owner = UUIDHandler.getUUID(name, null);
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
this.owner = owner;
|
this.setOwnerAbs(owner);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (lines[i - 1].length() == 15) {
|
if (lines[i - 1].length() == 15) {
|
||||||
@ -2433,19 +2457,19 @@ public class Plot {
|
|||||||
for (Entry<StringWrapper, UUID> entry : map.entrySet()) {
|
for (Entry<StringWrapper, UUID> entry : map.entrySet()) {
|
||||||
String key = entry.getKey().value;
|
String key = entry.getKey().value;
|
||||||
if (key.length() > name.length() && key.startsWith(name)) {
|
if (key.length() > name.length() && key.startsWith(name)) {
|
||||||
this.owner = entry.getValue();
|
this.setOwnerAbs(entry.getValue());
|
||||||
break loop;
|
break loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.owner = UUID.nameUUIDFromBytes(
|
this.setOwnerAbs(UUID.nameUUIDFromBytes(
|
||||||
("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8));
|
("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.hasOwner()) {
|
if (this.hasOwner()) {
|
||||||
this.create();
|
this.create();
|
||||||
}
|
}
|
||||||
return this.owner;
|
return this.getOwnerAbs();
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -2456,14 +2480,16 @@ public class Plot {
|
|||||||
* - Used when a plot is merged<br>
|
* - Used when a plot is merged<br>
|
||||||
*/
|
*/
|
||||||
public void removeRoadSouth() {
|
public void removeRoadSouth() {
|
||||||
if (this.area.getType() != PlotAreaType.NORMAL && this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
if (this.area.getType() != PlotAreaType.NORMAL
|
||||||
|
&& this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
||||||
Plot other = this.getRelative(Direction.SOUTH);
|
Plot other = this.getRelative(Direction.SOUTH);
|
||||||
Location bot = other.getBottomAbs();
|
Location bot = other.getBottomAbs();
|
||||||
Location top = this.getTopAbs();
|
Location top = this.getTopAbs();
|
||||||
Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ());
|
Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ());
|
||||||
Location pos2 = new Location(this.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ());
|
Location pos2 = new Location(this.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ());
|
||||||
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
||||||
} else if (this.area.getTerrain() != PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
} else if (this.area.getTerrain()
|
||||||
|
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
||||||
this.getManager().removeRoadSouth(this);
|
this.getManager().removeRoadSouth(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2479,7 +2505,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.owner == null) {
|
if (!this.hasOwner()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<Plot> connected = this.getConnectedPlots();
|
Set<Plot> connected = this.getConnectedPlots();
|
||||||
@ -2632,14 +2658,16 @@ public class Plot {
|
|||||||
* Remove the SE road (only effects terrain)
|
* Remove the SE road (only effects terrain)
|
||||||
*/
|
*/
|
||||||
public void removeRoadSouthEast() {
|
public void removeRoadSouthEast() {
|
||||||
if (this.area.getType() != PlotAreaType.NORMAL && this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
if (this.area.getType() != PlotAreaType.NORMAL
|
||||||
|
&& this.area.getTerrain() == PlotAreaTerrainType.ROAD) {
|
||||||
Plot other = this.getRelative(1, 1);
|
Plot other = this.getRelative(1, 1);
|
||||||
Location pos1 = this.getTopAbs().add(1, 0, 1);
|
Location pos1 = this.getTopAbs().add(1, 0, 1);
|
||||||
Location pos2 = other.getBottomAbs().subtract(1, 0, 1);
|
Location pos2 = other.getBottomAbs().subtract(1, 0, 1);
|
||||||
pos1.setY(0);
|
pos1.setY(0);
|
||||||
pos2.setY(MAX_HEIGHT);
|
pos2.setY(MAX_HEIGHT);
|
||||||
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
||||||
} else if (this.area.getTerrain() != PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
} else if (this.area.getTerrain()
|
||||||
|
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
||||||
this.area.getPlotManager().removeRoadSouthEast(this);
|
this.area.getPlotManager().removeRoadSouthEast(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2714,7 +2742,7 @@ public class Plot {
|
|||||||
if (!tmp.getMerged(Direction.SOUTH)) {
|
if (!tmp.getMerged(Direction.SOUTH)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
PlotSquared.debug("Fixing invalid merge: " + this);
|
||||||
if (tmp.isOwnerAbs(this.owner)) {
|
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
||||||
tmp.getSettings().setMerged(Direction.SOUTH, true);
|
tmp.getSettings().setMerged(Direction.SOUTH, true);
|
||||||
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
||||||
} else {
|
} else {
|
||||||
@ -2727,10 +2755,11 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (this.getMerged(Direction.EAST)) {
|
if (this.getMerged(Direction.EAST)) {
|
||||||
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.EAST));
|
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.EAST));
|
||||||
|
assert tmp != null;
|
||||||
if (!tmp.getMerged(Direction.WEST)) {
|
if (!tmp.getMerged(Direction.WEST)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
PlotSquared.debug("Fixing invalid merge: " + this);
|
||||||
if (tmp.isOwnerAbs(this.owner)) {
|
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
||||||
tmp.getSettings().setMerged(Direction.WEST, true);
|
tmp.getSettings().setMerged(Direction.WEST, true);
|
||||||
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
||||||
} else {
|
} else {
|
||||||
@ -2743,10 +2772,11 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (this.getMerged(Direction.SOUTH)) {
|
if (this.getMerged(Direction.SOUTH)) {
|
||||||
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.SOUTH));
|
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.SOUTH));
|
||||||
|
assert tmp != null;
|
||||||
if (!tmp.getMerged(Direction.NORTH)) {
|
if (!tmp.getMerged(Direction.NORTH)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
PlotSquared.debug("Fixing invalid merge: " + this);
|
||||||
if (tmp.isOwnerAbs(this.owner)) {
|
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
||||||
tmp.getSettings().setMerged(Direction.NORTH, true);
|
tmp.getSettings().setMerged(Direction.NORTH, true);
|
||||||
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
||||||
} else {
|
} else {
|
||||||
@ -2762,7 +2792,7 @@ public class Plot {
|
|||||||
if (!tmp.getMerged(Direction.EAST)) {
|
if (!tmp.getMerged(Direction.EAST)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
PlotSquared.debug("Fixing invalid merge: " + this);
|
||||||
if (tmp.isOwnerAbs(this.owner)) {
|
if (tmp.isOwnerAbs(this.getOwnerAbs())) {
|
||||||
tmp.getSettings().setMerged(Direction.EAST, true);
|
tmp.getSettings().setMerged(Direction.EAST, true);
|
||||||
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
DBFunc.setMerged(tmp, tmp.getSettings().getMerged());
|
||||||
} else {
|
} else {
|
||||||
@ -2775,11 +2805,11 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
Plot current;
|
Plot current;
|
||||||
while ((current = frontier.poll()) != null) {
|
while ((current = frontier.poll()) != null) {
|
||||||
if (current.owner == null || current.settings == null) {
|
if (!current.hasOwner() || current.settings == null) {
|
||||||
// Invalid plot
|
// Invalid plot
|
||||||
// merged onto unclaimed plot
|
// merged onto unclaimed plot
|
||||||
PlotSquared
|
PlotSquared.debug(
|
||||||
.debug("Ignoring invalid merged plot: " + current + " | " + current.owner);
|
"Ignoring invalid merged plot: " + current + " | " + current.getOwnerAbs());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tmpSet.add(current);
|
tmpSet.add(current);
|
||||||
@ -3034,23 +3064,27 @@ public class Plot {
|
|||||||
* @param cause the cause of the teleport
|
* @param cause the cause of the teleport
|
||||||
* @return if the teleport succeeded
|
* @return if the teleport succeeded
|
||||||
*/
|
*/
|
||||||
public void teleportPlayer(final PlotPlayer player, TeleportCause cause, Consumer<Boolean> resultConsumer) {
|
public void teleportPlayer(final PlotPlayer player, TeleportCause cause,
|
||||||
|
Consumer<Boolean> resultConsumer) {
|
||||||
Plot plot = this.getBasePlot(false);
|
Plot plot = this.getBasePlot(false);
|
||||||
Result result =
|
Result result =
|
||||||
PlotSquared.get().getEventDispatcher().callTeleport(player, player.getLocation(), plot).getEventResult();
|
PlotSquared.get().getEventDispatcher().callTeleport(player, player.getLocation(), plot)
|
||||||
|
.getEventResult();
|
||||||
if (result == Result.DENY) {
|
if (result == Result.DENY) {
|
||||||
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
|
sendMessage(player, Captions.EVENT_DENIED, "Teleport");
|
||||||
resultConsumer.accept(false);
|
resultConsumer.accept(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Consumer<Location> locationConsumer = location -> {
|
final Consumer<Location> locationConsumer = location -> {
|
||||||
if (Settings.Teleport.DELAY == 0 || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
if (Settings.Teleport.DELAY == 0 || Permissions
|
||||||
|
.hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||||
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT);
|
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT);
|
||||||
player.teleport(location, cause);
|
player.teleport(location, cause);
|
||||||
resultConsumer.accept(true);
|
resultConsumer.accept(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.TELEPORT_IN_SECONDS, Settings.Teleport.DELAY + "");
|
MainUtil
|
||||||
|
.sendMessage(player, Captions.TELEPORT_IN_SECONDS, Settings.Teleport.DELAY + "");
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
TaskManager.TELEPORT_QUEUE.add(name);
|
TaskManager.TELEPORT_QUEUE.add(name);
|
||||||
TaskManager.runTaskLater(() -> {
|
TaskManager.runTaskLater(() -> {
|
||||||
@ -3079,14 +3113,14 @@ 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.owner == null) {
|
if (!this.hasOwner()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!isMerged()) {
|
if (!isMerged()) {
|
||||||
return UUIDHandler.getPlayer(this.owner) != null;
|
return UUIDHandler.getPlayer(this.getOwnerAbs()) != null;
|
||||||
}
|
}
|
||||||
for (Plot current : getConnectedPlots()) {
|
for (final Plot current : getConnectedPlots()) {
|
||||||
if (current.hasOwner() && UUIDHandler.getPlayer(current.owner) != null) {
|
if (current.hasOwner() && UUIDHandler.getPlayer(current.getOwnerAbs()) != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3103,7 +3137,8 @@ public class Plot {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean setComponent(String component, Pattern blocks) {
|
public boolean setComponent(String component, Pattern blocks) {
|
||||||
PlotComponentSetEvent event = PlotSquared.get().getEventDispatcher().callComponentSet(this, component, blocks);
|
PlotComponentSetEvent event =
|
||||||
|
PlotSquared.get().getEventDispatcher().callComponentSet(this, component, blocks);
|
||||||
component = event.getComponent();
|
component = event.getComponent();
|
||||||
blocks = event.getPattern();
|
blocks = event.getPattern();
|
||||||
return this.getManager().setComponent(this.getId(), component, blocks);
|
return this.getManager().setComponent(this.getId(), component, blocks);
|
||||||
@ -3201,14 +3236,15 @@ public class Plot {
|
|||||||
* @param allowSwap whether to swap plots
|
* @param allowSwap whether to swap plots
|
||||||
* @return success
|
* @return success
|
||||||
*/
|
*/
|
||||||
public CompletableFuture<Boolean> move(final Plot destination, final Runnable whenDone, boolean allowSwap) {
|
public CompletableFuture<Boolean> move(final Plot destination, final Runnable whenDone,
|
||||||
|
boolean allowSwap) {
|
||||||
final PlotId offset = new PlotId(destination.getId().x - this.getId().x,
|
final PlotId offset = new PlotId(destination.getId().x - this.getId().x,
|
||||||
destination.getId().y - this.getId().y);
|
destination.getId().y - this.getId().y);
|
||||||
Location db = destination.getBottomAbs();
|
Location db = destination.getBottomAbs();
|
||||||
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.owner == null) {
|
if (!this.hasOwner()) {
|
||||||
TaskManager.runTaskLater(whenDone, 1);
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
return CompletableFuture.completedFuture(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
}
|
}
|
||||||
@ -3282,7 +3318,8 @@ public class Plot {
|
|||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
if (regions.isEmpty()) {
|
if (regions.isEmpty()) {
|
||||||
Plot plot = destination.getRelative(0, 0);
|
Plot plot = destination.getRelative(0, 0);
|
||||||
Plot originPlot = originArea.getPlotAbs(new PlotId(plot.id.x - offset.x, plot.id.y - offset.y));
|
Plot originPlot = originArea
|
||||||
|
.getPlotAbs(new PlotId(plot.id.x - offset.x, plot.id.y - offset.y));
|
||||||
final Runnable clearDone = () -> {
|
final Runnable clearDone = () -> {
|
||||||
for (final Plot current : plot.getConnectedPlots()) {
|
for (final Plot current : plot.getConnectedPlots()) {
|
||||||
getManager().claimPlot(current);
|
getManager().claimPlot(current);
|
||||||
@ -3326,7 +3363,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.owner == null) {
|
if (!this.hasOwner()) {
|
||||||
TaskManager.runTaskLater(whenDone, 1);
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
final HashSet<Plot> myPlots = new HashSet<>();
|
final HashSet<Plot> myPlots = new HashSet<>();
|
||||||
forEachPlotAbs(value -> {
|
forEachPlotAbs(value -> {
|
||||||
if (uuid.equals(value.owner)) {
|
if (uuid.equals(value.getOwnerAbs())) {
|
||||||
myPlots.add(value);
|
myPlots.add(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -25,20 +25,24 @@
|
|||||||
*/
|
*/
|
||||||
package com.github.intellectualsites.plotsquared.plot.object;
|
package com.github.intellectualsites.plotsquared.plot.object;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlotHandler {
|
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.hasOwner() && plot2.hasOwner())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Set<UUID> owners = plot1.getOwners();
|
final Set<UUID> owners = plot1.getOwners();
|
||||||
for (UUID owner : owners) {
|
for (final UUID owner : owners) {
|
||||||
if (plot2.isOwner(owner)) {
|
if (plot2.isOwner(owner)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
|||||||
PlotSettings s = p.getSettings();
|
PlotSettings s = p.getSettings();
|
||||||
|
|
||||||
final FlagContainer oldContainer = p.getFlagContainer();
|
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);
|
s.getAlias(), s.getPosition(), null, this, s.getMerged(), p.getTimestamp(), p.temp);
|
||||||
p.getFlagContainer().addAll(oldContainer);
|
p.getFlagContainer().addAll(oldContainer);
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class UUIDHandler {
|
|||||||
final HashSet<UUID> uuids = new HashSet<>();
|
final HashSet<UUID> uuids = new HashSet<>();
|
||||||
PlotSquared.get().forEachPlotRaw(plot -> {
|
PlotSquared.get().forEachPlotRaw(plot -> {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
uuids.add(plot.owner);
|
uuids.add(plot.getOwnerAbs());
|
||||||
uuids.addAll(plot.getTrusted());
|
uuids.addAll(plot.getTrusted());
|
||||||
uuids.addAll(plot.getMembers());
|
uuids.addAll(plot.getMembers());
|
||||||
uuids.addAll(plot.getDenied());
|
uuids.addAll(plot.getDenied());
|
||||||
@ -132,8 +132,8 @@ public class UUIDHandler {
|
|||||||
return implementation.getName(uuid);
|
return implementation.getName(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlotPlayer getPlayer(UUID uuid) {
|
@Nullable public static PlotPlayer getPlayer(@Nullable final UUID uuid) {
|
||||||
if (implementation == null) {
|
if (implementation == null || uuid == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return check(implementation.getPlayer(uuid));
|
return check(implementation.getPlayer(uuid));
|
||||||
|
@ -155,8 +155,8 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
UUIDHandlerImplementation.this.unknown.remove(offline);
|
UUIDHandlerImplementation.this.unknown.remove(offline);
|
||||||
Set<Plot> plots = PlotSquared.get().getPlotsAbs(offline);
|
Set<Plot> plots = PlotSquared.get().getPlotsAbs(offline);
|
||||||
if (!plots.isEmpty()) {
|
if (!plots.isEmpty()) {
|
||||||
for (Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
plot.owner = uuid;
|
plot.setOwnerAbs(uuid);
|
||||||
}
|
}
|
||||||
DBFunc.replaceUUID(offline, uuid);
|
DBFunc.replaceUUID(offline, uuid);
|
||||||
PlotSquared.debug("&cDetected invalid UUID stored for: " + name.value);
|
PlotSquared.debug("&cDetected invalid UUID stored for: " + name.value);
|
||||||
@ -177,8 +177,8 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
UUIDHandlerImplementation.this.unknown.remove(offlineUpper);
|
UUIDHandlerImplementation.this.unknown.remove(offlineUpper);
|
||||||
Set<Plot> plots = PlotSquared.get().getPlotsAbs(offlineUpper);
|
Set<Plot> plots = PlotSquared.get().getPlotsAbs(offlineUpper);
|
||||||
if (!plots.isEmpty()) {
|
if (!plots.isEmpty()) {
|
||||||
for (Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
plot.owner = uuid;
|
plot.setOwnerAbs(uuid);
|
||||||
}
|
}
|
||||||
replace(offlineUpper, uuid, name.value);
|
replace(offlineUpper, uuid, name.value);
|
||||||
}
|
}
|
||||||
@ -191,8 +191,8 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
if (!existing.equals(uuid)) {
|
if (!existing.equals(uuid)) {
|
||||||
Set<Plot> plots = PlotSquared.get().getPlots(existing);
|
Set<Plot> plots = PlotSquared.get().getPlots(existing);
|
||||||
if (!plots.isEmpty()) {
|
if (!plots.isEmpty()) {
|
||||||
for (Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
plot.owner = uuid;
|
plot.setOwnerAbs(uuid);
|
||||||
}
|
}
|
||||||
replace(existing, uuid, name.value);
|
replace(existing, uuid, name.value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user