mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Add server-plot flag, and option to disable on-claim teleportation
This commit is contained in:
parent
08ebf57c90
commit
ae57264487
@ -217,7 +217,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
}
|
||||
final Plot plot = area.getOwnedPlot(id);
|
||||
if (plot != null) {
|
||||
if (PlotPlayer.wrap(plot.owner) == null) {
|
||||
if (!MainUtil.isServerOwned(plot) || PlotPlayer.wrap(plot.getOwner()) == null) {
|
||||
if (world.getKeepSpawnInMemory()) {
|
||||
world.setKeepSpawnInMemory(false);
|
||||
return;
|
||||
|
@ -156,9 +156,9 @@ import java.util.UUID;
|
||||
// Add any existing plots to the current cluster
|
||||
for (Plot plot : plots) {
|
||||
if (plot.hasOwner()) {
|
||||
if (!cluster.isAdded(plot.owner)) {
|
||||
cluster.invited.add(plot.owner);
|
||||
DBFunc.setInvited(cluster, plot.owner);
|
||||
if (!cluster.isAdded(plot.getOwner())) {
|
||||
cluster.invited.add(plot.getOwner());
|
||||
DBFunc.setInvited(cluster, plot.getOwner());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ import java.util.UUID;
|
||||
}
|
||||
};
|
||||
UUID uuid = player.getUUID();
|
||||
String name = MainUtil.getName(plot.owner);
|
||||
String name = MainUtil.getName(plot.getOwner());
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info",
|
||||
"&cID: &6" + plot.getId().toString(), "&cOwner: &6" + name,
|
||||
"&cAlias: &6" + plot.getAlias(),
|
||||
|
@ -246,7 +246,7 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||
if (plot.owner == null) {
|
||||
if (plot.getOwner() == null) {
|
||||
plots.add(plot);
|
||||
}
|
||||
}
|
||||
@ -259,10 +259,10 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||
if (plot.owner == null) {
|
||||
if (plot.getOwner() == null) {
|
||||
continue;
|
||||
}
|
||||
if (UUIDHandler.getName(plot.owner) == null) {
|
||||
if (UUIDHandler.getName(plot.getOwner()) == null) {
|
||||
plots.add(plot);
|
||||
}
|
||||
}
|
||||
@ -352,7 +352,7 @@ public class ListCmd extends SubCommand {
|
||||
new RunnableVal3<Integer, Plot, PlotMessage>() {
|
||||
@Override public void run(Integer i, Plot plot, PlotMessage message) {
|
||||
String color;
|
||||
if (plot.owner == null) {
|
||||
if (plot.getOwner() == null) {
|
||||
color = "$3";
|
||||
} else if (plot.isOwner(player.getUUID())) {
|
||||
color = "$1";
|
||||
|
@ -670,6 +670,8 @@ public enum Captions {
|
||||
|
||||
NEVER("Never", "Info"), UNKNOWN("Unknown", "Info"),
|
||||
|
||||
SERVER("Server", "Info"),
|
||||
|
||||
EVERYONE("Everyone", "Info"), PLOT_UNOWNED(
|
||||
"$2The current plot must have an owner to perform this action", "Info"),
|
||||
|
||||
|
@ -290,6 +290,7 @@ public class Settings extends Config {
|
||||
public static final class Teleport {
|
||||
@Comment("Teleport to your plot on death") public static boolean ON_DEATH = false;
|
||||
@Comment("Teleport to your plot on login") public static boolean ON_LOGIN = false;
|
||||
@Comment("Teleport to your plot on claim") public static boolean ON_CLAIM = true;
|
||||
@Comment("Add a teleportation delay to all commands") public static int DELAY = 0;
|
||||
@Comment("The visit command is ordered by world instead of globally") public static boolean
|
||||
PER_WORLD_VISIT = false;
|
||||
|
@ -19,6 +19,7 @@ public class DBFunc {
|
||||
*/
|
||||
// TODO: Use this instead. public static final UUID EVERYONE = UUID.fromString("4aa2aaa4-c06b-485c-bc58-186aa1780d9b");
|
||||
public static final UUID EVERYONE = UUID.fromString("1-1-3-3-7");
|
||||
public static final UUID SERVER = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||
|
||||
/**
|
||||
* Abstract Database Manager
|
||||
|
@ -29,6 +29,7 @@ public final class Flags {
|
||||
public static final BooleanFlag TITLES = new BooleanFlag("titles");
|
||||
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
|
||||
public static final BooleanFlag HIDE_INFO = new BooleanFlag("hide-info");
|
||||
public static final BooleanFlag SERVER_PLOT = new BooleanFlag("server-plot");
|
||||
public static final LongFlag TIME = new LongFlag("time");
|
||||
public static final PlotWeatherFlag WEATHER = new PlotWeatherFlag("weather");
|
||||
public static final DoubleFlag PRICE = new DoubleFlag("price") {
|
||||
|
@ -169,7 +169,7 @@ public class PlotListener {
|
||||
replacements.put("%world%", plot.getArea().toString());
|
||||
replacements.put("%greeting%", greeting);
|
||||
replacements.put("%alias", plot.toString());
|
||||
replacements.put("%s", MainUtil.getName(plot.owner));
|
||||
replacements.put("%s", MainUtil.getName(plot.getOwner()));
|
||||
String main = StringMan
|
||||
.replaceFromMap(Captions.TITLE_ENTERED_PLOT.s(), replacements);
|
||||
String sub = StringMan
|
||||
|
@ -53,10 +53,12 @@ public class Plot {
|
||||
private static HashSet<RegionWrapper> regions_cache;
|
||||
|
||||
private final PlotId id;
|
||||
|
||||
/**
|
||||
* plot owner
|
||||
* (Merged plots can have multiple owners)
|
||||
* Direct access is Deprecated: use getOwners()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated public UUID owner;
|
||||
/**
|
||||
@ -324,20 +326,33 @@ public class Plot {
|
||||
* @return if the provided uuid is the owner of the plot
|
||||
*/
|
||||
public boolean isOwner(@Nonnull UUID uuid) {
|
||||
if (uuid.equals(this.owner)) {
|
||||
if (uuid.equals(this.getOwner())) {
|
||||
return true;
|
||||
}
|
||||
if (!isMerged()) {
|
||||
return false;
|
||||
}
|
||||
Set<Plot> connected = getConnectedPlots();
|
||||
return connected.stream().anyMatch(current -> uuid.equals(current.owner));
|
||||
return connected.stream().anyMatch(current -> uuid.equals(current.getOwner()));
|
||||
}
|
||||
|
||||
public boolean isOwnerAbs(UUID uuid) {
|
||||
return uuid.equals(this.owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* plot owner
|
||||
* (Merged plots can have multiple owners)
|
||||
* Direct access is Deprecated: use getOwners()
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated public UUID getOwner() {
|
||||
if (MainUtil.isServerOwned(this)) {
|
||||
return DBFunc.SERVER;
|
||||
}
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
|
||||
* <p>
|
||||
@ -347,25 +362,25 @@ public class Plot {
|
||||
* @return the plot owners
|
||||
*/
|
||||
public Set<UUID> getOwners() {
|
||||
if (this.owner == null) {
|
||||
if (this.getOwner() == null) {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
if (isMerged()) {
|
||||
Set<Plot> plots = getConnectedPlots();
|
||||
Plot[] array = plots.toArray(new Plot[plots.size()]);
|
||||
ImmutableSet.Builder<UUID> owners = ImmutableSet.builder();
|
||||
UUID last = this.owner;
|
||||
owners.add(this.owner);
|
||||
UUID last = this.getOwner();
|
||||
owners.add(this.getOwner());
|
||||
for (Plot current : array) {
|
||||
if (last == null || current.owner.getMostSignificantBits() != last
|
||||
if (last == null || current.getOwner().getMostSignificantBits() != last
|
||||
.getMostSignificantBits()) {
|
||||
owners.add(current.owner);
|
||||
last = current.owner;
|
||||
owners.add(current.getOwner());
|
||||
last = current.getOwner();
|
||||
}
|
||||
}
|
||||
return owners.build();
|
||||
}
|
||||
return ImmutableSet.of(this.owner);
|
||||
return ImmutableSet.of(this.getOwner());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1443,7 +1458,7 @@ public class Plot {
|
||||
}
|
||||
setSign(player.getName());
|
||||
MainUtil.sendMessage(player, Captions.CLAIMED);
|
||||
if (teleport) {
|
||||
if (teleport && Settings.Teleport.ON_CLAIM) {
|
||||
teleportPlayer(player);
|
||||
}
|
||||
PlotArea plotworld = getArea();
|
||||
@ -1579,7 +1594,7 @@ public class Plot {
|
||||
if (plot == null) {
|
||||
this.moveData(plot, whenDone);
|
||||
return true;
|
||||
} else if (plot.owner == null) {
|
||||
} else if (plot.getOwner() == null) {
|
||||
this.moveData(plot, whenDone);
|
||||
return true;
|
||||
}
|
||||
@ -2979,7 +2994,7 @@ public class Plot {
|
||||
// copy data
|
||||
for (Plot plot : plots) {
|
||||
Plot other = plot.getRelative(destination.getArea(), offset.x, offset.y);
|
||||
other.create(plot.owner, false);
|
||||
other.create(plot.getOwner(), false);
|
||||
if (!plot.getFlags().isEmpty()) {
|
||||
other.getSettings().flags = plot.getFlags();
|
||||
DBFunc.setFlags(other, plot.getFlags());
|
||||
|
@ -35,7 +35,7 @@ public class InboxOwner extends CommentInbox {
|
||||
}
|
||||
|
||||
@Override public boolean addComment(Plot plot, PlotComment comment) {
|
||||
if (plot.owner == null) {
|
||||
if (plot.getOwner() == null) {
|
||||
return false;
|
||||
}
|
||||
plot.addComment(comment);
|
||||
|
@ -20,7 +20,7 @@ public class InboxReport extends CommentInbox {
|
||||
}
|
||||
|
||||
@Override public boolean addComment(Plot plot, PlotComment comment) {
|
||||
if (plot.owner == null) {
|
||||
if (plot.getOwner() == null) {
|
||||
return false;
|
||||
}
|
||||
DBFunc.setComment(plot, comment);
|
||||
|
@ -335,6 +335,9 @@ public class MainUtil {
|
||||
if (owner.equals(DBFunc.EVERYONE)) {
|
||||
return Captions.EVERYONE.s();
|
||||
}
|
||||
if (owner.equals(DBFunc.SERVER)) {
|
||||
return Captions.SERVER.s();
|
||||
}
|
||||
String name = UUIDHandler.getName(owner);
|
||||
if (name == null) {
|
||||
return Captions.UNKNOWN.s();
|
||||
@ -342,6 +345,10 @@ public class MainUtil {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static boolean isServerOwned(Plot plot) {
|
||||
return plot.getFlag(Flags.SERVER_PLOT).orElse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the corner locations for a list of regions.
|
||||
*
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.util;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
@ -98,6 +100,9 @@ public class UUIDHandler {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
if (uuid.equals(DBFunc.SERVER)) {
|
||||
return Captions.SERVER.s();
|
||||
}
|
||||
return implementation.getName(uuid);
|
||||
}
|
||||
|
||||
|
@ -160,9 +160,15 @@ public class ExpireManager {
|
||||
applicable.add(et);
|
||||
}
|
||||
}
|
||||
|
||||
if (applicable.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
if (MainUtil.isServerOwned(plot)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
boolean shouldCheckAccountAge = false;
|
||||
|
||||
long diff = getAge(plot);
|
||||
@ -366,12 +372,12 @@ public class ExpireManager {
|
||||
int changes = changed == null ? 0 : changed.changes_sd;
|
||||
int modified = changed == null ? 0 : changed.changes;
|
||||
PlotSquared.debug(
|
||||
"$2[&5Expire&dManager$2] &cDeleted expired plot: " + plot + " User:" + plot.owner
|
||||
"$2[&5Expire&dManager$2] &cDeleted expired plot: " + plot + " User:" + plot.getOwner()
|
||||
+ " Delta:" + changes + "/" + modified + " Connected: " + StringMan
|
||||
.getString(plots));
|
||||
PlotSquared.debug("$4 - Area: " + plot.getArea());
|
||||
if (plot.hasOwner()) {
|
||||
PlotSquared.debug("$4 - Owner: " + UUIDHandler.getName(plot.owner));
|
||||
PlotSquared.debug("$4 - Owner: " + UUIDHandler.getName(plot.getOwner()));
|
||||
} else {
|
||||
PlotSquared.debug("$4 - Owner: Unowned");
|
||||
}
|
||||
@ -406,8 +412,8 @@ public class ExpireManager {
|
||||
}
|
||||
|
||||
public long getAccountAge(Plot plot) {
|
||||
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.owner)
|
||||
|| UUIDHandler.getPlayer(plot.owner) != null || plot.getRunning() > 0) {
|
||||
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.getOwner())
|
||||
|| UUIDHandler.getPlayer(plot.getOwner()) != null || plot.getRunning() > 0) {
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
long max = 0;
|
||||
@ -419,8 +425,8 @@ public class ExpireManager {
|
||||
}
|
||||
|
||||
public long getAge(Plot plot) {
|
||||
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.owner)
|
||||
|| UUIDHandler.getPlayer(plot.owner) != null || plot.getRunning() > 0) {
|
||||
if (!plot.hasOwner() || Objects.equals(DBFunc.EVERYONE, plot.getOwner())
|
||||
|| UUIDHandler.getPlayer(plot.getOwner()) != null || plot.getRunning() > 0) {
|
||||
return 0;
|
||||
}
|
||||
Optional<?> keep = plot.getFlag(Flags.KEEP);
|
||||
|
@ -90,7 +90,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (Settings.Redstone.DISABLE_OFFLINE) {
|
||||
if (UUIDHandler.getPlayer(plot.owner) == null) {
|
||||
if (UUIDHandler.getPlayer(plot.getOwner()) == null) {
|
||||
boolean disable = true;
|
||||
for (UUID trusted : plot.getTrusted()) {
|
||||
if (UUIDHandler.getPlayer(trusted) != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user