From 6528c60f4d8a8c31f850d71170b0667748a650c7 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Thu, 7 Oct 2021 10:10:00 +0200 Subject: [PATCH] fix: Fix greeting & farewell captions not being used (#3272) * fix: Fix greeting & farewell captions not being used Fixes #3250 * feat: Allow alias in greeting & farewell flag --- .../core/listener/PlotListener.java | 32 ++++++++++++++++--- Core/src/main/resources/lang/messages_en.json | 2 ++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java index 88acfcee6..d92bc2c3c 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java @@ -173,9 +173,21 @@ public class PlotListener { String greeting = plot.getFlag(GreetingFlag.class); if (!greeting.isEmpty()) { if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) { - plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage); + player.sendMessage( + TranslatableCaption.of("flags.greeting_flag_format"), + Template.of("world", plot.getWorldName()), + Template.of("plot_id", plot.getId().toString()), + Template.of("alias", plot.getAlias()), + Template.of("greeting", greeting) + ); } else { - plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendActionBar); + player.sendActionBar( + TranslatableCaption.of("flags.greeting_flag_format"), + Template.of("world", plot.getWorldName()), + Template.of("plot_id", plot.getId().toString()), + Template.of("alias", plot.getAlias()), + Template.of("greeting", greeting) + ); } } @@ -405,9 +417,21 @@ public class PlotListener { String farewell = plot.getFlag(FarewellFlag.class); if (!farewell.isEmpty()) { if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) { - plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage); + player.sendMessage( + TranslatableCaption.of("flags.farewell_flag_format"), + Template.of("world", plot.getWorldName()), + Template.of("plot_id", plot.getId().toString()), + Template.of("alias", plot.getAlias()), + Template.of("farewell", farewell) + ); } else { - plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendActionBar); + player.sendActionBar( + TranslatableCaption.of("flags.farewell_flag_format"), + Template.of("world", plot.getWorldName()), + Template.of("plot_id", plot.getId().toString()), + Template.of("alias", plot.getAlias()), + Template.of("farewell", farewell) + ); } } diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index ded6005a4..9f3864dc3 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -615,6 +615,8 @@ "flags.flag_error_title": "Flag value must be in the format \"A title\" \"The subtitle\".", "flags.area_flags": "Area flags: ", "flags.road_flags": "Road flags: ", + "flags.greeting_flag_format": "[;]: ", + "flags.farewell_flag_format": "[;]: ", "commands.description.add": "Allow a user to build in a plot while the plot owner is online.", "commands.description.alias": "Set the plot alias.", "commands.description.area": "Create a new plot area.",