Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Implement starting fade-in and final fade-out
Browse files Browse the repository at this point in the history
  • Loading branch information
EsotericEnderman committed Sep 3, 2024
1 parent 43eadf5 commit fc1856e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ val topLevelDomain = "net"
val projectNameString = rootProject.name

group = topLevelDomain + groupStringSeparator + mainProjectAuthor.lowercase() + groupStringSeparator + snakecase(projectNameString)
version = "0.0.9"
version = "0.0.10"

val buildDirectoryString = buildDir.toString()

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/net/slqmy/title_plugin/TitlePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public final class TitlePlugin extends JavaPlugin implements Listener {
private List<TextComponent> changingSubtitleComponents;
private long secondsBeforeChanging;

private long firstSubtitleFadeInTime;
private long lastSubtitleFadeOutTime;

private long fadeInTime;
private long stayTime;
private long fadeOutTime;
Expand All @@ -53,6 +56,9 @@ public void onEnable() {
.map((string) -> Component.text(ChatColor.translateAlternateColorCodes('&', string))).toList();
secondsBeforeChanging = configuration.getLong("seconds-before-changing", 5L);

firstSubtitleFadeInTime = configuration.getLong("first-subtitle-fade-in-time", 0L);
lastSubtitleFadeOutTime = configuration.getLong("last-subtitle-fade-out-time", 0L);

fadeInTime = configuration.getLong("fade-in-time", 0L);
stayTime = configuration.getLong("stay-time", 10L);
fadeOutTime = configuration.getLong("fade-out-time", 0L);
Expand Down Expand Up @@ -116,7 +122,7 @@ public void run() {

player.sendTitlePart(TitlePart.TITLE, titleComponent);
player.sendTitlePart(TitlePart.SUBTITLE, changingSubtitleComponents.get(subtitleIndex));
player.sendTitlePart(TitlePart.TIMES, Title.Times.times(Duration.ofSeconds(fadeInTime), Duration.ofSeconds(stayTime), Duration.ofSeconds(fadeOutTime)));
player.sendTitlePart(TitlePart.TIMES, Title.Times.times(Duration.ofSeconds(subtitleIndex == 0 ? firstSubtitleFadeInTime : fadeInTime), Duration.ofSeconds(stayTime), Duration.ofSeconds(subtitleIndex == changingSubtitleComponents.size() - 1 ? lastSubtitleFadeOutTime : fadeOutTime)));

subtitleIndex++;
if (subtitleIndex == changingSubtitleComponents.size()) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# This is the title that will be displayed once a player joins.
title: "&aTitle"

# The amount of time that the very first subtitle will fade in for.
first-subtitle-fade-in-time: 1

# The amount of time that the very last subtitle will fade out for.
last-subtitle-fade-out-time: 1

# The subtitles that will be displayed periodically as defined with 'seconds-before-changing'.
subtitle:
- "&aSubtitle 1"
Expand Down

0 comments on commit fc1856e

Please sign in to comment.