Leave a note when using deprecated commands

This commit is contained in:
NotMyFault 2021-07-24 18:01:26 +02:00
parent 9dd35e87d6
commit c9b012ea5b
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
4 changed files with 20 additions and 3 deletions

View File

@ -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;

View File

@ -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<URL>() {
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<List<String>> schematicAccess =
player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_SCHEMATICS)) {
schematicAccess.get().ifPresent(schematics -> schematics.add(file + ".schem"));

View File

@ -526,7 +526,7 @@ public abstract class SchematicHandler {
TaskManager.runTask(whenDone);
return;
}
upload(uuid, file, "schem", new RunnableVal<OutputStream>() {
upload(uuid, file, "schem", new RunnableVal<>() {
@Override
public void run(OutputStream output) {
try (NBTOutputStream nos = new NBTOutputStream(new GZIPOutputStream(output, true))) {

View File

@ -311,6 +311,7 @@
"errors.not_implemented": "<prefix><red>Not implemented.</red>",
"errors.stacktrace_begin": "<red>=== Begin of stacktrace ===</red>",
"errors.stacktrace_end": "<red>=== End of stacktrace ===</red>",
"errors.deprecated_commands": "<prefix><red>You are using a deprecated command scheduled for removal within the next major release of PlotSquared. Consider using the proper alternative: <red><gold><replacement></gold>",
"debugpaste.latest_log": "<red><file> is larger than <size>. Please reboot the server and submit a new paste.",
"debugpaste.empty_file": "<red>Skipping <file> because it's empty.",
"debugpaste.skip_multiverse": "<red>Skipping Multiverse <file> because it's not in use.",