From 185082f261a7556cde22d04d94ffafdf61f45bcc Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Fri, 4 Jan 2019 21:32:21 +0100 Subject: [PATCH] Improved Island#isSpawn() and Island#setSpawn() Javadoc + improved handling of Island#setSpawn() and added logging to the Island history --- .../bentobox/database/objects/Island.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/database/objects/Island.java b/src/main/java/world/bentobox/bentobox/database/objects/Island.java index 64153bb14..a44bb5629 100644 --- a/src/main/java/world/bentobox/bentobox/database/objects/Island.java +++ b/src/main/java/world/bentobox/bentobox/database/objects/Island.java @@ -407,7 +407,8 @@ public class Island implements DataObject { } /** - * @return spawn + * Returns whether the island is a spawn or not. + * @return {@code true} if the island is a spawn, {@code false} otherwise. */ public boolean isSpawn() { return spawn; @@ -567,10 +568,21 @@ public class Island implements DataObject { } /** - * @param isSpawn - if the island is the spawn + * Sets whether this island is a spawn or not. + *
+ * If {@code true}, the members and the owner will be removed from this island. + * The flags will also be resetted to default values. + * @param isSpawn {@code true} if the island is a spawn, {@code false} otherwise. */ public void setSpawn(boolean isSpawn){ spawn = isSpawn; + if (isSpawn) { + owner = null; + members.clear(); + setFlagsDefaults(); + setFlag(Flags.LOCK, RanksManager.VISITOR_RANK); + } + log(new LogEntry.Builder("SPAWN").data("value", String.valueOf(isSpawn)).build()); } /**