diff --git a/build.gradle.kts b/build.gradle.kts index dabef48..28509fa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -38,7 +38,7 @@ fun pascalcase(kebabcaseString: String): String { return pascalCaseString } -description = "A plugin for displaying titles." +description = "A plugin to display a title and a changing subtitle." val mainProjectAuthor = "Slqmy" val projectAuthors = listOfNotNull(mainProjectAuthor) @@ -48,7 +48,7 @@ val topLevelDomain = "net" val projectNameString = rootProject.name group = topLevelDomain + groupStringSeparator + mainProjectAuthor.lowercase() + groupStringSeparator + snakecase(projectNameString) -version = "0.0.3" +version = "0.0.4" val buildDirectoryString = buildDir.toString() @@ -72,10 +72,6 @@ repositories { dependencies { paperweight.paperDevBundle(paperApiVersion + "-R0.1-SNAPSHOT") - - implementation("dev.jorel" , "commandapi-bukkit-shade-mojang-mapped" , "9.5.1") - - implementation("net.lingala.zip4j", "zip4j", "2.11.5") } tasks { diff --git a/src/main/java/net/slqmy/title_plugin/TitlePlugin.java b/src/main/java/net/slqmy/title_plugin/TitlePlugin.java index 0f739bb..6d587cc 100644 --- a/src/main/java/net/slqmy/title_plugin/TitlePlugin.java +++ b/src/main/java/net/slqmy/title_plugin/TitlePlugin.java @@ -25,10 +25,8 @@ public final class TitlePlugin extends JavaPlugin implements Listener { private Component titleComponent; - private List changingSubtitleComponents; - - private long secondsBeforeChaning; + private long secondsBeforeChanging; @Override public void onEnable() { @@ -39,11 +37,9 @@ public void onEnable() { FileConfiguration configuration = getConfig(); - titleComponent = Component.text(ChatColor.translateAlternateColorCodes('&', configuration.getString("title", "Title"))); - + titleComponent = Component.text(ChatColor.translateAlternateColorCodes('&', configuration.getString("title", "Title (can be changed in config.yml)"))); changingSubtitleComponents = (List) Stream.of((configuration.getList("subtitle", List.of())).toArray(String[]::new)).map((string) -> Component.text(ChatColor.translateAlternateColorCodes('&', string))).toList(); - - secondsBeforeChaning = configuration.getLong("seconds-before-changing", 5L); + secondsBeforeChanging = configuration.getLong("seconds-before-changing", 5L); } @EventHandler @@ -52,19 +48,19 @@ public void onResourcePackLoad(PlayerJoinEvent event) { new BukkitRunnable() { - private int subTitleIndex = 0; + private int subtitleIndex = 0; @Override public void run() { player.sendTitlePart(TitlePart.TITLE, titleComponent); - player.sendTitlePart(TitlePart.SUBTITLE, changingSubtitleComponents.get(subTitleIndex)); + player.sendTitlePart(TitlePart.SUBTITLE, changingSubtitleComponents.get(subtitleIndex)); player.sendTitlePart(TitlePart.TIMES, Title.Times.times(Duration.ZERO, Duration.ofSeconds(10L), Duration.ZERO)); - getLogger().info(changingSubtitleComponents.get(subTitleIndex).toString()); + getLogger().info(changingSubtitleComponents.get(subtitleIndex).toString()); - subTitleIndex++; - subTitleIndex %= changingSubtitleComponents.size(); + subtitleIndex++; + subtitleIndex %= changingSubtitleComponents.size(); } - }.runTaskTimer(this, 0L, secondsBeforeChaning * 20L); + }.runTaskTimer(this, 0L, secondsBeforeChanging * 20L); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 233c24a..e4fda31 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,11 +1,11 @@ # This is the title that will be displayed once a player joins. -title: "&atitle" +title: "&aTitle" -# The subtitles that will be displayed. +# The subtitles that will be displayed periodically as defined with 'seconds-before-changing'. subtitle: - - "&asub1" - - "&asub2" - - "&asub3" + - "&aSubtitle 1" + - "&aSubtitle 2" + - "&aSubtitle 3" # The time in between subtitles displaying. seconds-before-changing: 5