Make titles duration configurable

This commit is contained in:
N0tMyFaultOG 2020-12-07 21:23:38 +01:00
parent 469d6ab907
commit bf7b75b619
No known key found for this signature in database
GPG Key ID: 823348042DA95A81
2 changed files with 7 additions and 4 deletions

View File

@ -49,6 +49,9 @@ public class Settings extends Config {
"For a single plot set `/plot flag set titles false` to disable it.", "For just you run `/plot toggle titles` to disable it.", "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 "For all plots: Add `titles: false` in the worlds.yml flags block to disable it."}) public static boolean
TITLES = true; TITLES = true;
@Comment("Plot titles fading in (duration in ticks)") public static int TITLES_FADE_IN = 10;
@Comment("Plot titles being staying visible (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;

View File

@ -795,7 +795,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
*/ */
public void sendTitle(@Nonnull final Caption title, @Nonnull final Caption subtitle, public void sendTitle(@Nonnull final Caption title, @Nonnull final Caption subtitle,
@Nonnull final Template... replacements) { @Nonnull final Template... replacements) {
sendTitle(title, subtitle, 10, 50, 20, replacements); sendTitle(title, subtitle, Settings.TITLES_FADE_IN, Settings.TITLES_STAY, Settings.TITLES_FADE_OUT, replacements);
} }
/** /**
@ -814,9 +814,9 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
final Component titleComponent = MiniMessage.get().parse(title.getComponent(this), replacements); final Component titleComponent = MiniMessage.get().parse(title.getComponent(this), replacements);
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(Duration.of(fadeIn * 50, ChronoUnit.MILLIS), final Title.Times times = Title.Times.of(Duration.of(Settings.TITLES_FADE_IN * 50L, ChronoUnit.MILLIS),
Duration.of(stay * 50, ChronoUnit.MILLIS), Duration.of(Settings.TITLES_STAY * 50L, ChronoUnit.MILLIS),
Duration.of(fadeOut * 50, ChronoUnit.MILLIS)); Duration.of(Settings.TITLES_FADE_OUT * 50L, ChronoUnit.MILLIS));
getAudience().showTitle(Title getAudience().showTitle(Title
.title(titleComponent, subtitleComponent, times)); .title(titleComponent, subtitleComponent, times));
} }