extends LocaleHolder { */ void shutdown(); + /** + * Completely shuts down the server. + */ + void shutdownServer(); + /** * Get the name of the plugin * @@ -279,6 +285,16 @@ public interface PlotPlatform
extends LocaleHolder { return injector().getInstance(ChunkManager.class); } + /** + * Get the {@link ExpireManager} implementation for the platform + * + * @return Expire manager + * @since 6.10.2 + */ + default @NonNull ExpireManager expireManager() { + return injector().getInstance(ExpireManager.class); + } + /** * Get the {@link PlotAreaManager} implementation. * @@ -308,7 +324,7 @@ public interface PlotPlatform
extends LocaleHolder {
* @return worldedit implementations
* @since 6.3.0
*/
- @AnnotationHelper.ApiDescription(info = "Internal use only")
+ @DoNotUse
@NonNull String worldEditImplementations();
/**
diff --git a/Core/src/main/java/com/plotsquared/core/PlotSquared.java b/Core/src/main/java/com/plotsquared/core/PlotSquared.java
index b717a470d..3898e8a61 100644
--- a/Core/src/main/java/com/plotsquared/core/PlotSquared.java
+++ b/Core/src/main/java/com/plotsquared/core/PlotSquared.java
@@ -197,6 +197,9 @@ public class PlotSquared {
this.loadCaptionMap();
} catch (final Exception e) {
LOGGER.error("Failed to load caption map", e);
+ LOGGER.error("Shutting down server to prevent further issues");
+ this.platform.shutdownServer();
+ throw new RuntimeException("Abort loading PlotSquared");
}
// Setup the global flag container
@@ -267,7 +270,7 @@ public class PlotSquared {
captionMap = this.captionLoader.loadAll(this.platform.getDirectory().toPath().resolve("lang"));
} else {
String fileName = "messages_" + Settings.Enabled_Components.DEFAULT_LOCALE + ".json";
- captionMap = this.captionLoader.loadSingle(this.platform.getDirectory().toPath().resolve("lang").resolve(fileName));
+ captionMap = this.captionLoader.loadOrCreateSingle(this.platform.getDirectory().toPath().resolve("lang").resolve(fileName));
}
this.captionMaps.put(TranslatableCaption.DEFAULT_NAMESPACE, captionMap);
LOGGER.info(
@@ -287,11 +290,11 @@ public class PlotSquared {
public void startExpiryTasks() {
if (Settings.Enabled_Components.PLOT_EXPIRY) {
- ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
- ExpireManager.IMP.runAutomatedTask();
+ ExpireManager expireManager = PlotSquared.platform().expireManager();
+ expireManager.runAutomatedTask();
for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) {
ExpiryTask task = new ExpiryTask(settings, this.getPlotAreaManager());
- ExpireManager.IMP.addTask(task);
+ expireManager.addTask(task);
}
}
}
@@ -642,7 +645,8 @@ public class PlotSquared {
} else {
list = new ArrayList<>(input);
}
- list.sort(Comparator.comparingLong(a -> ExpireManager.IMP.getTimestamp(a.getOwnerAbs())));
+ ExpireManager expireManager = PlotSquared.platform().expireManager();
+ list.sort(Comparator.comparingLong(a -> expireManager.getTimestamp(a.getOwnerAbs())));
return list;
}
diff --git a/Core/src/main/java/com/plotsquared/core/command/Auto.java b/Core/src/main/java/com/plotsquared/core/command/Auto.java
index 08bb7731a..18aa8166a 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Auto.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Auto.java
@@ -254,6 +254,7 @@ public class Auto extends SubCommand {
TranslatableCaption.of("permission.no_permission"),
TagResolver.resolver("node", Tag.inserting(Permission.PERMISSION_AUTO_MEGA))
);
+ return false;
}
if (!force && sizeX * sizeZ > Settings.Claim.MAX_AUTO_AREA) {
player.sendMessage(
diff --git a/Core/src/main/java/com/plotsquared/core/command/Buy.java b/Core/src/main/java/com/plotsquared/core/command/Buy.java
index 922d95f90..49222b66d 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Buy.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Buy.java
@@ -132,6 +132,7 @@ public class Buy extends Command {
plot.removeFlag(event.getFlag());
}
plot.setOwner(player.getUUID());
+ plot.getPlotModificationManager().setSign(player.getName());
player.sendMessage(
TranslatableCaption.of("working.claimed"),
TagResolver.resolver("plot", Tag.inserting(Component.text(plot.getId().toString())))
diff --git a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java
index 4aaa625d4..5d24194c0 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java
@@ -184,7 +184,7 @@ public class DatabaseCommand extends SubCommand {
);
worldFile.renameTo(newFile);
}
- plot.setId(newId.copy());
+ plot.setId(newId);
plot.setArea(pa);
plots.add(plot);
continue;
diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java
index ef55893fb..214b1474e 100644
--- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java
+++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java
@@ -19,6 +19,7 @@
package com.plotsquared.core.command;
import com.google.inject.Inject;
+import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.events.PlotFlagRemoveEvent;
@@ -143,10 +144,7 @@ public class DebugExec extends SubCommand {
return true;
}
case "start-expire" -> {
- if (ExpireManager.IMP == null) {
- ExpireManager.IMP = new ExpireManager(this.eventDispatcher);
- }
- if (ExpireManager.IMP.runAutomatedTask()) {
+ if (PlotSquared.platform().expireManager().runAutomatedTask()) {
player.sendMessage(TranslatableCaption.of("debugexec.expiry_started"));
} else {
player.sendMessage(TranslatableCaption.of("debugexec.expiry_already_started"));
@@ -154,7 +152,7 @@ public class DebugExec extends SubCommand {
return true;
}
case "stop-expire" -> {
- if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) {
+ if (!PlotSquared.platform().expireManager().cancelTask()) {
player.sendMessage(TranslatableCaption.of("debugexec.task_halted"));
} else {
player.sendMessage(TranslatableCaption.of("debugexec.task_cancelled"));
diff --git a/Core/src/main/java/com/plotsquared/core/command/Done.java b/Core/src/main/java/com/plotsquared/core/command/Done.java
index 1c0c6fc5f..39054ede6 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Done.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Done.java
@@ -19,6 +19,7 @@
package com.plotsquared.core.command;
import com.google.inject.Inject;
+import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.events.PlotDoneEvent;
@@ -29,7 +30,6 @@ import com.plotsquared.core.location.Location;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
-import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.expiration.PlotAnalysis;
import com.plotsquared.core.plot.flag.PlotFlag;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
@@ -96,7 +96,7 @@ public class Done extends SubCommand {
TagResolver.resolver("plot", Tag.inserting(Component.text(plot.getId().toString())))
);
final Settings.Auto_Clear doneRequirements = Settings.AUTO_CLEAR.get("done");
- if (ExpireManager.IMP == null || doneRequirements == null) {
+ if (PlotSquared.platform().expireManager() == null || doneRequirements == null) {
finish(plot, player, true);
plot.removeRunning();
} else {
diff --git a/Core/src/main/java/com/plotsquared/core/command/Download.java b/Core/src/main/java/com/plotsquared/core/command/Download.java
index 64c124896..ce3cf43f2 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Download.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Download.java
@@ -192,6 +192,7 @@ public class Download extends SubCommand {
schematicHandler.upload(compoundTag, null, null, new RunnableVal<>() {
@Override
public void run(URL value) {
+ plot.removeRunning();
player.sendMessage(
TranslatableCaption.of("web.generation_link_success"),
TagResolver.builder()
diff --git a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java
index 80c7f8a22..49d8f3d79 100644
--- a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java
+++ b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java
@@ -486,6 +486,7 @@ public final class FlagCommand extends Command {
return;
}
final Plot plot = player.getLocation().getPlotAbs();
+ final PlotFlag, ?> flagWithOldValue = plot.getFlagContainer().getFlag(flag.getClass());
PlotFlagRemoveEvent event = eventDispatcher.callFlagRemove(flag, plot);
if (event.getEventResult() == Result.DENY) {
player.sendMessage(
diff --git a/Core/src/main/java/com/plotsquared/core/command/Grant.java b/Core/src/main/java/com/plotsquared/core/command/Grant.java
index cdd9d4741..c82e0be6c 100644
--- a/Core/src/main/java/com/plotsquared/core/command/Grant.java
+++ b/Core/src/main/java/com/plotsquared/core/command/Grant.java
@@ -32,7 +32,6 @@ import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3;
-import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
@@ -42,6 +41,7 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
@@ -90,8 +90,8 @@ public class Grant extends Command {
TagResolver.resolver("value", Tag.inserting(Component.text(String.valueOf(uuids))))
);
} else {
- final UUIDMapping uuid = uuids.toArray(new UUIDMapping[0])[0];
- PlotPlayer> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuid.getUuid());
+ final UUID uuid = uuids.iterator().next();
+ PlotPlayer> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuid);
if (pp != null) {
try (final MetaDataAccess implements CommandCaller, OfflinePlotPlayer,
LOGGER.info("Plot {} was deleted + cleared due to {} getting banned", owned.getId(), getName());
}
}
- if (ExpireManager.IMP != null) {
- ExpireManager.IMP.storeDate(getUUID(), System.currentTimeMillis());
+ if (PlotSquared.platform().expireManager() != null) {
+ PlotSquared.platform().expireManager().storeDate(getUUID(), System.currentTimeMillis());
}
PlotSquared.platform().playerManager().removePlayer(this);
PlotSquared.platform().unregister(this);
@@ -1017,6 +1016,14 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer,
return this.lockRepository;
}
+ /**
+ * Removes any effects present of the given type.
+ *
+ * @param name the name of the type to remove
+ * @since 6.10.0
+ */
+ public abstract void removeEffect(@NonNull String name);
+
@FunctionalInterface
public interface PlotPlayerConverter
* - This will respect * nodes and plots.admin and can be used to check permission ranges (e.g. plots.plot.5)
* - Checking the PlotPlayer class directly will not take the above into account
+ *
+ * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
+ * classes
*/
+@Deprecated(forRemoval = true, since = "6.9.3")
public class Permissions {
+ /**
+ * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
+ * classes
+ */
+ @Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(PlotPlayer> player, Permission permission, boolean notify) {
return hasPermission(player, permission.toString(), notify);
}
@@ -45,18 +54,25 @@ public class Permissions {
* @param caller permission holder
* @param permission Permission
* @return {@code true} if the owner has the given permission, else {@code false}
+ * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
+ * classes
*/
+ @Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull Permission permission) {
return caller.hasPermission(permission.toString());
}
/**
- * Check if the owner of the profile has a given (global) permission
+ * Check if the owner of the profile has a given (global) permission. There is no guarantee that per-world permissions will
+ * be checked because unmaintained crap plugins like PEX exist.
*
* @param caller permission holder
* @param permission Permission
* @return {@code true} if the owner has the given permission, else {@code false}
+ * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
+ * classes
*/
+ @Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull String permission) {
return caller.hasPermission(permission);
}
@@ -70,7 +86,10 @@ public class Permissions {
* @param key Permission "key"
* @return {@code true} if the owner has the given permission, else {@code false}
* @since 6.0.10
+ * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
+ * classes
*/
+ @Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasKeyedPermission(
final @NonNull PermissionHolder caller, final @NonNull String permission,
final @NonNull String key
@@ -85,7 +104,10 @@ public class Permissions {
* @param permission permission
* @param notify if to notify the permission holder
* @return if permission is had
+ * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
+ * classes
*/
+ @Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(PlotPlayer> player, String permission, boolean notify) {
if (!hasPermission(player, permission)) {
if (notify) {
@@ -99,6 +121,11 @@ public class Permissions {
return true;
}
+ /**
+ * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
+ * classes
+ */
+ @Deprecated(forRemoval = true, since = "6.9.3")
public static int hasPermissionRange(PlotPlayer> player, Permission Permission, int range) {
return hasPermissionRange(player, Permission.toString(), range);
}
@@ -112,7 +139,10 @@ public class Permissions {
* @param stub The permission stub to check e.g. for `plots.plot.#` the stub is `plots.plot`
* @param range The range to check
* @return The highest permission they have within that range
+ * @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
+ * classes
*/
+ @Deprecated(forRemoval = true, since = "6.9.3")
public static int hasPermissionRange(PlotPlayer> player, String stub, int range) {
return player.hasPermissionRange(stub, range);
}
diff --git a/Core/src/main/java/com/plotsquared/core/util/PlotFlagUtil.java b/Core/src/main/java/com/plotsquared/core/util/PlotFlagUtil.java
new file mode 100644
index 000000000..d66339336
--- /dev/null
+++ b/Core/src/main/java/com/plotsquared/core/util/PlotFlagUtil.java
@@ -0,0 +1,53 @@
+/*
+ * PlotSquared, a land and world management plugin for Minecraft.
+ * Copyright (C) IntellectualSites ",
"flags.flag_error_integer": "Flag value must be a whole positive number.",
diff --git a/Core/src/test/java/com/plotsquared/core/plot/FlagTest.java b/Core/src/test/java/com/plotsquared/core/plot/FlagTest.java
index d1a7b2797..9b02f34da 100644
--- a/Core/src/test/java/com/plotsquared/core/plot/FlagTest.java
+++ b/Core/src/test/java/com/plotsquared/core/plot/FlagTest.java
@@ -101,7 +101,7 @@ public class FlagTest {
public void shouldSuccessfullyParseTitleFlagWithTitleEmptyAndSubTitleSingleWord() {
Assertions.assertDoesNotThrow(() -> {
var title = PlotTitleFlag.TITLE_FLAG_DEFAULT.parse("\"\" \"single\"").getValue();
- Assertions.assertEquals(" ", title.title());
+ Assertions.assertEquals("", title.title());
Assertions.assertEquals("single", title.subtitle());
}, "Should not throw a FlagParseException");
}
diff --git a/Core/src/test/java/com/plotsquared/core/util/StringManTest.java b/Core/src/test/java/com/plotsquared/core/util/StringManTest.java
index 8c1eb2aa1..14927ce42 100644
--- a/Core/src/test/java/com/plotsquared/core/util/StringManTest.java
+++ b/Core/src/test/java/com/plotsquared/core/util/StringManTest.java
@@ -32,7 +32,9 @@ public class StringManTest {
new Message("title", List.of("title")),
new Message("title \"sub title\"", List.of("title", "sub title")),
new Message("\"a title\" subtitle", List.of("a title", "subtitle")),
- new Message("\"title\" \"subtitle\"", List.of("title", "subtitle"))
+ new Message("\"title\" \"subtitle\"", List.of("title", "subtitle")),
+ new Message("\"How