diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java index 22d0b14b5..e09bedc47 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java @@ -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; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Cluster.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Cluster.java index 6ea60a37e..50e226c33 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Cluster.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Cluster.java @@ -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()); } } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java index 7491d11a4..1bbc3bd93 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Info.java @@ -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(), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java index 725e4ed2b..ff06a036a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java @@ -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() { @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"; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java index abd53533e..5b2ec9ab2 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java @@ -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"), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Settings.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Settings.java index 281e35caf..790306c2c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Settings.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Settings.java @@ -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; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java index 46ede5d3c..abb4dad24 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/DBFunc.java @@ -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 diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java index 06f5991d8..f4be6b5d6 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java @@ -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") { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java index c5cddf740..b3d15736b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java @@ -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 diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index b6971b44f..bb723aef3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -53,10 +53,12 @@ public class Plot { private static HashSet 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 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). *

@@ -347,25 +362,25 @@ public class Plot { * @return the plot owners */ public Set getOwners() { - if (this.owner == null) { + if (this.getOwner() == null) { return ImmutableSet.of(); } if (isMerged()) { Set plots = getConnectedPlots(); Plot[] array = plots.toArray(new Plot[plots.size()]); ImmutableSet.Builder 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()); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/comment/InboxOwner.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/comment/InboxOwner.java index 426a5ab49..29cf003cf 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/comment/InboxOwner.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/comment/InboxOwner.java @@ -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); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/comment/InboxReport.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/comment/InboxReport.java index 7c626d8e1..fa44db6c2 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/comment/InboxReport.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/comment/InboxReport.java @@ -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); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java index fa1a527fd..17366dbbb 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java @@ -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. * diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/UUIDHandler.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/UUIDHandler.java index 6696edbd5..930411c32 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/UUIDHandler.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/UUIDHandler.java @@ -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); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java index c9b75bf67..cf4e025eb 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/expiry/ExpireManager.java @@ -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); diff --git a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/listeners/PlayerEvents.java b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/listeners/PlayerEvents.java index 2d87746d6..c429ba0fd 100644 --- a/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/listeners/PlayerEvents.java +++ b/Nukkit/src/main/java/com/github/intellectualsites/plotsquared/nukkit/listeners/PlayerEvents.java @@ -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) {