Move notification-as-actionbar into the Chat config block

- Move titles alongside all its new options into its own config block
- Move `titles-as-actionbar` into the new titles block
- Enhance notification about removed config entries
This commit is contained in:
NotMyFault 2021-05-24 21:52:27 +02:00
parent 1d2aa74e51
commit 6f263735f0
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
4 changed files with 40 additions and 34 deletions

View File

@ -287,7 +287,10 @@ public class Config {
setAccessible(field); setAccessible(field);
return field; return field;
} catch (final Throwable e) { } catch (final Throwable e) {
logger.error("Invalid config field: {} for {}", logger.error("Invalid config field: {} for {}. It's likely you are in the process of updating from an older major " +
"release of PlotSquared. The entries named can be removed safely from the settings.yml. They are " +
"likely no longer in use, moved to a different location or have been merged with other " +
"configuration options. Check the changelog for more information.",
StringMan.join(split, "."), toNodeName(instance.getClass().getSimpleName()) StringMan.join(split, "."), toNodeName(instance.getClass().getSimpleName())
); );
e.printStackTrace(); e.printStackTrace();

View File

@ -47,17 +47,6 @@ public class Settings extends Config {
@Comment({"Show additional information in console. It helps us at IntellectualSites to find out more about an issue.", @Comment({"Show additional information in console. It helps us at IntellectualSites to find out more about an issue.",
"Leave it off if you don't need it, it can spam your console."}) "Leave it off if you don't need it, it can spam your console."})
public static boolean DEBUG = true; public static boolean DEBUG = true;
@Comment({"The big text that appears when you enter a plot.",
"For a single plot set `/plot flag set titles false` to disable it.", "For just you run `/plot toggle titles` to disable it.",
"For all plots: Add `titles: false` in the worlds.yml flags block to disable it."})
public static boolean
TITLES = true;
@Comment("Plot titles fading in (duration in ticks)")
public static int TITLES_FADE_IN = 10;
@Comment("Plot titles being shown (duration in ticks)")
public static int TITLES_STAY = 50;
@Comment("Plot titles fading out (duration in ticks)")
public static int TITLES_FADE_OUT = 20;
@Create // This value will be generated automatically @Create // This value will be generated automatically
public static ConfigBlock<Auto_Clear> AUTO_CLEAR = null; public static ConfigBlock<Auto_Clear> AUTO_CLEAR = null;
@ -153,9 +142,6 @@ public class Settings extends Config {
config.getStringList("ratings.categories") : config.getStringList("ratings.categories") :
Ratings.CATEGORIES; Ratings.CATEGORIES;
// Titles
TITLES = config.getBoolean("titles", TITLES);
// Update Notifications // Update Notifications
Enabled_Components.UPDATE_NOTIFICATIONS = Enabled_Components.UPDATE_NOTIFICATIONS =
config.getBoolean("update-notifications", Enabled_Components.UPDATE_NOTIFICATIONS); config.getBoolean("update-notifications", Enabled_Components.UPDATE_NOTIFICATIONS);
@ -508,6 +494,10 @@ public class Settings extends Config {
@Comment("Should the plot chat be logged to console?") @Comment("Should the plot chat be logged to console?")
public static boolean LOG_PLOTCHAT_TO_CONSOLE = true; public static boolean LOG_PLOTCHAT_TO_CONSOLE = true;
@Comment({"Whether an action bar message should be send over a chat message for notification purposes such for the ",
"notify-enter, notify-leave, greeting or farewell flag."})
public static boolean NOTIFICATION_AS_ACTIONBAR = false;
} }
@ -676,6 +666,27 @@ public class Settings extends Config {
} }
@Comment("Settings related to plot titles")
public static final class Titles {
@Comment({"The big text that appears when you enter a plot.",
"For a single plot set `/plot flag set titles false` to disable it.", "For just you run `/plot toggle titles` to disable it.",
"For all plots: Add `titles: false` in the worlds.yml flags block to disable it."})
public static boolean DISPLAY_TITLES = true;
@Comment("Plot titles fading in (duration in ticks)")
public static int TITLES_FADE_IN = 10;
@Comment("Plot titles being shown (duration in ticks)")
public static int TITLES_STAY = 50;
@Comment("Plot titles fading out (duration in ticks)")
public static int TITLES_FADE_OUT = 20;
@Comment({"Changes the notification method on plot entry from Title + SubTitle -> ActionBar.",
"The message still sent to the player is pulled from the lang key \"titles.title_entered_plot\".",
"If you would like to still show the owner of the plot, append the contents of \"titles.title_entered_plot_sub\" onto the " +
"former lang key."})
public static boolean TITLES_AS_ACTIONBAR = false;
}
@Comment({"Enable or disable parts of the plugin", @Comment({"Enable or disable parts of the plugin",
"Note: A cache will use some memory if enabled"}) "Note: A cache will use some memory if enabled"})
@ -732,7 +743,7 @@ public class Settings extends Config {
public static boolean EXTERNAL_PLACEHOLDERS = true; public static boolean EXTERNAL_PLACEHOLDERS = true;
@Comment("Make road regeneration persistent across restarts") @Comment("Make road regeneration persistent across restarts")
public static boolean public static boolean
PERSISTENT_ROAD_REGEN = false; PERSISTENT_ROAD_REGEN = true;
@Comment({"Enable the `/plot component` preset GUI", @Comment({"Enable the `/plot component` preset GUI",
"Read more about components here: https://github.com/IntellectualSites/PlotSquared/wiki/Plot-Components"}) "Read more about components here: https://github.com/IntellectualSites/PlotSquared/wiki/Plot-Components"})
public static boolean COMPONENT_PRESETS = true; public static boolean COMPONENT_PRESETS = true;
@ -758,14 +769,6 @@ public class Settings extends Config {
); );
@Comment("Whether PlotSquared should hook into MvDWPlaceholderAPI or not") @Comment("Whether PlotSquared should hook into MvDWPlaceholderAPI or not")
public static boolean USE_MVDWAPI = true; public static boolean USE_MVDWAPI = true;
@Comment({"Changes the notification method on plot entry from Title + SubTitle -> ActionBar.",
"The message still sent to the player is pulled from the lang key \"titles.title_entered_plot\".",
"If you would like to still show the owner of the plot, append the contents of \"titles.title_entered_plot_sub\" onto the " +
"former lang key."})
public static boolean TITLES_AS_ACTIONBAR = false;
@Comment({"Whether an action bar message should be send over a chat message for notification purposes such for the ",
"notify-enter, notify-leave, greeting or farewell flag."})
public static boolean NOTIFICATION_AS_ACTIONBAR = false;
} }

