From 600d38d3e283fbc0777f26720e330830b4f717da Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Fri, 2 Apr 2021 17:50:37 +0200 Subject: [PATCH] Add flag placeholders to flag commands --- .../plotsquared/core/command/FlagCommand.java | 16 +++++++++++----- .../java/com/plotsquared/core/command/Music.java | 8 ++++++-- Core/src/main/resources/lang/messages_en.json | 4 ++-- 3 files changed, 19 insertions(+), 9 deletions(-) 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 e3f7b73d3..dcefbed55 100644 --- a/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/FlagCommand.java @@ -352,7 +352,8 @@ public final class FlagCommand extends Command { return; } plot.setFlag(parsed); - player.sendMessage(TranslatableCaption.of("flag.flag_added")); + player.sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", String.valueOf(args[0])), + Template.of("value", String.valueOf(parsed))); } @CommandDeclaration(command = "add", @@ -418,7 +419,8 @@ public final class FlagCommand extends Command { player.sendMessage(TranslatableCaption.of("flag.flag_not_added")); return; } - player.sendMessage(TranslatableCaption.of("flag.flag_added")); + player.sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", String.valueOf(event.getFlag())), + Template.of("value", String.valueOf(event.getFlag().getValue()))); } @CommandDeclaration(command = "remove", @@ -490,14 +492,16 @@ public final class FlagCommand extends Command { if (list.removeAll((List) parsedFlag.getValue())) { if (list.isEmpty()) { if (plot.removeFlag(flag)) { - player.sendMessage(TranslatableCaption.of("flag.flag_removed")); + player.sendMessage(TranslatableCaption.of("flag.flag_removed"), Template.of("flag", String.valueOf(flag)), Template.of( + "value", + String.valueOf(parsedFlag.getValue()) + )); return; } else { player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); return; } } else { - // MainUtil.sendMessage(player, Permission.FLAG_REMOVED); PlotFlag plotFlag = parsedFlag.createFlagInstance(list); PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot); if (addEvent.getEventResult() == Result.DENY) { @@ -526,7 +530,9 @@ public final class FlagCommand extends Command { return; } } - player.sendMessage(TranslatableCaption.of("flag.flag_removed")); + player.sendMessage(TranslatableCaption.of("flag.flag_removed"), Template.of("flag", args[0]), Template.of("value", + String.valueOf(flag) + )); } @CommandDeclaration(command = "list", diff --git a/Core/src/main/java/com/plotsquared/core/command/Music.java b/Core/src/main/java/com/plotsquared/core/command/Music.java index 52d15754a..6ab9250e3 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Music.java +++ b/Core/src/main/java/com/plotsquared/core/command/Music.java @@ -104,7 +104,9 @@ public class Music extends SubCommand { return true; } plot.removeFlag(event.getFlag()); - getPlayer().sendMessage(TranslatableCaption.of("flag.flag_removed")); + getPlayer().sendMessage(TranslatableCaption.of("flag.flag_removed"), Template.of("flag", + String.valueOf(event.getFlag()) + )); } else if (item.getName().toLowerCase(Locale.ENGLISH).contains("disc")) { PlotFlag plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class) .createFlagInstance(item.getType()); @@ -117,7 +119,9 @@ public class Music extends SubCommand { return true; } plot.setFlag(event.getFlag()); - getPlayer().sendMessage(TranslatableCaption.of("flag.flag_added")); + getPlayer().sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", + String.valueOf(event.getFlag()) + ), Template.of("value", String.valueOf(event.getFlag().getValue()))); } else { getPlayer().sendMessage(TranslatableCaption.of("flag.flag_not_added")); } diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index c8381dab4..482f8516b 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -463,9 +463,9 @@ "flag.no_flags": "Global flags: None", "flag.flag_not_removed": "The flag could not be removed.", "flag.flag_not_added": "The flag could not be added.", - "flag.flag_removed": "The flag has been removed successfully.", + "flag.flag_removed": "The flag with the value has been removed successfully.", "flag.flag_partially_removed": "Successfully removed flag value(s).", - "flag.flag_added": "The flag has been added successfully.", + "flag.flag_added": "The flag with the value has been added successfully.", "flag.flag_list_see_info": "Click to view information about the flag.", "flag.flag_parse_error": "Failed to parse flag , value provided . Error: ", "flag.flag_info_header": "--------- PlotSquared Flags ---------",