From cf795287336824f0c128b60de48b441e8ec98d5a Mon Sep 17 00:00:00 2001 From: Zerken Date: Sat, 28 Oct 2023 04:40:45 +0000 Subject: [PATCH] Holiday Login Music Plugin --- client/src/main/java/plugin/api/API.java | 4 + client/src/main/java/rt4/client.java | 2 +- .../main/kotlin/HolidayLoginMusic/plugin.kt | 80 +++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 plugin-playground/src/main/kotlin/HolidayLoginMusic/plugin.kt diff --git a/client/src/main/java/plugin/api/API.java b/client/src/main/java/plugin/api/API.java index 9a25306..2f31ebc 100644 --- a/client/src/main/java/plugin/api/API.java +++ b/client/src/main/java/plugin/api/API.java @@ -279,6 +279,10 @@ public class API { MidiPlayer.playFadeOut(trackId, client.js5Archive6, volume); } + public static void SetLoginScreenMusicOnLoad(String song) { + client.TITLE_SONG = JagString.parse(song); + } + /** * Calculates the 2D screen position for a position in the SceneGraph. * diff --git a/client/src/main/java/rt4/client.java b/client/src/main/java/rt4/client.java index 384ad18..fc98275 100644 --- a/client/src/main/java/rt4/client.java +++ b/client/src/main/java/rt4/client.java @@ -42,7 +42,7 @@ public final class client extends GameShell { @OriginalMember(owner = "client!al", name = "r", descriptor = "Lclient!na;") public static final JagString aClass100_35 = JagString.parse("showVideoAd"); @OriginalMember(owner = "client!a", name = "e", descriptor = "Lclient!na;") - public static final JagString TITLE_SONG = JagString.parse("scape main"); + public static JagString TITLE_SONG = JagString.parse("scape main"); @OriginalMember(owner = "client!jm", name = "A", descriptor = "Lclient!na;") static final JagString aClass100_603 = JagString.parse(""); @OriginalMember(owner = "client!jm", name = "z", descriptor = "Lclient!na;") diff --git a/plugin-playground/src/main/kotlin/HolidayLoginMusic/plugin.kt b/plugin-playground/src/main/kotlin/HolidayLoginMusic/plugin.kt new file mode 100644 index 0000000..896046a --- /dev/null +++ b/plugin-playground/src/main/kotlin/HolidayLoginMusic/plugin.kt @@ -0,0 +1,80 @@ +package HolidayLoginMusic + +import plugin.Plugin +import plugin.annotations.PluginMeta +import plugin.api.API +import plugin.api.FontColor +import plugin.api.FontType +import plugin.api.TextModifier +import java.awt.Color +import java.time.LocalDate +import java.time.Month + + +@PluginMeta( + author = "Zerken", + description = "Plays specific music during holidays and skill release anniversaries at the login screen.", + version = 1.0 +) +open class plugin : Plugin() { + val halloweenStartDate = LocalDate.of(LocalDate.now().year, Month.OCTOBER, 17) + val halloweenEndDate = LocalDate.of(LocalDate.now().year, Month.NOVEMBER, 7) + val christmasStartDate = LocalDate.of(LocalDate.now().year, Month.DECEMBER, 1) + val christmasEndDate = LocalDate.of(LocalDate.now().year, Month.DECEMBER, 31) + val rs2ReleaseDate = LocalDate.of(LocalDate.now().year, Month.MARCH, 29) + val farmingReleaseDate = LocalDate.of(LocalDate.now().year, Month.JULY, 11) + val constructionReleaseDate = LocalDate.of(LocalDate.now().year, Month.MAY, 31) + val hunterReleaseDate = LocalDate.of(LocalDate.now().year, Month.NOVEMBER, 21) + val summonReleaseDate = LocalDate.of(LocalDate.now().year, Month.JANUARY, 15) + + val christmasMusicList = listOf("scape santa", "land of snow", "jungle bells") + var currentHoliday: String = "none" + + + fun checkIfHoliday(): String { + val currentDate = LocalDate.now() + if (!currentDate.isBefore(halloweenStartDate) && !currentDate.isAfter(halloweenEndDate)) + return "halloween" + if (!currentDate.isBefore(christmasStartDate) && !currentDate.isAfter(christmasEndDate)) + return "christmas" + if (currentDate.isEqual(rs2ReleaseDate)) + return "rs2release" + if (currentDate.isEqual(farmingReleaseDate)) + return "farmingrelease" + if (currentDate.isEqual(constructionReleaseDate)) + return "constructionrelease" + if (currentDate.isEqual(hunterReleaseDate)) + return "hunterrelease" + if (currentDate.isEqual(summonReleaseDate)) + return "summoningrelease" + + return "none" + } + + override fun Init() { + currentHoliday = checkIfHoliday() + when (currentHoliday) { + "halloween" -> API.SetLoginScreenMusicOnLoad("scape scared") + "christmas" -> API.SetLoginScreenMusicOnLoad(christmasMusicList.random()) + "rs2release" -> API.SetLoginScreenMusicOnLoad("scape original") + "farmingrelease" -> API.SetLoginScreenMusicOnLoad("ground scape") + "constructionrelease" -> API.SetLoginScreenMusicOnLoad("homescape") + "hunterrelease" -> API.SetLoginScreenMusicOnLoad("scape hunter") + "summoningrelease" -> API.SetLoginScreenMusicOnLoad("scape summon") + } + } + + override fun Draw(deltaTime: Long) { + if (!API.IsLoggedIn()) { + when(currentHoliday) { + "christmas" -> API.DrawText(FontType.LARGE, FontColor.fromColor(Color.GREEN), TextModifier.LEFT, "Happy Holidays.", 0, API.GetWindowDimensions().height - 5) + "halloween" -> API.DrawText(FontType.LARGE, FontColor.fromColor(Color.ORANGE), TextModifier.LEFT, "Happy Halloween.", 0, API.GetWindowDimensions().height - 5) + "rs2release" -> API.DrawText(FontType.LARGE, FontColor.fromColor(Color.YELLOW), TextModifier.LEFT, "On this day in 2004, RS2 was released.", 0, API.GetWindowDimensions().height - 5) + "farmingrelease" -> API.DrawText(FontType.LARGE, FontColor.fromColor(Color.YELLOW), TextModifier.LEFT, "On this day in 2005, the farming skill was released.", 0, API.GetWindowDimensions().height - 5) + "constructionrelease" -> API.DrawText(FontType.LARGE, FontColor.fromColor(Color.YELLOW), TextModifier.LEFT, "On this day in 2006, the construction skill was released.", 0, API.GetWindowDimensions().height - 5) + "hunterrelease" -> API.DrawText(FontType.LARGE, FontColor.fromColor(Color.YELLOW), TextModifier.LEFT, "On this day in 2006, the hunter skill was released.", 0, API.GetWindowDimensions().height - 5) + "summoningrelease" -> API.DrawText(FontType.LARGE, FontColor.fromColor(Color.YELLOW), TextModifier.LEFT, "On this day in 2008, the summoning skill was released.", 0, API.GetWindowDimensions().height - 5) + } + } + } +} \ No newline at end of file