From c9b012ea5b079a7f4ad50e0330d9f24efd0fcf26 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sat, 24 Jul 2021 18:01:26 +0200 Subject: [PATCH] Leave a note when using deprecated commands --- .../main/java/com/plotsquared/core/command/Chat.java | 8 +++++++- .../main/java/com/plotsquared/core/command/Save.java | 12 +++++++++++- .../com/plotsquared/core/util/SchematicHandler.java | 2 +- Core/src/main/resources/lang/messages_en.json | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Chat.java b/Core/src/main/java/com/plotsquared/core/command/Chat.java index e230c8cf0..0b5cc37bf 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Chat.java +++ b/Core/src/main/java/com/plotsquared/core/command/Chat.java @@ -28,9 +28,11 @@ package com.plotsquared.core.command; import com.plotsquared.core.configuration.caption.TranslatableCaption; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.PlotArea; +import net.kyori.adventure.text.minimessage.Template; /** - * @deprecated Deprecated in favor of "/plot toggle chat" and scheduled for removal within the next major release. + * @deprecated In favor of "/plot toggle chat" and + * scheduled for removal within the next major release. */ @Deprecated(forRemoval = true) @CommandDeclaration(command = "chat", @@ -44,6 +46,10 @@ public class Chat extends SubCommand { public boolean onCommand(PlotPlayer player, String[] args) { PlotArea area = player.getPlotAreaAbs(); check(area, TranslatableCaption.of("errors.not_in_plot_world")); + player.sendMessage( + TranslatableCaption.of("errors.deprecated_commands"), + Template.of("replacement", "/plot toggle chat") + ); if (player.getPlotAreaAbs().isForcingPlotChat()) { player.sendMessage(TranslatableCaption.of("chat.plot_chat_forced")); return true; diff --git a/Core/src/main/java/com/plotsquared/core/command/Save.java b/Core/src/main/java/com/plotsquared/core/command/Save.java index a49f8fa57..883893f50 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Save.java +++ b/Core/src/main/java/com/plotsquared/core/command/Save.java @@ -39,12 +39,18 @@ import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.TaskManager; +import net.kyori.adventure.text.minimessage.Template; import org.checkerframework.checker.nullness.qual.NonNull; import java.net.URL; import java.util.List; import java.util.UUID; +/** + * @deprecated In favor of "/plot download" (Arkitektonika) and scheduled + * for removal within the next major release. + */ +@Deprecated(forRemoval = true) @CommandDeclaration(command = "save", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, @@ -106,7 +112,7 @@ public class Save extends SubCommand { .replaceAll("[^A-Za-z0-9]", ""); final String file = time + '_' + world1 + '_' + id.getX() + '_' + id.getY() + '_' + size; UUID uuid = player.getUUID(); - schematicHandler.upload(compoundTag, uuid, file, new RunnableVal() { + schematicHandler.upload(compoundTag, uuid, file, new RunnableVal<>() { @Override public void run(URL url) { plot.removeRunning(); @@ -115,6 +121,10 @@ public class Save extends SubCommand { return; } player.sendMessage(TranslatableCaption.of("web.save_success")); + player.sendMessage( + TranslatableCaption.of("errors.deprecated_commands"), + Template.of("replacement", "/plot download") + ); try (final MetaDataAccess> schematicAccess = player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_SCHEMATICS)) { schematicAccess.get().ifPresent(schematics -> schematics.add(file + ".schem")); diff --git a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java index a90834bee..3310395de 100644 --- a/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java +++ b/Core/src/main/java/com/plotsquared/core/util/SchematicHandler.java @@ -526,7 +526,7 @@ public abstract class SchematicHandler { TaskManager.runTask(whenDone); return; } - upload(uuid, file, "schem", new RunnableVal() { + upload(uuid, file, "schem", new RunnableVal<>() { @Override public void run(OutputStream output) { try (NBTOutputStream nos = new NBTOutputStream(new GZIPOutputStream(output, true))) { diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 4910dc8e6..475c82c8f 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -311,6 +311,7 @@ "errors.not_implemented": "Not implemented.", "errors.stacktrace_begin": "=== Begin of stacktrace ===", "errors.stacktrace_end": "=== End of stacktrace ===", + "errors.deprecated_commands": "You are using a deprecated command scheduled for removal within the next major release of PlotSquared. Consider using the proper alternative: ", "debugpaste.latest_log": " is larger than . Please reboot the server and submit a new paste.", "debugpaste.empty_file": "Skipping because it's empty.", "debugpaste.skip_multiverse": "Skipping Multiverse because it's not in use.",