View File

@ -164,14 +164,14 @@ public class PlotListener {
final TitlesFlag.TitlesFlagValue titleFlag = plot.getFlag(TitlesFlag.class); final TitlesFlag.TitlesFlagValue titleFlag = plot.getFlag(TitlesFlag.class);
final boolean titles; final boolean titles;
if (titleFlag == TitlesFlag.TitlesFlagValue.NONE) { if (titleFlag == TitlesFlag.TitlesFlagValue.NONE) {
titles = Settings.TITLES; titles = Settings.Titles.DISPLAY_TITLES;
} else { } else {
titles = titleFlag == TitlesFlag.TitlesFlagValue.TRUE; titles = titleFlag == TitlesFlag.TitlesFlagValue.TRUE;
} }
final String greeting = plot.getFlag(GreetingFlag.class); final String greeting = plot.getFlag(GreetingFlag.class);
if (!greeting.isEmpty()) { if (!greeting.isEmpty()) {
if (!Settings.Enabled_Components.NOTIFICATION_AS_ACTIONBAR) { if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage); plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
} else { } else {
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendActionBar); plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendActionBar);
@ -186,7 +186,7 @@ public class PlotListener {
Caption caption = TranslatableCaption.of("notification.notify_enter"); Caption caption = TranslatableCaption.of("notification.notify_enter");
Template playerTemplate = Template.of("player", player.getName()); Template playerTemplate = Template.of("player", player.getName());
Template plotTemplate = Template.of("plot", plot.getId().toString()); Template plotTemplate = Template.of("plot", plot.getId().toString());
if (!Settings.Enabled_Components.NOTIFICATION_AS_ACTIONBAR) { if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
owner.sendMessage(caption, playerTemplate, plotTemplate); owner.sendMessage(caption, playerTemplate, plotTemplate);
} else { } else {
owner.sendActionBar(caption, playerTemplate, plotTemplate); owner.sendActionBar(caption, playerTemplate, plotTemplate);
@ -312,7 +312,7 @@ public class PlotListener {
Template ownerTemplate = Template.of("owner", owner); Template ownerTemplate = Template.of("owner", owner);
final Consumer<String> userConsumer = user -> { final Consumer<String> userConsumer = user -> {
if (Settings.Enabled_Components.TITLES_AS_ACTIONBAR) { if (Settings.Titles.TITLES_AS_ACTIONBAR) {
player.sendActionBar(header, plotTemplate, worldTemplate, ownerTemplate); player.sendActionBar(header, plotTemplate, worldTemplate, ownerTemplate);
} else { } else {
player.sendTitle(header, subHeader, plotTemplate, worldTemplate, ownerTemplate); player.sendTitle(header, subHeader, plotTemplate, worldTemplate, ownerTemplate);
@ -392,7 +392,7 @@ public class PlotListener {
final String farewell = plot.getFlag(FarewellFlag.class); final String farewell = plot.getFlag(FarewellFlag.class);
if (!farewell.isEmpty()) { if (!farewell.isEmpty()) {
if (!Settings.Enabled_Components.NOTIFICATION_AS_ACTIONBAR) { if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage); plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
} else { } else {
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendActionBar); plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendActionBar);
@ -407,7 +407,7 @@ public class PlotListener {
Caption caption = TranslatableCaption.of("notification.notify_leave"); Caption caption = TranslatableCaption.of("notification.notify_leave");
Template playerTemplate = Template.of("player", player.getName()); Template playerTemplate = Template.of("player", player.getName());
Template plotTemplate = Template.of("plot", plot.getId().toString()); Template plotTemplate = Template.of("plot", plot.getId().toString());
if (!Settings.Enabled_Components.NOTIFICATION_AS_ACTIONBAR) { if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
owner.sendMessage(caption, playerTemplate, plotTemplate); owner.sendMessage(caption, playerTemplate, plotTemplate);
} else { } else {
owner.sendActionBar(caption, playerTemplate, plotTemplate); owner.sendActionBar(caption, playerTemplate, plotTemplate);

View File

@ -811,7 +811,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
final @NonNull Caption title, final @NonNull Caption subtitle, final @NonNull Caption title, final @NonNull Caption subtitle,
final @NonNull Template... replacements final @NonNull Template... replacements
) { ) {
sendTitle(title, subtitle, Settings.TITLES_FADE_IN, Settings.TITLES_STAY, Settings.TITLES_FADE_OUT, replacements); sendTitle(title, subtitle, Settings.Titles.TITLES_FADE_IN, Settings.Titles.TITLES_STAY, Settings.Titles.TITLES_FADE_OUT, replacements);
} }
/** /**
@ -833,9 +833,9 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
final Component subtitleComponent = final Component subtitleComponent =
MiniMessage.get().parse(subtitle.getComponent(this), replacements); MiniMessage.get().parse(subtitle.getComponent(this), replacements);
final Title.Times times = Title.Times.of( final Title.Times times = Title.Times.of(
Duration.of(Settings.TITLES_FADE_IN * 50L, ChronoUnit.MILLIS), Duration.of(Settings.Titles.TITLES_FADE_IN * 50L, ChronoUnit.MILLIS),
Duration.of(Settings.TITLES_STAY * 50L, ChronoUnit.MILLIS), Duration.of(Settings.Titles.TITLES_STAY * 50L, ChronoUnit.MILLIS),
Duration.of(Settings.TITLES_FADE_OUT * 50L, ChronoUnit.MILLIS) Duration.of(Settings.Titles.TITLES_FADE_OUT * 50L, ChronoUnit.MILLIS)
); );
getAudience().showTitle(Title getAudience().showTitle(Title
.title(titleComponent, subtitleComponent, times)); .title(titleComponent, subtitleComponent, times));